(FILECREATED "31-Oct-86 12:41:31" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH119.;5 24688  

      changes to:  (FNS NC.DumpExportableCardToDoc)

      previous date: "20-Oct-86 17:00:32" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH119.;3)


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

(PRETTYCOMPRINT RHTPATCH119COMS)

(RPAQQ RHTPATCH119COMS ((* * This incorporates a somewhat massaged version of MarkM's changes to 
			     NCDOCUMENTCARD)
			  (* * New function for NCDOCUMENTCARD)
			  (FNS NC.DumpCardToDoc)
			  (* * Changes to NCDOCUMENTCARD)
			  (FNS NC.MakeDocument NC.DumpFileBoxToDoc NC.DumpNoteCardToDoc 
			       NC.DumpExportableCardToDoc)
			  (* * New macro for NCUTILITIES)
			  (MACROS NC.ActivateCardAndDo)
			  (* * Fixes for NCPROGINT)
			  (FNS NCP.SketchBasedP NCP.GraphBasedP)))
(* * This incorporates a somewhat massaged version of MarkM's changes to NCDOCUMENTCARD)

(* * New function for NCDOCUMENTCARD)

(DEFINEQ

(NC.DumpCardToDoc
  (LAMBDA (Card DocCard DocStream CurSection SubSectionNum HeadingsFromFileboxes TitlesFromNoteCards 
		BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks)
                                                             (* rht: "20-Oct-86 17:00")

          (* * rht 10/15/86: Integrated markM's changes and fixed box numbering.)


    (LET ((Type (NC.RetrieveType Card)))
         (COND
	   ((OR (NCP.SketchBasedP Card)
		  (NCP.GraphBasedP Card)
		  (GETPROP Type (QUOTE ExportSubstanceFn)))
	     (NC.ActivateCardAndDo Card
				   (NC.DumpExportableCardToDoc Card DocCard DocStream CurSection 
								 SubSectionNum HeadingsFromFileboxes 
								 TitlesFromNoteCards BuildBackLinks 
								 CopyEmbeddedLinks 
								 ExpandEmbeddedLinks Type)))
	   ((NCP.FileBoxP Card)
	     (NC.ActivateCardAndDo Card (NC.DumpFileBoxToDoc Card DocCard DocStream CurSection 
							       SubSectionNum HeadingsFromFileboxes 
							       TitlesFromNoteCards BuildBackLinks 
							       CopyEmbeddedLinks ExpandEmbeddedLinks))
	     )
	   ((NCP.TextBasedP Card)
	     (NC.ActivateCardAndDo Card (NC.DumpNoteCardToDoc Card DocCard DocStream CurSection 
								SubSectionNum HeadingsFromFileboxes 
								TitlesFromNoteCards BuildBackLinks 
								CopyEmbeddedLinks ExpandEmbeddedLinks)
				   ))
	   (T (NC.PrintMsg NIL NIL "Can't make document from non-exportable card " (
			       NC.RetrieveTitle Card)
			     (CHARACTER 13))
	      SubSectionNum)))))
)
(* * Changes to NCDOCUMENTCARD)

(DEFINEQ

(NC.MakeDocument
  (LAMBDA (Card Title NoDisplayFlg CardIdentifier)           (* rht: "15-Oct-86 17:52")

          (* * Called from a filebox's title bar. Makes a document by smashing all the descendant cards's text together.
	  Ask user if wants numbered section headings and titles. The former are made from FileBox titles, the latter from 
	  notecard titles. Delete embedded links at the end if the user desires.)



          (* * rht 10/22/84: Hacked to be callable from Programmer's interface.)



          (* * rht 11/17/84: Checks for cancel when choosing rootID and also when setting parameters.)



          (* * rht 8/25/85: Now dumps sketch and graph cards as well as text cards.)



          (* * rht 9/16/85: Now handles cr's around titles using para leading.)



          (* * fgh 11/178/85 Updated to handle Card and NoteFile objects.)



          (* * kirk 27Jun86 Moved NC.RetrieveTitle call so does not break when user Cancels)



          (* * rht 7/31/86: Now checks for card types having ExportSubstanceFn prop.)



          (* * kirk 8/22/86 Fix of free use of NoteFile var)



          (* * rht 10/15/86: Integrated markM's changes and fixed box numbering.)


    (PROG (RootCard RootTitle DocWindow DocCard DocWindowOrCard DocStream HeadingsFromFileboxes 
		      TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks 
		      InspectWin RootSubstanceType)
	    (OR NoDisplayFlg (SPAWN.MOUSE))
	    (SETQ DocWindowOrCard (NC.MakeNoteCard (QUOTE Text)
						       (fetch (Card NoteFile) of Card)
						       "Document" NoDisplayFlg NIL Card))
	    (if NoDisplayFlg
		then (SETQ DocWindow NIL)
		       (SETQ DocCard DocWindowOrCard)
	      else (SETQ DocWindow DocWindowOrCard)
		     (SETQ DocCard (NC.CoerceToCard DocWindow)))
                                                             (* NC.MakeNoteCard either returned an Card or a window
							     depending on NoDisplayFlg.)
	    (SETQ RootCard (OR (NC.CoerceToCard CardIdentifier)
				   (NC.SelectNoteCards T NIL NC.SelectingCardMenu DocWindow NIL 
			"Please select the Note Card or File Box the document should start from.")))
	    (if (NOT RootCard)
		then (NC.DeleteNoteCards Card T)
		       (RETURN NIL))
	    (SETQ RootTitle (NC.RetrieveTitle RootCard))
	    (NC.SetTitle DocCard (CONCAT "Document from %"" RootTitle "%""))
	    (AND DocWindow (WINDOWPROP DocWindow (QUOTE TITLE)
					   (NC.RetrieveTitle DocCard)))
	    (SETQ DocStream (NC.FetchSubstance DocCard))

          (* * Get MakeDocument parameters from user via inspector window.)


	    (if (NOT NoDisplayFlg)
		then (SETQ InspectWin (NC.BuildMakeDocInspector DocWindow))
		       (TOTOPW InspectWin)
		       (for while (OPENWP InspectWin) do (BLOCK)))
	    (if (EQ (GETPROP (QUOTE NC.MakeDocParameters)
				   (QUOTE --DONE--))
			(QUOTE QUIT))
		then (PUTPROP (QUOTE NC.MakeDocParameters)
				  (QUOTE --DONE--)
				  (QUOTE --CANCEL--))
		       (NC.DeleteNoteCards Card T)
		       (RETURN NIL))
	    (SETQ HeadingsFromFileboxes (GETPROP (QUOTE NC.MakeDocParameters)
						     (QUOTE HeadingsFromFileboxes)))
	    (SETQ TitlesFromNoteCards (GETPROP (QUOTE NC.MakeDocParameters)
						   (QUOTE TitlesFromNoteCards)))
	    (SETQ BuildBackLinks (GETPROP (QUOTE NC.MakeDocParameters)
					      (QUOTE BuildBackLinks)))
	    (SETQ CopyEmbeddedLinks (GETPROP (QUOTE NC.MakeDocParameters)
						 (QUOTE CopyEmbeddedLinks)))
	    (SETQ ExpandEmbeddedLinks (GETPROP (QUOTE NC.MakeDocParameters)
						   (QUOTE ExpandEmbeddedLinks)))

          (* * Call recursive routine to dump filebox.)


	    (RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
			(NC.PrintMsg DocWindow NIL "Collecting text from descendant cards ... ")

          (* * Clean up the SeenBefore markers placed on the cards and boxes just copied.)


			(RESETSAVE NIL (QUOTE (PROGN (for Card in (NC.FetchUserDataProp
									      DocCard
									      (QUOTE SeenCards))
							      do (NC.SetUserDataProp
								     Card
								     (QUOTE SeenBefore)
								     NIL))
							   (NC.SetUserDataProp DocCard
										 (QUOTE SeenCards)
										 NIL))))

          (* * Unbelievably kludgy hack to get around Intermezzo TEdit bug. Just insert and delete a CR.)


			(TEDIT.INSERT DocStream NC.CRString 1)
			(TEDIT.DELETE DocStream 1 1)
			(NC.DumpCardToDoc RootCard DocCard DocStream 0 0 HeadingsFromFileboxes 
					    TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks 
					    ExpandEmbeddedLinks)
			(NC.PrintMsg DocWindow NIL "Done!"))
	    (COND
	      ((NOT NoDisplayFlg)
		(BLOCK 250)
		(NC.ClearMsg DocWindow T)))
	    (RETURN DocWindowOrCard))))

(NC.DumpFileBoxToDoc
  (LAMBDA (FileBoxCard DocCard DocStream CurSection SubSectionNum HeadingsFromFileboxes 
		       TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks)
                                                             (* rht: "15-Oct-86 17:41")

          (* * Dump the contents of FileboxID to DocStream by recursively dumping all of its children.
	  Keep track of the section numbers in case HeadingsFromFileboxes = Numbered. Insert back pointers to the source 
	  cards and/or boxes depending on value of BuildBackpointers. Embedded links (or some subset of them) may be copied 
	  or expanded depending on the values of CopyEmbeddedLinks and ExpandEmbeddedLinks.)



          (* * rht 8/25/85: Fixed to handle sketch and graph cards.)



          (* * rht 9/16/85: Now handles cr's around titles using para leading.)



          (* * fgh 11/178/85 Updated to handle Card and NoteFile objects.)



          (* * rht 7/31/86: Now checks for card types having ExportSubstanceFn prop.)



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



          (* * rht 10/15/86: Integrated markM's changes and fixed box numbering.)


    (LET ((DocObject (TEXTOBJ DocStream))
	  ShrunkenFlg OldLoc)
         (NC.AddCRIfNeeded DocStream)
         (SETQ OldLoc (fetch (TEXTOBJ TEXTLEN) of DocObject))
         (if (AND (EQ HeadingsFromFileboxes (QUOTE NumberedBold))
		      (NOT (ZEROP SubSectionNum)))
	     then (SETQ CurSection (if (ZEROP CurSection)
					   then SubSectionNum
					 else (CONCAT CurSection "." SubSectionNum)))
		    (NC.AppendStringToStream DocStream (CONCAT CurSection " ")
					       T))
         (AND (NEQ HeadingsFromFileboxes (QUOTE NONE))
		(NC.AppendStringToStream DocStream (CONCAT (NC.RetrieveTitle FileBoxCard))
					   T))
         (AND (FMEMB BuildBackLinks (QUOTE (ToBoxes ToCardsBoxes)))
		(NCP.LocalGlobalLink NC.DocBackPtrLinkLabel DocCard FileBoxCard (QUOTE END)
				       (QUOTE Icon)))
         (if (GREATERP (fetch (TEXTOBJ TEXTLEN) of DocObject)
			   OldLoc)
	     then (NC.AddCRIfNeeded DocStream)
		    (NC.ChangeParaLeading DocStream))
         (if (NOT (NC.FetchUserDataProp FileBoxCard (QUOTE SeenBefore)))
	     then (SETQ ShrunkenFlg (NC.GetShrunkenWin FileBoxCard))
		    (NC.SetUserDataProp DocCard (QUOTE SeenCards)
					  (CONS FileBoxCard (NC.FetchUserDataProp DocCard
										      (QUOTE 
											SeenCards))))
		    (NC.SetUserDataProp FileBoxCard (QUOTE SeenBefore)
					  T)
		    (for Link in (NC.FetchToLinksInOrder FileBoxCard) bind (SubSectionCounter
										     ← 1)
		       eachtime (BLOCK) when (FMEMB (fetch (Link Label) of Link)
							    (LIST NC.FiledCardLinkLabel 
								    NC.SubBoxLinkLabel))
		       do (LET ((ChildCard (fetch (Link DestinationCard) of Link)))
			         (SETQ SubSectionCounter
				   (NC.DumpCardToDoc ChildCard DocCard DocStream CurSection 
						       SubSectionCounter HeadingsFromFileboxes 
						       TitlesFromNoteCards BuildBackLinks 
						       CopyEmbeddedLinks ExpandEmbeddedLinks))))
		    (NC.SetUserDataProp FileBoxCard (QUOTE SeenBefore)
					  NIL)
		    (AND ShrunkenFlg (SHRINKW (NC.FetchWindow FileBoxCard)))
		    (ADD1 SubSectionNum)
	   else (NC.PrintMsg NIL NIL (NC.RetrieveTitle FileBoxCard)
				 " only expanded once in this cycle.")
		  SubSectionNum))))

(NC.DumpNoteCardToDoc
  (LAMBDA (Card DocCard DocStream CurSection SubSectionNum HeadingsFromFileboxes TitlesFromNoteCards 
		BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks)
                                                             (* rht: "15-Oct-86 17:52")

          (* * Dump the CardID notecard to the document card DocStream.)



          (* * rht 8/25/85: Fixed to handle sketch and graph cards.)



          (* * rht 9/16/85: Now handles cr's around titles using para leading.)



          (* * fgh 11/178/85 Updated to handle Card and NoteFile objects.)



          (* * rht 7/31/86: Now checks for card types having ExportSubstanceFn prop.)



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



          (* * rht 10/15/86: Integrated markM's changes and fixed box numbering.)


    (LET ((CardStream (NC.FetchSubstance Card))
	  (DocObj (TEXTOBJ DocStream))
	  ShrunkenFlg CardObj OldLoc)
         (SETQ CardObj (TEXTOBJ CardStream))
         (NC.AddCRIfNeeded DocStream)
         (SETQ OldLoc (fetch (TEXTOBJ TEXTLEN) of DocObj))
         (AND (NEQ TitlesFromNoteCards (QUOTE NONE))
		(NC.AppendStringToStream DocStream (CONCAT (NC.RetrieveTitle Card))
					   (EQ TitlesFromNoteCards (QUOTE Bold))))
         (AND (FMEMB BuildBackLinks (QUOTE (ToCards ToCardsBoxes)))
		(NCP.LocalGlobalLink NC.DocBackPtrLinkLabel DocCard Card (QUOTE END)
				       (QUOTE Icon)))
         (if (GREATERP (fetch (TEXTOBJ TEXTLEN) of DocObj)
			   OldLoc)
	     then (NC.AddCRIfNeeded DocStream)
		    (NC.ChangeParaLeading DocStream))
         (if (NOT (NC.FetchUserDataProp Card (QUOTE SeenBefore)))
	     then (SETQ ShrunkenFlg (NC.GetShrunkenWin Card))
		    (NC.SetUserDataProp DocCard (QUOTE SeenCards)
					  (CONS Card (NC.FetchUserDataProp DocCard (QUOTE
										 SeenCards))))
		    (NC.SetUserDataProp Card (QUOTE SeenBefore)
					  T)

          (* * Step through list of notecard imageobjs in the card we're working on and either expand or copy or ignore each 
	  according to values of ExpandEmbeddedLinks and CopyEmbeddedLinks.)


		    (for Object in (TEDIT.LIST.OF.OBJECTS CardObj (FUNCTION 
								  NC.LinkIconImageObjP))
		       bind LinkSpec LinkLabel ToCard ToCardType (LastLoc ← 1)
			      (CurLoc ← 0)
			      ActiveP ExpandP CopyP AlreadyExpanded
		       eachtime (BLOCK)
		       do ((SETQ LinkSpec (NC.FetchLinkFromLinkIcon (CAR Object)))
			     (SETQ LinkLabel (fetch (Link Label) of LinkSpec))
			     (SETQ CurLoc (CADR Object))
                                                             (* Copy over any text between this obj and the last.)
			     (if (ILESSP LastLoc CurLoc)
				 then (TEDIT.COPY (TEDIT.SETSEL CardStream LastLoc
								      (IDIFFERENCE CurLoc LastLoc))
						      (TEDIT.SETSEL DocStream
								      (fetch TEXTLEN of DocObj)
								      1
								      (QUOTE RIGHT))))
			     (SETQ LastLoc (ADD1 CurLoc))
			     (SETQ CopyP (OR (EQ CopyEmbeddedLinks (QUOTE ALL))
						 (AND (LISTP CopyEmbeddedLinks)
							(FMEMB LinkLabel CopyEmbeddedLinks))))
			     (SETQ ExpandP (OR (EQ ExpandEmbeddedLinks (QUOTE ALL))
						   (AND (LISTP ExpandEmbeddedLinks)
							  (FMEMB LinkLabel ExpandEmbeddedLinks))))
			     (if (AND (SETQ AlreadyExpanded (NC.FetchUserDataProp
					      (SETQ ToCard (fetch (Link DestinationCard)
								of LinkSpec))
					      (QUOTE SeenBefore)))
					  ExpandP)
				 then (NC.PrintMsg NIL NIL (NC.RetrieveTitle ToCard)
						       " only expanded once in this cycle."
						       (CHARACTER 13)))
			     (if (OR CopyP (AND ExpandP AlreadyExpanded))
				 then                      (* Copy this link.)
					(TEDIT.COPY (TEDIT.SETSEL CardStream CurLoc 1)
						      (TEDIT.SETSEL DocStream
								      (ADD1 (fetch TEXTLEN
										 of DocObj))
								      0
								      (QUOTE RIGHT))))
			     (if (AND ExpandP (NOT AlreadyExpanded))
				 then                      (* Expand this link. Check type and make recursive 
							     call.)
					(SETQ SubSectionNum
					  (NC.DumpCardToDoc ToCard DocCard DocStream CurSection 
							      SubSectionNum HeadingsFromFileboxes 
							      TitlesFromNoteCards BuildBackLinks 
							      CopyEmbeddedLinks ExpandEmbeddedLinks)))
			     )
		       finally (COND
				   ((ILESSP CurLoc (fetch TEXTLEN of CardObj))
				     (TEDIT.COPY (TEDIT.SETSEL CardStream LastLoc
								   (IDIFFERENCE (fetch TEXTLEN
										     of CardObj)
										  CurLoc))
						   (TEDIT.SETSEL DocStream
								   (ADD1 (fetch TEXTLEN
									      of DocObj))
								   0
								   (QUOTE RIGHT)))))
				 (TEDIT.SETSEL DocStream (ADD1 (fetch TEXTLEN of DocObj))
						 0
						 (QUOTE RIGHT)))
		    (NC.SetUserDataProp Card (QUOTE SeenBefore)
					  NIL)
		    (AND ShrunkenFlg (SHRINKW (NC.FetchWindow Card)))
	   else (NC.PrintMsg NIL NIL (NC.RetrieveTitle Card)
				 " only expanded once in this cycle."
				 (CHARACTER 13)))
     SubSectionNum)))

(NC.DumpExportableCardToDoc
  (LAMBDA (Card DocCard DocStream CurSection SubSectionNum HeadingsFromFileboxes TitlesFromNoteCards 
		BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks CardType)
                                                             (* rht: "31-Oct-86 12:41")

          (* * Dump the CardID sketch or graph card to the document card DocStream.)



          (* * rht 9/16/85: Now handles cr's around titles using para leading.)



          (* * fgh 11/17/85 Updated to handle card objects and removal of SubstanceTypes.)



          (* * rht 7/31/86: Now can handle other card types than Graph or Sketch based ones, but they must have an 
	  appropriate fn on the ExportSubstanceFn property of the atom. That fn should return either an imageobj or a 
	  textstream.)



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



          (* * rht 10/15/86: Integrated markM's changes and fixed box numbering.)



          (* * rht 10/31/86: Now uses TEDIT.COPY rather than TEDIT.INCLUDE because the latter loses formatting info.)


    (DECLARE (GLOBALVARS NC.DocBackPtrLinkLabel))
    (LET ((CardStream (NC.FetchSubstance Card))
	  (DocObj (TEXTOBJ DocStream))
	  ShrunkenFlg OldLoc ThingToInsert)
         (NC.AddCRIfNeeded DocStream)
         (SETQ OldLoc (fetch (TEXTOBJ TEXTLEN) of DocObj))
         (AND (NEQ TitlesFromNoteCards (QUOTE NONE))
		(NC.AppendStringToStream DocStream (CONCAT (NC.RetrieveTitle Card))
					 (EQ TitlesFromNoteCards (QUOTE Bold))))
         (AND (FMEMB BuildBackLinks (QUOTE (ToCards ToCardsBoxes)))
		(NCP.LocalGlobalLink NC.DocBackPtrLinkLabel DocCard Card (QUOTE END)
				       (create LINKDISPLAYMODE
						 ATTACHBITMAPFLG ← T)))
         (if (GREATERP (fetch (TEXTOBJ TEXTLEN) of DocObj)
			   OldLoc)
	     then (NC.AddCRIfNeeded DocStream)
		    (NC.ChangeParaLeading DocStream))
         (if (NOT (NC.FetchUserDataProp Card (QUOTE SeenBefore)))
	     then (SETQ ShrunkenFlg (NC.GetShrunkenWin Card))
		    (NC.SetUserDataProp DocCard (QUOTE SeenCards)
					  (CONS Card (NC.FetchUserDataProp DocCard (QUOTE
										 SeenCards))))
		    (NC.SetUserDataProp Card (QUOTE SeenBefore)
					  T)

          (* * Stick an imageobj made from the card into the document. Also might be a textstream computed by the card type's
	  ExportSubstanceFn.)


		    (SETQ ThingToInsert (if (NCP.GraphBasedP CardType)
					      then (GRAPHEROBJ CardStream)
					    elseif (NCP.SketchBasedP CardType)
					      then (MAKE.IMAGE.OBJECT.OF.SKETCH CardStream
										    (
									     NC.FetchRegionViewed
										      Card)
										    (NC.FetchScale
										      Card))
					    elseif (LET ((ExportSubstanceFn (GETPROP
										CardType
										(QUOTE 
										ExportSubstanceFn))))
						          (AND ExportSubstanceFn (APPLY* 
										ExportSubstanceFn 
										       CardStream)))))
		    (AND CardStream (if (IMAGEOBJP ThingToInsert)
					  then (TEDIT.INSERT.OBJECT ThingToInsert DocStream)
					elseif (TEXTSTREAMP ThingToInsert)
					  then (TEDIT.COPY (TEDIT.SETSEL ThingToInsert 1
									       (fetch TEXTLEN
										  of (TEXTOBJ
											 
										    ThingToInsert)))
							       (TEDIT.SETSEL DocStream
									       (fetch TEXTLEN
										  of DocObj)
									       1
									       (QUOTE RIGHT)))))

          (* * Step through list of notecard imageobjs in the card we're working on and either expand or copy or ignore each 
	  according to values of ExpandEmbeddedLinks and CopyEmbeddedLinks.)


		    (for Link in (CAR (NC.CollectReferences Card NIL NIL NIL))
		       bind LinkLabel ToCard ToCardType ActiveFlg ExpandFlg CopyFlg AlreadyExpanded
		       eachtime (BLOCK)
		       do (SETQ LinkLabel (fetch (Link Label) of Link))
			    (SETQ CopyFlg (OR (EQ CopyEmbeddedLinks (QUOTE ALL))
						  (AND (LISTP CopyEmbeddedLinks)
							 (FMEMB LinkLabel CopyEmbeddedLinks))))
			    (SETQ ExpandFlg (OR (EQ ExpandEmbeddedLinks (QUOTE ALL))
						    (AND (LISTP ExpandEmbeddedLinks)
							   (FMEMB LinkLabel ExpandEmbeddedLinks))))
			    (if (AND (SETQ AlreadyExpanded (NC.FetchUserDataProp
					     (SETQ ToCard (fetch (Link DestinationCard)
							       of Link))
					     (QUOTE SeenBefore)))
					 ExpandFlg)
				then (NC.PrintMsg NIL NIL (NC.RetrieveTitle ToCard)
						      " only expanded once in this cycle."
						      (CHARACTER 13)))
			    (if (OR CopyFlg (AND ExpandFlg AlreadyExpanded))
				then                       (* Copy this link.)
				       (NCP.LocalGlobalLink LinkLabel DocCard ToCard (QUOTE
								END)))
			    (if (AND ExpandFlg (NOT AlreadyExpanded))
				then                       (* Expand this link. Check type and make recursive 
							     call.)
				       (SETQ SubSectionNum
					 (NC.DumpCardToDoc ToCard DocCard DocStream CurSection 
							     SubSectionNum HeadingsFromFileboxes 
							     TitlesFromNoteCards BuildBackLinks 
							     CopyEmbeddedLinks ExpandEmbeddedLinks)))
		       finally (TEDIT.SETSEL DocStream (ADD1 (fetch TEXTLEN of DocObj))
						 0
						 (QUOTE RIGHT)))
		    (NC.SetUserDataProp Card (QUOTE SeenBefore)
					  NIL)
		    (AND ShrunkenFlg (SHRINKW (NC.FetchWindow Card)))
	   else (NC.PrintMsg NIL NIL (NC.RetrieveTitle Card)
				 " only expanded once in this cycle."
				 (CHARACTER 13)))
     SubSectionNum)))
)
(* * New macro for NCUTILITIES)

(DECLARE: EVAL@COMPILE 
(DEFMACRO NC.ActivateCardAndDo (Card &REST Forms)
	  (* * rht 10/15/86: This written by MarkM. I changed slightly so as to accept a list of 
	     Forms rather than a singleton.)
	  (BQUOTE (LET ((NC.ActiveFlg (NC.ActiveCardP , Card)))
		       (OR NC.ActiveFlg (NC.GetNoteCard , Card))
		       (PROG1 (PROGN ,@ Forms)
			      (OR NC.ActiveFlg (NC.DeactivateCard , Card))))))
)
(* * Fixes for NCPROGINT)

(DEFINEQ

(NCP.SketchBasedP
  (LAMBDA (CardOrCardType)                                   (* rht: "15-Oct-86 18:18")

          (* * This card type is a subtype of Sketch.)



          (* * rht 10/15/86: Fixed typo.)


    (LET ((CardType (if (NC.CardP CardOrCardType)
			then (NCP.CardType CardOrCardType)
		      else CardOrCardType)))
         (if (NCP.CardTypeP CardType)
	     then (NC.IsSubTypeOfP CardType (QUOTE Sketch))
	   else (NCP.ReportError CardType " is not a loaded notecard type.")))))

(NCP.GraphBasedP
  (LAMBDA (CardOrCardType)                                   (* rht: "15-Oct-86 18:18")

          (* * This card type is a subtype of Graph.)



          (* * rht 10/15/86: Fixed typo.)


    (LET ((CardType (if (NC.CardP CardOrCardType)
			then (NCP.CardType CardOrCardType)
		      else CardOrCardType)))
         (if (NCP.CardTypeP CardType)
	     then (NC.IsSubTypeOfP CardType (QUOTE Graph))
	   else (NCP.ReportError CardType " is not a loaded notecard type.")))))
)
(PUTPROPS RHTPATCH119 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (956 2514 (NC.DumpCardToDoc 966 . 2512)) (2553 23008 (NC.MakeDocument 2563 . 7679) (
NC.DumpFileBoxToDoc 7681 . 11430) (NC.DumpNoteCardToDoc 11432 . 17023) (NC.DumpExportableCardToDoc 
17025 . 23006)) (23483 24606 (NCP.SketchBasedP 23493 . 24049) (NCP.GraphBasedP 24051 . 24604)))))
STOP