pragma runLim, 0 #include #include #include const string dummyList[0] = {} const string yesNo[] = {(NLS_("Yes")), (NLS_("No"))} const string cs[] = {(NLS_("This level")), (NLS_("One level down"))} const int createAfter = 0 const int createBelow = 1 const int createLastBelow = 2 const string AHeading = (NLS_("Object Heading")) const string AShortText = (NLS_("Object Short Text")) const string ALongText = (NLS_("Object Text")) Module sourceMod = current Module targetMod string sourceModName = sourceMod.(NLS_("Name")) int l bool fP, oP, sP int targetL bool targetF, targetO, targetS bool copyOutgoingLinks, copyIncomingLinks DB d DBE targetList, copyPos, copyOutLnks, copyInLnks DBE textMultiLine, textMultiLine2 Trigger trig Skip table_skip = null Skip attrList = create put(attrList, 1, "Requirement tag") put(attrList, 1, "Object Heading") put(attrList, 3, "method") put(attrList, 4, "procedure") put(attrList, 5, "results") put(attrList, 9, "Last verified by") put(attrList, 10, "Last verified on") put(attrList, 11, "Form version used") void loadTarget(DBE xx) { string s = (NLS_("/")) get targetList if (s == (NLS_(""))) return edit ( s) } void readCurr(DBE dbe) { read sourceModName } void saveSettings() { targetL = level targetMod targetF = filtering targetMod targetO = outlining targetMod targetS = sorting targetMod l = level sourceMod fP = filtering sourceMod oP = outlining sourceMod sP = sorting sourceMod } void defaultSettings(Module m) { current = m level 0 filtering off outlining off sorting off } void restoreSettings() { Object t current = targetMod for t in table_skip do toTable t level targetL filtering targetF outlining targetO sorting targetS refresh targetMod current = sourceMod level l filtering fP outlining oP sorting sP refresh sourceMod } bool checkSel() { string s = (NLS_("/")) get targetList if (s == (NLS_(""))) { ack(d,(NLS_("No destination module is selected"))) return false } if (null current sourceMod) { ack(d,(NLS_("Source module is empty"))) return false } string attrName int attrCount = 0 for attrName in attrList do { attrCount++ } if (attrCount == 0) { if (!confirm (NLS_("No attributes are selected for copying.\nIs this correct?"))) return false } targetMod = edit s return true } Object createNewObject(int copyPosition, Object tago) { Object newo current = targetMod if (null tago) { // no objects in destination module if (isShare targetMod) { ack (NLS_("Target module is in edit shareable mode.\nCannot create initial object in target module.")) raise d halt } newo = create targetMod } else if (!canWrite tago) { ack (NLS_("No permission to write to the current object in target module")) raise d halt } else if (isShare targetMod && copyPosition == createAfter && (level tago == 1 || !canWrite parent tago)) { ack (NLS_("Target module is in edit shareable mode.\nNeed permission to write to the parent of the target object")) raise d halt } else if (copyPosition == createAfter) { newo = create after tago } else if (copyPosition == createBelow) { newo = create below tago } else if (copyPosition == createLastBelow) { newo = create last below tago } return newo } void copyObject (Object s, t) { if (s==t) return string attrName = (NLS_("")) for attrName in attrList do { copyAttribute_(s,t,attrName) } if (cell s) { // copy across the table border attributes if the object is a cell copyAttribute_(s,t,(NLS_("TableTopBorder"))) copyAttribute_(s,t,(NLS_("TableBottomBorder"))) copyAttribute_(s,t,(NLS_("TableLeftBorder"))) copyAttribute_(s,t,(NLS_("TableRightBorder"))) copyAttribute_(s,t,(NLS_("TableCellWidth"))) copyAttribute_(s,t,(NLS_("TableCellAlign"))) } if (table s) put(table_skip, t, t) } // Copies all visible objects from under one root to under another // If there are breaks in hierarchy attaches copies to under last created target object void copyVisibleTree(Object sourceUnder, targetUnder) { // Copy the (visible) tree under sourceUnder to be under targetUnder // Also copy invisible objects that are table objects or row objects Object sourceo for sourceo in all sourceUnder do { if (isVisible sourceo || table sourceo || row sourceo) { Object targo = createNewObject(createLastBelow, targetUnder) copyObject(sourceo, targo) copyVisibleTree(sourceo, targo) } else { copyVisibleTree(sourceo, targetUnder) } } } // Returns first visible object in a module Object ftFirstValid(Module m) { Object o = first m while ((!null o) && (!isVisible o && !table o && !row o)) { o = next o } return o } /* NOTE : both these functions exist in both Copy Objects and Copy and Link. Change them in both */ /* Check whether object o is a child of object check */ bool childOf(Object check, Object o) { while (o!=check && o!=null) o = parent o return (o==check) } /* childOf */ // Given a starting object, returns the next visible object // (or null) which is not in the tree under the starting object Object ftNextValidSkipTree(Object starto) { Object checko if (null starto) return null checko = next starto while ((!null checko) && (childOf(starto, checko) || (!isVisible checko && !table checko && !row checko))) { checko = next checko } if ((!null checko) && cell(checko)) { /* Move to the table object */ checko = parent checko checko = parent checko } return checko } Object findFirstSelObject(Module sm) { Object o for o in sm do { // if ( isSelected o ) return o } return null } void Ver(Module sourceMod, targetMod) { Object latcho = current targetMod Buffer bufValue = create s = dateAndTime(today) "" space = "\n" string aux = "" aux = get(textMultiLine2) bufValue = richTextWithOle(latcho."results" ) bufValue += space bufValue += space bufValue += s bufValue += space bufValue += "Taking credit from module: "sourceModName" \nUser: "doorsname" \n" bufValue += space bufValue += aux latcho."results" = richText(bufValue) delete(bufValue) } void del(Module targetMod) { Object obj1, obj2 m = current Module string idStr string auxtag2 auxtag2 = obj2."Old tag" "" for obj1 in m do { idStr = obj1."Old tag" "" if (idStr == auxtag2) { if(obj1."Last Modified On" "" < dateAndTime(today)""){ delete obj1 } if(obj2."Last Modified On" "" < dateAndTime(today)""){ delete obj2 } } } } // Copies all visible objects from one module to another. // Performs this operation by: // walking across the source module picking out the roots of trees, i.e. next visible object // manually create a new object in target module, either under or after per user setting // copy contents of root object // copy visible tree under root // step to next visible tree root void copyAllVisible(Module sourceMod, targetMod, int copyDir) { Object latcho = current targetMod Object o, newo if (null latcho) { // module is empty copyDir = createAfter } // copy all visible trees // get first visible object o = ftFirstValid sourceMod while (!null o) { // copy root of tree newo = createNewObject(copyDir, latcho) copyObject(o, newo) // copy visible tree under it copyVisibleTree(o, newo) // step to next visible tree o = ftNextValidSkipTree o // move latcho if neccessary if (copyDir == createAfter) latcho = newo Ver(sourceMod, targetMod) }//while //save targetMod } void copyAllSelected(Module sourceMod, targetMod, int copyPosition) { Object latcho = current targetMod // get first selected object in source mod Object o = findFirstSelObject sourceMod while (!null o && isSelected o) { // copy all selected objects if ( isSelected o ) { // copy selected objects Object newo = createNewObject(copyPosition, latcho) copyObject(o, newo) // copy visible tree under it copyVisibleTree(o, newo) if (copyPosition == createAfter) { // move latcho if necessary latcho = newo Ver(sourceMod, targetMod) } else if (copyPosition == createBelow) { // latcho = newo copyPosition = createAfter Ver(sourceMod, targetMod) } } o = next sibling o //Ver(sourceMod, targetMod) } //save targetMod } // Button Callbacks void copyCurrent(DB db) { // copyOutgoingLinks = get copyOutLnks // copyIncomingLinks = get copyInLnks if (!checkSel) return if (!null table_skip) delete table_skip table_skip = create saveSettings if (l != 0 || fP || sP || oP) { if ((query((NLS_("Would you like to set the source level to all and switch filtering, sorting, and outlining off?")),yesNo)) == 0){ defaultSettings sourceMod } } defaultSettings targetMod Object starto = current targetMod Object o = current sourceMod int copyPosition = get copyPos Object newo = createNewObject(copyPosition, starto) copyObject(o, newo) copyVisibleTree(o, newo) restoreSettings } void copyAll(DB db) { int copyDir = get copyPos // copyOutgoingLinks = get copyOutLnks // copyIncomingLinks = get copyInLnks if (!checkSel) return if (!null table_skip) delete table_skip table_skip = create saveSettings defaultSettings targetMod defaultSettings sourceMod copyAllVisible(sourceMod, targetMod, copyDir) del(targetMod) restoreSettings } void copyDisplayed(DB db) { int copyDir = get copyPos // copyOutgoingLinks = get copyOutLnks // copyIncomingLinks = get copyInLnks if (!checkSel) return if (!null table_skip) delete table_skip table_skip = create if (!filtering sourceMod) { if (query((NLS_("Filtering is currently off. Do you want it switched back on?")),yesNo) == 0) filtering on } saveSettings defaultSettings targetMod copyAllVisible(sourceMod, targetMod, copyDir) del(targetMod) restoreSettings } void copySelection(DB db) { int copyDir = get copyPos // copyOutgoingLinks = get copyOutLnks // copyIncomingLinks = get copyInLnks if (!checkSel) return if (!null table_skip) delete table_skip table_skip = create saveSettings defaultSettings targetMod int copyPosition = get copyPos copyAllSelected(sourceMod, targetMod, copyPosition) del(targetMod) restoreSettings } void closeWin(DB db) { if (!null table_skip) delete table_skip delete trig hide d } bool closeModuleTrig(Trigger t) { if (!null table_skip) delete table_skip hide d return true } bool expand(DBE dbe_tree1, string branch) { fillTreeSimple2(dbe_tree1,(NLS_("")) branch) return true } void makeDialogue () { Object o = findFirstSelObject sourceMod d = create((NLS_("Copy data")), styleThemed|styleAutoparent) label(d, (NLS_("To module: "))) opposite d left d targetList = treeView(d,3,300,10) set(targetList, expand) left d copyPos = choice(d,(NLS_("Copy position")), cs, 0) hide copyPos //copyOutLnks = toggle(d, (NLS_("Copy outgoing links")), true) //copyInLnks = toggle(d, (NLS_("Copy incoming links")), true) //copyInLnks -> "left" -> "spaced" -> copyOutLnks //copyInLnks -> "top" -> "aligned" -> copyOutLnks textMultiLine = text(d, "results credits: " , "Taking credit from module: "sourceModName" \nUser: "doorsname"" , 100, 45, true) textMultiLine2 = text(d, "" , "" , 300, 100, false) label (d, "") //apply(d, (NLS_("Copy all")), copyAll) apply(d, (NLS_("Copy filtered")), copyDisplayed) apply(d, (NLS_("Copy selection")), copySelection) //apply(d, (NLS_("Copy current")), copyCurrent) close(d, true, closeWin) trig = trigger(module->sourceModName, close, 10, closeModuleTrig) realize d insert(targetList, (NLS_("")), iconDatabase, iconDatabase) fillTreeSimple2(targetList, (NLS_("/"))) } void fillDialogue() { attrList } // Main Program makeDialogue fillDialogue show d