// WEXP: Enhanced exporter from DOORS to Word /* Word exporter that handles: - mixed book and column formats - mixed paragraph styles and object boiler-plates - export into middle of DOT file, allows room for title pages, etc. - and lots more */ /* History: WHO WHEN WHAT JD 99/10/21 Moved include files into separate folder. Replaced use of AUTOTEXT by fields enclosed in << .. >> JD 99/10/23 Extracted Nokia-specific requirement indexing into separate functions. Added section breaks with portrai/landscape page orientation. Allowed columns on left of main column to be paragraph labels. View column titles ending in " R" are rotated. JD 99/11/12 Added "None" values to "Page Break" and "Section Break". JD 00/02/09 Added DB option to turn on Word update. JD 00/05/10 Added feature for insertion of complete view in place of object. JD 00/07/26 Added feature to allow exporter to alignment pages to odd or even numbers by exlicitly inserting blank pages. Added feature for insertion of blank page rubrick on alignment pages. Created advanced features button and dialog. JD 00/09/04 Complete code review for factorisation of OLE commands, etc. JD 00/10/11 Table scaling is for Word 2000 only. JD 00/11/08 Changed macro name from getPageNumber to WEXP_getPageNumber. Prompt for existence of old View Name attribute. Added Word 97 autofit behaviour on tables. Added revision marks feature. JD 01/01/19 Added bookmark export feature. Added baseline name to stored options. JD 01/07/10 Added single attribute creation access rights check at beginning. Added WEXP_notVerbose option, and changed ack to errorBox. JD 01/08/14 New attributes to control table cell shading, rotation and headers. JD 01/09/05 Moved all #includes into unencrypted wexp.dxl. JD 01/12/12 Fixed bug when creation of AVIEWNAME attribute fails. JD 02/01/04 Introduced export style attribute. JD 02/02/28 Fixed problem with WEXP leaving a WINWORD.EXE process around on cancel. Fixed problem with subdocument path names. Fixed problem with creation of object attributes. Added count of time taken in export. JD 02/12/23 Added option to use current filter on selected view. LLM 16/01/03 TREK 3.1 CR 22 - Added WEXP View Filter attribute JD 03/03/18 Added attributes for inserting view based on links. JD 04/06/18 Change "refresh" option to "visible". Permitted the use of "Standard view" for export. JD 04/07/27 Replaced some "ack"s with "infoBox". JD 04/08/04 Re-instated the "Close Word after" advanced option. JD 04/08/06 Converted regexps to work in DOORS 6.0a JD 05/01/28 Made WEXP behave exactly like the standard exporter when connecting to Word. JD 05/04/05 Refactored this code to allow repeated batch startup. JD 26/04/05 Added check to exclude link modules from list of sub-documents. KM 08/01/10 NAV CANADA: Fixed 'Cannot extract path name from...' problem in DOORS 8.2 due to Telelogic fix for Defect ID 25255 Lines modified have been commented with "KM 08/01/10" */ pragma runLim,0 //------------------------- Export UI builder code --------------------------- int WEXP_wordCheckVersion() { WEXP_objArgBlock = create() if ( null WEXP_objArgBlock ) { errorBox "Unable to create argument block. Low memory?" return 0 } // Get Word object WEXP_objWord = oleGetAutoObject(cObjWordApplication) if ( null WEXP_objWord ) { WEXP_objWord = oleCreateAutoObject(cObjWordApplication) } if ( null WEXP_objWord ) { errorBox "Unable to communicate with Word. Is it installed?" return 0 } // get version string wordVersion = WEXP_objWord."Application"."Version" if ( matches("^([0-9]+)[.]", wordVersion) ) return intOf(wordVersion[match 1]) return 0 } void WEXP_useTemplateNameSelected(DBE xx) { bool b = get WEXP_advancedNormalTemplateToggle if (b) { inactive WEXP_advancedTemplateName inactive WEXP_advancedTemplateLabel } else { active WEXP_advancedTemplateName active WEXP_advancedTemplateLabel } } bool WEXP_userExportOnClose(DB WEXP_exportBox) { return true } bool WEXP_exportAPI(DB WEXP_exportBox, Module exportMod, string vname, fname, tname, int layout, bool includeHeadings, refreshWord, pageBreaks, scaleViews, scaleTables, breakTables, retainTemplates, revisionMarks, notVerbose, ignoreStyles, joinLeftColumns, useFilesNotClip, exportMaster, exportSubdocs, noAttribPrompts, executeWordMacro, Baseline baseLineDetails, Module baseMod, string wordMacroName, bool closeAfter, string &errMsg) { // check view exists (without loading it yet!) bool foundView = false if ( vname == "Standard view" ) { foundView = true } else { string thisView for thisView in views exportMod do { if ( thisView == vname ) { foundView = true break } } } if ( !foundView ) { errMsg = "A view of this name does not exist: " vname "" return false } if (!fileExists_ tname) { errMsg = "A Word file of this name does not exist: " tname "" return false } WEXP_currMod = exportMod WEXP_wordFileName = fname WEXP_templateName = tname WEXP_exportView = vname WEXP_includeHeadingNumbers = includeHeadings WEXP_refreshWord = refreshWord WEXP_pageBreaks = pageBreaks WEXP_scaleViews = scaleViews WEXP_scaleTables = scaleTables WEXP_breakTables = breakTables WEXP_retainTemplates = retainTemplates WEXP_revisionMarks = revisionMarks WEXP_notVerbose = notVerbose WEXP_ignoreStyles = ignoreStyles WEXP_breaksAreParas = true WEXP_joinLeftColumns = joinLeftColumns WEXP_useFilesNotClip = useFilesNotClip WEXP_exportMaster = exportMaster WEXP_exportSubdocs = exportSubdocs WEXP_noAttribPrompts = noAttribPrompts WEXP_executeWordMacro = executeWordMacro WEXP_wordMacroName = wordMacroName WEXP_closeAfter = closeAfter WEXP_baseline = baseLineDetails WEXP_baselineMod = baseMod WEXP_baselineDate = null if ( !null WEXP_baseline ) WEXP_baselineDate = dateOf(baseLineDetails) WEXP_wordVersion = WEXP_wordCheckVersion() if ( WEXP_wordVersion == 0 ) { errMsg = "Unknown Word version = " WEXP_wordVersion "" return false } WEXP_initErrorLogging() // extract pathname - assumes subdocuments go into path specified string wordFilePath = "" // if ( matches("[\\/]([^\\/]*)$", fname) ) wordFilePath = fname[0:start 0] // KM 08/01/10 - Commented out if ( matches("[\\\\/]([^\\\\/]*)$", fname) ) wordFilePath = fname[0:start 0]; // KM 08/01/10 - added else { errMsg = "Cannot extract path name from " fname "'." return false } Date strtTime = today() if ( WEXP_exportMaster ) { WEXP_export(WEXP_exportBox, layout, WEXP_closeAfter) } if ( WEXP_exportSubdocs ) { if ( WEXP_exportMaster ) { // close Master document, since otherwise subdocs are already open WEXP_objWord."ActiveDocument"->"Close" } WEXP_modIndex = current // loop through subdocuments Object objSubdoc for objSubdoc in WEXP_modIndex do { // module name is in an attribute string modName = probeAttr_(objSubdoc, AMODNAME) if ( !exists module modName ) continue if ( type module modName != "Formal" ) continue // open module WEXP_currMod = read modName // has to be visible so that views work current = WEXP_currMod // construct name of Word subdocument WEXP_wordFileName = probeAttr_(objSubdoc, AWORDNAME) if ( WEXP_wordFileName == "" ) WEXP_wordFileName = probeAttr_(WEXP_currMod, AEXPORTNAME) // check if subdocument name as an absolute path if ( !matches("^[A-Za-z][:]", WEXP_wordFileName) ) WEXP_wordFileName = wordFilePath FileSep_ WEXP_wordFileName // if ( WEXP_wordFileName == "" ) WEXP_wordFileName = wordFilePath objSubdoc.AWORDNAME ".doc" // find name of export view WEXP_exportView = probeAttr_(WEXP_currMod, AEXPORTVIEW) if ( WEXP_exportView == "" ) WEXP_exportView = "Standard view" // check export view exists if ( !(load view WEXP_exportView) ) { errorBox "The view named '" WEXP_exportView "' does not exist in module '" modName "." continue } // find and check name of Word template WEXP_templateName = probeAttr_(WEXP_currMod, ATEMPLATE) if (!fileExists_ WEXP_templateName) { errorBox "The template file called '" WEXP_templateName "' for module '" modName "' does not exist." continue } // export this sub-document WEXP_export(WEXP_exportBox, layout, false) close WEXP_currMod } } Date finTime = today() if ( !WEXP_notVerbose ) { // display time taken for export string hhmmss(int ss) { int mm = ss/60 int hh = mm/60 mm -= hh*60 ss -= (hh*60+mm)*60 return "" ( hh < 10 ? "0" : "" ) hh ":" ( mm < 10 ? "0" : "" ) mm ":" ( ss < 10 ? "0" : "" )ss "" } infoBox("WEXPort complete. Time taken: " hhmmss(intOf(finTime)-intOf(strtTime))) } WEXP_showErrorLog() return true } bool WEXP_userExportCode(string vname, fname, tname, int layout, bool includeHeadings, bool WEXP_refreshWord, DB WEXP_exportBox) { current = WEXP_currMod // check view exists (without loading it yet!) bool foundView = false if ( vname == "Standard view" ) { foundView = true } else { string thisView for thisView in views current Module do { if ( thisView == vname ) { foundView = true break } } } if ( !foundView ) { errorBox "A view of this name does not exist: " vname "" return false } if (!fileExists_ tname) { errorBox "A Word file of this name does not exist: " tname "" return false } WEXP_wordFileName = fname WEXP_templateName = tname WEXP_exportView = vname WEXP_includeHeadingNumbers = includeHeadings if ( WEXP_wordVersion == 0 ) { errorBox "Unknown Word version = " WEXP_wordVersion "" return false } WEXP_initErrorLogging() if ( !WEXP_notVerbose ) { if ( !confirm "The Word exporter uses the system clipboard, as well as multiple Word documents.\n\n".. "Do not open any another Word document on this machine.\n\n".. "Do not use copy and paste in any application until the export has finished.\n\n".. "Continue export?" ) { return false } } // extract pathname - assumes subdocuments go into path specified string wordFilePath = "" // if ( matches("[\\/]([^\\/]*)$", fname) ) wordFilePath = fname[0:start 0] // KM 08/01/10 - Commented out if ( matches("[\\\\/]([^\\\\/]*)$", fname) ) wordFilePath = fname[0:start 0]; // KM 08/01/10 - Added else { warningBox "Cannot extract path name from " fname "'." return false } Date strtTime = today() if ( WEXP_exportMaster ) { if (!fileOverwriteOK_ fname) return false WEXP_export(WEXP_exportBox, layout, WEXP_closeAfter) } if ( WEXP_exportSubdocs ) { if ( WEXP_exportMaster ) { // close Master document, since otherwise subdocs are already open WEXP_objWord."ActiveDocument"->"Close" } WEXP_modIndex = current // loop through subdocuments Object objSubdoc for objSubdoc in WEXP_modIndex do { // module name is in an attribute string modName = probeAttr_(objSubdoc, AMODNAME) if ( !exists module modName ) continue if ( type module modName != "Formal" ) continue // open module WEXP_currMod = read modName // has to be visible so that views work current = WEXP_currMod // construct name of Word subdocument WEXP_wordFileName = probeAttr_(objSubdoc, AWORDNAME) if ( WEXP_wordFileName == "" ) WEXP_wordFileName = probeAttr_(WEXP_currMod, AEXPORTNAME) // check if subdocument name as an absolute path if ( !matches("^[A-Za-z][:]", WEXP_wordFileName) ) WEXP_wordFileName = wordFilePath FileSep_ WEXP_wordFileName // if ( WEXP_wordFileName == "" ) WEXP_wordFileName = wordFilePath objSubdoc.AWORDNAME ".doc" // find name of export view WEXP_exportView = probeAttr_(WEXP_currMod, AEXPORTVIEW) if ( WEXP_exportView == "" ) WEXP_exportView = "Standard view" // check export view exists if ( !(load view WEXP_exportView) ) { errorBox "The view named '" WEXP_exportView "' does not exist in module '" modName "." continue } // find and check name of Word template WEXP_templateName = probeAttr_(WEXP_currMod, ATEMPLATE) if (!fileExists_ WEXP_templateName) { errorBox "The template file called '" WEXP_templateName "' for module '" modName "' does not exist." continue } // export this sub-document WEXP_export(WEXP_exportBox, layout, false) close WEXP_currMod } } Date finTime = today() if ( !WEXP_notVerbose ) { // display time taken for export string hhmmss(int ss) { int mm = ss/60 int hh = mm/60 mm -= hh*60 ss -= (hh*60+mm)*60 return "" ( hh < 10 ? "0" : "" ) hh ":" ( mm < 10 ? "0" : "" ) mm ":" ( ss < 10 ? "0" : "" )ss "" } infoBox("WEXPort complete. Time taken: " hhmmss(intOf(finTime)-intOf(strtTime))) } WEXP_showErrorLog() return true } //----------------------------- Interface code ------------------------------ string WEXP_generateFileName(string s, string extension) { string modName = s if ( null modName ) { modName = WEXP_nameSubstitute } string newName = fileGoodName_(modName, WEXP_extSeparator extension, WEXP_extSeparator extension) return newName } string WEXP_generateFileName(string extension) { string modName = probeAttr_(current Module, AEXPORTNAME) if ( null modName ) { modName = probeAttr_(current Module, "Name") modName = WEXP_generateFileName(modName, extension) } return modName } // fill DBE list from views in formal module int WEXP_fillViewsList(DBE list, Module mod, string selectedView) { // check module if ( null mod ) { errorBox "WEXP_fillViewsList: null module." return 0 } realize(parentOf list) // empty list int n = noElems list if ( n > 0 ) { int i for i in 1:(noElems list) do delete(list, 0) } // list the views string vn = "Standard view" int i = chop_insert(list, vn) if ( vn == selectedView ) set(list, i, true) for vn in views mod do { i = chop_insert(list, vn) if ( vn == selectedView ) set(list, i, true) } return noElems list } void WEXP_closeExportBox(DB xx) { if (!WEXP_userExportOnClose WEXP_exportBox) return WEXP_closeDown() } string WEXP_dummyList[] = { } DB WEXP_selViewDB = create("Select view") DBE WEXP_selViewList = list(WEXP_selViewDB, "", 150, 10, WEXP_dummyList) void WEXP_doSelectViewOK(DB db) { string vn = get(WEXP_selViewList) set(WEXP_exportViewName, vn) release(WEXP_selViewDB) } void WEXP_doSelectView(DBE xx) { apply(WEXP_selViewDB, "OK", WEXP_doSelectViewOK) WEXP_fillViewsList(WEXP_selViewList, WEXP_currMod, currentView(WEXP_currMod)) block WEXP_selViewDB raise(WEXP_exportBox) } void WEXP_doSpool(DB db) { if ( isEdit(WEXP_currMod) ) { // save all the settings if ( WEXP_canWriteAttrib(WEXP_currMod, AEXPORTNAME) && isEdit WEXP_currMod ) WEXP_currMod.AEXPORTNAME = WEXP_wordFileName if ( WEXP_canWriteAttrib(WEXP_currMod, AEXPORTVIEW) && isEdit WEXP_currMod ) WEXP_currMod.AEXPORTVIEW = WEXP_exportView if ( WEXP_canWriteAttrib(WEXP_currMod, ABASELINE) && isEdit WEXP_currMod ) WEXP_currMod.ABASELINE = WEXP_baselineName if ( WEXP_canWriteAttrib(WEXP_currMod, AEXPORTOPTS1) && isEdit WEXP_currMod ) WEXP_currMod.AEXPORTOPTS1 = WEXP_refreshWord "," WEXP_pageBreaks "," WEXP_scaleViews "," WEXP_scaleTables "," WEXP_breakTables "," WEXP_retainTemplates "," WEXP_revisionMarks "," WEXP_notVerbose "," WEXP_joinLeftColumns "," WEXP_useFilesNotClip "," WEXP_closeAfter "" if ( WEXP_canWriteAttrib(WEXP_currMod, AEXPORTOPTS2) && isEdit WEXP_currMod ) WEXP_currMod.AEXPORTOPTS2 = WEXP_exportMaster "," WEXP_exportSubdocs "," WEXP_noAttribPrompts "," WEXP_breaksAreParas "," WEXP_tableMode "," WEXP_ignoreStyles "," WEXP_executeWordMacro "," WEXP_wordMacroName "," WEXP_closeAfter "" if ( WEXP_canWriteAttrib(WEXP_currMod, ATEMPLATE) && isEdit WEXP_currMod ) WEXP_currMod.ATEMPLATE = WEXP_templateName save(WEXP_currMod) } else { if ( !confirm "The current module is read-only. The current settings will be used in export.\n\nContinue?" ) { return } } eval_("#include ") hide(db) } void WEXP_doExport(DB xx) { int i = 0 // get WEXP_exportLayoutChoice bool h = false // get WEXP_exportHeadingsToggle bool r = WEXP_refreshWord int u = get WEXP_templateBut int m = get WEXP_exportMode bool useTemplate = ( u == 0 ) WEXP_tableMode = ( m == 1 ) string s = null string t = null string v = null WEXP_useFilter = get WEXP_useCurrFilter if (!null WEXP_exportFileName) { s = get WEXP_exportFileName // if (!fileOverwriteOK_ s) return } if (!null WEXP_templateFileName && useTemplate ) { t = get WEXP_templateFileName } else if (!null WEXP_documentFileName) { t = get WEXP_documentFileName } if (!null WEXP_exportViewName) { v = get WEXP_exportViewName } // open baseline for comparison Baseline b for b in WEXP_currMod do { string details = (major(b)) "." (minor(b)) " (" suffix(b) ")" // " " (dateOf intOf dateOf(b)) "" if ( details == WEXP_baselineName ) { WEXP_baseline = b WEXP_baselineMod = load(WEXP_currMod, b, false) WEXP_baselineDate = dateOf(b) break } } if (!WEXP_userExportCode(v,s,t,i,h,r,WEXP_exportBox)) return WEXP_closeExportBox WEXP_exportBox } DB WEXP_advDB = null DBE WEXP_exportMainOption = null DBE WEXP_clipBoardOption = null DBE WEXP_exportSubsOption = null DBE WEXP_noAttribPromptOption = null DBE WEXP_refreshWordOption = null DBE WEXP_pageBreaksOption = null DBE WEXP_scaleViewsOption = null DBE WEXP_scaleTablesOption = null DBE WEXP_breakTablesOption = null DBE WEXP_retainersOption = null DBE WEXP_verboseOption = null DBE WEXP_joinColsOption = null DBE WEXP_revisionOption = null DBE WEXP_baselines = null DBE WEXP_newLinesAsParas = null DBE WEXP_ignoreParaStyle = null DBE WEXP_macroOption = null DBE WEXP_macroName = null DBE WEXP_closeWordAfter = null void WEXP_doSelectRevisions(DBE dbe) { bool rev = get(dbe) if ( rev ) active WEXP_baselines else inactive WEXP_baselines } void WEXP_doSelectMacro(DBE dbe) { bool rev = get(dbe) if ( rev ) active WEXP_macroName else inactive WEXP_macroName } bool WEXP_advancedCancel = false void WEXP_doAdvancedCancel(DB db) { WEXP_advancedCancel = true release(db) raise(WEXP_exportBox) } void WEXP_doAdvancedCheck(DB db) { if ( get(WEXP_revisionOption) && (int get(WEXP_baselines)) < 0 ) { warningBox "You have selected the revision mark option.\n\nPlease also select a baseline." return } WEXP_advancedCancel = false release(DB) } void WEXP_doAdvanced(DB db) { WEXP_advancedCancel = false // count WEXP_baselines of current module int numBLs = 0 Baseline b for b in WEXP_currMod do numBLs++ string baseLines[numBLs] int i = numBLs for b in WEXP_currMod do { string details = (major(b)) "." (minor(b)) " (" suffix(b) ")" // " " (dateOf intOf dateOf(b)) "" baseLines[--i] = details if ( details == WEXP_baselineName ) WEXP_baselineIdx = i } WEXP_advDB = create(db, WEXP_wordAdvancedTitle) WEXP_exportMainOption = toggle(WEXP_advDB, "Export document from this module", WEXP_exportMaster) WEXP_exportSubsOption = toggle(WEXP_advDB, "Export sub-documents referenced in this module", WEXP_exportSubdocs) WEXP_refreshWordOption = toggle(WEXP_advDB, "Make Word visible during export", WEXP_refreshWord) WEXP_ignoreParaStyle = toggle(WEXP_advDB, "Ignore the DOORS 'Paragraph Style' attribute", WEXP_ignoreStyles) // WEXP_newLinesAsParas = toggle(WEXP_advDB, "Treat line breaks in Object Text as new paragraphs", WEXP_breaksAreParas) WEXP_joinColsOption = toggle(WEXP_advDB, "Join columns on left of main column", WEXP_joinLeftColumns) WEXP_pageBreaksOption = toggle(WEXP_advDB, "Insert blank page rubrick on alignment pages ", WEXP_pageBreaks) WEXP_scaleViewsOption = toggle(WEXP_advDB, "Scale views to fit width of page", WEXP_scaleViews) WEXP_scaleTablesOption = toggle(WEXP_advDB, "Scale DOORS tables to fit width of page", WEXP_scaleTables) WEXP_breakTablesOption = toggle(WEXP_advDB, "Allow table rows to break across pages", WEXP_breakTables) WEXP_retainersOption = toggle(WEXP_advDB, "Retain templates and bookmarks for further export", WEXP_retainTemplates) WEXP_revisionOption = toggle(WEXP_advDB, "Use Word revision marks on changed objects", WEXP_revisionMarks) WEXP_baselines = choice(WEXP_advDB, "Mark changes since baseline:", baseLines, WEXP_baselineIdx) WEXP_verboseOption = toggle(WEXP_advDB, "Do not display warning information", WEXP_notVerbose) WEXP_noAttribPromptOption = toggle(WEXP_advDB, "Do not prompt on missing attributes", WEXP_noAttribPrompts) WEXP_clipBoardOption = toggle(WEXP_advDB, "Use files instead of clipboard for OLEs", WEXP_useFilesNotClip) WEXP_macroOption = toggle(WEXP_advDB, "Execute Word macro after export", WEXP_executeWordMacro) WEXP_macroName = field (WEXP_advDB, "Name of Word macro:", WEXP_wordMacroName, 20) WEXP_closeWordAfter = toggle(WEXP_advDB, "Quit Word after export", WEXP_closeAfter) apply(WEXP_advDB, "OK", WEXP_doAdvancedCheck) ok(WEXP_advDB, "Cancel", WEXP_doAdvancedCancel) close(WEXP_advDB, false, WEXP_doAdvancedCancel) if ( WEXP_wordVersion < 9 ) { // set(WEXP_scaleTablesOption, false) // inactive(WEXP_scaleTablesOption) } set(WEXP_revisionOption, WEXP_doSelectRevisions) set(WEXP_macroOption, WEXP_doSelectMacro) if ( numBLs == 0 ) { set(WEXP_revisionOption, false) inactive WEXP_revisionOption inactive WEXP_baselines } WEXP_doSelectRevisions(WEXP_revisionOption) WEXP_doSelectMacro(WEXP_macroOption) block(WEXP_advDB) raise(WEXP_exportBox) if ( WEXP_advancedCancel ) return WEXP_refreshWord = get(WEXP_refreshWordOption) WEXP_pageBreaks = get(WEXP_pageBreaksOption) WEXP_scaleViews = get(WEXP_scaleViewsOption) WEXP_scaleTables = get(WEXP_scaleTablesOption) WEXP_breakTables = get(WEXP_breakTablesOption) WEXP_retainTemplates = get(WEXP_retainersOption) WEXP_revisionMarks = get(WEXP_revisionOption) WEXP_notVerbose = get(WEXP_verboseOption) WEXP_ignoreStyles = get(WEXP_ignoreParaStyle) WEXP_breaksAreParas = true // get(WEXP_newLinesAsParas) WEXP_joinLeftColumns = get(WEXP_joinColsOption) WEXP_useFilesNotClip = get(WEXP_clipBoardOption) WEXP_exportMaster = get(WEXP_exportMainOption) WEXP_exportSubdocs = get(WEXP_exportSubsOption) WEXP_noAttribPrompts = get(WEXP_noAttribPromptOption) WEXP_executeWordMacro = get(WEXP_macroOption) WEXP_wordMacroName = get(WEXP_macroName) WEXP_closeAfter = get(WEXP_closeWordAfter) if ( WEXP_revisionMarks && (int get(WEXP_baselines)) >= 0 ) { WEXP_baselineIdx = get(WEXP_baselines) WEXP_baselineName = baseLines[WEXP_baselineIdx] } raise(WEXP_exportBox) } bool WEXP_exportCloseModuleTrig(Trigger t) { if ( !null WEXP_exportBox ) hide WEXP_exportBox return true } void WEXP_exportSelectMode(DBE dbe) { if ( dbe == WEXP_templateBut ) { active(WEXP_templateFileName) inactive(WEXP_documentFileName) set(WEXP_documentBut, 1) } if ( dbe == WEXP_documentBut ) { inactive(WEXP_templateFileName) active(WEXP_documentFileName) set(WEXP_templateBut, 1) } } void WEXP_makeExporterUI(string dbTitle, string advTitle, int helpId, bool includeFilename, bool bookOnly, string extension, description) { WEXP_exportBox = centered dbTitle label(WEXP_exportBox, "Export from view:") WEXP_exportViewName = field(WEXP_exportBox, " ", WEXP_exportView, 50, false) WEXP_exportViewName->"left"->"unattached" DBE spacer = label(WEXP_exportBox, "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM") beside(WEXP_exportBox) WEXP_useCurrFilter = toggle(WEXP_exportBox, "Use current filter", WEXP_useFilter) WEXP_selectButt = button(WEXP_exportBox, "Select...", WEXP_doSelectView) left(WEXP_exportBox) WEXP_exportMode = radioBox(WEXP_exportBox, "Starting mode:", WEXP_templateModes, ( WEXP_tableMode ? 1 : 0 )) WEXP_templateBut = radioBox(WEXP_exportBox, "", WEXP_templateOpts, 0) WEXP_templateFileName = fileName(WEXP_exportBox, "(select a template)", "*.dot", "Document Template", false) WEXP_documentBut = radioBox(WEXP_exportBox, "", WEXP_documentOpts, 0) WEXP_documentFileName = fileName(WEXP_exportBox, "(select a file)", "*.doc", "Document", false) label(WEXP_exportBox, "Name of exported file:") WEXP_exportFileName = fileName(WEXP_exportBox, WEXP_exportName, "*.doc", "Document", false) close(WEXP_exportBox,true,WEXP_closeExportBox) // help(WEXP_exportBox,helpId) WEXP_exportButt = apply(WEXP_exportBox, "Export", WEXP_doExport) WEXP_spoolButt = apply(WEXP_exportBox, "Spool", WEXP_doSpool) WEXP_exportAdvancedButt = apply(WEXP_exportBox, "Advanced ...", WEXP_doAdvanced) WEXP_exportTrigger = trigger(module,close,10,WEXP_exportCloseModuleTrig) spacer->"top"->"aligned"->WEXP_exportViewName hide spacer set(WEXP_templateBut, WEXP_exportSelectMode) set(WEXP_documentBut, WEXP_exportSelectMode) if (!fileExists_ WEXP_templateName) { // resort to the default Microsoft office templates folder WEXP_templateName = getMSOfficeTemplatesFolder() WEXP_templateName = WEXP_templateName "\\Normal.dot" } if ( !matches("[.]doc$", WEXP_templateName) ) { WEXP_exportSelectMode(WEXP_templateBut) set(WEXP_templateFileName, WEXP_templateName) } else { WEXP_exportSelectMode(WEXP_documentBut) set(WEXP_documentFileName, WEXP_templateName) } realize WEXP_exportBox } // set defaults WEXP_wordTitle = "Export Document to Word (WEXP Version " WEXP_wordExpVersion ")" WEXP_useNormalTemplate = false WEXP_includeHeadingsDefault = false WEXP_useBookmarks = true void WEXP_createAttributes() { // check attribute creation access // (do this so that we can put a message out just once rather than for every attribute) if ( !WEXP_checkCreateObjAttrib(AWORDNAME, "String", "", false, false) && !WEXP_canCreateAttrib(WEXP_currMod, AWORDNAME) ) { if ( !confirm "Insufficient access for creation of object attributes in current module.\n\nThe consequence of this is that the exporter functionality will be restricted to 'Quick Start' mode.\n\nDo you want to continue?" ) halt } if ( !WEXP_checkCreateModAttrib(AEXPORTNAME, "String", "", false, false) && !WEXP_canCreateAttrib(WEXP_currMod, AEXPORTNAME) ) { if ( !confirm "Insufficient access for creation of module attributes in current module.\n\nThe consequence of this is that the exporter settings will not be preserved between sessions.\n\nDo you want to continue?" ) halt } // ensure existence of attributes WEXP_checkCreateModAttrib(AEXPORTNAME, "String", "", true, false, false) WEXP_checkCreateModAttrib(AEXPORTVIEW, "String", "", true, false, false) WEXP_checkCreateModAttrib(AEXPORTOPTS1, "Text", "", true, false, false) WEXP_checkCreateModAttrib(AEXPORTOPTS2, "Text", "", true, false, false) WEXP_checkCreateModAttrib(ABASELINE, "String", "", true, false, false) WEXP_checkCreateModAttrib(ATEMPLATE, "String", "Normal", true, false, false) WEXP_checkCreateModAttrib(ABLANKPAGE, "Text", "(Intentionally blank.):BlankPage", true, false, false) WEXP_checkCreateModAttrib(ADOCPROPS, "Text", "", true, false, false) WEXP_checkCreateObjAttrib(AWORDNAME, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(AWORDBMARK, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(ADOORSBMARK, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(AINDEXON, "Text", "", false, false, true, false) WEXP_checkCreateObjAttrib(AMODULEVIEW, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(AMODNAME, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(APARASTYLE, "Text", "", false, false, true, false) WEXP_checkCreateObjAttrib(AOBJTEMPL, "Text", "", false, false, true, false) WEXP_checkCreateObjAttrib(AOBJTEMPLAFT,"Text", "", false, false, true, false) WEXP_checkCreateObjAttrib(AVIEWNAME, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(AVIEWFILTER, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(ATRACEVIEW, "Text", "", false, false, true, false) WEXP_checkCreateObjAttrib(AOLEWIDTH, "Integer", "", false, false, true, false) WEXP_checkCreateObjAttrib(AOLEHEIGHT, "Integer", "", false, false, true, false) WEXP_checkCreateObjAttrib(AROTCELLTXT, "Boolean", "", false, false, true, false) WEXP_checkCreateObjAttrib(ASHDCELLTXT, "String", "", false, false, true, false) WEXP_checkCreateObjAttrib(ATABHEADER, "Boolean", "", false, false, true, false) WEXP_checkCreateObjAttrib(AOLEINLINE, "Boolean", "", false, false, true, false) WEXP_checkCreateObjAttrib(AFOOTNOTES, "Text", "", false, false, true, false) WEXP_checkCreateObjAttrib(APAGEBREAK, TBREAK, SECTBREAK, VNONE, false, false, true, false) WEXP_checkCreateObjAttrib(ASECTBREAK, TORIENT, PAGEORIENT, VNONE, false, false, true, false) WEXP_checkCreateObjAttrib(AEXPSTYLE, TSTYLE, EXPORTSTYLE, VTABLE, false, false, true, false) WEXP_checkCreateObjAttrib(APOSITION, TPOSITION, POSITION, VREPLACE, false, false, true, false) WEXP_checkCreateObjAttrib(ACAPTION, TCAPTION, CAPTION, "", false, false, true, false) if ( AVIEWNAME != "View Name" && exists attribute AVIEWNAME && exists attribute "View Name" ) { string opts[] = { "Yes", "No" } int ans = query("An attribute called 'View Name' exists in the module.\n\nDo you want to copy this into '" AVIEWNAME "'?", opts) if ( opts[ans] == "Yes" ) { // copy attribute into WEXP View Name Object o for o in WEXP_currMod do { if ( probeAttr_(o, AVIEWNAME) == "" ) o.AVIEWNAME = probeAttr_(o, "View Name") } } } } void WEXP_loadAttributes() { // set default export options from module attributes WEXP_exportName = probeAttr_(WEXP_currMod, AEXPORTNAME) WEXP_exportView = probeAttr_(WEXP_currMod, AEXPORTVIEW) WEXP_baselineName = probeAttr_(WEXP_currMod, ABASELINE) Buffer WEXP_exportOptions1= create() Buffer WEXP_exportOptions2= create() WEXP_exportOptions1 += probeAttr_(WEXP_currMod, AEXPORTOPTS1) WEXP_exportOptions2 += probeAttr_(WEXP_currMod, AEXPORTOPTS2) Regexp hasField = regexp "(^|,)([^,]+)($|,)" int n = 0 int i = 0 while ( search(hasField, WEXP_exportOptions1, i) ) { bool res = ( WEXP_exportOptions1[i+start(2):i+end(2)] == "true" ) if ( n == 0 ) WEXP_refreshWord = res if ( n == 1 ) WEXP_pageBreaks = res if ( n == 2 ) WEXP_scaleViews = res if ( n == 3 ) WEXP_scaleTables = res if ( n == 4 ) WEXP_breakTables = res if ( n == 5 ) WEXP_retainTemplates = res if ( n == 6 ) WEXP_revisionMarks = res if ( n == 7 ) WEXP_notVerbose = res if ( n == 8 ) WEXP_joinLeftColumns = res if ( n == 9 ) WEXP_useFilesNotClip = res if ( n == 10 ) WEXP_closeAfter = res n++ i += end(0)+1 } n = 0 i = 0 while ( search(hasField, WEXP_exportOptions2, i) ) { bool res = ( WEXP_exportOptions2[i+start(2):i+end(2)] == "true" ) if ( n == 0 ) WEXP_exportMaster = res if ( n == 1 ) WEXP_exportSubdocs = res if ( n == 2 ) WEXP_noAttribPrompts = res // if ( n == 3 ) WEXP_breaksAreParas = res if ( n == 4 ) WEXP_tableMode = res if ( n == 5 ) WEXP_ignoreStyles = res if ( n == 6 ) WEXP_executeWordMacro = res if ( n == 7 ) WEXP_wordMacroName = WEXP_exportOptions2[i+start(2):i+end(2)] n++ i += end(0)+1 } delete(WEXP_exportOptions1) delete(WEXP_exportOptions2) if ( WEXP_exportView == "" ) WEXP_exportView = currentView(WEXP_currMod) if ( null WEXP_exportName ) { WEXP_exportName = WEXP_generateFileName "doc" } // set default template name from module WEXP_templateName = probeAttr_(WEXP_currMod, ATEMPLATE) if ( null WEXP_templateName ) { string templatesDir = getMSOfficeTemplatesFolder() if (null templatesDir) { WEXP_templateName = "normal.dot" } else { WEXP_templateName = templatesDir "\\normal.dot" } } } void WEXP_start(Module m) { if ( null m ) { warningBox "WEXP_start: null Module passed to WEXP." halt } WEXP_currMod = m WEXP_loadingText = "Connecting to Word..." WEXP_loadingSteps = 1 WEXP_loadingProgress = 0 WEXP_showBanner(WEXP_currMod) // check Word WEXP_wordVersion = WEXP_wordCheckVersion() WEXP_hideBanner() WEXP_createAttributes() WEXP_loadAttributes() // show dialogue WEXP_makeExporterUI(WEXP_wordTitle, WEXP_wordAdvancedTitle, 0, true, true, "doc", "Book") show WEXP_exportBox } k") show WEXP_exportBox }