(FILECREATED "14-Jul-86 11:36:21" {QV}<NOTECARDS>1.3K>RHTPATCH070.;1 15008  

      changes to:  (VARS RHTPATCH070COMS)
		   (FNS NC.LinkIconWhenCopiedFn NC.LinkIconWhenMovedFn))


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

(PRETTYCOMPRINT RHTPATCH070COMS)

(RPAQQ RHTPATCH070COMS ((* * Changes to NCLINKS)
			  (FNS NC.LinkIconWhenCopiedFn NC.LinkIconWhenMovedFn)))
(* * Changes to NCLINKS)

(DEFINEQ

(NC.LinkIconWhenCopiedFn
  (LAMBDA (ImageObject ToWindowStream FromTextStream ToTextStream)
                                                             (* rht: "14-Jul-86 11:35")

          (* * Called when copying a link icon from FromTextStream to ToWindowStream. Sets the necessary link information up 
	  for card corresponding to ToWindowStream.)



          (* * rht 11/18/84: Major hacking. Now checks for all sorts of illegal cases. Either goes ahead with copy, converts 
	  link type to "Unspecified", or deletes the new "invisible" link. The latter will change when imageobj fns can 
	  return DON'T.)



          (* * rht 12/12/84: now does RETFROM instead of adding processes to delete imageobj's. This is cleaner, but still 
	  ugly.)



          (* * rht 3/25/85: Fixed to handle copies within a sketch card. That is indicated by nullity of the two textstream 
	  args.)



          (* * rht 3/24/86: Changed call to NC.CoerceToID to NC.CoerceToCard)



          (* * fgh 6/30/86 Now ERROR! out of attempt to copy between NoteFiles)



          (* * rht 7/14/86: Reversed order of tests for WINDOWP and TEXTSTREAMP in computation of NewSourceCard.)


    (PROG (Label (Link (NC.FetchLinkFromLinkIcon ImageObject))
		   SourceCard DestinationCard NewSourceCard NewLabel NewDisplayMode OldDisplayMode
		   (ImageObjectCopy (IMAGEOBJPROP ImageObject (QUOTE ImageObjectCopy)))
		   (Window (AND ToWindowStream (WFROMDS ToWindowStream T)))
		   (InTEditCopyFlg (COND
				     ((STKPOS (QUOTE TEDIT.COPY))
				       T)))
		   InsertPos)
	    (SETQ Label (fetch (Link Label) of Link))
	    (SETQ SourceCard (fetch (Link SourceCard) of Link))
	    (SETQ DestinationCard (fetch (Link DestinationCard) of Link))
	    (SETQ OldDisplayMode (fetch (Link DisplayMode) of Link))
	    (SETQ NewSourceCard (COND
		((TEXTSTREAMP ToTextStream)
		  (NC.CoerceToCard ToTextStream))
		((WINDOWP Window)
		  (NC.CoerceToCard Window))))
	    (COND
	      ((AND (NULL FromTextStream)
		      (NULL ToTextStream))                 (* We must be moving within a sketch.)
		(SETQ NewSourceCard SourceCard))
	      ((TEXTSTREAMP ToTextStream)                  (* If it's a text copy, then compute position to 
							     insert link at.)
		(SETQ InsertPos (NC.CharPosFromTextObject (TEXTOBJ ToTextStream)))))

          (* * If we are copying across NoteFiles, then its an error)


	    (if (AND NewSourceCard (NOT (NC.SameNoteFileP (fetch (Card NoteFile)
								     of SourceCard)
								  (fetch (Card NoteFile)
								     of NewSourceCard))))
		then (NC.PrintMsg Window T 
				      "Cannot copy links between cards from different NoteFiles."
				      (CHARACTER 13)
				      "Copy aborted."
				      (CHARACTER 13))
		       (ERROR!))
	    (COND
	      ((NULL NewSourceCard)                        (* Trying to copy to a non NoteCard stream)
		(NC.PrintMsg Window NIL (CONCAT "Tried to copy a NoteCards link icon" 
						    " to a non-NoteCards stream."
						    (CHARACTER 13)))
		(NC.CoerceToExternalPutLinkIcon ImageObjectCopy SourceCard DestinationCard Label)
		(RETURN NIL))
	      ((NULL (NC.LinksSupportedP NewSourceCard (QUOTE (Local))))
		(NC.PrintMsg Window NIL (CONCAT "Tried to copy a NoteCards link icon" 
						    " to a NoteCard that"
						    " does not support links!!."
						    (CHARACTER 13)
						    "Tsk. Tsk."
						    (CHARACTER 13)))
		(COND
		  (InTEditCopyFlg (RETFROM (QUOTE TEDIT.COPY)
					     NIL T))
		  (T (RETURN (QUOTE DON'T)))))
	      ((AND (FMEMB Label (QUOTE (FiledCard SubBox)))
		      (NEQ (NC.RetrieveType NewSourceCard)
			     (QUOTE FileBox)))             (* Copy from filebox to non-filebox.)
		(NC.PrintMsg NIL NIL (CONCAT 
				       "Tried to copy filedcard or subbox link to a non-filebox."
						 (CHARACTER 13)
						 "Link type of copy set to 'Unspecified'."
						 (CHARACTER 13)))
		(SETQ NewLabel NC.UnspecifiedLinkLabel)
		(SETQ NewDisplayMode (create LINKDISPLAYMODE
					  copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← 
						    T)))
	      ((AND (NEQ (NC.RetrieveType SourceCard)
			     (QUOTE FileBox))
		      (EQ (NC.RetrieveType NewSourceCard)
			    (QUOTE FileBox)))              (* Copy from non-filebox to filebox.)
		(NC.PrintMsg NIL NIL (CONCAT "Can't copy links from non-filebox to filebox."
						 (CHARACTER 13)
						 "Try using 'PutCardsHere'."
						 (CHARACTER 13)))
		(COND
		  (InTEditCopyFlg (RETFROM (QUOTE TEDIT.COPY)
					     NIL T))
		  (T (RETURN (QUOTE DON'T)))))
	      ((AND (FMEMB Label (QUOTE (FiledCard SubBox)))
		      (EQ NewSourceCard SourceCard))       (* Copy within same filebox.)
		(NC.PrintMsg NIL NIL (CONCAT 
					  "Can't copy links within a FileBox.  Try move instead."
						 (CHARACTER 13)))
		(COND
		  (InTEditCopyFlg (RETFROM (QUOTE TEDIT.COPY)
					     NIL T))
		  (T (RETURN (QUOTE DON'T)))))
	      ((AND (EQ (NC.RetrieveType NewSourceCard)
			    (QUOTE FileBox))
		      (for Link1 in (NC.FetchToLinks NewSourceCard)
			 thereis (AND (NC.ChildLinkP Link1)
					  (EQ DestinationCard (fetch (Link DestinationCard)
								   of Link1)))))
                                                             (* Copy to a filebox already containing this child.)
		(NC.PrintMsg NIL NIL (CONCAT (NC.RetrieveTitle DestinationCard)
						 " not copied: already appears as a child of "
						 (NC.RetrieveTitle NewSourceCard)
						 (CHARACTER 13)))
		(COND
		  (InTEditCopyFlg (RETFROM (QUOTE TEDIT.COPY)
					     NIL T))
		  (T (RETURN (QUOTE DON'T)))))
	      ((AND (EQ Label (QUOTE SubBox))
		      (OR (EQ NewSourceCard DestinationCard)
			    (NOT (NC.NotDaughterP DestinationCard NewSourceCard
						      (FUNCTION NC.ChildLinkP)))))
                                                             (* Copy to a filebox causes a cycle.)
		(NC.PrintMsg NIL NIL (CONCAT "Couldn't copy " Link " because of subbox cycle."
						 (CHARACTER 13)))
		(COND
		  (InTEditCopyFlg (RETFROM (QUOTE TEDIT.COPY)
					     NIL T))
		  (T (RETURN (QUOTE DON'T)))))
	      ((AND (FMEMB Label NC.SystemLinkLabels)
		      (NOT (FMEMB Label (QUOTE (FiledCard SubBox))))
		      (NEQ NewSourceCard SourceCard))      (* Copy of system link outside of own card.)
		(NC.PrintMsg NIL NIL (CONCAT "Tried to copy system link." (CHARACTER 13)
						 "Link type of copy set to 'Unspecified'."
						 (CHARACTER 13)))
		(SETQ NewLabel NC.UnspecifiedLinkLabel)
		(SETQ NewDisplayMode (create LINKDISPLAYMODE
					  copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← 
						    T))))
	    (NC.FillInLinkIcon ImageObjectCopy (OR NewLabel Label)
				 DestinationCard NewSourceCard (OR NewDisplayMode OldDisplayMode)
				 (NC.LinkAtCharPos InsertPos ToTextStream)))))

(NC.LinkIconWhenMovedFn
  (LAMBDA (ImageObject ToWindowStream FromTextStream ToTextStream)
                                                             (* rht: "14-Jul-86 11:35")

          (* * Called when moving a link icon from FromTextStream to ToWindowStream. Sets the necessary link information up 
	  for card corresponding to ToWindowStream.)



          (* * rht 11/18/84: Major hacking. Now checks for all sorts of illegal cases. Either goes ahead with move, converts 
	  link type to "Unspecified", or deletes the new "invisible" link. The code is very similar to 
	  NC.LinkIconWhenCopiedFn except that within-filebox moves are allowed. Also when aborting a move, we must insert a 
	  copy of the link back to take the place of the deleted original. This will all change when imageobj fns can return 
	  DON'T.)



          (* * rht 12/12/84: Now just RETFROM's rather than doing the addprocess stuff. Should be cleaner, but still ugly.)



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



          (* * rht 3/24/86: Changed call to NC.CoerceToID to NC.CoerceToCard)



          (* * kirk 24Mar86: added Dave Newman patch to avoid duplicate links in sketch cards)



          (* * rht 7/14/86: Reversed order of tests for WINDOWP and TEXTSTREAMP in computation of NewSourceCard.)


    (LET (Label (Link (NC.FetchLinkFromLinkIcon ImageObject))
		SourceCard DestinationCard NewSourceCard NewLabel NewDisplayMode OldDisplayMode
		(Window (AND ToWindowStream (WFROMDS ToWindowStream T)))
		InsertPos)
         (SETQ Label (fetch (Link Label) of Link))
         (SETQ NewSourceCard (COND
	     ((TEXTSTREAMP ToTextStream)
	       (NC.CoerceToCard ToTextStream))
	     ((WINDOWP Window)
	       (NC.CoerceToCard Window))))
         (SETQ SourceCard (fetch (Link SourceCard) of Link))
         (SETQ DestinationCard (fetch (Link DestinationCard) of Link))
         (SETQ OldDisplayMode (fetch (Link DisplayMode) of Link))

          (* * If we are copying across NoteFiles, then its an error)


         (if (AND NewSourceCard (NOT (NC.SameNoteFileP (fetch (Card NoteFile) of 
										       SourceCard)
							       (fetch (Card NoteFile) of 
										    NewSourceCard))))
	     then (NC.PrintMsg Window T 
				   "Cannot move links between cards from different NoteFiles."
				   (CHARACTER 13)
				   "Move aborted."
				   (CHARACTER 13))
		    (ERROR!))
         (COND
	   ((AND (NULL FromTextStream)
		   (NULL ToTextStream))                    (* We must be moving within a sketch.)
	     (SETQ NewSourceCard SourceCard))
	   ((TEXTSTREAMP ToTextStream)                     (* If it's a text copy, then compute position to 
							     insert link at.)
	     (SETQ InsertPos (NC.CharPosFromTextObject (TEXTOBJ ToTextStream)))))
         (COND
	   ((NULL NewSourceCard)                           (* Trying to copy to a non NoteCard stream)
	     (NC.PrintMsg Window NIL (CONCAT "Tried to move a NoteCards link icon" 
						 " to a non-NoteCards stream!!."
						 (CHARACTER 13)
						 "Tsk. Tsk."
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((NULL (NC.LinksSupportedP NewSourceCard (QUOTE (Local))))
	     (NC.PrintMsg Window NIL (CONCAT "Tried to move a NoteCards link icon" 
						 " to a NoteCard that"
						 " does not support links!!."
						 (CHARACTER 13)
						 "Tsk. Tsk."
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (FMEMB Label (QUOTE (FiledCard SubBox)))
		   (NEQ (NC.RetrieveType NewSourceCard)
			  (QUOTE FileBox)))                (* Move from filebox to non-filebox.)
	     (NC.PrintMsg NIL NIL (CONCAT 
				       "Tried to move filedcard or subbox link to a non-filebox."
					      (CHARACTER 13)
					      "Link type of copy set to 'Unspecified'."
					      (CHARACTER 13)))
	     (SETQ NewLabel NC.UnspecifiedLinkLabel)
	     (SETQ NewDisplayMode (create LINKDISPLAYMODE
				       copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T))
	     )
	   ((AND (NEQ (NC.RetrieveType SourceCard)
			  (QUOTE FileBox))
		   (EQ (NC.RetrieveType NewSourceCard)
			 (QUOTE FileBox)))                 (* Move from non-filebox to filebox.)
	     (NC.PrintMsg NIL NIL (CONCAT "Can't move links from non-filebox to filebox."
					      (CHARACTER 13)
					      "Try using PutCardsHere."
					      (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (EQ (NC.RetrieveType NewSourceCard)
			 (QUOTE FileBox))
		   (NEQ NewSourceCard SourceCard)
		   (for Link1 in (NC.FetchToLinks NewSourceCard)
		      thereis (AND (NC.ChildLinkP Link1)
				       (EQ DestinationCard (fetch (Link DestinationCard)
								of Link1)))))
                                                             (* Move to a filebox already containing this child.)
	     (NC.PrintMsg NIL NIL (CONCAT (NC.RetrieveTitle DestinationCard)
					      " not moved: already appears as a child of "
					      (NC.RetrieveTitle NewSourceCard)
					      (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (EQ Label (QUOTE SubBox))
		   (NEQ NewSourceCard SourceCard)
		   (OR (EQ NewSourceCard DestinationCard)
			 (NOT (NC.NotDaughterP DestinationCard NewSourceCard
						   (FUNCTION NC.ChildLinkP)))))
                                                             (* Move to a filebox causes a cycle.)
	     (NC.PrintMsg NIL NIL (CONCAT "Couldn't move " Link " because of subbox cycle."
					      (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (FMEMB Label NC.SystemLinkLabels)
		   (NOT (FMEMB Label (QUOTE (FiledCard SubBox))))
		   (NEQ NewSourceCard SourceCard))         (* Move of system link outside of own card.)
	     (NC.PrintMsg NIL NIL (CONCAT "Tried to copy system link." (CHARACTER 13)
					      "Link type of copy set to 'Unspecified'."
					      (CHARACTER 13)))
	     (SETQ NewLabel NC.UnspecifiedLinkLabel)
	     (SETQ NewDisplayMode (create LINKDISPLAYMODE
				       copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T))
	     ))
         (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMoved)
			 Link)
         (if (NEQ (QUOTE Sketch)
		      (fetch (Card Type) of SourceCard))
	     then (NC.FillInLinkIcon ImageObject (OR NewLabel Label)
					 DestinationCard NewSourceCard (OR NewDisplayMode 
									     OldDisplayMode)
					 (NC.LinkAtCharPos InsertPos ToTextStream))))))
)
(PUTPROPS RHTPATCH070 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (432 14926 (NC.LinkIconWhenCopiedFn 442 . 7884) (NC.LinkIconWhenMovedFn 7886 . 14924))))
)
STOP