(FILECREATED " 2-Mar-87 20:35:39" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH209.;3 7009   

      changes to:  (FNS NC.QuitCard)
		   (VARS RHTPATCH209COMS)

      previous date: " 2-Mar-87 19:51:30" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH209.;1)


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

(PRETTYCOMPRINT RHTPATCH209COMS)

(RPAQQ RHTPATCH209COMS ((* * Removes a circularity in WindowProp pointer that might have been the 
			     cause of vmem lossage reported by Ramana)
			  (* * Change to NCCARDS)
			  (FNS NC.QuitCard)))
(* * Removes a circularity in WindowProp pointer that might have been the cause of vmem 
lossage reported by Ramana)

(* * Change to NCCARDS)

(DEFINEQ

(NC.QuitCard
  (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg DontRecacheFlg DontCheckOpInProgressFlg 
			  InterestedWindow OperationMsg QuietFlg Don'tDeactivateFlg)
                                                             (* rht: " 2-Mar-87 20:35")

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



          (* * rht&rg 3/2/87: Smashed NoteCardObject windowprop before closing window to break a circularity.
	  Also made call to NC.AskYesOrNo when read-only notefile prompt with No rather than Yes.)


    (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 No)
							  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)))
						 (if Window
						     then (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))
							  (if Window
							      then 
                                                             (* Cut circularity from Window to itself.)
								     (WINDOWPROP Window
										   (QUOTE 
										   NoteCardObject)
										   NIL))))))))
)
(PUTPROPS RHTPATCH209 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (701 6927 (NC.QuitCard 711 . 6925)))))
STOP