(FILECREATED "13-Nov-86 16:32:36" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH144.;4 16084  

      changes to:  (VARS RHTPATCH144COMS)
		   (FNS NC.ProcessEditedPropList NC.AddPropToPropList NC.QuitCard)

      previous date: "13-Nov-86 15:32:35" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH144.;1)


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT RHTPATCH144COMS)

(RPAQQ RHTPATCH144COMS ((* * Fixes bug reported by DJ whereby closing card with open proplist 
			     editor caused break. Fixes other random bugs in proplist editing 
			     including one whereby proplist additions deleted the system Updates 
			     prop.)
			  (* * Change to NCCARDS)
			  (FNS NC.ClosePropListEditor NC.OpenPropListEditor NC.ProcessEditedPropList 
			       NC.QuitCard)))
(* * Fixes bug reported by DJ whereby closing card with open proplist editor caused break. 
Fixes other random bugs in proplist editing including one whereby proplist additions deleted 
the system Updates prop.)

(* * Change to NCCARDS)

(DEFINEQ

(NC.ClosePropListEditor
  (LAMBDA (Window SaveFlg)                                   (* rht: "13-Nov-86 15:08")

          (* Close the prop list editor, saving or not saving the edited prop list as specified by the SaveFlg or by the user
	  if SaveFlg is NIL)



          (* * fgh 11/13/85 Updated to handle Card object.)



          (* * fgh 6/8/86 Added call to RAPOSITIONATTACHEDWINDOWS)



          (* * rht 8/12/86 Now uses TEXTOBJ to get TextObj from window.)



          (* * kef 7/16/86: Added the call to release the write permission should the window property declare that it be 
	  necessary.)



          (* * kef 7/22/86: Now only releases the write permission if the card is inactive. The reason is that it was 
	  determined that a card being edited would update the property list upon being closed.)



          (* * fgh 8/30/86 Converted APPLY* to NC.ApplyFn. Added Card local var.)



          (* * rht 11/12/86: Now calls MAINWINDOW instead of WINDOWPROP to get Window's mainwindow and recovers card from a 
	  prop of Window.)


    (DECLARE (GLOBALVARS NC.SavePropEditMenu))
    (PROG (TextObj Answered OldPropList NewPropList MainWindow Card)
	    (SETQ Card (WINDOWPROP Window (QUOTE SavedCardObject)))
	    (SETQ MainWindow (MAINWINDOW Window))
	    (DETACHWINDOW Window)
	    (SETQ TextObj (CAR (NLSETQ (TEXTOBJ Window))))
	    (SETQ OldPropList (WINDOWPROP Window (QUOTE PROPERTYLIST.BEING.EDITED)))
	    (AND TextObj (COND
		     ((EQ SaveFlg (QUOTE Save))
		       (SETQ NewPropList (NC.ExtractPropList Window))
		       (NC.ProcessEditedPropList NewPropList OldPropList Card))
		     ((EQ SaveFlg (QUOTE NoSave)))
		     ((EQ (WINDOWPROP Window (QUOTE PropListEditor))
			    (QUOTE ShowOnly)))
		     (T (until Answered do (SELECTQ (MENU
							    (OR (AND (BOUNDP (QUOTE 
									      NC.SavePropEditMenu))
									 (type? MENU 
									      NC.SavePropEditMenu)
									 NC.SavePropEditMenu)
								  (SETQ NC.SavePropEditMenu
								    (create MENU
									      ITEMS ←(QUOTE
										(Save% Changes 
										  Cancel% Changes))
									      TITLE ← 
									      "Property Edits?"
									      CENTERFLG ← T))))
							  (Save% Changes (SETQ NewPropList
									   (NC.ExtractPropList
									     Window))
									 (NC.ProcessEditedPropList
									   NewPropList OldPropList 
									   Card)
									 (SETQ Answered T))
							  (Cancel% Changes (SETQ Answered T))
							  NIL)))))
	    (WINDOWPROP Window (QUOTE TEDIT.MENU)
			  NIL)
	    (WINDOWPROP Window (QUOTE TEDIT.PROPS)
			  NIL)
	    (WINDOWPROP Window (QUOTE PropListEditor)
			  NIL)
	    (WINDOWDELPROP Window (QUOTE CLOSEFN)
			     (FUNCTION NC.ClosePropListEditor))
	    (COND
	      ((AND (WINDOWPROP Window (QUOTE ReleaseWritePermissionP))
		      (NOT (NC.ActiveCardP Card)))
		(NC.ApplyFn ReleaseWritePermissionFn Card (QUOTE PROPLIST))
		(WINDOWPROP Window (QUOTE ReleaseWritePermissionP)
			      NIL)))
	    (COND
	      (TextObj (replace (TEXTOBJ \DIRTY) of TextObj with NIL)
		       (\TEDIT.QUIT (CAR (MKLIST (fetch (TEXTOBJ \WINDOW) of TextObj))))
		       (until (fetch (TEXTOBJ EDITFINISHEDFLG) of TextObj) do (BLOCK))))
	    (ADD.PROCESS (BQUOTE (PROGN (until (NULL (OPENWP , Window)) do (BLOCK))
					      (REPOSITIONATTACHEDWINDOWS , MainWindow)))))))

(NC.OpenPropListEditor
  (LAMBDA (WindowOrTextStream PropList Title ShowOnlyFlg MakeImageObjFlg ShowLinksFlg)
                                                             (* rht: "13-Nov-86 15:08")
                                                             (* Open a property list editor above the card 
							     specified by TextStream , which is either a TextStream
							     or a Window)

          (* * rht 8/11/86: Now takes ShowLinksFlg arg and passes to NC.PropListEditorOpenP so that we don't bail out if 
	  there's an open proplist not of our type.)



          (* * rht 11/13/86: Now hangs Card object off prop list editor's window so that we can get to the card from the 
	  proplist editor at close time.)


    (PROG ((Window (WINDOW.FROM.TEDIT.THING WindowOrTextStream))
	     (SystemProperties (QUOTE (ID Updates ItemDate LinksDate PropsDate TitleDate)))
	     EditWindow CardUID Card)                        (* Make sure there is no prop list editor already 
							     there)
	    (AND (NC.PropListEditorOpenP Window ShowLinksFlg)
		   (RETURN))
	    (SETQ CardUID (fetch (Card UID) of (SETQ Card (NC.CoerceToCard Window))))
                                                             (* FOR each prop/value pair with LISTP value.
							     Make a series of individual prop/value pairs 
							     corresponding to the elements of the LISTP)
	    (SETQ PropList (for Item on PropList by (CDDR Item)
				join (COND
					 ((NLISTP (CADR Item))
					   (LIST (create PropListItem
							     PropertyName ←(CAR Item)
							     Value ←(CADR Item)
							     OriginalListFlg ← NIL
							     AllowEditFlg ← NIL
							     AllowSelectFlg ← NIL
							     ButtonFn ← NIL)))
					 (T (for Element in (CADR Item)
					       collect (create PropListItem
								   PropertyName ←(CAR Item)
								   Value ← Element
								   OriginalListFlg ← T
								   AllowEditFlg ← NIL
								   AllowSelectFlg ← NIL
								   ButtonFn ← NIL))))))
                                                             (* If specified, translate all NOTECARDLINK values 
							     into Image Objects for display.)
	    (AND MakeImageObjFlg (for Item in PropList bind LinkIcon
				      when (type? Link (fetch (PropListItem Value)
							      of Item))
				      do (replace (PropListItem Value) of Item
					      with (SETQ LinkIcon (NC.MakeLinkIcon
							 (fetch (PropListItem Value) of Item)))
						     (IMAGEOBJPROP LinkIcon (QUOTE 
									     InsidePropListEditor)
								     T))))
                                                             (* Indicate which properties can be edited by user.)
	    (for Item in PropList do (COND
					     ((FMEMB (fetch (PropListItem PropertyName)
							  of Item)
						       SystemProperties)
					       (replace (PropListItem AllowEditFlg) of Item
						  with T)
					       (replace (PropListItem AllowSelectFlg) of Item
						  with T))
					     (ShowOnlyFlg (replace (PropListItem AllowEditFlg)
							     of Item with NIL)
							  (replace (PropListItem AllowSelectFlg)
							     of Item with T))
					     (T (replace (PropListItem AllowEditFlg) of Item
						   with NIL)
						(replace (PropListItem AllowSelectFlg)
						   of Item with NIL))))
                                                             (* Call the prop list editor)
	    (ATTACHWINDOW (SETQ EditWindow (CREATEW (CREATEREGION 1000 2000 100 100)
							  (OR Title "Edit Property List")
							  NIL T))
			    Window
			    (QUOTE TOP)
			    (QUOTE JUSTIFY)
			    (QUOTE LOCALCLOSE))
	    (WINDOWADDPROP EditWindow (QUOTE CLOSEFN)
			     (FUNCTION FREEATTACHEDWINDOW)
			     T)
	    (WINDOWPROP EditWindow (QUOTE PropListEditor)
			  (COND
			    (ShowOnlyFlg (QUOTE ShowOnly))
			    (T T)))
	    (WINDOWPROP EditWindow (QUOTE SavedCardObject)
			  Card)
	    (NC.EditPropList PropList EditWindow ShowOnlyFlg)
	    (RETURN EditWindow))))

(NC.ProcessEditedPropList
  (LAMBDA (EditedPropList OldPropList Card)                  (* rht: "13-Nov-86 16:25")
                                                             (* Take an edited prop list and set the prop list of 
							     the card as required.)

          (* * rht 2/1/85: Removed call to NC.MarkCardDirty.)



          (* * fgh 11/13/85 Updated to handle Card object.)



          (* * rht 11/13/86: No longer "spreads" out prop values.)


    (LET ((NewPropList (NC.FetchPropList Card)))
         (for Item in EditedPropList do (LET* ((Prop (fetch (PropListItem PropertyName)
							      of Item))
						     (NewValue (if (fetch (PropListItem 
										  OriginalListFlg)
									of (FASSOC Prop 
										      OldPropList))
								   then (LIST (CADR Item))
								 else (CADR Item))))
						    (if NewPropList
							then (LISTPUT NewPropList Prop NewValue)
						      else (SETQ NewPropList (LIST Prop 
											 NewValue)))))
         (NC.SetPropList Card NewPropList)
         (NC.SetPropListDirtyFlg Card T))))

(NC.QuitCard
  (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg DontRecacheFlg DontCheckOpInProgressFlg 
			  InterestedWindow OperationMsg QuietFlg Don'tDeactivateFlg)
                                                             (* rht: "13-Nov-86 15:32")

          (* * Force note card specified by ID to quit or stop)



          (* * rht 2/9/85: New arg DontSaveFlg prevents NC.CardSaveFn from being called. Used when aborting a card.
	  This is NOT equivalent to NC.QuitWithoutSaving.)



          (* * rht 6/25/85: Now moves card off screen before saving if NC.CloseCardsOffScreenFlg is non-nil.)



          (* * rht 6/25/85: Brought the insure proper filing check back here from NC.CardSaveFn. Bails out if user cancelled 
	  operation inside of NC.InsureProperFiling)



          (* * fgh 11/11/85: Updated to handle CardID and CardInfo objects.)



          (* * fgh 1/16/86 Put in code to insure that if one of the TopLevelCards is quit then it is reactivated immedialtely
	  to make sure it stays cached for fast access.)



          (* * fgh 2/5/86 Added call to NC.ApplyFn)



          (* * fgh 5/2/86 Added DontRecacheFlg arg)



          (* * fgh 6/9/86 Added code to check to make sure other operations are not in progress. And DontCheckOpInProgressFlg
	  arg to match)



          (* * fgh 6/26/86 Added InterestedWindow & OperationMsg arg.)



          (* * rht 7/2/86: Now bails out if notefile is readonly, user confirms, but we're supposed to write down changes.)



          (* * rht 7/13/86: Now takes QuietFlg arg.)



          (* * rht 7/14/86: Call NC.DeactivateCard from here instead of in card type QuitFn. Take a Don'tDeactivateFlg as 
	  well.)



          (* * rht 10/7/86: Now removes DELETEME imageobj's from card substance.)



          (* * rht 11/2/86: Now returns DON'T if operation in progress.)



          (* * rht 11/13/86: Now closes open proplist editor if any before saving.)


    (DECLARE (GLOBALVARS NC.RemoveDELETEMEImageObjsFromCardFlg))
    (PROG ((Card (NC.CoerceToCard CardIdentifier))
	     Window OperationInProgress ReadOnlyCardFlg)
	    (SETQ Window (NC.FetchWindow Card))
	    (OR InterestedWindow (SETQ InterestedWindow Window))
	    (SETQ ReadOnlyCardFlg (NC.ReadOnlyCardP Card))
                                                             (* The window not being open should mean that it's 
							     shrunken. If so, expand it.)
	    (COND
	      ((AND Window (NOT (OPENWP Window)))
		(EXPANDW Window)))

          (* * if in the middle of some other operation, get out of here.)


	    (if (AND (NULL DontCheckOpInProgressFlg)
			 (SETQ OperationInProgress (NC.OperationInProgress Card)))
		then (NC.PrintOperationInProgressMsg Window "Close Card" OperationInProgress)
		       (RETURN (QUOTE DON'T)))

          (* * if proper filing says don't quit then get out)


	    (OR DontSaveFlg ReadOnlyCardFlg (COND
		    ((EQ (NC.InsureProperFiling Card)
			   (QUOTE CANCELLED))
		      (RETURN (QUOTE DON'T)))))

          (* * If card is readonly but we've made changes that we're supposed to save, then get user confirmation and bail 
	  out.)


	    (if (AND (NOT DontSaveFlg)
			 (NOT Don'tDeactivateFlg)
			 ReadOnlyCardFlg
			 (NC.CardSomehowDirtyP Card)
			 (NULL QuietFlg)
			 (NOT (PROGN (NC.PrintMsg InterestedWindow T 
					       "Card has been changed, but notefile is readonly."
							(CHARACTER 13))
					 (NC.AskYesOrNo "Want to quit anyway, flushing changes? " 
							  NIL (QUOTE Yes)
							  NIL InterestedWindow))))
		then (RETURN (QUOTE DON'T)))

          (* * Otherwise go ahead and quit)


	    (RETURN (NC.ProtectedCardOperation Card Close% Card 
                                                             (* Close open proplist editor if any.)
						 (AND Window (LET ((PropListEditorWindow
								       (NC.PropListEditorOpenP
									 Window)))
								    (AND PropListEditorWindow
									   (CLOSEW 
									     PropListEditorWindow))))
						 (COND
						   ((AND Window NC.CloseCardsOffScreenFlg)
						     (COND
						       ((NOT (NC.FetchSavedRegion Card))
							 (NC.SetSavedRegion Card
									      (WINDOWPROP
										Window
										(QUOTE REGION)))))
						     (MOVEW Window 1500 1500)))
						 (OR DontSaveFlg
						       (if ReadOnlyCardFlg
							   then (NC.TurnOffDirtyFlgs Card)
							 else (AND 
							    NC.RemoveDELETEMEImageObjsFromCardFlg
								       (
							       NC.RemoveDELETEMEImageObjsFromCard
									 Card
									 (FUNCTION 
									   NC.DELETEMEImageObjP)))
								(NC.CardSaveFn Card
										 (OR 
									NC.CloseCardsOffScreenFlg 
										       QuietFlg)
										 NIL InterestedWindow 
										 OperationMsg)))
						 (AND Window (WINDOWDELPROP
							  Window
							  (QUOTE CLOSEFN)
							  (FUNCTION NC.QuitCard)))
						 (PROG1 (NC.ApplyFn QuitFn Card)
							  (AND CallCloseWFlg Window (CLOSEW
								   Window))
							  (OR Don'tDeactivateFlg (
								  NC.DeactivateCard Card))

          (* * if this is one of the top level cards, then make sure it stays cached)


							  (if (AND (NC.TopLevelCardP Card)
								       (NULL DontRecacheFlg)
								       (NULL Don'tDeactivateFlg))
							      then (NCP.ActivateCards Card))))))))
)
(PUTPROPS RHTPATCH144 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1035 16002 (NC.ClosePropListEditor 1045 . 4768) (NC.OpenPropListEditor 4770 . 9107) (
NC.ProcessEditedPropList 9109 . 10280) (NC.QuitCard 10282 . 16000)))))
STOP