(FILECREATED " 1-Oct-87 19:42:52" {QV}<NOTECARDS>1.3KNEXT>RHTPATCH290.;1 5434   

      changes to:  (VARS RHTPATCH290COMS)
		   (FNS NC.LinkIconWhenDeletedFn))


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

(PRETTYCOMPRINT RHTPATCH290COMS)

(RPAQQ RHTPATCH290COMS ((* * Fixes bug reported by John Tang whereby moving a cross-file link to 
			     another notefile leaves a half link.)
			  (* * Change to NCLINKS)
			  (FNS NC.LinkIconWhenDeletedFn)))
(* * Fixes bug reported by John Tang whereby moving a cross-file link to another notefile 
leaves a half link.)

(* * Change to NCLINKS)

(DEFINEQ

(NC.LinkIconWhenDeletedFn
  (LAMBDA (ImageObject Stream)                               (* rht: " 1-Oct-87 19:40")

          (* * When deleting a link icon image object from a card, make sure the link information on the source and 
	  destinmation cards get updated. When deleting a link image object from a prop list editor, just inform the user 
	  that this is a useless operation.)



          (* * rht 11/19/84: Now handles the case when a move is in progress. True if the old link is cached on the ImageObj.
	  Also changed so that SourceID is computed from ImageObject rather than from Stream. Similarly for the window.)



          (* * kirk 14Nov85: deleted use of PSA.Database)



          (* * fgh 5/2/86 Added code to handle deleting of links from ShowLinks editors.)



          (* * fgh 6/4/86 Added KLUDGE to take care of case when this is called under TEDIT.UNDO.MOVE)



          (* * rht 7/4/86: Now checks for readonly cards. Also passes checks for deleting from orphan card when calling 
	  NC.DeleteLink.)



          (* * fgh 7/14/86 Now deletes link icon directly, rather than depending on DeleteLink to do it.
	  Sets the Don'tDeleteLinkIconFlg in the call to DeleteLink to do so.)



          (* * rht 8/11/86: Now computes InsideShowLinksP and lets that determine value of Don'tDelLinkIcon flg in call to 
	  NC.DeleteLink.)



          (* * rht&pmi 12/8/86: Now checks whether we're called by TEDIT.MOVE. If so, don't cause orphan hook under 
	  NC.DelFromLink.)



          (* * rht 3/26/87: Now passes non-nil NoOrphanHookFlg to NC.DeleteLink in case we're deleting a cross-file link.)



          (* * rht 10/1/87: Fixed case when we're under a move to call NC.DeleteLink rather than NC.DelFromLink and 
	  NC.DelToLink individually.)


    (DECLARE (GLOBALVARS NC.DeletedLinkImageObject))
    (LET ((Link (NC.FetchLinkFromLinkIcon ImageObject))
	  LinkType OldLink StkPtr SourceCard DestinationCard InsideShowLinksP)
         (COND
	   ((NC.CheckForNotReadOnly (fetch (Link SourceCard) of Link)
				      NIL "Can't delete links in ")
	     (COND
	       ((IMAGEOBJPROP ImageObject (QUOTE LinkBeingMovedWithinCard))
                                                             (* TEdit is trying to delete the old link imageobj 
							     after moving within a card.)
		 (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMovedWithinCard)
				 NIL))
	       ((SETQ OldLink (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMoved)))
		 (NC.DeleteLink OldLink)
		 (replace (Link UID) of OldLink with -1)
		 (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMoved)
				 NIL))
	       ((SETQ StkPtr (STKPOS (QUOTE TEDIT.UNDO.MOVE)))

          (* * Called from TEDIT.UNDO.MOVE, don't relly want to delete the links. KLUDGE because TEDIT will not call the 
	  LinkIconInsertFn later on.)


		 (RELSTK StkPtr)
		 NIL)
	       (T 

          (* * if this is reversed source/dest {i.e., a From link} inside the show links editor, then return it to its 
	  original direction)


		  (COND
		    ((AND (SETQ InsideShowLinksP (IMAGEOBJPROP ImageObject (QUOTE 
									     InsidePropListEditor)))
			    (LISTGET (fetch (Link UserData) of Link)
				       (QUOTE Reversed)))
		      (SETQ Link (create Link using Link SourceCard ←(fetch (Link 
										  DestinationCard)
									      of Link)
							  DestinationCard ←(fetch (Link SourceCard)
									      of Link)))))

          (* * Then just delete the link)


		  (NC.CheckForOrphanDelete (SETQ SourceCard (fetch (Link SourceCard)
								   of Link))
					     (SETQ DestinationCard (fetch (Link DestinationCard)
									of Link)))
		  (NC.DeleteLink Link (OR (NC.SameCardP SourceCard (fetch (NoteFile 
										      OrphansCard)
									    of (fetch
										   (Card NoteFile)
										    of SourceCard)))
					      (NC.CrossFileLinkCardP DestinationCard)
					      (NC.CrossFileLinkCardP SourceCard))
				   (NOT InsideShowLinksP))
		  (create IMAGEOBJ smashing ImageObject OBJECTDATUM ←(fetch (IMAGEOBJ 
										      OBJECTDATUM)
									    of 
									NC.DeletedLinkImageObject)
						IMAGEOBJPLIST ←(fetch (IMAGEOBJ IMAGEOBJPLIST)
								  of NC.DeletedLinkImageObject)
						IMAGEOBJFNS ←(fetch (IMAGEOBJ IMAGEOBJFNS)
								of NC.DeletedLinkImageObject))
		  (replace (Link UID) of Link with -1))))
	   (T (ERROR!))))))
)
(PUTPROPS RHTPATCH290 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (633 5352 (NC.LinkIconWhenDeletedFn 643 . 5350)))))
STOP