(FILECREATED "27-May-87 17:48:43" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH268.;2 6616   

      changes to:  (VARS RHTPATCH268COMS)

      previous date: "27-May-87 11:34:12" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH268.;1)


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

(PRETTYCOMPRINT RHTPATCH268COMS)

(RPAQQ RHTPATCH268COMS ((* * Fix to bug %#184: NCP.LocalGlobalLink using wrong display mode 
			     default.)
			  (* * Changes to NCPROGINT)
			  (FNS NCP.LocalGlobalLink NCP.CoerceToLinkDisplayMode)
			  (* * PLEASE remove NC.MakeNewDisplayMode and NC.LinkIconPutFn from 
			     NCCONVERTVERSION2TO3. They're already in NCLINKS. Also remove the 
			     comment in NCCONVERTVERSION2TO3 coms right above the FNS for 
			     NC.ConvertLinkFormat.)))
(* * Fix to bug %#184: NCP.LocalGlobalLink using wrong display mode default.)

(* * Changes to NCPROGINT)

(DEFINEQ

(NCP.LocalGlobalLink
  (LAMBDA (LinkType SourceCard DestinationCard FromLoc DisplayMode)
                                                             (* rht: "27-May-87 11:12")

          (* * Create a link from within the text of the SourceCard card to the DestinationCard card.)



          (* * rht 4/1/85: Changed to handle old-style link display modes.)



          (* * rht 11/17/85: Updated to handle new card and notefile objects.)



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)



          (* * rht 5/27/87: Changed call to NCP.CoerceToLinkDisplayMode slightly.)


    (PROG ((CoercedDisplayMode (NCP.CoerceToLinkDisplayMode (OR DisplayMode SourceCard)))
	     WasActive NoteFile)
	    (if (NULL CoercedDisplayMode)
		then (NCP.ReportError (QUOTE NCP.LocalGlobalLink)
					  (CONCAT DisplayMode " is invalid link display mode."
						    (CHARACTER 13)
						    "No link created."))
		       (RETURN NIL))
	    (if (EQ LinkType NC.FiledCardLinkLabel)
		then (if (AND (NOT (NCP.FileBoxP DestinationCard))
				    (NCP.FileBoxP SourceCard))
			   then (OR (SETQ WasActive (NCP.CardCachedP SourceCard))
					(NCP.CacheCards SourceCard))
				  (NCP.ChangeLoc SourceCard FromLoc)
				  (NCP.FileCards DestinationCard SourceCard)
				  (RETURN (PROG1 (CAR (NCP.GetLinks SourceCard 
									    DestinationCard 
									    NC.FiledCardLinkLabel))
						     (OR WasActive (NCP.UncacheCards SourceCard T)
							   )))
			 else (NCP.ReportError (QUOTE NCP.LocalGlobalLink)
						   (CONCAT 
						   "FiledCard link must be from a box to a card."
							     (CHARACTER 13)
							     "No link created."))
				(RETURN NIL)))
	    (if (EQ LinkType NC.SubBoxLinkLabel)
		then (if (AND (NCP.FileBoxP DestinationCard)
				    (NCP.FileBoxP SourceCard))
			   then (OR (SETQ WasActive (NCP.CardCachedP SourceCard))
					(NCP.CacheCards SourceCard))
				  (NCP.ChangeLoc SourceCard FromLoc)
				  (NCP.FileCards DestinationCard SourceCard)
				  (RETURN (PROG1 (CAR (NCP.GetLinks SourceCard 
									    DestinationCard 
									    NC.SubBoxLinkLabel))
						     (OR WasActive (NCP.UncacheCards SourceCard T)
							   )))
			 else (NCP.ReportError (QUOTE NCP.LocalGlobalLink)
						   (CONCAT 
						       "SubBox link must be from a box to a box."
							     (CHARACTER 13)
							     "No link created."))
				(RETURN NIL)))             (* Inserting non-hierarchical link into a filebox.)
	    (if (NCP.FileBoxP SourceCard)
		then (NCP.ReportError (QUOTE NCP.LocalGlobalLink)
					  (CONCAT 
				 "Local links from fileboxes must be either SubBox or FiledCard."
						    (CHARACTER 13)
						    "No link created."))
		       (RETURN NIL))
	    (if (NOT (FMEMB LinkType (NCP.LinkTypes (SETQ NoteFile (fetch (Card NoteFile)
										of SourceCard)))))
		then (if (NC.AskYesOrNo (CONCAT 
						   "That link type hasn't been used in NoteFile "
							(fetch (NoteFile FullFileName)
							   of NoteFile)
							(CHARACTER 13)
							"Want to create a new link type: " LinkType 
							"? ")
					      "--" NIL T (NC.AttachPromptWindow
						(WFROMMENU (fetch (NoteFile Menu) of NoteFile)))
					      NIL NIL)
			   then (NCP.CreateLinkType LinkType NoteFile)
			 else (RETURN NIL)))
	    (OR (SETQ WasActive (NCP.CardCachedP SourceCard))
		  (NCP.CacheCards SourceCard))
	    (AND FromLoc (NCP.ChangeLoc SourceCard FromLoc))
	    (RETURN (PROG1 (NC.InsertLinkInText (NC.FetchSubstance SourceCard)
						      LinkType DestinationCard SourceCard 
						      CoercedDisplayMode)
			       (OR WasActive (NCP.UncacheCards SourceCard T)))))))

(NCP.CoerceToLinkDisplayMode
  (LAMBDA (Thing)                                            (* rht: "27-May-87 11:28")

          (* * Thing can be a cardtype, link, atom, list or LINKDISPLAYMODE record.)



          (* * Fixed so that returns non-nil, if Thing is already a linkdisplaymode.)



          (* * rht 5/27/87: Now checks for case of card type up front.)


    (PROG (DisplayMode)
	    (SETQ DisplayMode (COND
		((type? LINKDISPLAYMODE Thing)
		  (RETURN Thing))
		((NCP.CardTypeP Thing)
		  (NCP.CardTypeVar Thing (QUOTE LinkDisplayMode)))
		((NCP.ValidCardP Thing)
		  (NC.FetchLinkDisplayMode Thing))
		((NCP.ValidLinkP Thing)
		  (NCP.LinkDisplayMode Thing))
		(T Thing)))
	    (SETQ DisplayMode (COND
		((type? LINKDISPLAYMODE DisplayMode)
		  (RETURN DisplayMode))
		((FMEMB DisplayMode NCP.LinkDisplayModes)
		  (NC.MakeNewDisplayMode DisplayMode))
		((LISTP DisplayMode)
		  (create LINKDISPLAYMODE
			    SHOWTITLEFLG ←(CAR DisplayMode)
			    SHOWLINKTYPEFLG ←(CADR DisplayMode)
			    ATTACHBITMAPFLG ←(CADDR DisplayMode)))
		(T DisplayMode)))
	    (RETURN (if (type? LINKDISPLAYMODE DisplayMode)
			  then DisplayMode
			else NIL)))))
)
(* * PLEASE remove NC.MakeNewDisplayMode and NC.LinkIconPutFn from NCCONVERTVERSION2TO3. 
They're already in NCLINKS. Also remove the comment in NCCONVERTVERSION2TO3 coms right above 
the FNS for NC.ConvertLinkFormat.)

(PUTPROPS RHTPATCH268 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (892 6309 (NCP.LocalGlobalLink 902 . 5015) (NCP.CoerceToLinkDisplayMode 5017 . 6307))))
)
STOP