(FILECREATED "20-Nov-87 15:28:25" {QV}<NOTECARDS>1.3KNEXT>RGPATCH065.;3 50362 changes to: (VARS RGPATCH065COMS) (FNS NC.EditPropList) previous date: "20-Nov-87 14:51:25" {QV}<NOTECARDS>1.3KNEXT>RGPATCH065.;1) (* Copyright (c) 1987 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT RGPATCH065COMS) (RPAQQ RGPATCH065COMS ((* * rg 11/20/87 this patch file restores changes that were accidentally smashed by RGPATCH063) (* * changes to various files - no new fns) (FNS NC.CopyCards NC.CopyStructure NC.EditPropList NC.LinkIconWhenDeletedFn NC.OpenPropListEditor NC.PropListEditorOpenP NC.RelabelLink NC.SeverExternalLinks NC.ShowLinks NC.UpdateLinkImages))) (* * rg 11/20/87 this patch file restores changes that were accidentally smashed by RGPATCH063 ) (* * changes to various files - no new fns) (DEFINEQ (NC.CopyCards [LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg InterestedWindow CopyExternalToLinksMode) (* pmi: "29-Oct-87 16:15") (* * Create copies of cards in Cards. If DestNoteFileOrFileBox is a notefile, then destination will be the contents box in that notefile, else the FileBox's notefile. RootCards should be NIL or a subset of Cards. If NIL, then file all Cards in the dest filebox. Otherwise, just file RootCards in that filebox and assume others are linked somehow to the RootCards. Links between cards in Cards are copied, but links from or to outside cards aren't.) (* * Currently all Cards must be in same notefile, but this perhaps could be relaxed if could prevent possibility of two cards in different notefiles having the same UID.) (* * kirk 24Apr86 Added calls to select cards if none provided) (* * rht 9/2/86: Added InterestedWindow arg.) (* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.) (* * rg 3/18/87 added NC.CardSelectionOperation wrapper) (* * rg 4/2/87 changed NC.CardSelectionOperation to NCP.WithLockedCards ; added NC.IfAllCardsFree wrapper) (* * rht&rg&pmi 4/22/87: No longer calls ERROR!) (* * rg 6/2/87 was checking for CANCELLED instead of DON'T) (* * rg 6/5/87 deletes new cards if we cancel out halfway through) (* * rht 6/6/87: Now optionally copies "external" links. Passes extra new args to NC.FixUpLinksInCardCopy.) (* * rht 6/22/87: Now returns list of cards copied, like it used to.) (* * pmi 10/29/87: Now returns list of card copies, instead of cards copied.) (NCP.WithLockedCards (NC.IfAllCardsFree (NC.LockListOfCards Cards "Copy Cards") (PROG (NumCards SourceNoteFile DestNoteFile BoxToFileIn TempStream CardHashArray LinksHashArray CurrentLinkLabels NewLinkLabels NewCardsAndLocsOnStream CopyExternalToLinksFlg NewCardList) (* * Make sure the arguments are valid.) (if (NULL Cards) then (if (NULL (SETQ Cards (NC.SelectNoteCards NIL NIL NC.SelectingCardsMenu NIL "Shift-select from the same NoteFile cards to copy:" NIL))) then (RETURN NIL))) (SETQ Cards (MKLIST Cards)) (SETQ NumCards (LENGTH Cards)) (* All Cards to copy must live in same notefile.) (SETQ SourceNoteFile (fetch (Card NoteFile) of (CAR Cards))) (if [NOT (AND (type? NoteFile SourceNoteFile) (OPENP (fetch (NoteFile Stream) of SourceNoteFile] then (NC.ReportError "NC.CopyCards" (CONCAT (fetch (NoteFile FullFileName) of SourceNoteFile) " not an open notefile."))) (if (NOT (for Card in Cards always (NC.SameNoteFileP (fetch (Card NoteFile) of Card) SourceNoteFile))) then (NC.ReportError "NC.CopyCards" "All cards in Cards arg don't live in the same notefile.")) (* Compute dest notefile and dest filebox.) (if (NOT DestNoteFileOrFileBox) then (if (EQ (QUOTE DON'T) (SETQ DestNoteFileOrFileBox (NC.SelectNoteCards T NIL NC.SelectingCardMenu NIL "Shift-select the FileBox to contain these cards." T))) then (RETURN NIL))) (if (type? NoteFile DestNoteFileOrFileBox) then (SETQ DestNoteFile DestNoteFileOrFileBox) (SETQ BoxToFileIn (fetch (NoteFile TableOfContentsCard) of DestNoteFile)) elseif (NCP.FileBoxP DestNoteFileOrFileBox) then (SETQ BoxToFileIn DestNoteFileOrFileBox) (SETQ DestNoteFile (fetch (Card NoteFile) of BoxToFileIn)) else (NC.ReportError "NC.CopyCards" (CONCAT "Arg not notefile or filebox: " DestNoteFileOrFileBox))) (if [NOT (AND (type? NoteFile DestNoteFile) (OPENP (fetch (NoteFile Stream) of DestNoteFile] then (NC.ReportError "NC.CopyCards" (CONCAT (fetch (NoteFile FullFileName) of DestNoteFile) " not an open notefile."))) (if (LDIFFERENCE (SETQ RootCards (MKLIST RootCards)) Cards) then (NC.ReportError "NC.CopyCards" "RootCards argument not subset of Cards argument.")) (if (NULL RootCards) then (SETQ RootCards Cards)) (* * Figure out whether to copy "external" links.) [SETQ CopyExternalToLinksFlg (SELECTQ CopyExternalToLinksMode (COPY T) (DON'TCOPY NIL) (SELECTQ (NC.AskUserWithMenu (QUOTE (Yes No Cancel)) (CONCAT "You've asked to copy " (LENGTH Cards) " cards." (CHARACTER 13) "Links among these cards will be automatically copied." (CHARACTER 13) "Do you also want to copy links pointing from these cards to elsewhere? ") InterestedWindow) (Yes T) (No NIL) (RETURN NIL] (* * Now get to work.) (SETQ TempStream (OPENSTREAM (QUOTE {NODIRCORE}) (QUOTE BOTH))) (SETQ CurrentLinkLabels (NC.RetrieveLinkLabels DestNoteFile)) (SETQ NewLinkLabels (TCONC NIL)) (SETQ LinksHashArray (HASHARRAY NC.CopyCardsLinksHashArraySize NIL (FUNCTION NC.MakeHashKey) (FUNCTION NC.SameUIDP))) (SETQ CardHashArray (HASHARRAY NumCards NIL (FUNCTION NC.MakeHashKeyFromCard) (FUNCTION NC.SameCardP))) (* * Create new cards in DestNoteFile for each card. Make these cards by copying original cards to a temp stream. Keep track of UID mappings between original cards and card copies using CardHashArray.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Copying cards: creating empty copies." (CHARACTER 13) "Processing item " 1 " out of " NumCards "..." (CHARACTER 13))) (SETQ NewCardsAndLocsOnStream NIL) [RESETLST [RESETSAVE NIL (QUOTE (PROGN (if RESETSTATE then (for CardAndLoc in NewCardsAndLocsOnStream do ( NC.DeleteNoteCardInternal (CAR CardAndLoc) T InterestedWindow)) (NC.ClearMsg InterestedWindow T] (for Card in Cards as i from 1 bind NewCard WasActiveFlg HadStatusNILFlg IndexLocs eachtime (BLOCK) unless (NC.CrossFileLinkCardP Card) do [OR QuietFlg (if (ZEROP (REMAINDER i 100)) then (NC.PrintMsg InterestedWindow T "Copying cards: creating empty copies." (CHARACTER 13) "Processing item " i " out of " NumCards "..." (CHARACTER 13] (if (NOT (SETQ WasActiveFlg (NC.ActiveCardP Card))) then (NC.GetNoteCard Card)) (if (SETQ HadStatusNILFlg (NULL (fetch (Card Status) of Card))) then (* Have to have Status slot ACTIVE in order that Put to stream won't break.) (replace (Card Status) of Card with (QUOTE ACTIVE))) (SETQ IndexLocs (NC.PutNoteCardToStream Card NIL T TempStream)) (if HadStatusNILFlg then (replace (Card Status) of Card with NIL)) (if (NOT WasActiveFlg) then (NC.DeactivateCard Card)) (* Make new empty card for copy.) (SETQ NewCard (NC.GetNewCard DestNoteFile)) (* Map old cards to card copies.) (PUTHASH Card NewCard CardHashArray) (push NewCardsAndLocsOnStream (CONS NewCard IndexLocs] (* * For each card, get it off the temp stream, fix its links, fix browser info if necessary, and write it down to the dest notefile.) (SETFILEPTR TempStream 0) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Copying cards: fixing links and browser cards." (CHARACTER 13) "Processing item " 1 " out of " NumCards "..." (CHARACTER 13))) (SETQ NewCardList (for NewCardAndLocsOnStream in NewCardsAndLocsOnStream as i from 1 eachtime (BLOCK) bind (CrossFileLinkModePropList ← (LIST DestNoteFile NIL)) collect [OR QuietFlg (if (ZEROP (REMAINDER i 100)) then (NC.PrintMsg InterestedWindow T "Copying cards: fixing links and browser cards." (CHARACTER 13) "Processing item " i " out of " NumCards "..." (CHARACTER 13] (LET ((NewCard (CAR NewCardAndLocsOnStream)) (IndexLocs (CDR NewCardAndLocsOnStream))) (* Have to make status active for Get fns to work.) (NC.SetStatus NewCard (QUOTE ACTIVE)) (NC.GetNoteCardFromStream NewCard TempStream IndexLocs) (NC.FixUpLinksInCardCopy NewCard CardHashArray LinksHashArray CurrentLinkLabels NewLinkLabels InterestedWindow CopyExternalToLinksFlg CrossFileLinkModePropList) (if (NC.IsSubTypeOfP (NC.FetchType NewCard) (QUOTE Browser)) then (NC.FixUpBrowserCardCopy NewCard CardHashArray)) (NC.PutNoteCard NewCard) NewCard))) (* * Link RootCards under filebox in DestNotefile.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Copying cards: filing " (LENGTH RootCards) " new cards in " (NC.FetchTitle BoxToFileIn) "..." (CHARACTER 13))) (NC.FileBoxCollectChildren NIL BoxToFileIn (for RootCard in RootCards eachtime (BLOCK) collect (GETHASH RootCard CardHashArray)) T) (* * Put out any new link labels to the dest notefile.) (AND (SETQ NewLinkLabels (CDAR NewLinkLabels)) (NC.StoreLinkLabels DestNoteFile (APPEND NewLinkLabels CurrentLinkLabels))) (OR QuietFlg (NC.ClearMsg InterestedWindow T)) (RETURN NewCardList]) (NC.CopyStructure [LAMBDA (RootCards DestinationFileBox TraversalSpecs InterestedWindow QuietFlg) (* pmi: "29-Oct-87 17:17") (* * Copy a NoteCard structure into a filebox) (* * kirk 13/7/86: Placed TraversalSpecs after RootCards selection and changed prompt message) (* * rht 9/2/86: Threw away CheckFlg arg. Wasn't being used. Changed to call NCP.CollectCards instead of outdated NC.CollectCards. Changed arg named ToPosition to DestinationFileBox. Also changed FromCard to RootCard. Passes two link types to NC.AskTraversalSpecs.) (* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.) (* * rht 3/9/87: Now accepts multiple root cards.) (* * rg 3/9/87 added NC.ProtectedSessionOperation wrapper) (* * RG 3/18/87 changed NC.ProtectedSessionOperation to NCP.WithLockedCards ; added NC.IfAllCardsFree wrapper) (* * rht&rg&pmi 4/22/87: Removed calls to ERROR!) (* * rg 6/2/87 added check for DON'T to selection of dest filebox) (* * pmi 10/29/87: Now saves cards returned from NCP.CollectCards to return to NC.MoveStructure.) (DECLARE (GLOBALVARS NC.SelectingCardsMenu NC.SelectingCardMenu)) (NCP.WithLockedCards (SETQ RootCards (MKLIST RootCards)) (NC.IfAllCardsFree (NC.LockListOfCards RootCards "Copy Structure") (LET (OriginalCards) (if [AND (OR RootCards (SETQ RootCards (NC.SelectNoteCards NIL NIL NC.SelectingCardsMenu NIL "Shift-select the root cards of the structure"))) [OR TraversalSpecs (SETQ TraversalSpecs (NC.AskTraversalSpecs (fetch (Card NoteFile) of (CAR RootCards) ) (QUOTE (SubBox FiledCard] (OR DestinationFileBox (NEQ (SETQ DestinationFileBox (NC.SelectNoteCards T (FUNCTION [LAMBDA (Card) (NC.FileBoxP Card T]) NC.SelectingCardMenu NIL "Shift-select the FileBox to contain the structure." T)) (QUOTE DON'T] then (NC.CopyCards (SETQ OriginalCards (NCP.CollectCards RootCards (fetch (TRAVERSALSPECS LinkTypes) of TraversalSpecs) (fetch (TRAVERSALSPECS Depth) of TraversalSpecs))) DestinationFileBox RootCards QuietFlg InterestedWindow) OriginalCards]) (NC.EditPropList [LAMBDA (propList window showOnlyFlg) (* Randy.Gobbel "20-Nov-87 14:45") (* * propList is a list of RECORDS of type PropListItem) (* * Edit a property list using the TEDIT menu-based editor. The var window is the window to use. If none supplied, get one from user.) (* * rht 4/11/86: Now stashes length of propList on WINDOWPROP.) (* * rht 8/12/86: Moved code to add NC.ClosePropListEditor on CLOSEFN from NC.OpenPropListEditor to here so that it can before TEDIT.DEACTIVATE.WINDOW on the CLOSEFN list.) (* * rht 1/16/87: Now stashes prop names on windowprop rather than number of props.) (* * pmi 3/25/87: Added NC.MenuFont to all menus) (* * rg 11/19/87 menu items put on global vars (for make read-only)) (* * rht/rg 11/20/87 Now kills any existing edit process in editW before starting new one.) (DECLARE (GLOBALVARS NC.MenuFont NC.ShowPropListMenu NC.EditPropListMenu)) (PROG (menuStream textObj editW button editProcess (font (FONTCREATE (QUOTE HELVETICA) 8)) (CH# 1) (ENDCH# 1)) (* Init the editList and the propFnsList) (* Create a TEDITMenu that reflects the structure of the proplist) [SETQ menuStream (\TEXTMENU.DOC.CREATE (for X in propList join (NCONC [LIST (LIST (QUOTE MB.BUTTON) (MKSTRING (fetch (PropListItem PropertyName) of X)) (OR (fetch (PropListItem ButtonFn) of X) (FUNCTION NC.EditPropButtonFN] (COND [(NOT (IMAGEOBJP (fetch (PropListItem Value) of X))) (COND ((fetch (PropListItem AllowEditFlg) of X) (LIST (LIST (QUOTE MB.TEXT) (CONCAT (CHARACTER 9) " [" (MKSTRING (fetch (PropListItem Value) of X)) "]" (CHARACTER 13)) font))) (T (LIST (LIST (QUOTE MB.TEXT) (CHARACTER 9) font) (LIST (QUOTE MB.INSERT) (MKSTRING (fetch (PropListItem Value) of X))) (LIST (QUOTE MB.TEXT) (CHARACTER 13) font] (T (LIST (LIST (QUOTE MB.TEXT) (CHARACTER 9) font) (LIST (QUOTE MB.INSERT)) (LIST (QUOTE MB.TEXT) (CHARACTER 13) font] (SETQ textObj (TEXTOBJ menuStream)) (* Go back and insert the ImageObjects into their value fields.) (SETQ CH# 0) [for prop in propList when (OR (IMAGEOBJP (fetch (PropListItem Value) of prop)) (NULL (fetch (PropListItem AllowEditFlg) of prop))) do (MBUTTON.FIND.NEXT.FIELD textObj (SETQ CH# (ADD1 CH#))) (SETQ CH# (fetch CH# of (fetch SCRATCHSEL of textObj))) (COND ((IMAGEOBJP (CADR prop)) (TEDIT.INSERT.OBJECT (fetch (PropListItem Value) of prop) menuStream CH#] (SETQ CH# 0) (for prop in propList do (SETQ button (MBUTTON.FIND.NEXT.BUTTON textObj (ADD1 CH#))) (SETQ CH# (CDR button)) (* If the buttonProtect flag is on, protect the button) (AND (fetch (PropListItem AllowSelectFlg) of prop) (IMAGEOBJPROP (CAR button) (QUOTE EditPropListNoDelete) T))) (* Set up window and window title) [SETQ editW (COND (window window) (T (CREATEW (GETREGION) "Edit Property List"] (* Point to the proplist being edited so we can update it when this menu is closed. (See NC.CloseEditPropListWindow)) (WINDOWPROP editW (QUOTE PROPERTYLIST.BEING.EDITED) propList) (WINDOWPROP editW (QUOTE PROPERTYLIST.PROPNAMES) (for Item in propList collect (CAR Item))) (* Set the right margin to very-far-away. Prevents stuff from wrapping around) (TEDIT.PARALOOKS textObj [QUOTE (RIGHTMARGIN 1000 TABS (50 (80 . LEFT] 1 (GETFILEINFO menuStream (QUOTE LENGTH))) (* Set the first tab so the fields will line up correctly) (* Set selection to the top -- make it look pretty) (replace (SELECTION SET) of (fetch (TEXTOBJ SEL) of textObj) with NIL) (* Kill any existing tedit process. Notice we have to do WINDOWPROP because calling TEXTSTREAM breaks if window doesn't have one.) (LET [(OldTextStream (WINDOWPROP editW (QUOTE TEXTSTREAM] (if (TEXTSTREAMP OldTextStream) then (TEDIT.KILL OldTextStream))) [SETQ editProcess (TEDIT menuStream editW NIL (LIST (QUOTE MENU) (COND (showOnlyFlg NC.ShowPropListMenu) (T NC.EditPropListMenu] (until (TEDIT-PROCESS-P editProcess) do (BLOCK)) (if showOnlyFlg then (NC.MakeTEditReadOnly editW)) (WINDOWADDPROP editW (QUOTE CLOSEFN) (FUNCTION NC.ClosePropListEditor) T]) (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!]) (NC.OpenPropListEditor [LAMBDA (WindowOrTextStream PropList Title ShowOnlyFlg MakeImageObjFlg ShowLinksFlg) (* rht: "30-Sep-87 12:21") (* Open a property list editor above the card specified by TextStream , which is either a TextStream or a Window) (* * rht 8/11/86: Now takes ShowLinksFlg arg and passes to NC.PropListEditorOpenP so that we don't bail out if there's an open proplist not of our type.) (* * rht 11/13/86: Now hangs Card object off prop list editor's window so that we can get to the card from the proplist editor at close time.) (* * rht 12/11/86: Now only breaks out list if we're under ShowLinks.) (* * rht 9/30/87: Now allows reuse of ShowLinks editor window.) (PROG ((Window (WINDOW.FROM.TEDIT.THING WindowOrTextStream)) (SystemProperties (QUOTE (ID Updates ItemDate LinksDate PropsDate TitleDate))) EditWindow CardUID Card) (* Make sure there is no prop list editor already there. Okay, however, to reuse ShowLinks editor.) (if (AND (SETQ EditWindow (NC.PropListEditorOpenP Window ShowLinksFlg)) (NOT ShowLinksFlg)) then (RETURN)) [SETQ CardUID (fetch (Card UID) of (SETQ Card (NC.CoerceToCard Window] (* FOR each prop/value pair with LISTP value. Make a series of individual prop/value pairs corresponding to the elements of the LISTP) [SETQ PropList (for Item on PropList by (CDDR Item) join (COND ((AND (LISTP (CADR Item)) (type? Link (CAADR Item))) (for Element in (CADR Item) collect (create PropListItem PropertyName ← (CAR Item) Value ← Element OriginalListFlg ← T AllowEditFlg ← NIL AllowSelectFlg ← NIL ButtonFn ← NIL))) (T (LIST (create PropListItem PropertyName ← (CAR Item) Value ← (CADR Item) OriginalListFlg ← NIL AllowEditFlg ← NIL AllowSelectFlg ← NIL ButtonFn ← NIL] (* If specified, translate all NOTECARDLINK values into Image Objects for display.) [AND MakeImageObjFlg (for Item in PropList bind LinkIcon when (type? Link (fetch (PropListItem Value) of Item)) do (replace (PropListItem Value) of Item with (SETQ LinkIcon (NC.MakeLinkIcon (fetch (PropListItem Value) of Item))) (IMAGEOBJPROP LinkIcon (QUOTE InsidePropListEditor) T] (* Indicate which properties can be edited by user.) [for Item in PropList do (COND ((FMEMB (fetch (PropListItem PropertyName) of Item) SystemProperties) (replace (PropListItem AllowEditFlg) of Item with T) (replace (PropListItem AllowSelectFlg) of Item with T)) (ShowOnlyFlg (replace (PropListItem AllowEditFlg) of Item with NIL) (replace (PropListItem AllowSelectFlg) of Item with T)) (T (replace (PropListItem AllowEditFlg) of Item with NIL) (replace (PropListItem AllowSelectFlg) of Item with NIL] (* Call the prop list editor) (OR (WINDOWP EditWindow) (ATTACHWINDOW (SETQ EditWindow (CREATEW (CREATEREGION 1000 2000 100 100) (OR Title "Edit Property List") NIL T)) Window (QUOTE TOP) (QUOTE JUSTIFY) (QUOTE LOCALCLOSE))) (WINDOWADDPROP EditWindow (QUOTE CLOSEFN) (FUNCTION FREEATTACHEDWINDOW) T) (WINDOWPROP EditWindow (QUOTE PropListEditor) (COND (ShowOnlyFlg (QUOTE ShowOnly)) (T T))) (WINDOWPROP EditWindow (QUOTE SavedCardObject) Card) (NC.EditPropList PropList EditWindow ShowOnlyFlg) (RETURN EditWindow]) (NC.PropListEditorOpenP [LAMBDA (Window ShowLinksFlg) (* rht: "30-Sep-87 12:10") (* Is there a prop list editor opened on this window?) (* * rht 8/11/86: Now doesn't return NIL unless there's an open proplist editor of our type.) (* * rht 9/30/87: Now returns the attached window if successful.) (for AttachedWindow in (ALLATTACHEDWINDOWS Window) thereis (AND (WINDOWPROP AttachedWindow (QUOTE PropListEditor)) [LET [(ShowLinks (WINDOWPROP AttachedWindow (QUOTE ShowLinks] (* Check that ShowLinksFlg iff ShowLinks.) (OR (AND ShowLinksFlg ShowLinks) (AND (NULL ShowLinksFlg) (NULL ShowLinks] AttachedWindow]) (NC.RelabelLink [LAMBDA (LinkOrLinkIcon Window NewLinkLabel ForceRedisplayFlg) (* rht: "30-Sep-87 20:52" pp pp) (* Relabel a NoteCard link. Ask user for new label. Update all the proper references to this link.) (* * rht 11/19/84: Fixed so that Card is defined before first use.) (* * kirk 14Nov85: deleted use of and LinkID) (* * kef 8/8/86: Added obtaining write lock and NC.PutFromLinks.) (* * fgh 8/30/86 Adapted to NC.IfCardPartNotBusy) (* * rht 9/29/86: Changed Ken's call to NC.CardBeingEditedP to NC.ActiveCardP and other minor mod's.) (* * rg 5/15/87 now calls NC.LinksCachedP instead of NC.ActiveCardP) (* * rht 5/27/87: Now passes new label through cross file link if its dest notefile is open.) (* * pmi 9/11/87: Fixes bug 692 - can no longer change link label when notefile is open read-only.) (* * rht 9/30/87: Now tries to update ShowLinks windows if any.) (LET (Link LinkIcon Card DestinationCard OldLabel NoteCardType GlobalLinkFlg) [if (NC.LinkIconImageObjP LinkOrLinkIcon) then (SETQ Link (NC.FetchLinkFromLinkIcon LinkOrLinkIcon)) (SETQ LinkIcon LinkOrLinkIcon) else (SETQ Link LinkOrLinkIcon) (OR (SETQ GlobalLinkFlg (NC.GlobalLinkP Link)) (SETQ LinkIcon (NC.FetchLinkIconForLink Link] (SETQ Card (fetch (Link SourceCard) of Link)) (if (NC.CheckForNotReadOnly Card Window "Can't change link type of links in ") then [COND ((WINDOWP Window)) ((NC.ActiveCardP Card) (SETQ Window (NC.FetchWindow Card] (SETQ DestinationCard (fetch (Link DestinationCard) of Link)) (NC.IfCardPartNotBusy DestinationCard (QUOTE FROMLINKS) (COND ((NC.SystemLinkLabelP (fetch (Link Label) of Link)) (NC.PrintMsg Window T "This is a system maintained pointer." (CHARACTER 13) "You cannot change its label." (CHARACTER 13)) (SPAWN.MOUSE) (DISMISS 1500) (NC.ClearMsg Window T)) ((SETQ NewLinkLabel (OR NewLinkLabel (NC.AskLinkLabel Window NIL NIL T T))) (SETQ NoteCardType (NC.RetrieveType Card)) (* * Put new label in Link Icon or global links list) (if GlobalLinkFlg then (for GlobalLink in (NC.FetchGlobalLinks Card) when (NC.SameLinkP GlobalLink Link) do (replace (Link Label) of GlobalLink with NewLinkLabel) (NC.SetLinksDirtyFlg Card T) (RETURN)) else (replace (Link Label) of ( NC.FetchLinkFromLinkIcon LinkIcon) with NewLinkLabel) (NC.MarkCardDirty Card)) (* * Update ToLink list of the SourceCard card) (for ToLink in (NC.FetchToLinks Card) when (NC.SameLinkP ToLink Link) do (replace (Link Label) of ToLink with NewLinkLabel) (NC.SetLinksDirtyFlg Card T) (RETURN)) (* * Update link icons in any displayed ShowLinks windows.) (LET ((ShowLinksWin (NC.FetchShowLinksWindow Card))) (if ShowLinksWin then (NC.ChangeLinkLabelInShowLinksWin Link ShowLinksWin NewLinkLabel))) (LET ((ShowLinksWin (NC.FetchShowLinksWindow DestinationCard))) (if ShowLinksWin then (NC.ChangeLinkLabelInShowLinksWin Link ShowLinksWin NewLinkLabel))) (* * Update FromLink list of DestinationCard card) (if (NC.LinksCachedP DestinationCard) then (for FromLink in (NC.FetchFromLinks DestinationCard) when (NC.SameLinkP FromLink Link) do (replace (Link Label) of FromLink with NewLinkLabel) (NC.SetLinksDirtyFlg DestinationCard T) (RETURN)) else (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of DestinationCard)) (NC.GetLinks DestinationCard) (for FromLink in (NC.FetchFromLinks DestinationCard) when (NC.SameLinkP FromLink Link) do (replace (Link Label) of FromLink with NewLinkLabel) (NC.SetLinksDirtyFlg DestinationCard T) (RETURN)) (NC.PutFromLinks DestinationCard) (NC.UncacheLinks DestinationCard))) (* * Pass change through cross-file link to other notefile if open.) [if (NC.CrossFileLinkCardP Card) then (LET ((RemoteCrossFileLinkCard ( NC.FetchRemoteCrossFileLinkCard Card))) (AND RemoteCrossFileLinkCard (NC.CheckCrossFileLinkType RemoteCrossFileLinkCard Card Link] [if (NC.CrossFileLinkCardP DestinationCard) then (LET ((RemoteCrossFileLinkCard ( NC.FetchRemoteCrossFileLinkCard DestinationCard))) (AND RemoteCrossFileLinkCard (NC.CheckCrossFileLinkType RemoteCrossFileLinkCard DestinationCard Link] (* * Update images in SourceCard window) (if (WINDOWP Window) then (NC.UpdateLinkImages Window (fetch (Link DestinationCard) of Link))) (if (AND (NULL ForceRedisplayFlg) (NC.TEditBasedP NoteCardType)) then (QUOTE CHANGED) else NIL]) (NC.SeverExternalLinks [LAMBDA (ListOfCards QuietFlg InterestedWindow) (* rht: "31-Oct-87 19:32") (* * Delete all links in ListOfCards to or from cards not in ListOfCards. Furthermore, do it efficiently by caching an external card only long enough to delete all the links between it and ListOfCards. Note that we depend on the fact that every card in ListOfCards has its AboutToBeDeletedFlg set.) (* * rht&pmi 5/29/87: Now passes non-nil LeaveCachedFlg to NC.RetrieveToLinks and NC.RetrieveFromLinks. Not sure if this is really necessary.) (* * pmi 6/8/87: Added call to NC.GreyCard to grey cards being deleted before deleting all of their links.) (* * rht 10/31/87: Now uncaches links after call to NC.PutLinks on "external" source cards.) (LET (LinksToSever NumLinksToSever) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Gathering external links of " (LENGTH ListOfCards) " cards.")) [SETQ LinksToSever (NC.UnionListsOfLinks (for Card in ListOfCards join (* Grey the cards being deleted.) (NC.GreyCard Card) (for Link in (NC.RetrieveToLinks Card T) unless (NC.UIDGetProp (fetch (Card UID) of (fetch (Link DestinationCard) of Link)) (QUOTE AboutToBeDeletedFlg)) collect Link)) (for Card in ListOfCards join (for Link in (NC.RetrieveFromLinks Card T) unless (NC.UIDGetProp (fetch (Card UID) of (fetch (Link SourceCard) of Link)) (QUOTE AboutToBeDeletedFlg)) collect Link] (* * Now sort links so that links with same external anchor card are grouped together. Furthermore, the links having that anchor card has source card are grouped before the ones having that card as destination card.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Sorting " (SETQ NumLinksToSever (LENGTH LinksToSever)) " links prior to severing.")) [SORT LinksToSever (FUNCTION (LAMBDA (Link1 Link2) (LET (DestCard1 DestCard2 ExtCard1 ExtCard2 Link1SourceIsExtFlg) (SETQ ExtCard1 (if (NC.UIDGetProp (fetch (Card UID) of (SETQ DestCard1 (fetch (Link DestinationCard) of Link1))) (QUOTE AboutToBeDeletedFlg)) then (SETQ Link1SourceIsExtFlg T) (fetch (Link SourceCard) of Link1) else DestCard1)) (SETQ ExtCard2 (if (NC.UIDGetProp (fetch (Card UID) of (SETQ DestCard2 (fetch (Link DestinationCard) of Link2))) (QUOTE AboutToBeDeletedFlg)) then (fetch (Link SourceCard) of Link2) else DestCard2)) (if (NC.SameCardP ExtCard1 ExtCard2) then Link1SourceIsExtFlg else (LESSP (fetch (Card IndexLoc) of ExtCard1) (fetch (Card IndexLoc) of ExtCard2] (* * Now walk down the list of links one by one activating the external anchor cards as needed.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Severing links: 1 out of " NumLinksToSever " ...")) (for Link in LinksToSever as i from 1 bind PreviousExtCard WasNotActiveFlg PreviousExtCardIsSourceFlg eachtime (BLOCK) when (NC.ValidLinkP Link) do (OR QuietFlg (if (ZEROP (REMAINDER i 10)) then (NC.PrintMsg InterestedWindow T "Severing links: " i " out of " NumLinksToSever " ..."))) (LET (ExtCard ExtCardIsSourceFlg) (SETQ ExtCard (if (NC.UIDGetProp (fetch (Card UID) of (fetch (Link DestinationCard) of Link)) (QUOTE AboutToBeDeletedFlg)) then (SETQ ExtCardIsSourceFlg T) (fetch (Link SourceCard) of Link) else (fetch (Link DestinationCard) of Link))) [if (NOT (NC.SameCardP ExtCard PreviousExtCard)) then (* Write down changes to previous external card's substance.) (if WasNotActiveFlg then (if PreviousExtCardIsSourceFlg then (* Have to call NC.CardSaveFn first and then NC.QuitCard with Don'tSaveFlg to avoid insureProperFiling check.) (NC.CardSaveFn PreviousExtCard T) (NC.QuitCard PreviousExtCard NIL T NIL NIL NIL T) else (NC.PutLinks PreviousExtCard) (NC.UncacheLinks PreviousExtCard))) (* If ExtCard not active, then cache.) (if (SETQ WasNotActiveFlg (NOT (NC.ActiveCardP ExtCard))) then (if ExtCardIsSourceFlg then (* Cache whole card if it's the link's source.) (NC.GetNoteCard ExtCard) else (* Else only need the links since we're deleting the from link.) (NC.GetLinks ExtCard] (* Delete the appropriate half of the link.) (if ExtCardIsSourceFlg then (NC.DeleteToLink Link) else (NC.DeleteFromLink Link)) (replace (Link UID) of Link with -1) (SETQ PreviousExtCard ExtCard) (SETQ PreviousExtCardIsSourceFlg ExtCardIsSourceFlg)) finally (if (AND WasNotActiveFlg (NC.ValidCardP PreviousExtCard)) then (if PreviousExtCardIsSourceFlg then (* Have to call NC.CardSaveFn first and then NC.QuitCard with Don'tSaveFlg to avoid insureProperFiling check.) (NC.CardSaveFn PreviousExtCard T) (NC.QuitCard PreviousExtCard NIL T NIL NIL NIL T) else (NC.PutLinks PreviousExtCard) (NC.UncacheLinks PreviousExtCard]) (NC.ShowLinks [LAMBDA (CardIdentifier) (* rht: "30-Sep-87 15:31") (* Open an inspector for the links for note card specified by TextStream above the window for the note card.) (* * fgh 11/13/85 Updated to handle Card object.) (* * fgh 5/2/86 Included calls to NC.InsureLinkDisplayMode to handle litatom link display modes. Added InsdiePropListEditor and Reverse indicators to UserData field of Links in show links editor. Also added ShowLinks property onto the editor window so other functions can detect that a window is a show links window.) (* * rht 8/11/86: Now passes non-nil ShowLinksFlg to NC.OpenPropListEditor.) (* * rg 4/6/87 removed NC.ProtectedCardOperation wrapper.) (* * pmi 6/19/87: Now places each link's UID on the corresponding link created for the inspector. Checks for the validity of each link's source and destination cards and deletes links that are bad (half-links.)) (* * rht 9/30/87: Now takes arbitrary CardIdentifier as arg.) (LET ((Card (NC.CoerceToCard CardIdentifier)) Links EditWindow) [SETQ Links (NCONC [for Link in (NC.FetchToLinks Card) when (if (NC.ValidCardP (fetch (Link DestinationCard) of Link)) then (* The link is good, include it in the show links window.) T else (* The link is bad, delete it and don't include it in the show links window.) (NC.DeleteLink Link) NIL) join (LIST (COND ((EQ (fetch (Link AnchorMode) of Link) (QUOTE GlobalGlobal)) "Global TO") (T "TO")) (LIST (create Link using Link DisplayMode ← (create LINKDISPLAYMODE copying (NC.InsureLinkDisplayMode (fetch (Link DisplayMode) of Link)) SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T) UserData ← (QUOTE ( InsidePropListEditor T)) UID ← (fetch (Link UID) of Link] (for Link in (NC.FetchFromLinks Card) when (if (NC.ValidCardP (fetch (Link SourceCard) of Link)) then (* The link is good, include it in the show links window.) T else (* The link is bad, delete it and don't include it in the show links window.) (NC.DeleteLink Link) NIL) join (LIST "FROM" (LIST (create Link using Link DisplayMode ← (create LINKDISPLAYMODE copying (NC.InsureLinkDisplayMode (fetch (Link DisplayMode) of Link)) SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T) SourceCard ← (fetch (Link DestinationCard) of Link) DestinationCard ← (fetch (Link SourceCard) of Link) UserData ← (QUOTE (InsidePropListEditor T Reversed T)) UID ← (fetch (Link UID) of Link] (WINDOWPROP (SETQ EditWindow (NC.OpenPropListEditor (NC.FetchWindow Card) Links "List of Links" T T T)) (QUOTE ShowLinks) T) EditWindow]) (NC.UpdateLinkImages [LAMBDA (SourceWindowOrCard DestinationCard) (* rht: "30-Sep-87 19:35") (* * Update the Link Image Objects in SourceCard that point to DestinationID) (* * rht 10/2/85: Now checks if card's window was shrunk. If so, unshrink, modify and reshrink.) (* * fgh 11/17/85 Updated to handle card objects.) (* * fgh 2/5/86 Addeed call to NC.ApplyFn) (* * rht 9/30/87: Added calls to NC.UpdateLinkImagesInShowLinks.) (LET (SourceWindow SourceCard NoteCardType ShrunkenWin) (COND ((WINDOWP SourceWindowOrCard) (SETQ SourceWindow SourceWindowOrCard) (SETQ SourceCard (NC.CoerceToCard SourceWindowOrCard))) (T (SETQ SourceWindow (NC.FetchWindow SourceWindowOrCard)) (SETQ SourceCard SourceWindowOrCard))) (COND ((SETQ ShrunkenWin (NC.GetShrunkenWin SourceWindow)) (EXPANDW ShrunkenWin))) (SETQ NoteCardType (NC.RetrieveType SourceCard)) (NC.UpdateLinkImagesInShowLinks SourceCard DestinationCard) (NC.UpdateLinkImagesInShowLinks DestinationCard SourceCard) (NC.ApplyFn UpdateLinkIconsFn SourceCard DestinationCard) (COND (ShrunkenWin (SHRINKW SourceWindow))) NIL]) ) (PUTPROPS RGPATCH065 COPYRIGHT ("Xerox Corporation" 1987)) (DECLARE: DONTCOPY (FILEMAP (NIL (889 50281 (NC.CopyCards 899 . 13113) (NC.CopyStructure 13115 . 15943) (NC.EditPropList 15945 . 21910) (NC.LinkIconWhenDeletedFn 21912 . 26618) (NC.OpenPropListEditor 26620 . 31301) ( NC.PropListEditorOpenP 31303 . 32208) (NC.RelabelLink 32210 . 38658) (NC.SeverExternalLinks 38660 . 45164) (NC.ShowLinks 45166 . 48911) (NC.UpdateLinkImages 48913 . 50279))))) STOP