(FILECREATED " 4-Nov-86 21:01:37" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH135.;3 25771  

      changes to:  (FNS NC.DelReferencesToCardFromText NC.DelReferencesToCardFromGraph 
			NC.DeleteLinkIconSketchElement NC.DelReferencesToCardFromBrowser 
			NC.SmartDeleteLinks NC.DelReferencesToCardFromSketch)
		   (VARS RHTPATCH135COMS)

      previous date: " 4-Nov-86 14:56:18" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH135.;1)


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

(PRETTYCOMPRINT RHTPATCH135COMS)

(RPAQQ RHTPATCH135COMS ((* * Fix so that deleting cards with links doesn't replace link icons with 
			     deleted icons.)
			  (FILES (FROM NOTECARDS)
				 NCGRAPHCARD NCBROWSERCARD NCSKETCHCARD)
			  (* * Changes to NCLINKS)
			  (FNS NC.SmartDeleteLinks NC.DeleteLink NC.DelReferencesToCard)
			  (* * Changes to NCTEXTCARD)
			  (FNS NC.DelReferencesToCardFromText)
			  (* * Changes to NCGRAPHCARD)
			  (FNS NC.DelReferencesToCardFromGraph)
			  (* * Changes to NCSKETCHCARD)
			  (FNS NC.DelReferencesToCardFromSketch NC.DeleteLinkIconSketchElement)
			  (* * Changes to NCBROWSERCARD)
			  (FNS NC.DelReferencesToCardFromBrowser)))
(* * Fix so that deleting cards with links doesn't replace link icons with deleted icons.)

(FILESLOAD (FROM NOTECARDS)
	   NCGRAPHCARD NCBROWSERCARD NCSKETCHCARD)
(* * Changes to NCLINKS)

(DEFINEQ

(NC.SmartDeleteLinks
  (LAMBDA (ListOfLinks QuietFlg InterestedWindow Don'tPutToBeDeletedCardsFlg 
		       Don'tCreateDeletedImageObjFlg)        (* rht: " 4-Nov-86 17:34")

          (* * Delete a bunch of links efficiently. Sort so that links with same source bunch together.
	  This way, only read and write each source card once. If a card has the AboutToBeDeletedFlg UID prop set and 
	  Don'tPutToBeDeletedCardsFlg is non-nil, then don't put it down to the file even if changes were made.
	  Just throw away its cache.)



          (* * rht 10/17/86: Now passes non-nil NoOrphanHookFlg to NC.DeleteLink unless destination card is marked as about 
	  to be deleted.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (LET (DestCardsw/oLinksCached NumLinksToDelete)

          (* * For each destination card, make sure its links are cached. At the same time, collect these cards for future 
	  uncaching.)


         (SETQ DestCardsw/oLinksCached (for Link in ListOfLinks bind DestCard
					    when (NOT (NC.LinksCachedP (SETQ DestCard
									       (fetch (Link 
										  DestinationCard)
										  of Link))))
					    collect (NC.GetLinks DestCard)
						      DestCard))

          (* * Sort the List of links so that links with same source cards bunch together.)


         (OR QuietFlg (NC.PrintMsg InterestedWindow T "Sorting " (SETQ NumLinksToDelete
					 (LENGTH ListOfLinks))
				       " links prior to deletion."))
         (SORT ListOfLinks (FUNCTION (LAMBDA (Link1 Link2)
		     (LESSP (fetch (Card IndexLoc) of (fetch (Link SourceCard) of Link1))
			      (fetch (Card IndexLoc) of (fetch (Link SourceCard) of Link2)))))
		 )

          (* * Now bring up source cards one at a time and do the delete of the links.)


         (OR QuietFlg (NC.PrintMsg InterestedWindow T "Deleting links: 1 out of " 
				       NumLinksToDelete " ..."))
         (for Link in ListOfLinks as i from 1 bind PreviousSourceCard WasNotActiveFlg 
							     SavedFromLinks HadLinksCachedFlg
	    eachtime (BLOCK)
	    do (OR QuietFlg (if (ZEROP (REMAINDER i 10))
				    then (NC.PrintMsg InterestedWindow T "Deleting links: " i 
							  " out of "
							  NumLinksToDelete " ...")))
		 (LET ((SourceCard (fetch (Link SourceCard) of Link)))
		      (if (NOT (NC.SameCardP SourceCard PreviousSourceCard))
			  then                             (* Write down changes to previous card's substance.)
				 (if WasNotActiveFlg
				     then                  (* Have to call NC.CardSaveFn first and then 
							     NC.QuitCard with Don'tSaveFlg to avoid 
							     insureProperFiling check.)
					    (if (AND Don'tPutToBeDeletedCardsFlg
							 (NC.UIDGetProp (fetch (Card UID)
									     of PreviousSourceCard)
									  (QUOTE 
									      AboutToBeDeletedFlg)))
						then       (* Throw away cache if card about to be deleted.)
						       (NC.DeactivateCard PreviousSourceCard)
					      else (NC.CardSaveFn PreviousSourceCard T)
						     (NC.QuitCard PreviousSourceCard NIL T NIL NIL 
								    NIL NIL T))
                                                             (* Recache links for previous card if they were cached
							     before.)
					    (if HadLinksCachedFlg
						then (NC.GetLinks PreviousSourceCard)))
                                                             (* Cache card and overwrite from links with previously
							     cached ones.)
				 (if (SETQ WasNotActiveFlg (NOT (NC.ActiveCardP SourceCard)))
				     then                  (* Save cached from links for this card.)
					    (SETQ SavedFromLinks (if (SETQ HadLinksCachedFlg
									   (NC.LinksCachedP 
										       SourceCard))
								       then (NC.FetchFromLinks
										SourceCard)))
					    (NC.GetNoteCard SourceCard)
					    (if HadLinksCachedFlg
						then (NC.SetFromLinks SourceCard SavedFromLinks)))
			    )
		      (NC.DeleteLink Link (NC.UIDGetProp (fetch (Card UID)
								of (fetch (Link DestinationCard)
									of Link))
							     (QUOTE AboutToBeDeletedFlg))
				       NIL
				       (NC.UIDGetProp (fetch (Card UID)
							   of (fetch (Link SourceCard)
								   of Link))
							(QUOTE AboutToBeDeletedFlg)))
		      (SETQ PreviousSourceCard SourceCard))
	    finally (if WasNotActiveFlg
			  then                             (* Have to call NC.CardSaveFn first and then 
							     NC.QuitCard with Don'tSaveFlg to avoid 
							     insureProperFiling check.)
				 (if (AND Don'tPutToBeDeletedCardsFlg (NC.UIDGetProp
						(fetch (Card UID) of PreviousSourceCard)
						(QUOTE AboutToBeDeletedFlg)))
				     then                  (* Throw away cache if card about to be deleted.)
					    (NC.DeactivateCard PreviousSourceCard)
				   else (NC.CardSaveFn PreviousSourceCard T)
					  (NC.QuitCard PreviousSourceCard NIL T NIL NIL NIL NIL T))
                                                             (* Recache links for previous card if they were cached
							     before.)
				 (if HadLinksCachedFlg
				     then (NC.GetLinks PreviousSourceCard))))

          (* * Finally, write down links for cards whose links have changed and whose links weren't cached when this function
	  was called.)


         (for DestCard in DestCardsw/oLinksCached eachtime (BLOCK) when (
									    NC.FetchLinksDirtyFlg
										    DestCard)
	    do (NC.PutLinks DestCard))
         (OR QuietFlg (NC.ClearMsg InterestedWindow T)))))

(NC.DeleteLink
  (LAMBDA (Link NoOrphanHookFlg Don'tDelLinkIconFlg Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 14:22")

          (* * Delete a link with the option of not putting an orphan hook in case of last filing link.
	  Also option of not deleting link icon from the source card's substance.)



          (* * fgh 5/2/86 Included calls to NC.DelReferencesToCardFromShowLinks in order to clean up ShowLinks windows when 
	  links are deleted.)



          (* * kef 7/17/86: Added the requirement that the write permissions be obtained for the TOLINKS of the Source Card 
	  and the FROMLINKS of the Destination Card.)



          (* * kef 7/22/86: Puts the links for the Destination Card now right away while we are still holding onto the write 
	  lock for the FROMLINKS.)



          (* * kef 7/30/86: Modified to check for Client's concept of whether he owns the write lock or not, thus deciding 
	  whether or not to setup the release of the write lock afterwards.)



          (* * fgh 8/30/86 Adpated to use NC.IfCardPartNotBusy. Note use of ERROR!. Unfortunately, it appears that the only 
	  way to keep TEDIT from deleting the Link's Image Object is to bail out but good. The control structure here works 
	  because NC.IfCardPartNotBusy returns NIL if the CardPart is busy. The Ts at the end as the last SExpr in each call 
	  to NC.IfCardPartNotBusy insure that NC.IfCardPartNotBusy returns non-NIL otherwise.)



          (* * rht 9/29/86: Removed the call to NC.PutFromLinks. Looks to me like it'll get called anyway by NC.DelFromLink 
	  if necessary.)



          (* * rht 10/6/86: Delete crossfilelink cards when their links are deleted.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (LET ((SourceCard (fetch (Link SourceCard) of Link))
	  (DestinationCard (fetch (Link DestinationCard) of Link))
	  BusyCardPart)
         (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
		       (OR (NC.IfCardPartNotBusy DestinationCard (QUOTE FROMLINKS)
						   (OR (NC.IfCardPartNotBusy DestinationCard
									       (QUOTE TOLINKS)
									       (OR 
									      Don'tDelLinkIconFlg
										     (
									   NC.DelReferencesToCard
										       SourceCard 
										       Link 
								    Don'tCreateDeletedImageObjFlg))
									       (NC.DelFromLink
										 Link NoOrphanHookFlg)
									       (NC.DelToLink Link)
									       (
							      NC.DelReferencesToCardFromShowLinks
										 SourceCard Link)
									       (
							      NC.DelReferencesToCardFromShowLinks
										 DestinationCard Link)

          (* * This UID replacement is worrisome. Does it mean that link deletion can't be undone?)


									       (replace
										 (Link UID)
										  of Link
										  with -1)
									       T)
							 (ERROR!))
						   T)
			     (ERROR!)))

          (* * Delete cross file link cards when their links are deleted.)


         (if (NC.CrossFileLinkCardP DestinationCard)
	     then (NC.DeleteNoteCard DestinationCard))
         (if (NC.CrossFileLinkCardP SourceCard)
	     then (NC.DeleteNoteCard SourceCard)))))

(NC.DelReferencesToCard
  (LAMBDA (SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 14:19")
                                                             (* The card specified by DestinationID is being 
							     deleted. Remove all references to it from the card 
							     specified by SourceCard)

          (* * kirk: 13Nov85: deleted use of DatabaseStream)



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



          (* * kef 7/31/86: Added wrapping of write lock grabbing so that deactivating the card preserves the nesting of 
	  write lock ownership.)



          (* * kef 8/5/86: Added putting of Main Card data in ActiveP case. This is so that if subsequent other people bring 
	  up the card, they will see the fact that link card was deleted.)



          (* * kef 8/7/86: Now requires that the card is being edited rather than just Active to thwart direct write through 
	  to NoteFile.)



          (* * rht 8/11/86 Added ShrunkenFlg so that SourceCard is reshrunk afterwards if necessary.)



          (* * fgh 8/30/86 Changed APPLY* to NC.ApplyFn. Appears there might be trouble here since we don't appear to wait if
	  we can't get all the write permission locks. I am assuming for now that this is being taken care of at a higher 
	  level.)



          (* * rht 9/19/86: It was testing NC.BeingEditedP to decide whether had to obtain write permission, etc. I think 
	  NC.ActiveCardP is enough. NC.BeingEditedP is bogus anyway as it doesn't work on card's whose editors don't have 
	  processes like graph cards.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (LET ((ShrunkenFlg (NC.GetShrunkenWin SourceCard))
	  NoteCardType Substance)
         (COND
	   ((NC.ActiveCardP SourceCard)
	     (SETQ NoteCardType (NC.RetrieveType SourceCard))
	     (SETQ Substance (NC.FetchSubstance SourceCard))
	     (NC.ApplyFn DeleteLinksFn SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
	     (NC.PutMainCardData SourceCard))
	   (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
			    (if (NC.ValidCardP (NC.GetNoteCard SourceCard))
				then (RESETLST (RESETSAVE (for CardPart
								   in (QUOTE (SUBSTANCE TOLINKS 
										    GLOBALTOLINKS 
											 PROPLIST))
								   do (NC.ApplyFn 
									  ObtainWritePermissionFn 
										    SourceCard 
										    CardPart))
								(BQUOTE (NC.DeactivateCard , 
										       SourceCard)))
						   (SETQ NoteCardType (NC.RetrieveType SourceCard)
						     )
						   (SETQ Substance (NC.FetchSubstance SourceCard))
						   (NC.ApplyFn DeleteLinksFn SourceCard 
							       LinkOrDestinationCard 
							       Don'tCreateDeletedImageObjFlg)
						   (NC.PutMainCardData SourceCard))))))
         (NC.DelReferencesToCardFromGlobalList SourceCard LinkOrDestinationCard)
         (AND ShrunkenFlg (SHRINKW (NC.FetchWindow SourceCard))))))
)
(* * Changes to NCTEXTCARD)

(DEFINEQ

(NC.DelReferencesToCardFromText
  (LAMBDA (SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 21:01")
                                                             (* Delete all IMAGEOBJECTS in textstream specified by 
							     Substance that are Link Icons whose DESTINATIONID is 
							     eq to Destination ID)

          (* * rht 9/12/85: Fixed so restores old selection after putting in deleted link icon.)



          (* * kirk: 14Nov85: changed EQs to NC.Sames. Deleted use of LinkID.)



          (* * rht 4/30/86: Now only inserts NC.DeletedLinkImageObject if NC.UseDeletedLinkIconIndicators is non-nil.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (DECLARE (GLOBALVARS NC.NoDeleteImageFns NC.UseDeletedLinkIconIndicatorsFlg 
			     NC.DeletedLinkImageObject))
    (LET ((LinkFlg (type? Link LinkOrDestinationCard))
	  DestinationCard Substance)
         (COND
	   (LinkFlg (OR (NC.CardP SourceCard)
			  (SETQ SourceCard (fetch (Link SourceCard) of LinkOrDestinationCard))))
	   (T (SETQ DestinationCard LinkOrDestinationCard)))
         (SETQ Substance (NC.FetchSubstance SourceCard))
         (for Link in (TEDIT.LIST.OF.OBJECTS (TEXTOBJ Substance)
						   (FUNCTION NC.LinkIconImageObjP))
	    bind OldSel when (COND
				   (LinkFlg (NC.SameLinkP LinkOrDestinationCard
							    (NC.FetchLinkFromLinkIcon (CAR Link)))
					    )
				   (T (NC.SameCardP DestinationCard (fetch (Link DestinationCard)
									 of (
									 NC.FetchLinkFromLinkIcon
										(CAR Link))))))
	    do (replace (IMAGEOBJ IMAGEOBJFNS) of (CAR Link) with NC.NoDeleteImageFns) 
                                                             (* WHENDELETEDFN taken care of earlier in delete 
							     cycle)
		 (SETQ OldSel (TEDIT.GETSEL Substance))
		 (TEDIT.DELETE Substance (CADR Link)
				 1)
		 (AND NC.UseDeletedLinkIconIndicatorsFlg (NOT Don'tCreateDeletedImageObjFlg)
			(TEDIT.INSERT.OBJECT NC.DeletedLinkImageObject Substance (CADR Link)))
		 (TEDIT.SETSEL Substance OldSel)))))
)
(* * Changes to NCGRAPHCARD)

(DEFINEQ

(NC.DelReferencesToCardFromGraph
  (LAMBDA (SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 20:58")
                                                             (* Delete from the graph specified by Graph all link 
							     icon nodes whose DESTINATIONID is eq to DestinationID)

          (* * rht 11/17/84: Now only redisplays graph if ID is both active *and* has a window.)



          (* * kirk 14Nov85: deleted use of LinkID)



          (* * rht 4/30/86: Now uses value of NC.UseDeletedLinkIconIndicators to determine whether to delete node or replace 
	  with Deleted indicator.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (DECLARE (GLOBALVARS NC.UseDeletedLinkIconIndicatorsFlg NC.DeletedLinkImageObject))
    (LET ((ImageBox (NC.DeletedLinkImageBoxFn NC.DeletedLinkImageObject))
	  LinkIcon
	  (LinkFlg (type? Link LinkOrDestinationCard))
	  DestinationCard Graph)
         (COND
	   (LinkFlg (OR (NC.CardP SourceCard)
			  (SETQ SourceCard (fetch (Link SourceCard) of LinkOrDestinationCard))))
	   (T (SETQ DestinationCard LinkOrDestinationCard)))
         (SETQ Graph (NC.FetchSubstance SourceCard))
         (for GraphNode in (fetch (GRAPH GRAPHNODES) of Graph)
	    when (AND (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of GraphNode)))
			  (COND
			    (LinkFlg (NC.SameLinkP LinkOrDestinationCard (NC.FetchLinkFromLinkIcon
						       LinkIcon)))
			    (T (NC.SameCardP (fetch (Link DestinationCard) of (
									 NC.FetchLinkFromLinkIcon
										      LinkIcon))
					       DestinationCard))))
	    do (if (AND NC.UseDeletedLinkIconIndicatorsFlg (NOT Don'tCreateDeletedImageObjFlg)
			      )
		     then (replace (GRAPHNODE NODELABEL) of GraphNode with 
									NC.DeletedLinkImageObject)
			    (replace (GRAPHNODE NODEWIDTH) of GraphNode
			       with (fetch (IMAGEBOX XSIZE) of ImageBox))
			    (replace (GRAPHNODE NODEHEIGHT) of GraphNode
			       with (fetch (IMAGEBOX YSIZE) of ImageBox))
		   else (NC.GraphRemoveNode GraphNode Graph (NC.FetchWindow SourceCard)
						T)))
         (COND
	   ((AND (NC.ActiveCardP SourceCard)
		   (NC.FetchWindow SourceCard))
	     (REDISPLAYGRAPH (NC.FetchWindow SourceCard)))))))
)
(* * Changes to NCSKETCHCARD)

(DEFINEQ

(NC.DelReferencesToCardFromSketch
  (LAMBDA (SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 14:52")

          (* * Remove all Link Icons pointing to Destination from the sketch Substance.)



          (* * rht 8/20/85: Rewritten to use Richard's sketch programmer's interface. Eliminates references to sketch 
	  records. I'm changing the innards of the affected link icons rather than deleting them and reinserting.
	  That's because deleting the icon would cause a recursive call.)



          (* * kirk 14Nov85: deleted use of LinkID)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (PROG ((LinkFlg (type? Link LinkOrDestinationCard))
	     DestinationCard SketchSubstance)
	    (COND
	      (LinkFlg (OR (NC.CardP SourceCard)
			     (SETQ SourceCard (fetch (Link SourceCard) of LinkOrDestinationCard)
			       )))
	      (T (SETQ DestinationCard LinkOrDestinationCard)))
	    (SETQ SketchSubstance (NC.FetchSubstance SourceCard))
	    (for SketchElement in (SKETCH.LIST.OF.ELEMENTS SketchSubstance
								 (FUNCTION 
								   NC.LinkIconSketchElementP))
	       bind LinkIcon when (PROGN (SETQ LinkIcon (SKETCH.IMAGEOBJ.OF.ELEMENT 
										    SketchElement))
					       (COND
						 (LinkFlg (NC.SameLinkP LinkOrDestinationCard
									  (NC.FetchLinkFromLinkIcon
									    LinkIcon)))
						 (T (NC.SameCardP DestinationCard
								    (fetch (Link DestinationCard)
								       of (
									 NC.FetchLinkFromLinkIcon
									      LinkIcon))))))
	       do (NC.DeleteLinkIconSketchElement SketchElement SourceCard 
						      Don'tCreateDeletedImageObjFlg)))))

(NC.DeleteLinkIconSketchElement
  (LAMBDA (SketchElement CardID Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 21:01")

          (* * This replaces the link icon for SketchElement from SketchWin with deleted link icon.)



          (* * rht 4/30/86: Changed to simply delete the link icon if NC.UseDeletedLinkIconIndicators is NIL)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (DECLARE (GLOBALVARS NC.DeletedLinkImageFns NC.UseDeletedLinkIconIndicatorsFlg 
			     NC.DeletedLinkImageObject))
    (LET ((Position (SKETCH.POSITION.OF.ELEMENT SketchElement))
	  (SketchSubstance (NC.FetchSubstance CardID))
	  (LinkIcon (SKETCH.IMAGEOBJ.OF.ELEMENT SketchElement))
	  (Window (NC.FetchWindow CardID))
	  Scale)
         (if (AND NC.UseDeletedLinkIconIndicatorsFlg (NOT Don'tCreateDeletedImageObjFlg))
	     then (SETQ Scale (if Window
				      then (VIEWER.SCALE Window)
				    else (NC.FetchScale CardID)))
		    (create IMAGEOBJ smashing LinkIcon OBJECTDATUM ←(IMAGEOBJPROP 
									NC.DeletedLinkImageObject
											(QUOTE
											  OBJECTDATUM)
											)
						  IMAGEOBJFNS ← NC.DeletedLinkImageFns)
		    (AND Window (SKETCH.ELEMENT.CHANGED SketchSubstance SketchElement Window))
	   else (SKETCH.DELETE.ELEMENT SketchElement SketchSubstance T)))))
)
(* * Changes to NCBROWSERCARD)

(DEFINEQ

(NC.DelReferencesToCardFromBrowser
  (LAMBDA (SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 21:01")

          (* * Delete from the browser specified by SourceCard all link icon nodes whose DESTINATIONID is eq to 
	  DestinationID. This just checks the case of the SourceCard being a browser root and then passes off to GRAPHCARD's 
	  DelReferencesFn.)



          (* * rht 4/30/86: No longer passes control up to Super's DeleteLinksFn. Work is now done here.)



          (* * rht 9/2/86: Now sets dirtyflg of substance if change was made.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (DECLARE (GLOBALVARS NC.UseDeletedLinkIconIndicatorsFlg NC.DeletedLinkImageObject))
    (LET ((LinkFlg (type? Link LinkOrDestinationCard))
	  (ImageBox (NC.DeletedLinkImageBoxFn NC.DeletedLinkImageObject))
	  LinkIcon Graph DestinationCard BrowserRoots RootCardToDelete)
         (if LinkFlg
	     then (OR (NC.CardP SourceCard)
			  (SETQ SourceCard (fetch (Link SourceCard) of LinkOrDestinationCard)))
		    (SETQ DestinationCard (fetch (Link DestinationCard) of 
									    LinkOrDestinationCard))
	   else (SETQ DestinationCard LinkOrDestinationCard))
         (if (SETQ RootCardToDelete (for RootCard in (SETQ BrowserRoots (
								 NC.FetchBrowserRoots SourceCard))
					   eachtime (BLOCK) do (if (NC.SameCardP 
										  DestinationCard 
											 RootCard)
									 then (RETURN RootCard))))
	     then (NC.SetBrowserRoots SourceCard (DREMOVE RootCardToDelete BrowserRoots)))
         (SETQ Graph (NC.FetchSubstance SourceCard))
         (for GraphNode in (fetch (GRAPH GRAPHNODES) of Graph)
	    when (AND (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of GraphNode)))
			  (if LinkFlg
			      then (NC.SameLinkP LinkOrDestinationCard (NC.FetchLinkFromLinkIcon
						       LinkIcon))
			    else (NC.SameCardP (fetch (Link DestinationCard)
						      of (NC.FetchLinkFromLinkIcon LinkIcon))
						   DestinationCard)))
	    do (if (AND NC.UseDeletedLinkIconIndicatorsFlg (NOT Don'tCreateDeletedImageObjFlg)
			      )
		     then (replace (GRAPHNODE NODELABEL) of GraphNode with 
									NC.DeletedLinkImageObject)
			    (replace (GRAPHNODE NODEWIDTH) of GraphNode
			       with (fetch (IMAGEBOX XSIZE) of ImageBox))
			    (replace (GRAPHNODE NODEHEIGHT) of GraphNode
			       with (fetch (IMAGEBOX YSIZE) of ImageBox))
			    (NC.SetSubstanceDirtyFlg SourceCard T)
		   else (NC.BrowserRemoveNode Graph (NC.FetchWindow SourceCard)
						  NIL GraphNode T)))
         (if (AND (NC.ActiveCardP SourceCard)
		      (NC.FetchWindow SourceCard))
	     then (REDISPLAYGRAPH (NC.FetchWindow SourceCard))))))
)
(PUTPROPS RHTPATCH135 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1363 14042 (NC.SmartDeleteLinks 1373 . 7395) (NC.DeleteLink 7397 . 10827) (
NC.DelReferencesToCard 10829 . 14040)) (14077 16425 (NC.DelReferencesToCardFromText 14087 . 16423)) (
16461 19075 (NC.DelReferencesToCardFromGraph 16471 . 19073)) (19112 22481 (
NC.DelReferencesToCardFromSketch 19122 . 20994) (NC.DeleteLinkIconSketchElement 20996 . 22479)) (22519
 25689 (NC.DelReferencesToCardFromBrowser 22529 . 25687)))))
STOP