(FILECREATED "24-Apr-87 17:03:50" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH247.;2 10172  

      changes to:  (VARS RHTPATCH247COMS)
		   (FNS NC.ClosePropListEditor)

      previous date: "24-Apr-87 16:54:13" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH247.;1)


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

(PRETTYCOMPRINT RHTPATCH247COMS)

(RPAQQ RHTPATCH247COMS ((* * Fixes two nasty storage leaks, one when NC.QuitCard is called with nil 
			     CallCloseWFlg, the other from ShowLinks menu.)
			  (* * Changes to NCCARDS)
			  (FNS NC.QuitCard NC.ClosePropListEditor)))
(* * Fixes two nasty storage leaks, one when NC.QuitCard is called with nil CallCloseWFlg, the
 other from ShowLinks menu.)

(* * Changes to NCCARDS)

(DEFINEQ

(NC.QuitCard
  (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg DontRecacheFlg InterestedWindow OperationMsg 
			  QuietFlg Don'tDeactivateFlg)       (* rht: "24-Apr-87 16:17")

          (* * 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.)



          (* * rg 3/4/87 rewritten to use new NC.ProtectedCardOperation, removed DontCheckOpInProgressFlg arg)



          (* * rht 3/24/87: Now calls NC.CoerceToInterestedWindow and passes InterestedWindow to NC.InsureProperFiling.)



          (* * rht 4/24/87: Fixed a vmem leak: when CallCloseWFlg is nil it doesn't clear CardObject windowprop.)


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

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


	           (OR DontSaveFlg ReadOnlyCardFlg (COND
			   ((EQ (NC.InsureProperFiling Card InterestedWindow)
				  (QUOTE DON'T))
			     (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 (PROGN                        (* 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)
									    InterestedWindow 
									    OperationMsg)))
				      (AND Window (WINDOWDELPROP Window (QUOTE CLOSEFN)
								     (FUNCTION NC.QuitCard)))
				      (PROG1 (NC.ApplyFn QuitFn Card)
					       (AND Window (WINDOWPROP Window (QUOTE 
										   NoteCardObject)
									   NIL))
					       (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))))))))))

(NC.ClosePropListEditor
  (LAMBDA (Window SaveFlg)                                   (* rht: "24-Apr-87 16:49")

          (* 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.)



          (* * rht 1/16/87: Now checks that tedit stream has been modified before using user as to whether to save changes.
	  No longer puts up stupid save/cancel menu.)



          (* * rht&rg 4/24/87: Now smashes more windowprops to prevent storage leaks.)


    (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 NoSave)))
		     ((EQ (WINDOWPROP Window (QUOTE PropListEditor))
			    (QUOTE ShowOnly)))
		     ((OR (EQ SaveFlg (QUOTE Save))
			    (TEDIT.STREAMCHANGEDP TextObj))
		       (SETQ NewPropList (NC.ExtractPropList Window))
		       (NC.ProcessEditedPropList NewPropList OldPropList Card))))
	    (WINDOWPROP Window (QUOTE TEDIT.MENU)
			  NIL)
	    (WINDOWPROP Window (QUOTE TEDIT.PROPS)
			  NIL)
	    (WINDOWPROP Window (QUOTE PropListEditor)
			  NIL)
	    (WINDOWPROP Window (QUOTE SavedCardObject)
			  NIL)
	    (WINDOWPROP Window (QUOTE PROPERTYLIST.BEING.EDITED)
			  NIL)
	    (WINDOWPROP Window (QUOTE PROPERTYLIST.PROPNAMES)
			  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)))))))
)
(PUTPROPS RHTPATCH247 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (751 10090 (NC.QuitCard 761 . 6610) (NC.ClosePropListEditor 6612 . 10088)))))
STOP