(FILECREATED "21-Mar-85 17:53:40" {PHYLUM}<NOTECARDS>RELEASE1.2>NCDOCUMENTCARD.;4 21802 changes to: (FNS NC.DumpNoteCardToDoc NC.DumpFileBoxToDoc) previous date: "13-Mar-85 00:54:36" {PHYLUM}<NOTECARDS>RELEASE1.2>NCDOCUMENTCARD.;3) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT NCDOCUMENTCARDCOMS) (RPAQQ NCDOCUMENTCARDCOMS ((E (SETQ NC.SystemDate (DATE)) (UNMARKASCHANGED (QUOTE NC.SystemDate) (QUOTE VARS))) (VARS NC.SystemDate) (P (UNMARKASCHANGED (QUOTE NC.SystemDate) (QUOTE VARS))) (* * Stuff for the Document compiler facility.) (FILES NCTEXTSUBSTANCE NCTEXTCARD) (GLOBALVARS NC.MakeDocParameters) (VARS (NC.MakeDocParameters (QUOTE ((HeadingsFromFileboxes NumberedBold UnnumberedBold NONE) (TitlesFromNoteCards Bold NotBold NONE) (BuildBackLinks ToCardsBoxes ToCards ToBoxes NONE) (CopyEmbeddedLinks ALL NONE Select) (ExpandEmbeddedLinks ALL NONE Select) (--DONE--))))) (* * MakeDocument stuff) (FNS NC.MakeDocument NC.DumpFileBoxToDoc NC.DumpNoteCardToDoc NC.FetchToLinksInOrder NC.AppendLinkToText NC.BuildMakeDocInspector NC.MakeDocInspectorSelectionFn NC.AppendStringToStream) (P (SETPROPLIST (QUOTE NC.MakeDocParameters) (QUOTE (HeadingsFromFileboxes NumberedBold TitlesFromNoteCards Bold BuildBackLinks NONE CopyEmbeddedLinks ALL ExpandEmbeddedLinks NONE --DONE-- --CANCEL-- VALUE ((HeadingsFromFileboxes NumberedBold UnnumberedBold NONE) (TitlesFromNoteCards Bold NotBold NONE) (BuildBackpointers ToCardsBoxes ToCards ToBoxes NONE) (CopyEmbeddedLinks ALL NONE Select) (ExpandEmbeddedLinks ALL NONE Select) (--DONE--)))))) (FNS NC.AddDocumentCard) (P (NC.AddDocumentCard)))) (RPAQQ NC.SystemDate "21-Mar-85 17:53:43") (UNMARKASCHANGED (QUOTE NC.SystemDate) (QUOTE VARS)) (* * Stuff for the Document compiler facility.) (FILESLOAD NCTEXTSUBSTANCE NCTEXTCARD) (DECLARE: DOEVAL@COMPILE DONTCOPY (GLOBALVARS NC.MakeDocParameters) ) (RPAQQ NC.MakeDocParameters ((HeadingsFromFileboxes NumberedBold UnnumberedBold NONE) (TitlesFromNoteCards Bold NotBold NONE) (BuildBackLinks ToCardsBoxes ToCards ToBoxes NONE) (CopyEmbeddedLinks ALL NONE Select) (ExpandEmbeddedLinks ALL NONE Select) (--DONE--))) (* * MakeDocument stuff) (DEFINEQ (NC.MakeDocument (LAMBDA (ID Title NoDisplayFlg WindowOrTextStreamOrID) (* rht: "15-Feb-85 15:50") (* * 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.) (PROG (RootID RootTitle DocWindow DocCardID DocWindowOrID DocStream HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks InspectWin WasActive) (OR NoDisplayFlg (SPAWN.MOUSE)) (SETQ DocWindowOrID (NC.MakeNoteCard (QUOTE Text) "Document" NoDisplayFlg NIL ID)) (COND (NoDisplayFlg (SETQ DocWindow NIL) (SETQ DocCardID DocWindowOrID)) (T (SETQ DocWindow DocWindowOrID) (SETQ DocCardID (NC.IDFromWindow DocWindow)))) (* NC.MakeNoteCard either returned an ID or a window depending on NoDisplayFlg.) (SETQ RootTitle (NC.FetchTitle (SETQ RootID (COND ((NC.IDP WindowOrTextStreamOrID) WindowOrTextStreamOrID) ((TEXTSTREAMP WindowOrTextStreamOrID) (NC.IDFromWindow (WINDOW.FROM.TEDIT.THING WindowOrTextStreamOrID))) ((WINDOWP WindowOrTextStreamOrID) (NC.IDFromWindow WindowOrTextStreamOrID)) (T (PROGN (NC.SelectNoteCards T NIL NC.SelectingCardMenu DocWindow NIL "Please select the Note Card or File Box the document should start from."))))) )) (COND ((NOT RootID) (NC.DeleteNoteCards ID T) (RETURN NIL))) (NC.SetTitle DocCardID (CONCAT "Document from %"" RootTitle "%"")) (AND DocWindow (WINDOWPROP DocWindow (QUOTE TITLE) (NC.FetchTitle DocCardID))) (SETQ DocStream (NC.FetchSubstance DocCardID)) (* * Get MakeDocument parameters from user via inspector window.) (COND ((NOT NoDisplayFlg) (SETQ InspectWin (NC.BuildMakeDocInspector DocWindow)) (TOTOPW InspectWin) (for while (OPENWP InspectWin) do (BLOCK)))) (COND ((EQ (GETPROP (QUOTE NC.MakeDocParameters) (QUOTE --DONE--)) (QUOTE QUIT)) (PUTPROP (QUOTE NC.MakeDocParameters) (QUOTE --DONE--) (QUOTE --CANCEL--)) (NC.DeleteNoteCards ID 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 ... ") (OR (SETQ WasActive (NC.ActiveCardP RootID)) (NC.GetNoteCard RootID PSA.Database)) (SELECTQ (NC.RetrieveType RootID PSA.Database) (FileBox (NC.DumpFileBoxToDoc RootID DocCardID DocStream "" HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks T)) (Text (NC.DumpNoteCardToDoc RootID DocCardID DocStream "" 1 HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks T)) NIL) (OR WasActive (NC.DeactivateCard RootID)) (* * Clean up the SeenBefore markers placed on the cards and boxes just copied.) (RESETSAVE NIL (QUOTE (PROGN (for ID in (GETPROP DocCardID (QUOTE SeenCards)) do (REMPROP ID (QUOTE SeenBefore))) (REMPROP DocCardID (QUOTE SeenCards))))) (NC.PrintMsg DocWindow NIL "Done!")) (COND ((NOT NoDisplayFlg) (BLOCK 250) (NC.ClearMsg DocWindow T))) (RETURN DocWindowOrID)))) (NC.DumpFileBoxToDoc (LAMBDA (FileBoxID DocID DocStream CurSection HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks NoInitialCRs) (* rht: "21-Mar-85 17:49") (* * 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.) (PROG ((DocObject (TEXTOBJ DocStream))) (OR NoInitialCRs (NC.AppendStringToStream DocStream (CONCAT (CHARACTER 13) (CHARACTER 13)))) (AND (EQ HeadingsFromFileboxes (QUOTE NumberedBold)) (NC.AppendStringToStream DocStream (CONCAT CurSection " ") T)) (AND (NEQ HeadingsFromFileboxes (QUOTE NONE)) (NC.AppendStringToStream DocStream (CONCAT (NC.FetchTitle FileBoxID)) T)) (AND (FMEMB BuildBackLinks (QUOTE (ToBoxes ToCardsBoxes))) (NC.AppendLinkToText DocID FileBoxID NC.DocBackPtrLinkLabel (QUOTE Icon))) (COND ((GETPROP FileBoxID (QUOTE SeenBefore)) (NC.PrintMsg NIL NIL FileBoxID " only expanded once.") (RETURN))) (ADDPROP DocID (QUOTE SeenCards) FileBoxID T) (PUTPROP FileBoxID (QUOTE SeenBefore) T) (NC.AppendStringToStream DocStream (CONCAT (CHARACTER 13) (CHARACTER 13))) (for Link in (NC.FetchToLinksInOrder FileBoxID) bind ChildID ActiveP Type (SubSectionNum ← 1) (FirstTime ← T) when (FMEMB (fetch (NOTECARDLINK LINKLABEL) of Link) (BQUOTE (, NC.FiledCardLinkLabel , NC.SubBoxLinkLabel))) do (SETQ ChildID (fetch (NOTECARDLINK DESTINATIONID) of Link)) (SETQ ActiveP (NC.ActiveCardP ChildID)) (COND ((EQ (SETQ Type (NC.RetrieveType ChildID PSA.Database)) (QUOTE FileBox)) (OR ActiveP (NC.GetNoteCard ChildID PSA.Database)) (NC.DumpFileBoxToDoc ChildID DocID DocStream (COND ((EQUAL "" CurSection) (CONCAT SubSectionNum)) (T (CONCAT CurSection "." SubSectionNum))) HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks FirstTime) (SETQ SubSectionNum (ADD1 SubSectionNum)) (OR ActiveP (NC.DeactivateCard ChildID))) ((EQ (NCP.CardTypeSubstance Type) (QUOTE TEXT)) (OR ActiveP (NC.GetNoteCard ChildID PSA.Database)) (SETQ SubSectionNum (NC.DumpNoteCardToDoc ChildID DocID DocStream CurSection SubSectionNum HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks FirstTime)) (OR ActiveP (NC.DeactivateCard ChildID))) (T (NC.PrintMsg NIL NIL "Ignoring non-text card " ChildID (CHARACTER 13)))) (SETQ FirstTime NIL))))) (NC.DumpNoteCardToDoc (LAMBDA (CardID DocID DocStream SectionNum BoxNum HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks NoInitialCRs) (* rht: "21-Mar-85 17:36") (* * Dump the CardID notecard to the document card DocStream.) (PROG ((CardStream (NC.FetchSubstance CardID)) CardObj (DocObj (TEXTOBJ DocStream))) (SETQ CardObj (TEXTOBJ CardStream)) (OR NoInitialCRs (PROGN (NC.AppendStringToStream DocStream (CONCAT (CHARACTER 13))) (AND (NEQ TitlesFromNoteCards (QUOTE NONE)) (NC.AppendStringToStream DocStream (CONCAT (CHARACTER 13)))))) (AND (NEQ TitlesFromNoteCards (QUOTE NONE)) (NC.AppendStringToStream DocStream (CONCAT (NC.FetchTitle CardID)) (EQ TitlesFromNoteCards (QUOTE Bold)))) (AND (FMEMB BuildBackLinks (QUOTE (ToCards ToCardsBoxes))) (NC.AppendLinkToText DocID CardID NC.DocBackPtrLinkLabel (QUOTE Icon))) (COND ((GETPROP CardID (QUOTE SeenBefore)) (NC.PrintMsg NIL NIL CardID " only expanded once." (CHARACTER 13)) (RETURN))) (ADDPROP DocID (QUOTE SeenCards) CardID T) (PUTPROP CardID (QUOTE SeenBefore) T) (NC.AppendStringToStream DocStream (CONCAT (CHARACTER 13) (CHARACTER 13))) (* * 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 ToID (LastLoc ← 1) (CurLoc ← 0) ActiveP ExpandP CopyP AlreadyExpanded do (SETQ LinkSpec (NC.FetchLinkFromLinkIcon (CAR Object))) (SETQ LinkLabel (fetch (NOTECARDLINK LINKLABEL) of LinkSpec)) (SETQ CurLoc (CADR Object)) (* Copy over any text between this obj and the last.) (COND ((ILESSP LastLoc CurLoc) (TEDIT.COPY (TEDIT.SETSEL CardStream LastLoc (IDIFFERENCE CurLoc LastLoc)) (TEDIT.SETSEL DocStream (fetch TEXTLEN of DocObj) 0 (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)))) (COND ((AND (SETQ AlreadyExpanded (GETPROP (SETQ ToID (fetch (NOTECARDLINK DESTINATIONID) of LinkSpec)) (QUOTE SeenBefore))) ExpandP) (NC.PrintMsg NIL NIL ToID " only expanded once." (CHARACTER 13)))) (COND ((OR CopyP (AND ExpandP AlreadyExpanded)) (* Copy this link.) (TEDIT.COPY (TEDIT.SETSEL CardStream CurLoc 1) (TEDIT.SETSEL DocStream (fetch TEXTLEN of DocObj) 0 (QUOTE RIGHT))))) (COND ((AND ExpandP (NOT AlreadyExpanded)) (* Expand this link. Check type and make recursive call.) (SETQ ActiveP (NC.ActiveCardP ToID)) (SELECTQ (NC.RetrieveType ToID PSA.Database) (Text (OR ActiveP (NC.GetNoteCard ToID PSA.Database)) (SETQ BoxNum (NC.DumpNoteCardToDoc ToID DocID DocStream SectionNum BoxNum HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks (EQ CurLoc 1))) (OR ActiveP (NC.DeactivateCard ToID))) (FileBox (OR ActiveP (NC.GetNoteCard ToID PSA.Database)) (NC.DumpFileBoxToDoc ToID DocID DocStream (COND ((EQUAL SectionNum "") (CONCAT BoxNum)) (T (CONCAT SectionNum "." BoxNum))) HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks (EQ CurLoc 1)) (SETQ BoxNum (ADD1 BoxNum)) (OR ActiveP (NC.DeactivateCard ToID))) (NC.PrintMsg NIL NIL "Ignoring non-text card " ToID (CHARACTER 13))))) finally (COND ((ILESSP CurLoc (fetch TEXTLEN of DocObj)) (TEDIT.COPY (TEDIT.SETSEL CardStream LastLoc (IDIFFERENCE (fetch TEXTLEN of CardObj) CurLoc)) (TEDIT.SETSEL DocStream (fetch TEXTLEN of DocObj) 0 (QUOTE RIGHT))))) (TEDIT.SETSEL DocStream (fetch TEXTLEN of DocObj) 0 (QUOTE RIGHT))) (RETURN BoxNum)))) (NC.FetchToLinksInOrder (LAMBDA (ID) (* fgh: " 1-Oct-84 21:08") (* * Return the list of To links appearing in the text of ID in the order in which they appear.) (for ObjectPair in (TEDIT.LIST.OF.OBJECTS (TEXTOBJ (NC.FetchSubstance ID)) (FUNCTION NC.LinkIconImageObjP)) collect (NC.FetchLinkFromLinkIcon (CAR ObjectPair))))) (NC.AppendLinkToText (LAMBDA (SourceID DestinationID LinkLabel DisplayMode) (* fgh: "28-Sep-84 19:08") (* * Insert a link icon in SourceID's textstream at the cursor. This is somewhat like NC.InsertLinkAndTitleBeforeMarker. Leaves cursor (selection) positioned at end of text ready for insertion.) (PROG (TextStream) (NC.InsertLinkBeforeMarker SourceID DestinationID LinkLabel DisplayMode 9999 NIL T) (SETQ TextStream (NC.FetchSubstance SourceID)) (TEDIT.SETSEL TextStream (GETEOFPTR TextStream) 0 (QUOTE RIGHT))))) (NC.BuildMakeDocInspector (LAMBDA (MainWin) (* rht: " 6-Nov-84 22:28") (* * Build and dislay an inspector window on the parameters for making documents.) (PROG (InspectWindow Region (PromptWin (GETPROMPTWINDOW MainWin))) (SETQ Region (WINDOWPROP (OR PromptWin MainWin) (QUOTE REGION))) (SETQ InspectWindow (INSPECTW.CREATE (QUOTE NC.MakeDocParameters) (for Item in NC.MakeDocParameters collect (CAR Item)) (FUNCTION GETPROP) NIL "Use left button to change values." NIL (FUNCTION NC.InspectorTitleCommandFn) "MakeDocument Parameters" (FUNCTION NC.MakeDocInspectorSelectionFn) (create POSITION XCOORD ←(fetch LEFT of Region) YCOORD ←(IPLUS (fetch BOTTOM of Region) (fetch HEIGHT of Region))) NIL)) (MOVEW InspectWindow (MAKEWITHINREGION (WINDOWPROP InspectWindow (QUOTE REGION)) WHOLESCREEN)) (WINDOWPROP InspectWindow (QUOTE NoteCardsMakeDocInspector) T) (RETURN InspectWindow)))) (NC.MakeDocInspectorSelectionFn (LAMBDA (Property ValueFlg InspectWin) (* rht: "17-Nov-84 15:43") (* * Called when user buttons in the make document inspector menu on the Property parameter. Put up a menu of choices for new values for this parameter.) (* * rht 11/17/84: Now can select --CANCEL--. Notice strange way of checking for --DONE-- versus --CANCEL--. This is because the Inspector package doesn't send the property name in Property arg if ValueFlg is on. That bug has been reported.) (PROG (Menu Answer) (COND ((FMEMB Property (QUOTE (--DONE-- --CANCEL--))) (CLOSEW InspectWin) (COND (ValueFlg (PUTPROP (QUOTE NC.MakeDocParameters) (QUOTE --DONE--) (QUOTE QUIT)))) (RETURN NIL))) (AND ValueFlg (RETURN (INSPECTW.SELECTITEM InspectWin))) (SETQ Menu (create MENU ITEMS ←(CDR (FASSOC Property NC.MakeDocParameters)) TITLE ← "Choose New Value")) (SETQ Answer (MENU Menu)) (COND ((AND Answer (OR (NEQ Answer (QUOTE Select)) (SETQ Answer (NC.AskLinkLabel InspectWin T T NIL NIL T)))) (PUTPROP (QUOTE NC.MakeDocParameters) Property Answer) (INSPECTW.REDISPLAY InspectWin Property))) (INSPECTW.SELECTITEM InspectWin)))) (NC.AppendStringToStream (LAMBDA (Stream String BoldFlg) (* rht: "16-Nov-84 12:38") (* * Add the String to the end of the tedit Stream.) (* * rht 11/16/84: Now calls TEDIT.LOOKS in any case, bold or no.) (PROG ((StrLen (NCHARS String))) (TEDIT.INSERT Stream String (TEDIT.SETSEL Stream (fetch (TEXTOBJ TEXTLEN) of (TEXTOBJ Stream)) 0 (QUOTE RIGHT)) NIL T) (TEDIT.LOOKS Stream (COND (BoldFlg (QUOTE (FACE BRR))) (T (QUOTE (FACE MRR)))) (ADD1 (IDIFFERENCE (fetch (TEXTOBJ TEXTLEN) of (TEXTOBJ Stream)) StrLen)) StrLen)))) ) (SETPROPLIST (QUOTE NC.MakeDocParameters) (QUOTE (HeadingsFromFileboxes NumberedBold TitlesFromNoteCards Bold BuildBackLinks NONE CopyEmbeddedLinks ALL ExpandEmbeddedLinks NONE --DONE-- --CANCEL-- VALUE ((HeadingsFromFileboxes NumberedBold UnnumberedBold NONE) (TitlesFromNoteCards Bold NotBold NONE) (BuildBackpointers ToCardsBoxes ToCards ToBoxes NONE) (CopyEmbeddedLinks ALL NONE Select) (ExpandEmbeddedLinks ALL NONE Select) (--DONE--))))) (DEFINEQ (NC.AddDocumentCard (LAMBDA NIL (* fgh: "15-Feb-85 13:13") (NC.AddCardType (QUOTE Document) (QUOTE Text) (QUOTE TEXT) (BQUOTE ((MakeCardFn , (FUNCTION NC.MakeDocument)))) (BQUOTE ((LinkDisplayMode Icon) (CardDisplayedInMenuFlg , T)))))) ) (NC.AddDocumentCard) (PUTPROPS NCDOCUMENTCARD COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (2510 20784 (NC.MakeDocument 2520 . 7514) (NC.DumpFileBoxToDoc 7516 . 10920) ( NC.DumpNoteCardToDoc 10922 . 16154) (NC.FetchToLinksInOrder 16156 . 16610) (NC.AppendLinkToText 16612 . 17234) (NC.BuildMakeDocInspector 17236 . 18531) (NC.MakeDocInspectorSelectionFn 18533 . 20021) ( NC.AppendStringToStream 20023 . 20782)) (21327 21696 (NC.AddDocumentCard 21337 . 21694))))) STOP