(FILECREATED "29-Oct-87 17:28:51" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH068.;3 19082
changes to: (VARS PMIPATCH068COMS)
(FNS NC.CopyStructure NC.CopyCards NCP.CopyCards NC.MoveCards NCP.MoveCards)
previous date: "29-Oct-87 16:20:56" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH068.;2)
(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)
(PRETTYCOMPRINT PMIPATCH068COMS)
(RPAQQ PMIPATCH068COMS ((* * pmi 10/29/87: Created NCP.MoveCards to give prog. int. access to
NC.MoveCards. Added CopyExternalToLinksMode argument to NC.MoveCards to
be passed down to NC.CopyCards so that it can be controlled from
NCP.MoveCards. Also modified NC.CopyCards to return the new copies
instead of the original cards.)
(* * Changed in NCDATABASE)
(FNS NC.MoveCards NC.CopyCards)
(* * Changed in NCINTERFACE)
(FNS NC.CopyStructure)
(* * Changed in NCPROGINT)
(FNS NCP.CopyCards)
(* * New for NCPROGINT)
(FNS NCP.MoveCards)))
(* * pmi 10/29/87: Created NCP.MoveCards to give prog. int. access to NC.MoveCards. Added
CopyExternalToLinksMode argument to NC.MoveCards to be passed down to NC.CopyCards so that it
can be controlled from NCP.MoveCards. Also modified NC.CopyCards to return the new copies
instead of the original cards.)
(* * Changed in NCDATABASE)
(DEFINEQ
(NC.MoveCards
(LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg InterestedWindow CopyExternalToLinksMode)
(* pmi: "29-Oct-87 11:12")
(* * Move cards into a filebox by copying and deleting.)
(* * rht&rg&pmi 4/22/87: Took out ERROR!)
(* * rg 6/2/87 added NCP.WithLockedCards wrapper)
(* * pmi 10/29/87: Added CopyExternalToLinksMode argument to be passed down to NC.CopyCards.)
(DECLARE (GLOBALVARS NC.SelectingCardsMenu))
(NCP.WithLockedCards (NC.IfAllCardsFree (NC.LockListOfCards Cards "Move Cards")
(OR Cards (SETQ Cards
(NC.SelectNoteCards NIL NIL
NC.SelectingCardsMenu NIL
"Shift-select from the same NoteFile cards to move:")))
(if Cards
then (SETQ Cards (MKLIST Cards))
(NC.CopyCards Cards DestNoteFileOrFileBox
RootCards QuietFlg
InterestedWindow
CopyExternalToLinksMode)
(NC.DeleteNoteCards Cards T NIL
InterestedWindow
QuietFlg NIL))))))
(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))))))
)
(* * Changed in NCINTERFACE)
(DEFINEQ
(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))))))
)
(* * Changed in NCPROGINT)
(DEFINEQ
(NCP.CopyCards
(LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg CopyExternalToLinksMode)
(* pmi: "29-Oct-87 16:15")
(* * Make copies of Cards and all links among them, not including external links. RootCards should be a subset of
Cards or nil. If nil, then all cards in Cards are considered roots. If DestNoteFileOrFileBox is a filebox, then all
roots are filed in that box, otherwise, the contents box of the notefile is used.)
(* * Note that all cards currently must be in the same notefile.)
(* * pmi 10/29/87: Added CopyExternalToLinksMode argument to be passed down to NC.CopyCards.)
(NC.CopyCards Cards DestNoteFileOrFileBox RootCards QuietFlg NIL CopyExternalToLinksMode)))
)
(* * New for NCPROGINT)
(DEFINEQ
(NCP.MoveCards
(LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg CopyExternalToLinksMode)
(* pmi: "29-Oct-87 11:19")
(* * pmi 10/29/87: Move cards into a filebox.)
(NC.MoveCards Cards DestNoteFileOrFileBox RootCards QuietFlg NIL CopyExternalToLinksMode)))
)
(PUTPROPS PMIPATCH068 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
(FILEMAP (NIL (1362 14834 (NC.MoveCards 1372 . 2580) (NC.CopyCards 2582 . 14832)) (14870 17722 (
NC.CopyStructure 14880 . 17720)) (17756 18600 (NCP.CopyCards 17766 . 18598)) (18631 19000 (
NCP.MoveCards 18641 . 18998)))))
STOP