|
DOORS Project reporting V1.0
|
00001 /* **************************************************************************** 00002 ----------------------------------------------------------------------------- 00003 D E S C R I P T I O N 00004 ----------------------------------------------------------------------------- 00005 $ProjectName: GS-TC_Tool_Support 00006 $Source: Project Report.dxl 00007 $Revision: 00008 $Date: 01/08/2011 00009 $State: in_work 00010 Purpose: Project report in word format 00011 Target system: n/a 00012 ----------------------------------------------------------------------------- 00013 N O T E S 00014 ----------------------------------------------------------------------------- 00015 Notes: 00016 00017 ----------------------------------------------------------------------------- 00018 A U T H O R I D E N T I T Y 00019 ----------------------------------------------------------------------------- 00020 Network account Name Department 00021 ---------------- -------------------- --------------------------- 00022 rab1kor Ranjana Bhat RBEI/ETT2 00023 ------------------------------------------------------------------------------ 00024 R E V I S I O N H I S T O R Y 00025 00026 27.07.2011 rab1kor - the PP script is taken as base and the features required in project report for GSTC tools is implemented GSTCS 424 is a base requirement in JIRA and this creates a simple table view exporting from DOORS to word, without any formatting 00027 01.08.2011 rab1kor- implementation for including field name and attribute name in the XML and to display filed name in the word export (GSTCS 442) 00028 19.08.2011 rab1kor- book marking for the table, and for the attributes and column hyperlinking is added, macro is changed in the .dot file 00029 24.08.11 rab1kor - requirements for GSTCS 442 are implemented 00030 00031 00032 00033 ------------------------------------------------------------------------------ 00034 *****************************************************************************/ 00035 pragma runLim,0 00036 00037 00038 /* ***************************** 00039 include files with different functionalities 00040 **************************************/ 00041 00042 #include <utils/attrutil.inc> 00043 #include <utils/ole.inc> // all word properties are stored in this 00044 #include <utils/fileops.dxl> // 00045 #include <utils/doctools/rtfattr.inc> 00046 #include <utils/doctools/itfutil.inc> 00047 00048 00049 checkPlatform "Microsoft Word" 00050 00051 /* ************************************** 00052 Regular expressions used in filter functions 00053 ***************************************/ 00054 /*Regexp REcolumnFilter = regexp "Column '(.*)' contains \"(.*)\"(.*)" 00055 Regexp REcontainsFilter = regexp "(.*) (CONTAINS|Contains) '(.*)' *(.*)" 00056 Regexp REcontentsFilter = regexp "(CONTAINS|Contains) '(.*)'(.*)" 00057 Regexp REmultiValueFilter = regexp "(.*) (excludes|includes) (.*)" 00058 Regexp REemptyFilter = regexp "(.*) is (not |)empty" 00059 Regexp REcompareFilter = regexp "(.*) (>=|>|<=|<|!=|==) (.*)" 00060 Regexp REcurrentObjectFilter = regexp "(Exclude|Include) Object (.*)" 00061 Regexp REleavesFilter = regexp "(|Non-)Leaves" 00062 Regexp RElinksFilter = regexp "Has (no |)(in-|out-|in or out )links through (.*)"*/ 00063 00064 /*reg expression for bookmarling attribute defined in []*/ 00065 Regexp reg2 = regexp "\\[(.*)\\]" 00066 00067 Module m = null 00068 00069 string s_Bookmarking = null 00070 int SectionStructureLevel_i1 = null 00071 /* *************************************** 00072 All Dialogbox elements are declared 00073 ***************************************/ 00074 DB dbProjectReportGUI = null 00075 DBE dbeConfigFileList = null 00076 DBE dbeTemplateList = null 00077 00078 /* *************************************** 00079 All skiplist elements are declared 00080 ***************************************/ 00081 Skip wordStyleFonts = null 00082 Skip wordStyleNames = null 00083 Skip OpenModules_sk = create 00084 Skip BookMarking = createString 00085 Skip FunctionList = create 00086 00087 /* *************************************** 00088 All OLE objects are declared 00089 ***************************************/ 00090 OleAutoArgs autoArgs = create 00091 OleAutoObj objWord 00092 OleAutoObj objDocs = null 00093 OleAutoObj objDoc =null 00094 OleAutoObj objSel = null 00095 OleAutoObj objTables = null 00096 OleAutoObj Root_ole 00097 OleAutoObj xmldoc 00098 OleAutoArgs objArgBlock = null 00099 00100 OleAutoObj objExcel = null 00101 OleAutoObj objWorkbooks = null 00102 OleAutoObj objWorkbook = null 00103 OleAutoObj objSheet = null 00104 00105 00106 00107 /* *************************************** 00108 All variables of diff datatype are declared 00109 ***************************************/ 00110 00111 bool InitWord_b = false 00112 00113 bool doStyleMapping = false 00114 bool includeHeadingNumbers = false 00115 bool issueWarnings = true 00116 int ProcessTables_i[100] 00117 int noWordStyles = 0 00118 bool bMultipleHeader = false 00119 const int SECOND_PART = 2 00120 const int MAXROWNUMBER = 5000 00121 00122 const string XML_CONFIG_ATTRIBUTE = "PROJECT_REPORT" 00123 //GSTCS442 00124 bool b_FPresent = false 00125 int i_Count = 0 00126 int i_Count1 = 0 00127 bool keyMatches_b = false 00128 string BaselineEnabled_s 00129 00130 string TemplateFileName_s = "" 00131 string ConfigFileName_s =null 00132 Buffer errorLogBuffer = null 00133 string sStyleNormal 00134 string headingStyleNames[maxWordLevel] //GSTCS442 00135 string bodyStyleNames[maxWordLevel] //GSTCS442 00136 string s_Scriptpath ="" 00137 string s_Tablename =null 00138 string s_columnname 00139 string Target_s 00140 string BaselineEnabled 00141 string TableBookMarking_b =null 00142 int istart=0 00143 int iend =0 00144 int offset_i 00145 const int debug=1 00146 int SectionStructure_i[10] 00147 00148 int arrResultX = 0; 00149 int arrResultY = 0; 00150 int arrResultX_size = 0; 00151 int arrResultY_size = 0; 00152 00153 bool Baseline_b =false 00154 00155 /* *************************************** 00156 font table definition with different font styles 00157 ***************************************/ 00158 const string fontTableBeginning = "\\deff0{\\fonttbl" 00159 // fonts in this part of the font table will be used for anything 00160 // outside the Latin-1 character set 00161 const string fontTableEnd = 00162 "{\\f1\\fswiss\\fprq2\\fcharset0 Arial;} 00163 {\\f2\\froman\\fprq2\\fcharset2 Symbol;} 00164 {\\f3\\fswiss\\fprq2\\fcharset128 Arial Unicode MS;} 00165 {\\f4\\fswiss\\fprq2\\fcharset129 Arial Unicode MS;} 00166 {\\f5\\fswiss\\fprq2\\fcharset130 Arial Unicode MS;} 00167 {\\f6\\fswiss\\fprq2\\fcharset134 Arial Unicode MS;} 00168 {\\f7\\fswiss\\fprq2\\fcharset136 Arial Unicode MS;} 00169 {\\f8\\fswiss\\fcharset161 Arial;} 00170 {\\f9\\fswiss\\fcharset162 Arial;} 00171 {\\f10\\fswiss\\fcharset163 Arial;} 00172 {\\f11\\fswiss\\fcharset177 Arial;} 00173 {\\f12\\fswiss\\fcharset178 Arial;} 00174 {\\f13\\fswiss\\fcharset186 Arial;} 00175 {\\f14\\fswiss\\fcharset204 Arial;} 00176 {\\f15\\fswiss\\fprq2\\fcharset222 Arial Unicode MS;} 00177 {\\f16\\fswiss\\fcharset238 Arial;} 00178 }" 00179 /****************************************Macro functions************************/ 00180 /* ****************************************** 00181 Function: setRowBorder() 00182 *************************************************/ 00183 void setRowFontNormal () { 00184 clear objArgBlock 00185 put (objArgBlock, "MacroName", "setRowFontNormal") 00186 checkRes (oleMethod (objWord, "Run", objArgBlock)) 00187 } 00188 void setRowBorder() { 00189 clear objArgBlock 00190 put (objArgBlock, "MacroName", "setRowBorder") 00191 checkRes (oleMethod (objWord, "Run", objArgBlock)) 00192 } 00193 00194 void setRowFormatBoldGray () { 00195 clear objArgBlock 00196 put (objArgBlock, "MacroName", "setRowFormatBoldGray") 00197 checkRes (oleMethod (objWord, "Run", objArgBlock)) 00198 } 00199 00200 void setRowFontNormalNextRow () { 00201 clear objArgBlock 00202 put (objArgBlock, "MacroName", "setRowFontNormalNextRow") 00203 checkRes (oleMethod (objWord, "Run", objArgBlock)) 00204 } 00205 void setRowFormatNormal() { 00206 clear objArgBlock 00207 put (objArgBlock, "MacroName", "setRowFormatNormal") 00208 checkRes (oleMethod (objWord, "Run", objArgBlock)) 00209 } 00210 00211 int str2int(string s){ 00212 int r = 0 00213 int l = length(s) 00214 int c 00215 for (i = l - 1; i > -1; i--){ 00216 c = intOf(s[i]) 00217 if (c > 57 or c < 48) return -1 00218 r = r + (c - 48) * intOf((real 10.0) ^ realOf(l - i - 1)) 00219 } 00220 return r 00221 } // 00222 00223 00224 /* ****************************************Excel related functions************************* 00225 00226 ******************************************************************************************/ 00227 00228 00229 string new_col_group( string s1, string s2) 00230 { 00231 string strResult 00232 00233 if (s1 == "") 00234 { 00235 strResult = s2 00236 } 00237 else 00238 { 00239 strResult = s1 "\n" s2 00240 } 00241 00242 return strResult 00243 } // new_col_group 00244 00245 string ExcelAlphaCol(int col) 00246 { 00247 string strResult 00248 00249 if (col < 1) 00250 { 00251 strResult = "A" 00252 } 00253 else if ( col <= 26 ) 00254 { 00255 strResult = charOf( intOf( 'A' ) + col - 1)"" 00256 } 00257 else 00258 { 00259 strResult = ExcelAlphaCol(col/26) ExcelAlphaCol(col%26) 00260 } 00261 return strResult 00262 } // ExcelAlphaCol 00263 00264 00265 string ExcelAddress( int col, int row ) 00266 { 00267 string strResult 00268 00269 strResult = ExcelAlphaCol(col)"" row "" 00270 00271 return strResult 00272 } //ExcelAddress 00273 00274 00275 string ExcelRowAddress( int rowStart, int rowEnd ) { 00276 return "$" rowStart ":" "$" rowEnd "" 00277 } 00278 00279 string ExcelColAddress( int colStart, int colEnd ) { 00280 return "$" ExcelAlphaCol(colStart) ":" "$" ExcelAlphaCol(colEnd) "" 00281 } 00282 /* ************************************************************************** 00283 Function : ExcelAvailable() 00284 description: to check the availability of the excel file 00285 *********************************************************************************/ 00286 bool ExcelAvailable() 00287 { 00288 bool is_available = false 00289 00290 if ( null objExcel) 00291 { 00292 is_available = false 00293 } 00294 else 00295 { 00296 is_available = true 00297 } 00298 00299 return is_available 00300 } 00301 /* ************************************************************************** 00302 Function : ExcelSetVisible() 00303 description: to make the excel file visible only if it exists 00304 *********************************************************************************/ 00305 void ExcelSetVisible( bool bVisible ) 00306 { 00307 if (ExcelAvailable()) 00308 { 00309 olePut( objExcel, "Visible", bVisible ) 00310 } 00311 } // ExcelSetVisible 00312 00313 /* ************************************************************************** 00314 Function : ExcelInit() 00315 description: Initialize the excel application, get the workbook, worksheet and make it active 00316 *********************************************************************************/ 00317 void ExcelInit(bool bVisible) 00318 { 00319 00320 OleAutoArgs objArgBlock = create 00321 OleAutoObj objExcelCell = null 00322 00323 objExcel = oleCreateAutoObject( "Excel.Application" ) 00324 00325 if (null objExcel) { 00326 ack "Unable to communicate with Excel!\nIs it installed?" 00327 } 00328 else 00329 { 00330 ExcelSetVisible( bVisible) 00331 oleGet( objExcel, "Workbooks", objWorkbooks ) 00332 00333 if (null objWorkbooks) { 00334 ack "Unable to get workbooks !" 00335 } 00336 00337 00338 oleMethod( objWorkbooks, "Add" ) 00339 oleGet( objExcel, "ActiveWorkbook", objWorkbook ) 00340 if (null objWorkbook) { 00341 ack "Unable to get workbook !" 00342 } 00343 00344 00345 clear( objArgBlock ) 00346 put( objArgBlock, 1 ) // 1st sheet 00347 oleGet( objWorkbook, "Sheets", objArgBlock, objSheet) 00348 if (null objSheet) { 00349 ack "Unable to get sheet !" 00350 } 00351 oleMethod( objSheet, "Activate" ) 00352 00353 delete objArgBlock 00354 } 00355 } // ExcelInit 00356 00357 00358 OleAutoObj ExcelNewSheet(string sSheetName){ 00359 OleAutoArgs objArgBlock = create 00360 OleAutoObj objWorksheets 00361 oleGet(objWorkbook, "Sheets", objWorksheets) 00362 oleMethod(objWorksheets, "Add") 00363 clear objArgBlock 00364 put (objArgBlock, 1) 00365 oleGet( objWorkbook, "Sheets", objArgBlock, objSheet) 00366 olePut(objSheet, "Name", sSheetName) 00367 delete objArgBlock 00368 return objSheet 00369 } 00370 void ExcelColAutoFit(int colStart, int colEnd ) 00371 { 00372 OleAutoArgs objArgBlock = create 00373 OleAutoObj objExcelCell = null 00374 OleAutoObj objRange = null 00375 OleAutoObj objColumns = null 00376 00377 put( objArgBlock, ExcelColAddress(colStart, colEnd) ) 00378 oleGet( objSheet, "Range", objArgBlock, objRange ) 00379 oleGet( objRange, "Columns", objColumns ) 00380 olePut( objColumns, "AutoFit",true) 00381 } 00382 00383 void ExcelColShrinkToFit(int colStart, int colEnd ) 00384 { 00385 OleAutoArgs objArgBlock = create 00386 OleAutoObj objExcelCell = null 00387 OleAutoObj objRange = null 00388 OleAutoObj objColumns = null 00389 00390 put( objArgBlock, ExcelColAddress(colStart, colEnd) ) 00391 oleGet( objSheet, "Range", objArgBlock, objRange ) 00392 olePut( objRange, "ShrinkToFit",true ) 00393 } 00394 00395 00396 00397 void ExcelSelectCol(int colStart, int colEnd ) 00398 { 00399 OleAutoArgs objArgBlock = create 00400 OleAutoObj objExcelCell = null 00401 OleAutoObj objRange = null 00402 OleAutoObj objColumns = null 00403 00404 put( objArgBlock, ExcelColAddress(colStart, colEnd) ) 00405 oleGet( objSheet, "Range", objArgBlock, objRange ) 00406 oleGet( objRange, "Columns", objColumns ) 00407 //oleMethod( objRange, "Select" ) 00408 //olePut( objRange, "ShrinkToFit",true ) 00409 olePut( objColumns, "AutoFit",true) 00410 //Selection.Columns.AutoFit 00411 } 00412 00413 void ExcelPut( int col, int row, string content ) 00414 { 00415 OleAutoArgs objArgBlock = create 00416 OleAutoObj objExcelCell = null 00417 int l=length(content) 00418 00419 if (ExcelAvailable()) 00420 { 00421 clear( objArgBlock ) 00422 put( objArgBlock, ExcelAddress(col,row) ) 00423 oleGet( objSheet, "Range", objArgBlock, objExcelCell ) 00424 if (null objExcelCell) 00425 { 00426 ack "NULL cell ("col","row")" 00427 } 00428 else 00429 { 00430 //enclose string in " if value starts with =, - or a digit 00431 if ( null content) 00432 { 00433 // do nothing 00434 } 00435 else if (l < 20 && matches("^[=0-9.,e-]+$", content)) 00436 { 00437 olePut( objExcelCell, "value", "=\""content"\"" ) 00438 } 00439 else if (content[0] == '\'') 00440 { 00441 olePut( objExcelCell, "value", "'"content ) 00442 } 00443 else 00444 { 00445 olePut( objExcelCell, "value", content ) 00446 } 00447 } 00448 delete objArgBlock 00449 } 00450 } // ExcelPut 00451 00452 00453 /* ************************************************************************** 00454 Function : clearWordState() 00455 description: 00456 *********************************************************************************/ 00457 void wordMergeRowVBA(){ 00458 00459 OleAutoObj Cells_ole 00460 OleAutoObj Selection_ole 00461 00462 00463 oleMethod(objSel, "SelectRow") 00464 oleGet(objSel, "Cells", Cells_ole) 00465 oleMethod(Cells_ole, "Merge") 00466 } 00467 /* ************************************************************************** 00468 Function : clearWordState() 00469 description: 00470 *********************************************************************************/ 00471 void clearWordState() 00472 { 00473 exportEndProgress 00474 checkRes(olePut(objWord,cPropertyScreenUpdating,true)) 00475 halt 00476 } 00477 /* ************************************************************************** 00478 Function : logError() 00479 description: error logging is captured 00480 *********************************************************************************/ 00481 void logError(string errDescription, string errMessage, Object o) 00482 { 00483 errorLogBuffer += errDescription 00484 errorLogBuffer += " failed with error message: '" 00485 errorLogBuffer += errMessage 00486 errorLogBuffer += "' for object " 00487 errorLogBuffer += (identifier o) 00488 errorLogBuffer += "\n\n" 00489 } 00490 /* ************************************************************************** 00491 Function : vbaCheckRes() 00492 description: verification method used for OLE methods 00493 *********************************************************************************/ 00494 void vbaCheckRes(string res) 00495 { 00496 if (res != "") 00497 { 00498 00499 ack "OLE method failed: " res 00500 clearWordState 00501 } 00502 } 00503 00504 /* ************************************************************************** 00505 Function : collapseSelection() 00506 description: 00507 *********************************************************************************/ 00508 void collapseSelection() 00509 { 00510 clear objArgBlock 00511 put(objArgBlock, cParamDirection, wdCollapseEnd) 00512 vbaCheckRes(oleMethod(objSel, cMethodCollapse, objArgBlock)) 00513 } 00514 /* ************************************************************************** 00515 Function : collapseSelectionBackwards() 00516 description: 00517 *********************************************************************************/ 00518 void collapseSelectionBackwards() 00519 { 00520 clear objArgBlock 00521 put(objArgBlock, cParamDirection, wdCollapseStart) 00522 vbaCheckRes(oleMethod(objSel, cMethodCollapse, objArgBlock)) 00523 } 00524 00525 /* ************************************************************************** 00526 Function : vbaGetStyleName() 00527 description: takes style number as input, resolves the styles, style, style name and returns the same 00528 *********************************************************************************/ 00529 string vbaGetStyleName(OleAutoObj objDoc, int styleNumber) 00530 { 00531 OleAutoObj objStyles = null 00532 OleAutoObj objStyle = null 00533 string styleName = null 00534 00535 vbaCheckRes(oleGet(objDoc, cPropertyStyles, objStyles)) // styles is a collection of all style 00536 00537 if (null objStyles) 00538 { 00539 ack "Unable to get handle on styles collection" 00540 clearWordState 00541 } 00542 00543 clear objArgBlock 00544 put(objArgBlock, styleNumber) 00545 00546 vbaCheckRes(oleMethod(objStyles, cMethodItem, objArgBlock, objStyle)) // fetch the style number 00547 00548 if (null objStyle) 00549 { 00550 ack "Unable to get handle on style" 00551 clearWordState 00552 } 00553 00554 vbaCheckRes(oleGet(objStyle, cPropertyNameLocal, styleName))// fetch the style name 00555 00556 if (null styleName) 00557 { 00558 ack "Unable to get style name" 00559 clearWordState 00560 } 00561 00562 closeIfNonNull objStyle 00563 closeIfNonNull objStyles 00564 00565 return styleName 00566 } 00567 00568 00569 /* ************************************************************************** 00570 Function : wordCheckVersion () 00571 description: get the word document's version, either by takingthe existing word, or by creating a new one 00572 *********************************************************************************/ 00573 string wordCheckVersion() 00574 { 00575 objArgBlock = create 00576 00577 if (null objArgBlock) 00578 { 00579 ack "Unable to create argument block. Low memory?" 00580 return "" 00581 } 00582 // Get Word object 00583 objWord = oleGetAutoObject(cObjWordApplication) // get the word application 00584 00585 if (null objWord) 00586 { 00587 objWord = oleCreateAutoObject(cObjWordApplication) // else create a new word object 00588 } 00589 00590 string versionString 00591 vbaCheckRes(oleGet(objWord,cPropertyVersion, versionString)) //version of the word document 00592 return versionString 00593 00594 } 00595 00596 /* ************************************************************************** 00597 Function : wordPreChecksVBA () 00598 description: to make the word document visible, active and set the control 00599 *********************************************************************************/ 00600 bool wordPreChecksVBA() 00601 { 00602 Object curro = current Object 00603 m = current Module 00604 00605 // Make Word visible 00606 if (!doStyleMapping) 00607 { 00608 makeVisible objWord 00609 } 00610 00611 // Get documents collection 00612 checkRes(oleGet(objWord,cPropertyDocuments,objDocs)) //get the document 00613 00614 if (null objDocs) 00615 { 00616 ack "Unable to get Documents collection" 00617 return false 00618 } 00619 00620 clear objArgBlock 00621 put(objArgBlock,TemplateFileName_s) 00622 checkRes(oleMethod(objDocs,cMethodAdd,objArgBlock)) 00623 00624 // Get a handle on the document 00625 checkRes(oleGet(objWord,cPropertyActiveDocument,objDoc)) //activate the document 00626 if (null objDoc) 00627 { 00628 ack "Unable to get active document" 00629 halt 00630 } 00631 00632 // Get a handle on the selection object 00633 checkRes(oleGet(objWord,cPropertySelection,objSel)) //select the object in the document 00634 00635 if (null objSel) 00636 { 00637 ack "Unable to get selection object" 00638 halt 00639 } 00640 // Get a handle on the tables collection 00641 checkRes(oleGet(objDoc,cPropertyTables,objTables)) //defines the set of all tables defined in the document 00642 00643 if (null objTables) 00644 { 00645 ack "Unable to get tables collection" 00646 halt 00647 } 00648 00649 return true 00650 } 00651 /* ************************************************************************** 00652 Function : getWordStyleNames () 00653 description: to get the Fontname, style name etc 00654 *********************************************************************************/ 00655 void getWordStyleNames(OleAutoObj objDoc) 00656 { 00657 OleAutoObj objStyles = null 00658 OleAutoObj objStyle = null 00659 OleAutoObj objFont = null 00660 OleAutoObj objParaFormat = null 00661 OleAutoObj objListTemplate = null 00662 00663 string styleName = null 00664 string fontName = null 00665 00666 int styleType = 0 00667 int leftIndent = 0 00668 int count, stylesToCheck 00669 00670 wordStyleNames = create 00671 wordStyleFonts = create 00672 00673 vbaCheckRes(oleGet(objDoc, cPropertyStyles, objStyles)) 00674 00675 if (null objStyles) 00676 { 00677 ack "Unable to get handle on styles collection" 00678 clearWordState 00679 } 00680 00681 vbaCheckRes(oleGet(objStyles, cPropertyCount, stylesToCheck)) 00682 00683 for (count = 1; count <= stylesToCheck; count++) 00684 { 00685 clear objArgBlock 00686 put(objArgBlock, count) 00687 00688 vbaCheckRes(oleMethod(objStyles, cMethodItem, objArgBlock, objStyle)) 00689 00690 if (null objStyle) 00691 { 00692 ack "Unable to get handle on style" 00693 clearWordState 00694 } 00695 00696 // Don't use character styles 00697 vbaCheckRes(oleGet(objStyle, cPropertyType, styleType)) 00698 00699 if (styleType != wdStyleTypeParagraph) 00700 { 00701 closeIfNonNull objStyle 00702 continue 00703 } 00704 00705 styleName = "" 00706 fontName = "" 00707 leftIndent = 0 00708 00709 vbaCheckRes(oleGet(objStyle, cPropertyNameLocal, styleName)) 00710 00711 if (null styleName) 00712 { 00713 ack "Unable to get style name" 00714 clearWordState 00715 } 00716 put(wordStyleNames,noWordStyles,styleName) 00717 00718 oleGet(objStyle, cPropertyListTemplate, objListTemplate) 00719 00720 oleGet(objStyle, cPropertyParagraphFormat, objParaFormat) 00721 closeIfNonNull objParaFormat 00722 00723 // get font name so we can set the correct default font 00724 vbaCheckRes(oleGet(objStyle, cPropertyFont, objFont)) 00725 00726 if (null objFont) 00727 { 00728 ack "Unable to get handle on font" 00729 clearWordState 00730 } 00731 00732 vbaCheckRes(oleGet(objFont, cPropertyName, fontName)) 00733 00734 if (null fontName) 00735 { 00736 ack "Unable to get font name" 00737 clearWordState 00738 } 00739 00740 closeIfNonNull objFont 00741 closeIfNonNull objStyle 00742 00743 put(wordStyleFonts,styleName,fontName) 00744 00745 noWordStyles++ 00746 } 00747 00748 closeIfNonNull objStyles 00749 00750 string tempWordStyles[noWordStyles] 00751 00752 for (count = 0; count < noWordStyles; count++) 00753 { 00754 find(wordStyleNames, count, tempWordStyles[count]) 00755 } 00756 00757 sort tempWordStyles 00758 delete wordStyleNames 00759 wordStyleNames = create 00760 00761 for (count = 0; count < noWordStyles; count++) 00762 { 00763 put(wordStyleNames, count, tempWordStyles[count]) 00764 } 00765 } 00766 00767 /* ************************************************************************** 00768 Function : fillStyleNameArrays () 00769 description: headingstyle and bodystyle are set in string of arrays 00770 *********************************************************************************/ 00771 void fillStyleNameArrays() 00772 { 00773 int count 00774 string styleName 00775 00776 for (count = 0; count < maxWordLevel; count++) 00777 { 00778 styleName = vbaGetStyleName(objDoc,wordHeadingStyles[count]) 00779 headingStyleNames[count] = styleName 00780 } 00781 00782 styleName = vbaGetStyleName(objDoc,wdStyleNormal) 00783 00784 for (count = 0; count < maxWordLevel; count++) 00785 { 00786 bodyStyleNames[count] = styleName 00787 } 00788 } 00789 /*************************Bookmark Update for the header through macro*****************/ 00790 void HeaderBookmark (string bm) 00791 { 00792 00793 clear objArgBlock 00794 put (objArgBlock, "MacroName", "SetHeaderBaseline") 00795 put (objArgBlock, "varg1", bm) 00796 checkRes (oleMethod (objWord, "Run", objArgBlock)) 00797 00798 } 00799 00800 /* ************************************************************************** 00801 Function : InitWord () 00802 description: initialize the word document 00803 *********************************************************************************/ 00804 void InitWord() 00805 { 00806 string sBaselinever =null 00807 string wordVersion = wordCheckVersion () 00808 00809 if (wordVersion =="") 00810 { 00811 return 00812 } 00813 wordPreChecksVBA () 00814 fillStyleNameArrays() 00815 getWordStyleNames objDoc 00816 sStyleNormal = vbaGetStyleName(objDoc, wdStyleNormal) 00817 00818 if(Baseline_b==true) 00819 { 00820 Module mod =current 00821 Baseline b = getMostRecentBaseline(mod) 00822 sBaselinever = (major b)"."(minor b)(suffix b) 00823 //bool baselineExists(mod,b) 00824 if(baselineExists(mod,b)) 00825 { 00826 HeaderBookmark(sBaselinever) 00827 } 00828 else 00829 { 00830 ack("Selected module is not baselined hence baseline version is not updated \n") 00831 continue 00832 } 00833 00834 00835 00836 00837 } 00838 } 00839 /* ************************************************************************** 00840 Function : UpdateTOC () 00841 description: To update the table of contents. 00842 *********************************************************************************/ 00843 void UpdateTOC(){ 00844 00845 OleAutoObj Fields_ole 00846 OleAutoArgs autoArgs = create 00847 int i 00848 00849 oleGet(objDoc, "Fields", Fields_ole) 00850 oleMethod(Fields_ole, "Update", autoArgs, i) 00851 } 00852 00853 00854 /* ************************************************************************** 00855 Function : makeFontTableFromStyle () 00856 description: get the font name from font skiplist using stylename as key and generate a font table 00857 *********************************************************************************/ 00858 00859 string makeFontTableFromStyle(string styleName) 00860 { 00861 // build a font table with the appropriate default font for the style 00862 string fontName = "" 00863 string defaultFontEntry 00864 string fontTable 00865 00866 find(wordStyleFonts, styleName, fontName) 00867 00868 defaultFontEntry = "{\\f0\\fnil " fontName ";}" 00869 fontTable = fontTableBeginning defaultFontEntry fontTableEnd 00870 00871 return fontTable 00872 } 00873 00874 /* ************************************************************************** 00875 Function : pasteAndApplyStyle () 00876 description: pasting of the data (richtext) from doors to word 00877 *********************************************************************************/ 00878 string pasteAndApplyStyle(OleAutoObj objSelection, RTF_string__ s, string styleName) 00879 { 00880 //styleName = vbaGetStyleName(objDoc,wdStyleNormal) 00881 string fontTable = makeFontTableFromStyle(styleName) 00882 setRichClip(s, styleName,fontTable ) 00883 return oleMethod(objSelection, cMethodPaste) 00884 00885 } 00886 00887 /* ************************************************************************** 00888 Function : pasteAndApplyStyle () 00889 description: pasting of the data (buffer) from doors to word 00890 *********************************************************************************/ 00891 string pasteAndApplyStyle(OleAutoObj objSelection, Buffer b, string styleName) 00892 { 00893 //styleName = vbaGetStyleName(objDoc,wdStyleNormal) 00894 string fontTable = makeFontTableFromStyle(styleName) 00895 setRichClip(b, styleName,fontTable) 00896 return oleMethod(objSelection, cMethodPaste) 00897 } 00898 /* ************************************************************************** 00899 Function : endKey () 00900 description: table of contents will be stored in the begining 00901 without this it will be at the end of the document 00902 *********************************************************************************/ 00903 void endKey() 00904 { 00905 // move past the object 00906 clear objArgBlock 00907 put(objArgBlock, wdStory) 00908 vbaCheckRes(oleMethod(objSel,cMethodEndKey,objArgBlock)) 00909 } 00910 00911 /* ************************************************************************** 00912 Function : MakeSection () 00913 description: make different sections in the document (like headlines, text etc) 00914 *********************************************************************************/ 00915 void MakeSection(string Headline_s, string Text_s, string SectionStructure_s, int SectionStructureLevel_i){ 00916 /* local declaration */ 00917 string TitleText_s = "" 00918 OleAutoObj TableOfContents_ole 00919 OleAutoObj Range_ole 00920 OleAutoArgs autoArgs = create 00921 int SelStart_i = 0 00922 int SelEnd_i = 0 00923 string styleName = vbaGetStyleName(objDoc,wdStyleNormal) 00924 oleGet(objDoc, "TablesOfContents", TableOfContents_ole) 00925 00926 /* make Section Headline */ 00927 if (Headline_s != ""){ 00928 //TitleText_s = Headline_s 00929 TitleText_s = SectionStructure_s " " Headline_s 00930 //pasteAndApplyStyle(objSel, richText TitleText_s, styleName) 00931 print ".. "TitleText_s"....\n" 00932 pasteAndApplyStyle(objSel, richText TitleText_s,headingStyleNames[SectionStructureLevel_i]) //the section level is defined with this. the HeadingStyleNames[maxword] has all levels defined. 00933 } 00934 oleMethod(objSel, "TypeParagraph") 00935 oleGet(objSel, "Range", Range_ole) 00936 clear autoArgs 00937 put (autoArgs, "Range", Range_ole) 00938 // put (autoArgs, "Level", SectionStructureLevel_i + 1) 00939 put (autoArgs, "Level", SectionStructureLevel_i+1) 00940 put (autoArgs, "Entry", TitleText_s) 00941 oleMethod(TableOfContents_ole, "MarkEntry", autoArgs) 00942 endKey() 00943 if (Text_s != ""){ 00944 pasteAndApplyStyle(objSel, richText Text_s, bodyStyleNames[0]) 00945 oleMethod(objSel, "TypeParagraph") 00946 } 00947 00948 } 00949 00950 /* ************************************************************************** 00951 Complete section for filtering processing 00952 * **************************************************************************/ 00953 00954 //the rest of the stuff will be as in the following constants 00955 Array FilterArray 00956 const int OPERATOR = 0 00957 const int LEVEL = 1 00958 const int PARENT = 2 00959 const int FILTER = 3 00960 const int STRING = 4 00961 const int SIMPLE = 5 00962 00963 //constants for compound filters 00964 const int NONE = 0 00965 const int NOTop = 1 00966 const int ANDop = 2 00967 const int ORop = 3 00968 string Ops[]={"NONE", "NOT", "AND", "OR"} 00969 00970 //general globals 00971 int DeepestLevel 00972 int FilterCount 00973 string WholeThing 00974 00975 //This stuff is for tokenizing/ detokenizing 00976 Regexp DodgyChars = regexp "(\"|\\(|\\)|\\[|\\]|\\.|\\^|\\||\\$|\\+|\\*|\\\\)" 00977 Skip TokenSkip 00978 int NumberOfTokens 00979 bool ProcessTokens 00980 00981 string appName ="VBScript.RegExp" 00982 OleAutoObj RegExpObj = oleCreateAutoObject(appName) 00983 if (null (RegExpObj)) error "Cannot connect to OLE Application >"appName"<!" 00984 00985 OleAutoObj MatchesColl 00986 OleAutoObj MatchObj 00987 OleAutoObj SubMatchesColl 00988 OleAutoArgs args = create 00989 Regexp Escapes = regexp "(\"|\\(|\\)|\\[|\\]|\\.|\\^|\\||\\$|\\+|\\*|\\\\|?)" 00990 00991 void addEscapesForRegexp(string &txt) { 00992 if ( txt == "" ) return 00993 00994 Buffer b = create 00995 int i = 0 00996 00997 while ( Escapes txt[i:] ) { 00998 b += txt[i:i+start(0)-1] 00999 if( txt[i+start(0):i+end(0)] =="\\\\") b += "\\\\\\\\" 01000 elseif ( txt[i+start(0):i+end(0)] == txt[i:][match 0] ) b += "\\" txt[i+start(0):i+end(0)] 01001 else b += txt[i+start(0):i+end(0)] 01002 i += (end 0)+1 01003 } 01004 b += txt[i:] 01005 txt = stringOf b 01006 delete(b) 01007 } 01008 01009 string VBReplace(string inStr, FindStr, RepStr, bool IgnoreCase) { 01010 string Str="" 01011 clear args 01012 addEscapesForRegexp(FindStr) 01013 olePut(RegExpObj,"Pattern",FindStr) 01014 olePut(RegExpObj,"IgnoreCase",IgnoreCase) 01015 put(args, inStr) 01016 put(args, RepStr) 01017 oleMethod(RegExpObj,"Replace",args,Str) 01018 return Str 01019 } 01020 01021 void ReturnSubMatches( Skip PassedSkip, string inStr, FindPattern, int SubMatchNum, bool IgnoreCase) { 01022 string SubMatch 01023 clear args 01024 olePut(RegExpObj,"IgnoreCase",IgnoreCase) 01025 olePut(RegExpObj,"Global",true) 01026 int NumOfMatches=0,i,j=0 01027 01028 olePut(RegExpObj,"Pattern",FindPattern) 01029 put(args, inStr) 01030 oleMethod(RegExpObj,"Execute",args,MatchesColl) 01031 oleGet(MatchesColl,"Count",NumOfMatches) 01032 01033 if(NumOfMatches==0) return 01034 01035 for(i=0;i<NumOfMatches;i++) { 01036 clear args; put(args,i) 01037 oleGet(MatchesColl,"Item",args,MatchObj) 01038 01039 oleGet(MatchObj,"SubMatches",SubMatchesColl) 01040 clear args; put(args,SubMatchNum) 01041 oleGet(SubMatchesColl,"Item",args,SubMatch) 01042 01043 if(!null SubMatch) { 01044 if(!find(PassedSkip,SubMatch)) { 01045 put(PassedSkip,SubMatch,SubMatch) 01046 } 01047 } 01048 } 01049 MatchesColl =null 01050 MatchObj =null 01051 SubMatchesColl=null 01052 } 01053 01054 string ReturnFirstSubMatch( string inStr, FindPattern, int SubMatchNum, bool IgnoreCase) { 01055 string SubMatch 01056 clear args 01057 olePut(RegExpObj,"IgnoreCase",IgnoreCase) 01058 olePut(RegExpObj,"Global",false) 01059 int NumOfMatches=0,i,j=0 01060 01061 olePut(RegExpObj,"Pattern",FindPattern) 01062 put(args, inStr) 01063 oleMethod(RegExpObj,"Execute",args,MatchesColl) 01064 oleGet(MatchesColl,"Count",NumOfMatches) 01065 if(NumOfMatches==0) return "" 01066 clear args; put(args,0) 01067 oleGet(MatchesColl,"Item",args,MatchObj) 01068 01069 oleGet(MatchObj,"SubMatches",SubMatchesColl) 01070 clear args; put(args,SubMatchNum) 01071 oleGet(SubMatchesColl,"Item",args,SubMatch) 01072 01073 if(null SubMatch) return "" 01074 01075 MatchesColl =null 01076 MatchObj =null 01077 SubMatchesColl=null 01078 return SubMatch 01079 } 01080 01081 string ReturnFirstMatch( string inStr, FindPattern, bool IgnoreCase) { 01082 string MatchStr 01083 clear args 01084 olePut(RegExpObj,"IgnoreCase",IgnoreCase) 01085 olePut(RegExpObj,"Global",false) 01086 int NumOfMatches=0,i,j=0 01087 01088 olePut(RegExpObj,"Pattern",FindPattern) 01089 put(args, inStr) 01090 oleMethod(RegExpObj,"Execute",args,MatchesColl) 01091 oleGet(MatchesColl,"Count",NumOfMatches) 01092 if(NumOfMatches==0) return "" 01093 01094 clear args; put(args,0) 01095 oleGet(MatchesColl,"Item",args,MatchObj) 01096 oleGet(MatchObj,"Value",MatchStr) 01097 if(null MatchStr) return "" 01098 01099 MatchesColl =null 01100 MatchObj =null 01101 return MatchStr 01102 } 01103 01104 01105 void ReturnMatches( Skip PassedSkip, string inStr, FindPattern, bool IgnoreCase) { 01106 string MatchStr 01107 clear args 01108 olePut(RegExpObj,"IgnoreCase",IgnoreCase) 01109 olePut(RegExpObj,"Global",true) 01110 int NumOfMatches=0,i,j=0 01111 01112 olePut(RegExpObj,"Pattern",FindPattern) 01113 put(args, inStr) 01114 oleMethod(RegExpObj,"Execute",args,MatchesColl) 01115 oleGet(MatchesColl,"Count",NumOfMatches) 01116 01117 if(NumOfMatches==0) return 01118 01119 for(i=0;i<NumOfMatches;i++) { 01120 clear args; put(args,i) 01121 oleGet(MatchesColl,"Item",args,MatchObj) 01122 01123 oleGet(MatchObj,"Value",MatchStr) 01124 if(!null MatchStr) { 01125 if(!find(PassedSkip,MatchStr)) { 01126 put(PassedSkip,MatchStr,MatchStr) 01127 } 01128 } 01129 } 01130 MatchesColl =null 01131 MatchObj =null 01132 } 01133 // regular Expressions needed to recognize "simple" Filters 01134 Regexp REcolumnFilter = regexp "Column '(.*)' contains \"(.*)\"(.*)" 01135 Regexp REcontainsFilter = regexp "(.*) (CONTAINS|Contains) '(.*)' (.*)" 01136 Regexp REcontentsFilter = regexp "(CONTAINS|Contains) '(.*)'(.*)" 01137 Regexp REmultiValueFilter = regexp "(.*) (excludes|includes) (.*)" 01138 Regexp REemptyFilter = regexp "(.*) is (not |)empty" 01139 Regexp REcompareFilter = regexp "(.*) (>=|>|<=|<|!=|==) (.*)" 01140 Regexp REcurrentObjectFilter = regexp "(Exclude|Include) Object (.*)" 01141 Regexp REleavesFilter = regexp "(|Non-)Leaves" 01142 Regexp RElinksFilter = regexp "Has (no |)(in-|out-|in or out )links through (.*)" 01143 bool FilterError 01144 01145 01146 void printFilterError (string input, string err){ 01147 ack "ERROR on parsing filter string '"input"' (please redo your filter): \n"err"\n" 01148 FilterError = true 01149 } 01150 01151 01152 void DeTokenizeString(string &inp) { 01153 string Tok, OrigStr 01154 for OrigStr in TokenSkip do { 01155 Tok = (string key TokenSkip) 01156 inp = VBReplace(inp, Tok, OrigStr,false) 01157 } 01158 } 01159 01160 01161 // function to parse a "simple" Filter, that means, which is not combined of other Filters 01162 Filter parseSimpleFilter (string input){ 01163 if(ProcessTokens) DeTokenizeString(input) 01164 01165 if (REcolumnFilter input){ // any type of "Column" filters 01166 string params = input[match 3] 01167 string colName = input[match 1] 01168 string val = input[match 2] 01169 if (null params) return column (colName, val, false, false) 01170 else if (params == " (with regexps and case sensitive)") return column (colName, val, true, true) 01171 else if (params == " (with regexps)") return column (colName, val, false, true) 01172 else if (params == " (case sensitive)") return column (colName, val, true, false) 01173 else{ 01174 printFilterError (input, "unrecognized parameter to Column Filter >>"params"<<\n"//- 01175 "possible values are : '(with regexps)', '(case sensitive)', '(with regexps and case sensitive)' or nothing") 01176 } 01177 } 01178 else if (REcontainsFilter input){ // any type of Attribute contains filter 01179 if (input[match 4] == "[with regexps]") return contains (attribute input[match 1], input[match 3]) 01180 else if (null input[match 4]) 01181 return contains (attribute input[match 1], input[match 3], input[match 2] == "Contains") 01182 else{ 01183 printFilterError (input, "unrecognized parameter to Contains Filter >>"input[match 4]"<<\n"//- 01184 "possible values are : '[with regexps]' or nothing") 01185 } 01186 } 01187 else if (REcontentsFilter input){ // any type of "Any Text Attribute" contains filter 01188 if (input[match 3] == " [with regexps]") return contents (input[match 2]) 01189 else if (null input[match 3]) return contents (input[match 2], input[match 1] == "Contains") 01190 else{ 01191 printFilterError (input, "unrecognized parameter to Contains in any Text Attribute Filter >>"input[match 3]"<<\n"//- 01192 "possible values are : '[with regexps]' or nothing") 01193 } 01194 } 01195 else if (REmultiValueFilter input){ // both types of filter for multivalued attributes 01196 if (input[match 2] == "excludes") 01197 return excludes (attribute input[match 1], input[match 3]) 01198 else return includes (attribute input[match 1], input[match 3]) 01199 } 01200 else if (REemptyFilter input){ // is Empty and is not Empty filters 01201 if (null input[match 2]) 01202 return isNull (attribute input[match 1]) 01203 else return notNull (attribute input[match 1]) 01204 } 01205 else if (REcompareFilter input){ // any type of comarison filters 01206 string cmd = input[match 2] 01207 string thisAtt = input[match 1] 01208 if (thisAtt == "Object Number" or exists attribute thisAtt) { 01209 if (cmd == ">=") return (attribute input[match 1] >= input[match 3]) 01210 else if (cmd == ">") return (attribute input[match 1] > input[match 3]) 01211 else if (cmd == "<=") return (attribute input[match 1] <= input[match 3]) 01212 else if (cmd == "<") return (attribute input[match 1] < input[match 3]) 01213 else if (cmd == "!=") return (attribute input[match 1] != input[match 3]) 01214 else if (cmd == "==") return (attribute input[match 1] == input[match 3]) 01215 } 01216 else { 01217 printFilterError (input, "Attribute '" thisAtt "' does not exist") 01218 } 01219 } 01220 else if (REcurrentObjectFilter input){ // filter that includes/excludes current Object respectively any Object 01221 Object ThisObj =object (intOf (input[match 2])) 01222 if (null ThisObj) { 01223 printFilterError (input, "Object " input[match 2] " no longer exists.") 01224 } 01225 current = ThisObj 01226 if (input[match 1] == "Exclude") return excludeCurrent 01227 else return includeCurrent 01228 } 01229 else if (REleavesFilter input){ // filter to show only leaves 01230 if (null input[match 1]) return includeLeaves 01231 else return excludeLeaves 01232 } 01233 else if (RElinksFilter input){ // any Link related filters 01234 LinkFilter lf 01235 if (input[match 2] == "in-") lf = linkFilterIncoming 01236 else if(input[match 2] == "out-") lf = linkFilterOutgoing 01237 else lf = linkFilterBoth 01238 if (null input[match 1]) return hasLinks (lf, input[match 3]) 01239 else return hasNoLinks (lf, input[match 3]) 01240 } 01241 else printFilterError (input, "unrecognized Filter string") 01242 return null 01243 } 01244 01245 01246 Filter ProcessFilterParts() { 01247 int i,j,k, temp 01248 string str, FiltString 01249 bool b 01250 int ParentArray[FilterCount] 01251 // Stream out = write "C:\\Temp\\Debug.tsv" 01252 // out << "String\tOperator\tParent\tID\tSimple\tLevel\n" 01253 for(i=0;i<FilterCount;i++) { 01254 // str = (string get(FilterArray,i,STRING)) // cast get as string 01255 // out << str "\t" 01256 // temp = (int get(FilterArray,i,OPERATOR)) 01257 // out << Ops[temp] "\t" 01258 temp = (int get(FilterArray,i,PARENT)) 01259 ParentArray[i]=temp 01260 // out << temp "\t" i "\t" 01261 // b = (bool get(FilterArray,i,SIMPLE)) 01262 // out << b "\t" 01263 // temp =(int get(FilterArray,i,LEVEL)) 01264 // out << temp "\n" 01265 } 01266 // close out 01267 01268 int ThisLev, ThisOp, ThisPar, ParOp 01269 bool IsItSimple 01270 Filter ThisFilt 01271 01272 //check for simplest case 01273 IsItSimple = (bool get(FilterArray,0,SIMPLE)) 01274 if (IsItSimple) return parseSimpleFilter(WholeThing) 01275 01276 //make all the simple filters on the first pass 01277 for(i=DeepestLevel;i>0;i--) { 01278 for(j=0;j<FilterCount;j++) { 01279 ThisLev = (int get(FilterArray,j,LEVEL)) 01280 if(ThisLev ==i) { 01281 IsItSimple = (bool get(FilterArray,j,SIMPLE)) 01282 //look for simple filters and make them 01283 if(IsItSimple) { 01284 FiltString =(string get(FilterArray,j,STRING)) 01285 ThisFilt =parseSimpleFilter(FiltString) 01286 put(FilterArray, ThisFilt, ParentArray[j], FILTER) 01287 } 01288 } 01289 } 01290 } 01291 01292 01293 //combine the simple filters on the second pass 01294 Filter FirstPart, SecondPart 01295 for(k=DeepestLevel;k>0;k--) { 01296 for(i=0;i<FilterCount;i++) { 01297 ThisLev = (int get(FilterArray,i,LEVEL)) 01298 if(ThisLev ==k) { 01299 ThisOp = (int get(FilterArray,i,OPERATOR)) 01300 //look for AND find object with same parent and combine 01301 //object with same parent will always be below object with operator 01302 j=i+1 01303 FirstPart=(Filter get(FilterArray,i,FILTER)) 01304 //cope with meaningless brackets by looking for a filter at the next level down 01305 //the following is a semi frig 01306 if(null FirstPart and ThisOp>0) { 01307 FirstPart =(Filter get(FilterArray,i+1,FILTER)) 01308 int TempLev= (int get(FilterArray,i+1,LEVEL)) 01309 if((null FirstPart) or (TempLev-1!=ThisLev)) { 01310 ack "null filter passed can't recover" 01311 halt 01312 } 01313 } 01314 if(ThisOp == ANDop or ThisOp == ORop) { 01315 while(j<FilterCount) { 01316 if(ParentArray[i]==ParentArray[j]) { 01317 SecondPart =(Filter get(FilterArray,j,FILTER)) 01318 break 01319 } 01320 j++ 01321 } 01322 //cope with meaningless brackets by looking for a filter at the next level down 01323 //the following is a semi frig 01324 if(null SecondPart) { 01325 SecondPart =(Filter get(FilterArray,j+1,FILTER)) 01326 int TempLev= (int get(FilterArray,j+1,LEVEL)) 01327 if((null SecondPart) or (TempLev-1!=ThisLev)) { 01328 ack "null filter passed can't recover" 01329 halt 01330 } 01331 } 01332 01333 if(ThisOp == ANDop) ThisFilt = FirstPart && SecondPart 01334 else ThisFilt = FirstPart || SecondPart 01335 if(ParentArray[i]==-1) put(FilterArray, ThisFilt, 0, FILTER) 01336 else put(FilterArray, ThisFilt, ParentArray[i], FILTER) 01337 01338 } 01339 elseif(ThisOp == NOTop) { 01340 ThisFilt = ! FirstPart 01341 if(ParentArray[i]==-1) put(FilterArray, ThisFilt, 0, FILTER) 01342 else put(FilterArray, ThisFilt, ParentArray[i], FILTER) 01343 01344 } 01345 elseif(ThisOp == NONE) { 01346 //do nothing except for the mental case of two sets of meaningless brackets 01347 // if(ParentArray[i]!=-1) { 01348 // ParOp =(int get(FilterArray,ParentArray[i],OPERATOR)) 01349 // if(ParOp == NONE) put(FilterArray, ThisFilt, ParentArray[i], FILTER) 01350 // } 01351 } 01352 else { 01353 ack "error in operator part" 01354 halt 01355 } 01356 01357 } 01358 } 01359 } 01360 //Final filter will or should! rise to the top element 01361 ThisFilt =(Filter get(FilterArray,0,FILTER)) 01362 return ThisFilt 01363 } 01364 01365 01366 //attributes and enumerations can have brackets in which buggers things up totally 01367 void TokenizeString(string &input) { 01368 string Str = input 01369 bool Changed, dummy=false 01370 AttrDef ad 01371 AttrType at 01372 AttrBaseType abt 01373 int j,i 01374 string s, ThisToken, AtName 01375 char c 01376 01377 for ad in current Module do { 01378 at = ad.type 01379 abt = at.type 01380 if(ad.system) continue 01381 01382 //process attribute names (they can have brackets) 01383 AtName= ad.name 01384 if (DodgyChars AtName) { 01385 Changed=false 01386 ThisToken = "FCU" NumberOfTokens "K" 01387 NumberOfTokens++ 01388 //need to do a simple replace but DOORS is shit at regexps it just won't work 01389 //hence call a vbs script what an ass! 01390 input = VBReplace(input, AtName, ThisToken, false) 01391 01392 //add to skip with token key 01393 if (Str!=input) { 01394 ProcessTokens=true 01395 put(TokenSkip,ThisToken, AtName) 01396 } 01397 } 01398 01399 if (abt == attrEnumeration) { 01400 //process attribute enumerations (the main culprits) 01401 for (j=0; j<(at.size); j++){ 01402 s=at.strings[j] 01403 if (DodgyChars s) { 01404 Changed=false 01405 ThisToken = "FCU" NumberOfTokens "K" 01406 NumberOfTokens++ 01407 //need to do a simple replace but DOORS can't do regexps with escape chars in the middle 01408 //it just won't work, hence call a vb script: what an ass! 01409 input = VBReplace(input, s, ThisToken, false) 01410 01411 //add to skip with token key 01412 if (Str!=input) { 01413 ProcessTokens=true 01414 put(TokenSkip,ThisToken, s) 01415 } 01416 } 01417 } 01418 } 01419 } 01420 } 01421 01422 void ProcessFilter (string b, int Thelevel, int Parent){ 01423 int bCount = 0, i=0 01424 bool isInString = false 01425 Filter leftFilter = null 01426 int stopAt = length b 01427 bool NoBrackets=true 01428 int StartAt 01429 01430 while (i < stopAt){ 01431 if (b[i] == '\'' && (i == 0 || b[i-1] != '\\')) isInString = !isInString 01432 if (isInString == false){ 01433 if (b[i] == '('){ // found brackets 01434 StartAt =i 01435 NoBrackets=false 01436 bCount++ 01437 i = i+1 01438 01439 while (bCount>0 && i < stopAt){ 01440 if (b[i] == '\'' && (i == 0 || b[i-1] != '\\')) isInString = !isInString 01441 if (!isInString){ 01442 if (b[i] == '(') bCount++ 01443 if (b[i] == ')') bCount-- 01444 } 01445 i++ 01446 } 01447 //add the string to the array 01448 put(FilterArray, Thelevel, FilterCount, LEVEL) 01449 put(FilterArray, b[StartAt+1:i-2], FilterCount, STRING) 01450 put(FilterArray, false, FilterCount, SIMPLE) 01451 put(FilterArray, Parent, FilterCount, PARENT) 01452 put(FilterArray, null, FilterCount, FILTER) 01453 01454 //look for NOT this is only relevant at the start of the string 01455 if (b[0:2] == "NOT") { 01456 put(FilterArray, NOTop, FilterCount, OPERATOR) 01457 } 01458 //look for an AND/OR after the brackets 01459 elseif (i < stopAt-2 && (b[i:i+2]== "AND" or b[i+1:i+3] == "AND")){ 01460 put(FilterArray, ANDop, FilterCount, OPERATOR) 01461 } 01462 elseif (i < stopAt-2 && (b[i:i+1] == "OR" or b[i+1:i+2] == "OR")){ // priority 4 01463 put(FilterArray, ORop, FilterCount, OPERATOR) 01464 } 01465 else { 01466 put(FilterArray, NONE, FilterCount, OPERATOR) 01467 } 01468 FilterCount++ 01469 01470 //recurse to next level 01471 ProcessFilter(b[StartAt+1:i-2],Thelevel+1, FilterCount-1) 01472 } 01473 else i++ 01474 } 01475 else i++ 01476 } 01477 01478 if (NoBrackets){ 01479 //Simple filter 01480 put(FilterArray, NONE, FilterCount, OPERATOR) 01481 put(FilterArray, b, FilterCount, STRING) 01482 put(FilterArray, Thelevel, FilterCount, LEVEL) 01483 put(FilterArray, Parent, FilterCount, PARENT) 01484 put(FilterArray, true, FilterCount, SIMPLE) 01485 put(FilterArray, null, FilterCount, FILTER) 01486 FilterCount++ 01487 } 01488 if(Thelevel>DeepestLevel) DeepestLevel = Thelevel 01489 } 01490 01491 Filter parseFilter (string input){ 01492 FilterCount=0 01493 DeepestLevel=0 01494 FilterArray = create(1,1) 01495 WholeThing = input 01496 TokenSkip = createString 01497 NumberOfTokens=0 01498 ProcessTokens=false 01499 TokenizeString(input) 01500 //print input 01501 ProcessFilter (input, 1, -1) 01502 Filter F = ProcessFilterParts 01503 delete TokenSkip 01504 delete FilterArray 01505 return F 01506 } 01507 01508 // END INCLUDE 01509 01510 /* ************************************************************************** 01511 end of section for filtering processing 01512 * **************************************************************************/ 01513 /* ************************************************************************** 01514 Function: CheckModuleOpen () 01515 Description: to verify the module selected is opened or not 01516 * **************************************************************************/ 01517 bool CheckModuleOpen(string ModuleName_s) 01518 { 01519 ModName_ ModuleName_mn = module(ModuleName_s) 01520 if (open module ModuleName_s){ 01521 m = data(moduleVersion(ModuleName_mn)) 01522 current = m 01523 /*print "Module " ModuleName_s " is already open.\n"*/ 01524 return true 01525 } 01526 else{ 01527 m = read(ModuleName_s, false) 01528 put(OpenModules_sk, ModuleName_s, m) 01529 if (null m){ 01530 return false 01531 } 01532 else{ 01533 current = m 01534 return true 01535 } 01536 } 01537 } 01538 01539 /* ************************************************************************** 01540 Function: getRange () 01541 Description: portion of a document that's contained in the specified object 01542 * **************************************************************************/ 01543 OleAutoObj getRange(OleAutoObj obj) 01544 { 01545 OleAutoObj objRange = null 01546 vbaCheckRes(oleGet(obj,cPropertyRange,objRange))//Range object that represents the portion of a document that's contained in the specified object 01547 01548 if (null objRange) 01549 { 01550 ack "Unable to get range object" 01551 clearWordState 01552 } 01553 01554 return objRange 01555 } 01556 /* ************************************************************************** 01557 Function: wordMakeSizedTableVBA () 01558 Description: create table with no.of rows and columns 01559 * **************************************************************************/ 01560 OleAutoObj wordMakeSizedTableVBA(int noRows, int noCols,string TableBookMarking_b) 01561 { 01562 01563 OleAutoObj objTable = null 01564 OleAutoObj objRange = null 01565 string s_Bookmarking = null 01566 01567 // make a table maxCols,rows 01568 collapseSelection 01569 01570 if (noRows == 0 || noCols == 0) 01571 { 01572 return 01573 } 01574 01575 objRange = getRange objSel 01576 01577 clear objArgBlock 01578 put(objArgBlock, objRange) 01579 put(objArgBlock, noRows) 01580 put(objArgBlock, noCols) 01581 if (noRows!=null && noCols!=null) 01582 { 01583 vbaCheckRes(oleMethod(objTables, cMethodAdd, objArgBlock,objTable)) 01584 } 01585 01586 if (null objTable) 01587 { 01588 ack "Failed to make table" 01589 clearWordState 01590 } 01591 01592 i_Count1++ 01593 /* table book-marking created */ 01594 //if(TableBookMarking_b == true) 01595 01596 if(TableBookMarking_b != ""|| TableBookMarking_b!= null) 01597 { 01598 01599 OleAutoObj objBookMarks = null 01600 oleGet(objDoc, "Bookmarks", objBookmarks) 01601 clear objArgBlock 01602 //insert the bookmark 01603 string s_Bookmarking = "Table""_"i_Count1 TableBookMarking_b"" 01604 01605 s_Tablename=s_Bookmarking 01606 put(objArgBlock, s_Bookmarking) 01607 vbaCheckRes(oleMethod(objBookmarks, cMethodAdd, objArgBlock)) 01608 } 01609 else 01610 s_Tablename = null 01611 01612 01613 closeIfNonNull objRange 01614 collapseSelection 01615 01616 return objTable 01617 } 01618 /* ************************************************************************** 01619 Function: styleIndex () 01620 Description: 01621 * **************************************************************************/ 01622 01623 int styleIndex(Object o) 01624 { 01625 int styleLevel = (level o) 01626 int styleLevel1 = styleLevel 01627 if (styleLevel > maxWordLevel) 01628 { 01629 styleLevel = maxWordLevel 01630 } 01631 if(SectionStructureLevel_i1 != null or SectionStructureLevel_i1 == 0 ) 01632 { 01633 styleLevel = SectionStructureLevel_i1-offset_i+styleLevel+1 01634 } 01635 //styleLevel-- 01636 01637 return styleLevel 01638 } 01639 /* ********************************************************************************************** 01640 function: wordGetNumberedCellVBA() 01641 description: Heading style and body styles are defined and assigned for attributes in different levels 01642 **********************************************************************************************/ 01643 OleAutoObj wordGetNumberedCellVBA(OleAutoObj objTable, int rowNo, int cellNo) 01644 { 01645 OleAutoObj objCell = null 01646 clear objArgBlock 01647 put(objArgBlock, rowNo) 01648 put(objArgBlock, cellNo) 01649 01650 vbaCheckRes(oleMethod(objTable, cMethodCell, objArgBlock, objCell)) 01651 01652 if (null objCell) 01653 { 01654 ack "Failed to get cell handle" 01655 clearWordState 01656 } 01657 01658 return objCell 01659 } 01660 /* ********************************************************************************************** 01661 function: getStyleForAttribute() 01662 description: Heading style and body styles are defined and assigned for attributes in different levels (currently the default style is taken for all) 01663 **********************************************************************************************/ 01664 string getStyleForAttribute(Object o, string aName) 01665 { 01666 //string styleName = paraStyleGetAttributeMap_(o, aName) 01667 if (null o) 01668 { 01669 return bodyStyleNames[0] 01670 } 01671 string styleName = paraStyleGetAttributeMap_(o, aName) 01672 if (!null styleName) 01673 { 01674 return styleName 01675 } 01676 int styleLevel 01677 if (cell o) 01678 { 01679 styleLevel = cellHeadingLevel - 1 01680 } 01681 else 01682 { 01683 styleLevel = styleIndex o 01684 } 01685 01686 if (aName == AHeading) 01687 { 01688 return headingStyleNames[styleLevel] 01689 } 01690 else 01691 { 01692 return bodyStyleNames[styleLevel] 01693 } 01694 01695 } 01696 01697 /* *********************************************************************** 01698 function: wordSetCellContentsVBA() 01699 Description: sets the table cells with the data from the selected object attribute from the selected module and the view. 01700 **********************************************************************************/ 01701 01702 void wordSetCellContentsVBA(OleAutoObj objCell, Object o, string s) 01703 { 01704 if (null s) 01705 { 01706 return 01707 } 01708 01709 int styleLevel 01710 01711 if (null o) 01712 { 01713 styleLevel = 0 01714 } 01715 else 01716 { 01717 styleLevel = styleIndex o 01718 } 01719 01720 vbaCheckRes(oleMethod(objCell, cMethodSelect)) 01721 collapseSelectionBackwards 01722 01723 pasteAndApplyStyle(objSel, richText s, getStyleForAttribute(o,"")) 01724 01725 //This removes a carriage return from the table cell 01726 collapseSelection 01727 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01728 } 01729 01730 /* *********************************************************************** 01731 function: nextCellVBA() 01732 Description: rows will be inserted in table format one after the other 01733 **********************************************************************************/ 01734 OleAutoObj nextCellVBA(OleAutoObj objTable, objCell) 01735 { 01736 OleAutoObj nextCell = null 01737 01738 if (null objCell) 01739 { 01740 01741 nextCell = wordGetNumberedCellVBA(objTable,1,1) 01742 01743 } 01744 else 01745 { 01746 vbaCheckRes(oleGet(objCell, cPropertyNext, nextCell)) 01747 } 01748 01749 if (null nextCell) 01750 { 01751 ack "Unable to get handle on next cell" 01752 clearWordState 01753 } 01754 01755 closeIfNonNull objCell 01756 01757 return nextCell 01758 } 01759 /* *********************************************************************** 01760 function: insertBlankRow() 01761 Description: rows will be inserted in table format one after the other 01762 **********************************************************************************/ 01763 OleAutoObj insertBlankRow(OleAutoObj objTable, OleAutoObj objCell) 01764 { 01765 01766 Column c 01767 01768 for c in m do 01769 { 01770 objCell = nextCellVBA(objTable,objCell) 01771 vbaCheckRes(oleMethod(objCell, cMethodSelect)) 01772 } 01773 01774 return objCell 01775 } 01776 01777 /* *********************************************************************** 01778 function: pasteHeading() 01779 Description: 01780 **********************************************************************************/ 01781 string pasteHeading(OleAutoObj objSelection, Object o, bool doNumbers) 01782 { 01783 string styleName = getStyleForAttribute(o,AHeading) 01784 string errmess = null 01785 if (doNumbers) 01786 { 01787 string s = (number o) " " 01788 errmess = pasteAndApplyStyle(objSelection, richText s, styleName) 01789 if (null errmess) 01790 { 01791 collapseSelection 01792 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01793 vbaCheckRes(olePut(objSel, cPropertyStyle, wdStyleNormal)) 01794 errmess = pasteAndApplyStyle(objSelection, richTextWithOle o.AHeading, styleName) 01795 } 01796 return errmess 01797 } 01798 else 01799 { 01800 01801 return pasteAndApplyStyle(objSelection, richTextWithOle o.AHeading, styleName) 01802 } 01803 } 01804 /* *********************************************************************** 01805 function: wordDumpBodyVBA() 01806 Description: 01807 **********************************************************************************/ 01808 void wordDumpBodyVBA(Object o, string ObjValue) 01809 { 01810 string errMess 01811 01812 if (!hasCopyableText o) 01813 { 01814 return 01815 } 01816 01817 collapseSelection 01818 01819 Buffer textBuffer = create 01820 if (issueWarnings && containsUnregisteredOle(o.ALongText)) { 01821 warningBox "Object " (identifier o) " contains one or more unregistered OLE objects in '" ALongText "'.\n\nThese OLE objects will be exported as pictures." 01822 } 01823 01824 if (ObjValue!=null) 01825 { 01826 textBuffer = ObjValue 01827 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o, "")) 01828 01829 } 01830 else 01831 { 01832 textBuffer = richTextWithOle o.ALongText 01833 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o, ALongText)) 01834 } 01835 01836 delete(textBuffer) 01837 if (!null errMess) 01838 { 01839 logError("Error pasting object text", errMess, o) 01840 } 01841 01842 collapseSelection 01843 } 01844 void wordDumpTableAttributeVBA(Object o) 01845 { 01846 string errMess = "" 01847 if (!hasCopyableTableAttributes(o)) 01848 { 01849 return 01850 } 01851 string attribName = o.(reserved AMainColumnAttribute) 01852 Buffer textBuffer = create 01853 textBuffer = richTextWithOle o.attribName 01854 if (0 < length textBuffer) { 01855 if (issueWarnings && containsUnregisteredOle(o.attribName)) { 01856 warningBox "Object " (identifier o) " contains one or more unregistered OLE objects in '" attribName "'.\n\nThese OLE objects will be exported as pictures." 01857 } 01858 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o, attribName)) 01859 } 01860 delete(textBuffer) 01861 if (!null errMess) 01862 { 01863 logError("Error pasting "attribName" of cell", errMess, o) 01864 } 01865 collapseSelection 01866 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01867 } 01868 01869 void wordDumpTableCellMarkerVBA(OleAutoObj objCell, Object o) 01870 { 01871 vbaCheckRes(oleMethod(objCell, cMethodSelect)) 01872 collapseSelectionBackwards 01873 01874 pasteAndApplyStyle(objSel, richText cTableMarkerString, 01875 getStyleForAttribute(o, AHeading)) 01876 01877 collapseSelection 01878 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01879 } 01880 /* *********************************************************************** 01881 function: wordDumpCellVBA() 01882 Description: 01883 **********************************************************************************/ 01884 void wordDumpCellVBA(OleAutoObj objCell, Object o, bool doNumber,string ObjValue) 01885 { 01886 string errMess = "" 01887 //Check cell access 01888 if (!canRead(o)) 01889 { 01890 return 01891 } 01892 vbaCheckRes(oleMethod(objCell, cMethodSelect)) 01893 collapseSelectionBackwards 01894 01895 //Get the attribute associated with the table (main column attribute) 01896 string attributeName = o.(reserved AMainColumnAttribute) 01897 if (null attributeName) 01898 { 01899 bool isPicture = hasPicture o 01900 bool hasText = hasCopyableText o 01901 bool hasHead = hasCopyableHeading o 01902 01903 if (isPicture) 01904 { 01905 hasText = false 01906 } 01907 01908 if (!hasText && !hasHead && !isPicture) 01909 { 01910 if (doNumber) 01911 { 01912 string s = number o 01913 01914 pasteAndApplyStyle(objSel, richText s, 01915 getStyleForAttribute(o,AHeading)) 01916 collapseSelection 01917 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01918 } 01919 01920 return 01921 } 01922 01923 01924 if (hasHead) 01925 { 01926 errMess = pasteHeading(objSel, o, doNumber) 01927 01928 if (!null errMess) 01929 { 01930 logError("Error pasting object heading of cell", errMess, o) 01931 } 01932 01933 collapseSelection 01934 01935 if (!hasText) 01936 { 01937 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01938 } 01939 } 01940 if (isPicture) 01941 { 01942 /* picture objects cannot have text */ 01943 if (hasCopyablePicture o) 01944 { 01945 // wordDumpPictureVBA(o,objSel,false) 01946 return 01947 } 01948 } 01949 if (hasText) 01950 { 01951 if (ObjValue!=null) 01952 { 01953 wordDumpBodyVBA(o, ObjValue) 01954 } 01955 else 01956 { 01957 wordDumpBodyVBA(o,null) 01958 } 01959 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 01960 } 01961 } 01962 else 01963 { 01964 wordDumpTableAttributeVBA(o) 01965 } 01966 01967 } 01968 01969 /* *********************************************************************** 01970 function: wordDumpNamedCellVBA() 01971 Description: 01972 **********************************************************************************/ 01973 void wordDumpNamedCellVBA(OleAutoObj objCell, Object o, string attrInCell, string ObjValue) 01974 { 01975 Buffer textBuffer = create 01976 if (!canRead(o.attrInCell)) 01977 { 01978 return 01979 } 01980 01981 if (null (richTextWithOle o.attrInCell)) 01982 { 01983 return 01984 } 01985 01986 string errMess 01987 01988 vbaCheckRes(oleMethod(objCell, cMethodSelect)) 01989 collapseSelectionBackwards 01990 if (ObjValue==null) 01991 { 01992 01993 fullAttributeValueWithOle_(o,attrInCell,true,textBuffer) 01994 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o,attrInCell)) 01995 } 01996 else 01997 { 01998 textBuffer =ObjValue 01999 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o,attrInCell)) 02000 02001 } 02002 delete(textBuffer) 02003 if (!null errMess) 02004 { 02005 logError("Error pasting column attribute into table cell", errMess, o) 02006 } 02007 02008 collapseSelection 02009 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace)) 02010 } 02011 /* *********************************************************************** 02012 function: GetValue() 02013 Description: to fetch the value from the selected object and with the attribute name 02014 **********************************************************************************/ 02015 string GetValue(Object obj,string AttributeName_s, string s_Scriptpath) 02016 { 02017 string tsSub2 = null 02018 string tsSub = null 02019 02020 if(AttributeName_s == "Main") 02021 { 02022 if( obj."Object Heading""" == null) 02023 { 02024 tsSub2 = richTextWithOle obj."Object Text""" 02025 } 02026 else 02027 { 02028 tsSub2 = richTextWithOle obj."Object Heading""" 02029 } 02030 02031 } 02032 else if(AttributeName_s == "Object ID" || AttributeName_s == "Object Identifier") 02033 { 02034 tsSub2 = identifier(obj) 02035 } 02036 else 02037 { 02038 AttrDef ad = find(current Module, AttributeName_s) 02039 if(ad != null) 02040 { 02041 tsSub2 = obj.AttributeName_s"" 02042 } 02043 } 02044 if (s_Scriptpath!=null) 02045 { 02046 02047 tsSub2 = identifier(obj) 02048 s_Scriptpath = "\nattrDXLName3="tsSub2"" s_Scriptpath 02049 tsSub2 = eval_(s_Scriptpath) 02050 } 02051 02052 return tsSub2 02053 } 02054 /* *********************************************************************** 02055 function: exportTableLayoutRowHeader() 02056 Description: 02057 **********************************************************************************/ 02058 OleAutoObj exportTableLayoutRowHeader(Object o, OleAutoObj objTable, objCell) 02059 { 02060 Column c 02061 string s 02062 02063 for c in m do 02064 { 02065 objCell = nextCellVBA(objTable, objCell) 02066 02067 if (main c) 02068 { 02069 if (!canRead o) 02070 { 02071 // insert read locked string, as per DOORS display 02072 wordSetCellContentsVBA(objCell,o,cReadLockedDataMarker) 02073 } 02074 else 02075 { 02076 if (table o) 02077 { 02078 wordDumpTableCellMarkerVBA(objCell, o) 02079 } 02080 else 02081 { 02082 wordDumpCellVBA(objCell,o,includeHeadingNumbers && (!cell o),null) 02083 } 02084 } 02085 } 02086 else 02087 { 02088 string attrInCol = attrName c 02089 02090 if (isDumpableAttribute attrInCol) 02091 { 02092 wordDumpNamedCellVBA(objCell,o,attrInCol,null) 02093 } 02094 else 02095 { 02096 if (attrInCol == "Object Identifier") 02097 { 02098 s = text(c,o) 02099 } 02100 else 02101 { 02102 if (issueWarnings && containsUnregisteredOle(c, o)) { 02103 warningBox "Object " (identifier o) " contains one or more unregistered OLE objects.\n\nThese OLE objects will be exported as pictures." 02104 } 02105 s = richTextWithOle(c,o) 02106 } 02107 02108 if (null s) 02109 { 02110 continue 02111 } 02112 02113 wordSetCellContentsVBA(objCell,o,s) 02114 } 02115 } 02116 } 02117 02118 return objCell 02119 } 02120 /* *********************************************************************** 02121 function: exportTableLayoutRow() 02122 Description: 02123 **********************************************************************************/ 02124 OleAutoObj exportTableLayoutRow(Object o, OleAutoObj objTable, objCell, string StrColumnBookMarking_s[],int NumOfColumns_i,string StrColumn_s1[],bool b_FPresent) 02125 { 02126 Column c 02127 string s 02128 string ObjValue 02129 string colName_s 02130 string s_ParamsValue 02131 int i = 0 02132 02133 for c in m do 02134 { 02135 ObjValue ="" 02136 string s_Bookmarking1 = "" 02137 if(StrColumnBookMarking_s[i] == "true" || StrColumnBookMarking_s[i] == "True") 02138 { 02139 for s_ParamsValue in BookMarking do 02140 { 02141 02142 if (main c) 02143 { 02144 colName_s = "Main" 02145 } 02146 else 02147 { 02148 if (StrColumn_s1[i]!=null) 02149 { 02150 02151 colName_s = StrColumn_s1[i] 02152 } 02153 else 02154 { 02155 colName_s = attrName c 02156 } 02157 } 02158 02159 string s_key = key(BookMarking) 02160 bool keyMatches_b= matches(colName_s,s_key) 02161 if(keyMatches_b == true) 02162 { 02163 02164 if(reg2 s_ParamsValue) 02165 { 02166 string s_ParamsValue1 = s_ParamsValue[match 1] 02167 s_ParamsValue = GetValue(o,s_ParamsValue1,null) 02168 } 02169 if (StrColumn_s1[i]==null) 02170 { 02171 if(s_Bookmarking1 != null) 02172 { 02173 s_Bookmarking1 = s_Bookmarking1"_"s_ParamsValue 02174 } 02175 else 02176 { 02177 s_Bookmarking1 = s_ParamsValue 02178 } 02179 } 02180 else 02181 { 02182 // the bookmark has to be created by taking the field name for bookmark name 02183 s_Bookmarking= StrColumn_s1[i] 02184 if(s_Bookmarking != null) 02185 { 02186 02187 s_Bookmarking1 = s_Bookmarking1"_"s_ParamsValue 02188 } 02189 else 02190 { 02191 s_Bookmarking1 = s_ParamsValue 02192 } 02193 02194 } 02195 } 02196 } 02197 02198 } 02199 i++ 02200 02201 objCell = nextCellVBA(objTable, objCell) 02202 string FunctionList_s 02203 if (b_FPresent ==true) 02204 { 02205 string s_FunctionList1 = null 02206 string attrInCol = attrName c 02207 for FunctionList_s in FunctionList do 02208 { 02209 string AttributeName_s = key(FunctionList) 02210 if(attrInCol== AttributeName_s) 02211 { 02212 s_FunctionList1 = FunctionList_s 02213 ObjValue = GetValue(o,AttributeName_s,s_FunctionList1) 02214 break 02215 } 02216 02217 } 02218 02219 } 02220 if (main c) 02221 { 02222 if (!canRead o) 02223 { 02224 wordSetCellContentsVBA(objCell,o,cReadLockedDataMarker) 02225 02226 } 02227 02228 else 02229 { 02230 if (ObjValue!=null) 02231 { 02232 wordDumpCellVBA(objCell,o,includeHeadingNumbers && (!cell o),ObjValue) 02233 } 02234 wordDumpCellVBA(objCell,o,includeHeadingNumbers && (!cell o),null) 02235 } 02236 } 02237 else 02238 { 02239 string attrInCol = attrName c 02240 if (isDumpableAttribute attrInCol) 02241 { 02242 if (ObjValue!=null) 02243 { 02244 wordDumpNamedCellVBA(objCell,o,attrInCol,ObjValue) 02245 } 02246 else 02247 { 02248 wordDumpNamedCellVBA(objCell,o,attrInCol,null) 02249 } 02250 } 02251 else 02252 { 02253 if (attrInCol == "Object Identifier") 02254 { 02255 s = text(c,o) 02256 } 02257 else 02258 { 02259 if (issueWarnings && containsUnregisteredOle(c, o)) { 02260 warningBox "Object " (identifier o) " contains one or more unregistered OLE objects.\n\nThese OLE objects will be exported as pictures." 02261 } 02262 s = richTextWithOle(c,o) 02263 } 02264 02265 if (null s) 02266 { 02267 continue 02268 } 02269 02270 wordSetCellContentsVBA(objCell,o,s) 02271 } 02272 } 02273 if(s_Bookmarking1 != "") 02274 { 02275 02276 vbaCheckRes(oleMethod(objCell, cMethodSelect)) 02277 vbaCheckRes(oleGet(objCell, "Range", objCellRange)) 02278 OleAutoObj objBookMarks = null 02279 oleGet(objDoc, "Bookmarks", objBookmarks) 02280 clear objArgBlock 02281 put(objArgBlock, s_Bookmarking1) 02282 vbaCheckRes(oleMethod(objBookmarks, cMethodAdd, objArgBlock)) 02283 } 02284 } 02285 02286 return objCell 02287 } 02288 /* ************************************************************************************************************** 02289 function : convertMillimetersToPoints () 02290 Description: conversion of data 02291 ****************************************************************** ******************************************************/ 02292 int convertMillimetersToPoints( int milliMeters ) { 02293 // points = mm * ( 72.0 Points per Inch ) / ( 25.4 mm per Inch ) 02294 return intOf( realOf( milliMeters ) * ( 72.0 / 25.4 ) ) 02295 } 02296 /* ************************************************************************************************************** 02297 function : SetColumnWidth () 02298 Description: to set the column width as defined by the user in the XML configuration file 02299 ****************************************************************** ******************************************************/ 02300 void SetColumnWidth(OleAutoObj objColumn, int ColumnWidth_i){ 02301 clear objArgBlock 02302 put (objArgBlock, ColumnWidth_i) 02303 put (objArgBlock, 0) 02304 oleMethod(objColumn, "SetWidth", objArgBlock) // setwidth is a method used to set the column or cell width in a table 02305 } 02306 /* ************************************************************************************************************** 02307 function : AutoFitBehavior () 02308 Description: based on table cells contents or based on width of the document window, it resizes the table 02309 ****************************************************************** ******************************************************/ 02310 void AutoFitBehavior(OleAutoObj Table_ole){ 02311 clear objArgBlock 02312 put (objArgBlock, 1) 02313 checkRes (oleMethod (Table_ole, "AutoFitBehavior", objArgBlock)) 02314 } 02315 02316 /* ************************************************************************************************************** 02317 function : create_View () 02318 Description: if the Type=view this function is called and it will export the columns /attribute data into the word document 02319 ****************************************************************** ******************************************************/ 02320 void create_View(string StrColumn_s[],string StrColumn_s1[], string TableBookMarking_b,int ColWidth_i[], int NumOfColumns_i, bool AutoWidth_b, string StrColumnBookMarking_s[], string StrColHyperLinking_s[], bool b_FPresent){ 02321 02322 /* local Declarations */ 02323 int i //iterator 02324 string sErrorMessage = "" //Error Message 02325 string currObjType 02326 string nextObjType 02327 Column c //Column 02328 int NumberOfColumns_i //Number of Columns in Module 02329 int NumOfRows_i = 1 //Number of Rows 02330 int n = 0 //actual number of columns in view 02331 02332 int CountObjects_i = 0 02333 bool IsResetFormat_b 02334 OleAutoObj ViewTable_ole //OLE Object of ViewTable 02335 OleAutoObj Rows_ole //OLE Object of Rows 02336 OleAutoObj ActualCell_ole //OLE Object of actual cell 02337 OleAutoObj Columns_ole //OLE Object of Columns 02338 OleAutoObj Column_ole //OLE Object of Column 02339 02340 OleAutoArgs autoArgs =create //create autoArgs 02341 string StrColumn_s2[100] 02342 string s_FunctionList1 02343 string FunctionList_s 02344 string ObjValue 02345 02346 Object o = current Object 02347 m = current Module 02348 bool offest_b = false 02349 if (NumOfColumns_i < 1){ 02350 return "No Column match!" 02351 } 02352 for (i=0; i< NumOfColumns_i; i++) { 02353 if (StrColumn_s[i] != "Main" and StrColumn_s[i] != "Object Identifier" ) 02354 { 02355 if ( (exists attribute (StrColumn_s[i])) == false ){ 02356 sErrorMessage = sErrorMessage "Attribute " (StrColumn_s[i])" not exists!\n" 02357 } 02358 } 02359 } 02360 02361 02362 02363 if ( sErrorMessage != ""){ 02364 ack sErrorMessage 02365 halt 02366 } 02367 02368 /* delete all Columns in Moduleview */ 02369 for c in current Module do{ 02370 n++ 02371 } 02372 for i in 0:n do{ 02373 delete(column 0) 02374 } 02375 02376 /* Show selected Columns */ 02377 for (i = 0; i < NumOfColumns_i; i++){ 02378 c = insert(column i) 02379 if (StrColumn_s[i] != "Main") 02380 { 02381 attribute(c, StrColumn_s[i]) 02382 // GSTCS 442 implementation 02383 if (StrColumn_s1[i]!= null) 02384 { 02385 StrColumn_s2[i] = StrColumn_s1[i] 02386 } 02387 02388 else 02389 { 02390 StrColumn_s2[i] = StrColumn_s[i] 02391 } 02392 02393 } 02394 else 02395 { 02396 main(c) 02397 StrColumn_s2[i] = "Main" 02398 02399 } 02400 } 02401 02402 02403 /* Create Table with x Colums an y rows */ 02404 ViewTable_ole = wordMakeSizedTableVBA(1, NumOfColumns_i,TableBookMarking_b) 02405 02406 oleGet(ViewTable_ole, cPropertyRows, Rows_ole) 02407 oleGet(ViewTable_ole, cPropertyColumns, Columns_ole) 02408 02409 ActualCell_ole = wordGetNumberedCellVBA (ViewTable_ole, 1, 1) 02410 02411 if ( bMultipleHeader == false) 02412 { 02413 /* Add new Row */ 02414 oleMethod (Rows_ole, cMethodAdd) 02415 NumOfRows_i++ 02416 02417 /* Generate Title Row */ 02418 for (i = 0; i < NumOfColumns_i; i++){ 02419 ActualCell_ole = wordGetNumberedCellVBA(ViewTable_ole, 1, i+1) 02420 wordSetCellContentsVBA(ActualCell_ole, null, StrColumn_s2[i]) 02421 if(StrColHyperLinking_s[i] == "true") 02422 { 02423 02424 vbaCheckRes(oleMethod(ActualCell_ole, cMethodSelect)) 02425 collapseSelectionBackwards 02426 //This removes a carriage return from the table cell 02427 collapseSelection 02428 OleAutoObj objCellRange = null 02429 vbaCheckRes(oleGet(ActualCell_ole, "Range", objCellRange)) 02430 //delete(autoArgs) 02431 //Retrieve the bookmarks collection 02432 OleAutoObj objBookMarks = null 02433 oleGet(objDoc, "Bookmarks", objBookmarks) 02434 clear objArgBlock 02435 //insert the bookmark, with a specified tablebookmark name and the column count concatenated 02436 string s_Bookmarking=s_Tablename"Column"i_Count"" 02437 put(objArgBlock, s_Bookmarking) 02438 vbaCheckRes(oleMethod(objBookmarks, cMethodAdd, objArgBlock)) 02439 i_Count++ 02440 02441 } 02442 } 02443 setRowBorder() 02444 setRowFormatBoldGray() 02445 IsResetFormat_b = true 02446 } 02447 for o in m do{ 02448 if(offest_b == false) 02449 { 02450 offset_i = level(o) 02451 print offset_i 02452 offest_b = true 02453 } 02454 02455 CountObjects_i++ 02456 } 02457 02458 if (CountObjects_i == 0) 02459 { 02460 oleMethod(objSel,"MoveRight") 02461 oleMethod(objSel,"MoveDown") 02462 return 02463 } 02464 /* reset CountObject */ 02465 CountObjects_i = 0 02466 02467 02468 for o in m do 02469 { 02470 /* increase CountObject */ 02471 CountObjects_i++ 02472 02473 if (CountObjects_i > MAXROWNUMBER) 02474 { 02475 break 02476 } 02477 02478 if (exportCheckProgress) 02479 { 02480 break 02481 } 02482 exportStepProgress 02483 02484 if (row o) 02485 { 02486 continue 02487 } 02488 if (tableContents m) 02489 { 02490 if (table o) 02491 { 02492 continue 02493 } 02494 } 02495 else 02496 { 02497 if (cell o) 02498 { 02499 continue 02500 } 02501 } 02502 if ( (exists attribute ("ObjType")) == false) 02503 { 02504 currObjType = "R" 02505 nextObjType = "X" 02506 02507 if ((!null next o) and (level(o) < level(next o))) 02508 { 02509 currObjType = "H" 02510 if (!null next next o) 02511 { 02512 nextObjType = "H" 02513 } 02514 } 02515 } 02516 else 02517 { 02518 currObjType = o."ObjType""" 02519 if (!null next o) 02520 { 02521 nextObjType = (next o)."ObjType""" 02522 } 02523 else 02524 { 02525 nextObjType = "X" 02526 } 02527 } 02528 // Check if current object is a Header 02529 if (currObjType == "H") 02530 { 02531 //ActualCell_ole = exportTableLayoutRowHeader(o, ViewTable_ole, ActualCell_ole) 02532 ActualCell_ole = exportTableLayoutRowHeader(o, ViewTable_ole, ActualCell_ole) 02533 if (IsResetFormat_b) 02534 { 02535 setRowFormatNormal() 02536 } 02537 setRowBorder() 02538 if ((!null next o) and (nextObjType != "H")) 02539 IsResetFormat_b = true 02540 } 02541 else 02542 { 02543 // export the cell contents 02544 if (b_FPresent == true) 02545 { 02546 ActualCell_ole = exportTableLayoutRow(o, ViewTable_ole, ActualCell_ole,StrColumnBookMarking_s,NumOfColumns_i,StrColumn_s1,b_FPresent) 02547 } 02548 02549 else 02550 { 02551 ActualCell_ole = exportTableLayoutRow(o, ViewTable_ole, ActualCell_ole,StrColumnBookMarking_s,NumOfColumns_i,StrColumn_s1,null) 02552 } 02553 if (IsResetFormat_b) 02554 { 02555 setRowFormatNormal() 02556 } 02557 setRowBorder() 02558 } 02559 if ((!null next o) and (nextObjType == "H") and (level(next(o)) == 1)) 02560 { 02561 02562 oleMethod (Rows_ole, cMethodAdd) 02563 NumOfRows_i++ 02564 ActualCell_ole = insertBlankRow(ViewTable_ole, ActualCell_ole) 02565 setRowFontNormal() 02566 02567 } 02568 // Add new Row (Do not add row if last object (of the current set)) 02569 if (!null next o) 02570 { 02571 oleMethod (Rows_ole, cMethodAdd) 02572 NumOfRows_i++ 02573 if ((next o)."Object Text""" != "") 02574 { 02575 setRowFontNormalNextRow() 02576 } 02577 } 02578 02579 02580 } // End loop over all objects of current Module 02581 02582 if (AutoWidth_b==true) 02583 { 02584 clear autoArgs 02585 put (autoArgs, 1) 02586 oleMethod(ViewTable_ole, "AutoFitBehavior", autoArgs) 02587 } 02588 else 02589 { 02590 for (i = NumOfColumns_i-1 ; i >= 0; i--) 02591 { 02592 clear autoArgs 02593 put(autoArgs, i+1) 02594 oleMethod(Columns_ole, cMethodItem, autoArgs, Column_ole) 02595 if (ColWidth_i[i] > 0) 02596 { 02597 /* Convert Millimeters input to points */ 02598 //ColWidth_i[i] = convertMillimetersToPoints(ColWidth_i[i]) 02599 SetColumnWidth(Column_ole, ColWidth_i[i]) 02600 02601 } 02602 else 02603 { 02604 clear autoArgs 02605 put(autoArgs, 1) 02606 oleMethod(Column_ole, "AutoFit") 02607 } 02608 } 02609 } 02610 02611 /* if MAXROWNUMBER is reached print Hint */ 02612 if (CountObjects_i > MAXROWNUMBER){ 02613 //oleMethod (Rows_ole, cMethodAdd) 02614 NumOfRows_i++ 02615 ActualCell_ole = insertBlankRow(ViewTable_ole, ActualCell_ole) 02616 setRowFontNormal() 02617 wordSetCellContentsVBA(ActualCell_ole, null, "View exceeds max Numbers of Rows, only " MAXROWNUMBER " are displayed.") 02618 wordMergeRowVBA() 02619 oleGet(objSel, "Font", Font_ole) 02620 olePut(Font_ole, "Bold", true) 02621 setRowBorder() 02622 } 02623 02624 02625 02626 oleMethod(objSel,"MoveRight") 02627 oleMethod(objSel,"MoveDown") 02628 02629 // To close the tables array 02630 closeIfNonNull ViewTable_ole 02631 } 02632 /* ******************************************************* 02633 *function : FunctionforParam () 02634 *Description: the function to read the parameters mentioned for the function evocation(function post processing node) 02635 ************************************************************/ 02636 string FunctionforParam(OleAutoObj FParamList_ole, int NumOfParams_i) 02637 { 02638 OleAutoObj Params_ole=null 02639 int ParamIterator_i =0 02640 02641 string Param_s="" 02642 string sParameters ="" 02643 Buffer bParam= create 02644 02645 02646 if(NumOfParams_i != null) 02647 { 02648 for (ParamIterator_i = 0; ParamIterator_i < NumOfParams_i; ParamIterator_i++) 02649 { 02650 clear autoArgs 02651 put(autoArgs, ParamIterator_i) 02652 oleMethod(FParamList_ole, "Item", autoArgs, Params_ole) 02653 clear autoArgs 02654 put(autoArgs, "Param") 02655 oleMethod(Params_ole, "getAttribute", autoArgs, Param_s) 02656 02657 if(bParam ""!=null) 02658 { 02659 bParam = bParam"@#$%"Param_s 02660 } 02661 02662 else 02663 { 02664 02665 bParam =Param_s 02666 } 02667 sParameters = stringOf bParam 02668 02669 } 02670 delete bParam 02671 } 02672 02673 return sParameters 02674 02675 } 02676 /* ***************************************************************** 02677 function : ProcessTable () 02678 Description: the table attribute and the elements init will be processed like column text, width etc 02679 ******************************************************************/ 02680 02681 void ProcessTable(OleAutoObj Table_ole) 02682 { 02683 /* local declarations */ 02684 string ModuleName_s 02685 string Filtertext_s 02686 02687 string Type_s 02688 string StrColumn_s[100] 02689 string StrColumn_s1[100] 02690 02691 string TableStyle_s 02692 string Module_s 02693 string Filter_s 02694 string AutoWidth_s 02695 string Ancestors_s 02696 string Descendants_s 02697 OleAutoObj Columns_ole 02698 OleAutoObj ColumnList_ole 02699 OleAutoObj Column_ole 02700 string PrintTableInfo_s 02701 OleAutoObj FParamList_ole 02702 int NumOfColumns_i 02703 int ColWidth_i[100] 02704 bool AutoWidth_b 02705 int ColumnsIterator_i 02706 string Columnwidth_s //GSTCS 442 02707 int Columnwidth_i //GSTCS 442 02708 int NumOfParams_i 02709 string Attrname_s 02710 string Fieldname_s 02711 string ColHyperLinking_s 02712 string StrColHyperLinking_s[100] 02713 string ParamValue_s 02714 OleAutoObj BookMarkingAttr_ole 02715 OleAutoObj ParamList_ole 02716 int Param_i =0 02717 int ParamsIterator_i 02718 OleAutoObj Params_ole 02719 string Param_s 02720 string ColBookMarking[100] 02721 string TableBookMarking_s= null 02722 // bool TableBookMarking_b = false 02723 string TableBookMarking_b 02724 OleAutoObj FileList_ole 02725 OleAutoObj FunctionList_ole 02726 string sParamstr 02727 string FilePath_s ="" 02728 string FunctionList_s 02729 string s_FunctionList 02730 string ObjValue 02731 bool b_Tablebookmark = false 02732 02733 styleName = vbaGetStyleName(objDoc,wdStyleNormal) 02734 02735 /* get Path of Module */ 02736 clear autoArgs 02737 put( autoArgs, "Module") 02738 oleMethod(Table_ole, "getAttribute", autoArgs, ModuleName_s) 02739 clear autoArgs 02740 put( autoArgs, "Filtertext") 02741 oleMethod(Table_ole, "getAttribute", autoArgs, Filtertext_s) 02742 clear autoArgs 02743 put( autoArgs, "Ancestors") 02744 oleMethod(Table_ole, "getAttribute", autoArgs, Ancestors_s) 02745 02746 clear autoArgs 02747 put( autoArgs, "Descendants") 02748 oleMethod(Table_ole, "getAttribute", autoArgs, Descendants_s) 02749 clear autoArgs 02750 put( autoArgs, "Description") 02751 oleMethod(Table_ole, "getAttribute", autoArgs, Description_s) 02752 clear autoArgs 02753 put( autoArgs, "Type") 02754 oleMethod(Table_ole, "getAttribute", autoArgs, Type_s) 02755 02756 02757 clear autoArgs 02758 put( autoArgs, "PrintTableInfo") 02759 oleMethod(Table_ole, "getAttribute", autoArgs, PrintTableInfo_s) 02760 02761 clear autoArgs 02762 put( autoArgs, "TableBookmarking") 02763 oleMethod(Table_ole, "getAttribute", autoArgs, TableBookMarking_s) 02764 02765 /*currently the tablestyle is not used*/ 02766 clear autoArgs 02767 put(autoArgs, "Style") 02768 oleMethod(Table_ole, "getAttribute", autoArgs, TableStyle_s) 02769 02770 if (TableBookMarking_s!=null || TableBookMarking_s!="") 02771 { 02772 b_Tablebookmark =true 02773 TableBookMarking_b = TableBookMarking_s 02774 02775 } 02776 02777 else 02778 { 02779 b_Tablebookmark =false 02780 02781 } 02782 02783 /* get autoStyle for table */ 02784 02785 clear autoArgs 02786 put(autoArgs, "Columns") 02787 oleMethod(Table_ole, "selectSingleNode", autoArgs, Columns_ole) 02788 02789 clear autoArgs 02790 put (autoArgs, "Autowidth") 02791 oleMethod(Columns_ole, "getAttribute", autoArgs, AutoWidth_s) 02792 02793 02794 clear autoArgs 02795 put(autoArgs, "Column") 02796 oleMethod(Columns_ole, "selectNodes", autoArgs, ColumnList_ole) 02797 02798 oleGet(ColumnList_ole, "Length", NumOfColumns_i) 02799 02800 02801 if (!CheckModuleOpen(ModuleName_s)) 02802 { 02803 print "Can not open Module " ModuleName_s ".\n" 02804 return 02805 } 02806 02807 02808 filtering off 02809 02810 /* get Filter */ 02811 if (!null Filtertext_s || Filtertext_s != "") 02812 { 02813 f = parseFilter(Filtertext_s) 02814 if ((Ancestors_s == "true") || (Ancestors_s == "True") || (Ancestors_s == "1")) 02815 { 02816 ancestors(true) 02817 } 02818 else 02819 { 02820 ancestors(false) 02821 } 02822 if ((Descendants_s == "true") || (Descendants_s == "True") || (Descendants_s == "1")) 02823 { 02824 descendants(true) 02825 } 02826 else 02827 { 02828 descendants(false) 02829 } 02830 /* activate Filter */ 02831 set (m,f,accepted,rejected) 02832 filtering on 02833 } 02834 else 02835 { 02836 Filtertext_s = "No Filter defined" 02837 } 02838 if ( PrintTableInfo_s =="true") 02839 { 02840 /* print Modulename */ 02841 Module_s = "Module: " ModuleName_s "\n" 02842 pasteAndApplyStyle(objSel, richText Module_s, bodyStyleNames[0]) 02843 /* print Filtername */ 02844 Filter_s = "Filter: " Filtertext_s "\t Ancestors: " Ancestors_s "\t Descendants: " Descendants_s "\n" 02845 pasteAndApplyStyle(objSel, richText Filter_s, bodyStyleNames[0]) 02846 02847 } 02848 else 02849 { 02850 //string s_errmess = "PrintTableinfo is false \n" 02851 //pasteAndApplyStyle(objSel, richText s_errmess, bodyStyleNames[0]) 02852 } 02853 02854 if ((!null AutoWidth_s) and ((AutoWidth_s == "true") or (AutoWidth_s == "True") or (AutoWidth_s == "1"))){ 02855 AutoWidth_b = true 02856 } 02857 else{ 02858 AutoWidth_b = false 02859 } 02860 /* get Columns */ 02861 for (ColumnsIterator_i = 0; ColumnsIterator_i < NumOfColumns_i; ColumnsIterator_i++) 02862 { 02863 clear autoArgs 02864 put(autoArgs, ColumnsIterator_i) 02865 oleMethod(ColumnList_ole, "Item", autoArgs, Column_ole) 02866 clear autoArgs 02867 02868 put(autoArgs, "Attributename") 02869 oleMethod(Column_ole, "getAttribute", autoArgs,Attrname_s) 02870 StrColumn_s[ColumnsIterator_i] = Attrname_s 02871 02872 clear autoArgs 02873 put(autoArgs, "FieldName") 02874 oleMethod(Column_ole, "getAttribute", autoArgs, Fieldname_s) //GSTCS 442 02875 StrColumn_s1[ColumnsIterator_i] = Fieldname_s 02876 02877 clear autoArgs 02878 put(autoArgs, "Columnwidth") 02879 oleMethod(Column_ole, "getAttribute", autoArgs, Columnwidth_s) //GSTCS 442 02880 if (Columnwidth_s!=null) 02881 { 02882 Columnwidth_i = intOf(Columnwidth_s) 02883 ColWidth_i[ColumnsIterator_i] = Columnwidth_i 02884 } 02885 02886 clear autoArgs 02887 put(autoArgs, "ColHyperLinking") 02888 oleMethod(Column_ole, "getAttribute", autoArgs, ColHyperLinking_s) 02889 02890 clear autoArgs 02891 put(autoArgs, "Function_Post_Processing") 02892 oleMethod(Column_ole, "selectSingleNode", autoArgs, FunctionList_ole) 02893 02894 if (FunctionList_ole != null) 02895 { 02896 02897 b_FPresent = true 02898 clear autoArgs 02899 put(autoArgs, "Params") 02900 oleMethod(FunctionList_ole, "selectNodes", autoArgs, FParamList_ole) 02901 if(FParamList_ole != null) 02902 { 02903 02904 oleGet(FParamList_ole, "Length", NumOfParams_i) 02905 sParamstr= FunctionforParam(FParamList_ole,NumOfParams_i) 02906 } 02907 02908 02909 clear autoArgs 02910 put(autoArgs, "Filepath") 02911 oleMethod(FunctionList_ole, "selectSingleNode", autoArgs, FileList_ole) 02912 oleGet(FileList_ole, "text", FilePath_s) 02913 FunctionList_s = "\nattrDXLName1 = \"" sParamstr "\"\nattrDXLName2 = \"" Attrname_s "\" \n#include <"FilePath_s">" 02914 put(FunctionList,Attrname_s,FunctionList_s) 02915 02916 } 02917 if(!null ColHyperLinking_s) 02918 { 02919 StrColHyperLinking_s[ColumnsIterator_i] = ColHyperLinking_s 02920 } 02921 else 02922 { 02923 StrColHyperLinking_s[ColumnsIterator_i] = "false" 02924 } 02925 02926 clear autoArgs 02927 put(autoArgs, "BookMarkingAttr") 02928 oleMethod(Column_ole, "selectSingleNode", autoArgs, BookMarkingAttr_ole) 02929 if(BookMarkingAttr_ole != null) 02930 { 02931 02932 clear autoArgs 02933 put(autoArgs, "Params") 02934 oleMethod(BookMarkingAttr_ole, "selectNodes", autoArgs, ParamList_ole) 02935 if(ParamList_ole != null) 02936 { 02937 02938 oleGet(ParamList_ole, "Length", Param_i) 02939 } 02940 02941 02942 if(Param_i != 0) 02943 { 02944 for (ParamsIterator_i = 0; ParamsIterator_i < Param_i; ParamsIterator_i++) 02945 { 02946 02947 clear autoArgs 02948 put(autoArgs, ParamsIterator_i) 02949 oleMethod(ParamList_ole, "Item", autoArgs, Params_ole) 02950 clear autoArgs 02951 put(autoArgs, "Param") 02952 oleMethod(Params_ole, "getAttribute", autoArgs, Param_s) 02953 if (Fieldname_s != null) 02954 { 02955 //put(BookMarking,Fieldname_s"_"ParamsIterator_i"",Param_s) 02956 put(BookMarking,Fieldname_s"_"ParamsIterator_i"",Param_s) 02957 } 02958 else 02959 { 02960 //put(BookMarking,Attrname_s"_"ParamsIterator_i"",Param_s) 02961 put(BookMarking,Attrname_s"_"ParamsIterator_i"",Param_s) 02962 } 02963 ColBookMarking[ColumnsIterator_i]="true" 02964 } 02965 //ColBookMarking[ColumnsIterator_i] = "true" 02966 } 02967 } 02968 else 02969 { 02970 ColBookMarking[ColumnsIterator_i] = "false" 02971 } 02972 02973 } 02974 if ((Type_s == "View") || (Type_s == "V") || (Type_s == "v")) 02975 { 02976 if (b_Tablebookmark==true ) 02977 { 02978 create_View(StrColumn_s,StrColumn_s1,TableBookMarking_b,ColWidth_i,NumOfColumns_i,AutoWidth_b,ColBookMarking,StrColHyperLinking_s,b_FPresent) 02979 } 02980 else 02981 { 02982 02983 create_View(StrColumn_s,StrColumn_s1,null,ColWidth_i,NumOfColumns_i,AutoWidth_b,ColBookMarking,StrColHyperLinking_s,b_FPresent) 02984 } 02985 } 02986 } 02987 bool process_leaves( int deep, Object oLeaf, Column col, int Ycoord, Skip refList, string colGroup, string Attribute_s[], string Heading_s[], Array &arrResult) 02988 { 02989 string s, strValue, strNewGroup 02990 int refIdx 02991 Regexp matchHeading = regexp Heading_s[deep-1] // Note: array started by 0, but from user point ov view we start by 1 02992 Regexp matchAttribute = regexp Attribute_s[deep-1] // Note: array started by 0, but from user point ov view we start by 1 02993 02994 if (debug == 1) 02995 { 02996 print "process_leaves:\t"Ycoord"\t"colGroup"\n" 02997 } 02998 02999 while ( ! null oLeaf) 03000 { 03001 if (leaf oLeaf) 03002 { 03003 s = oLeaf."Object Heading" 03004 if ( s == "") // if heading is empty use text as value 03005 { 03006 s = oLeaf."Object Text" 03007 } 03008 03009 if ((length(Attribute_s[deep-1]) > 1 ) && matchAttribute s ) 03010 { 03011 strNewGroup=new_col_group(colGroup, s) 03012 03013 strValue = oLeaf.(attrName col)"" 03014 03015 if (debug == 1) 03016 { 03017 print "\t\t"s"\t"strValue"\n" 03018 } 03019 03020 // check if heading is already known. 03021 // If yes, print value in same column as before 03022 // otherwise append column 03023 if (find(refList,strNewGroup,refIdx)) 03024 { 03025 put(arrResult,strValue, refIdx, Ycoord) 03026 } 03027 else 03028 { 03029 if (arrResultX_size >= 255) 03030 { 03031 strError = "Sorry, but the script supports no more than 255 columns (attributes).\nPlease add an appropriate filter!" 03032 return false 03033 } 03034 put(refList,strNewGroup,arrResultX_size) 03035 if (! null colGroup) // fill first row 03036 { 03037 put(arrResult,colGroup,arrResultX_size+0,0) 03038 } 03039 put(arrResult,s,arrResultX_size+0,1) // add title to 2nd row 03040 put(arrResult,strValue, arrResultX_size++, Ycoord) // and finally the value 03041 } 03042 } 03043 } 03044 else 03045 { 03046 s = oLeaf."Object Heading" 03047 strNewGroup=new_col_group(colGroup, s) 03048 if ((length(Heading_s[deep-1]) > 1 ) && matchHeading s ) 03049 { 03050 if (!process_leaves( deep+1, first oLeaf, col, Ycoord, refList, strNewGroup, Attribute_s, Heading_s, arrResult )) 03051 { 03052 return false 03053 } 03054 } 03055 } 03056 oLeaf = next sibling oLeaf 03057 } // while 03058 return true 03059 } // process_leaves 03060 03061 void Transpose(string Value_s, string Attribute_s[], string Heading_s[], Object oFather, Array &arrResult) 03062 { 03063 Module mSource = current 03064 Column c 03065 string s, s1, s2 03066 string strMasterHeading = oFather."Object Heading" 03067 const string strEmpty = "" 03068 string strError 03069 Object oChild = first oFather 03070 Object oGrandChild 03071 Object oRoot 03072 Object oLeaf 03073 03074 bool mainSeen = false 03075 int NoOfValueColumns = 0 03076 bool PrintValueTitle = true 03077 bool OnlyOneValueColumn = true 03078 03079 arrResultX = 0; 03080 arrResultY = 0; 03081 arrResultX_size = 0; 03082 arrResultY_size = 0; 03083 03084 03085 // 03086 // now get some values from the GUI 03087 strMatchValues = Value_s 03088 03089 // 03090 // Before we start with the real work, it must be ensured 03091 // that at least two sub chapter levels exist 03092 if (null oChild) 03093 { 03094 strError = "Current object has no children.\n" 03095 } 03096 // else if (null first oChild) 03097 // { 03098 // strError = "Current object has no grand children.\n" 03099 // } 03100 else 03101 { 03102 Skip refList = create 03103 string strTitle 03104 oRoot = oChild // oRoot is the first child and we have to start here for each value 03105 arrResultY = 0 03106 int deep = 0; 03107 03108 // If we have to print the column header of the values field in the first column, 03109 // we have to start in column 2 with the chapter titles, otherwise in column 1 03110 if (PrintValueTitle) 03111 { 03112 arrResultX_size = 2; 03113 } 03114 else 03115 { 03116 arrResultX_size = 1; 03117 } 03118 03119 for c in mSource do // Loop over all columns 03120 { 03121 oChild = oRoot 03122 deep = 2 03123 // as long as we do not see the main column all columns are skipped 03124 // after the main column has been processed, all further columns are treaded as value columns 03125 03126 if (main c) // print table headers 03127 { 03128 mainSeen = true 03129 arrResultY = 2 // 1st row group, 2nd row title 03130 continue 03131 } 03132 03133 if ( !mainSeen) 03134 { 03135 continue 03136 } 03137 03138 strTitle = (title c) 03139 if ( ! matches(strMatchValues, strTitle)) 03140 { 03141 continue; 03142 } 03143 03144 NoOfValueColumns++ 03145 03146 while ( ! null oChild) 03147 { 03148 arrResultX=0 03149 if (PrintValueTitle) 03150 { 03151 put(arrResult,strTitle, arrResultX++, arrResultY) 03152 } 03153 s = oChild."Object Heading" 03154 if(s == "") 03155 { 03156 s = oChild."Object Text" 03157 03158 } 03159 put(arrResult,s, arrResultX++, arrResultY) 03160 oGrandChild = first oChild 03161 03162 if (!process_leaves(deep+1,oGrandChild, c, arrResultY, refList, strMasterHeading, Attribute_s, Heading_s, arrResult)) 03163 { 03164 break; 03165 } 03166 03167 oChild = next sibling oChild 03168 arrResultY++ 03169 }// while child 03170 03171 if (OnlyOneValueColumn ) 03172 { 03173 break 03174 } 03175 } // column 03176 03177 arrResultY_size = arrResultY 03178 } 03179 } //DoApply 03180 string GetLevelNumber(string Level_s, int Level_i){ 03181 Buffer Level_buf = create 03182 int len = length(Level_s) 03183 int i 03184 int LevelCount_i= 0 03185 string ReturnLevel_s 03186 for (i = 0; i < len; i++){ 03187 if(Level_s[i] == '.'){ 03188 LevelCount_i++ 03189 } 03190 if(LevelCount_i < Level_i) 03191 Level_buf += Level_s[i] 03192 else{ 03193 ReturnLevel_s = stringOf(Level_buf) 03194 break 03195 } 03196 } 03197 return ReturnLevel_s 03198 } 03199 void ProcessTranspose(OleAutoObj Transpose_ole){ 03200 OleAutoObj Heading_ole 03201 OleAutoObj Attribute_ole 03202 OleAutoObj RegexpList_ole 03203 OleAutoObj Regexp_ole 03204 OleAutoObj Value_ole 03205 string ModuleName_s 03206 string Filtertext_s 03207 string Ancestors_s 03208 string Descendants_s 03209 string Description_s 03210 string Regexp_s 03211 string Level_s 03212 string Value_s 03213 string ObjectNo_s 03214 string sLastValue 03215 string SheetName_s 03216 int NumberOfRegexp_i 03217 int Iterator_i 03218 int Iterator_x 03219 int Iterator_y 03220 int ObjectNo_i 03221 string Heading_s[10] = {".*",".*",".*",".*",".*",".*",".*",".*",".*",".*"} 03222 string Attribute_s[10] = {".*",".*",".*",".*",".*",".*",".*",".*",".*",".*"} 03223 Object EntryObject_o 03224 Array arrResult = create(1,1) 03225 03226 clear autoArgs 03227 put( autoArgs, "Module") 03228 oleMethod(Transpose_ole, "getAttribute", autoArgs, ModuleName_s) 03229 clear autoArgs 03230 put( autoArgs, "Filtertext") 03231 oleMethod(Transpose_ole, "getAttribute", autoArgs, Filtertext_s) 03232 clear autoArgs 03233 put( autoArgs, "Ancestors") 03234 oleMethod(Transpose_ole, "getAttribute", autoArgs, Ancestors_s) 03235 clear autoArgs 03236 put( autoArgs, "Descendants") 03237 oleMethod(Transpose_ole, "getAttribute", autoArgs, Descendants_s) 03238 clear autoArgs 03239 put( autoArgs, "Description") 03240 oleMethod(Transpose_ole, "getAttribute", autoArgs, Description_s) 03241 clear autoArgs 03242 put( autoArgs, "ObjectNo") 03243 oleMethod(Transpose_ole, "getAttribute", autoArgs, ObjectNo_s) 03244 clear autoArgs 03245 put( autoArgs, "SheetName") 03246 oleMethod(Transpose_ole, "getAttribute", autoArgs, SheetName_s) 03247 ObjectNo_i = str2int(ObjectNo_s) 03248 clear autoArgs 03249 put(autoArgs, "Heading") 03250 oleMethod(Transpose_ole, "selectSingleNode", autoArgs, Heading_ole) 03251 clear autoArgs 03252 put(autoArgs, "Regexp") 03253 oleMethod(Heading_ole, "selectNodes", autoArgs, RegexpList_ole) 03254 oleGet(RegexpList_ole, "Length", NumberOfRegexp_i) 03255 for (Iterator_i = 0; Iterator_i < NumberOfRegexp_i; Iterator_i++){ 03256 clear autoArgs 03257 put(autoArgs, Iterator_i) 03258 oleMethod(RegexpList_ole, "Item", autoArgs, Regexp_ole) 03259 clear autoArgs 03260 put (autoArgs, "Text") 03261 oleMethod(Regexp_ole, "getAttribute", autoArgs, Regexp_s) 03262 clear autoArgs 03263 put (autoArgs, "Level") 03264 oleMethod(Regexp_ole, "getAttribute", autoArgs, Level_s) 03265 Level_i = str2int(Level_s)-1 03266 Heading_s[Level_i] = Regexp_s 03267 } 03268 clear autoArgs 03269 put(autoArgs, "Attribute") 03270 oleMethod(Transpose_ole, "selectSingleNode", autoArgs, Attribute_ole) 03271 clear autoArgs 03272 put(autoArgs, "Regexp") 03273 oleMethod(Attribute_ole, "selectNodes", autoArgs, RegexpList_ole) 03274 oleGet(RegexpList_ole, "Length", NumberOfRegexp_i) 03275 for (Iterator_i = 0; Iterator_i < NumberOfRegexp_i; Iterator_i++){ 03276 clear autoArgs 03277 put(autoArgs, Iterator_i) 03278 oleMethod(RegexpList_ole, "Item", autoArgs, Regexp_ole) 03279 clear autoArgs 03280 put (autoArgs, "Text") 03281 oleMethod(Regexp_ole, "getAttribute", autoArgs, Regexp_s) 03282 clear autoArgs 03283 put (autoArgs, "Level") 03284 oleMethod(Regexp_ole, "getAttribute", autoArgs, Level_s) 03285 Level_i = str2int(Level_s)-1 03286 Attribute_s[Level_i] = Regexp_s 03287 } 03288 clear autoArgs 03289 put(autoArgs, "Value") 03290 oleMethod(Transpose_ole, "selectSingleNode", autoArgs, Value_ole) 03291 clear autoArgs 03292 put(autoArgs, "Attribute") 03293 oleMethod(Value_ole, "getAttribute", autoArgs, Value_s) 03294 03295 /* open module */ 03296 if (!CheckModuleOpen(ModuleName_s)){ 03297 print "Can not open Module " ModuleName_s ".\n" 03298 return 03299 } 03300 if (!exists attribute Value_s){ 03301 ack ("Attribute " Value_s " doesn't exists, Skip this Transpose.") 03302 return 03303 } 03304 03305 /* set filter */ 03306 filtering off 03307 if (!null Filtertext_s || Filtertext_s != ""){ 03308 f = parseFilter(Filtertext_s) 03309 if ((Ancestors_s == "true") || (Ancestors_s == "True") || (Ancestors_s == "1")){ 03310 ancestors(true) 03311 } 03312 else{ 03313 ancestors(false) 03314 } 03315 if ((Descendants_s == "true") || (Descendants_s == "True") || (Descendants_s == "1")){ 03316 descendants(true) 03317 } 03318 else{ 03319 descendants(false) 03320 } 03321 /* activate Filter */ 03322 set (m,f,accepted,rejected) 03323 filtering on 03324 } 03325 else{ 03326 Filtertext_s = "No Filter defined" 03327 } 03328 EntryObject_o = object(ObjectNo_i, m) 03329 if (!null EntryObject_o){ 03330 /* call transpose */ 03331 Transpose(Value_s, Attribute_s, Heading_s, EntryObject_o, arrResult) 03332 /* new Worksheet in Excel */ 03333 if (!null SheetName_s){ 03334 ExcelNewSheet(SheetName_s) 03335 } 03336 else{ 03337 ExcelNewSheet("") 03338 } 03339 /* Print in Excel Sheet */ 03340 for arrResultY in 1:arrResultY_size do{ 03341 sLastValue = "" 03342 for arrResultX in 1:arrResultX_size do{ 03343 string s = get(arrResult, arrResultX-1, arrResultY-1) 03344 03345 // In case only one Value column is porcessed, we do 03346 // not print the title of the Value column in the first column 03347 03348 if (arrResultX > 1) 03349 { 03350 // for the first (group) line print only a value if it 03351 // differs from the previuos column 03352 if ((s != sLastValue) || (arrResultY > 1)) 03353 { 03354 ExcelPut(arrResultX-1,arrResultY,s) 03355 sLastValue = s 03356 } 03357 } 03358 else if (arrResultY == 3) 03359 { 03360 ExcelPut(1,1,s) 03361 } 03362 } 03363 } 03364 } 03365 else{ 03366 ack("Object not found!") 03367 return 03368 } 03369 delete arrResult 03370 } // ProcessTranspose 03371 03372 03373 /* ***************************************************************** 03374 function : HandleSection () 03375 Description: XMl file reading for looping of sections information and table etc 03376 ******************************************************************/ 03377 void HandleSection(OleAutoObj Section_ole, int SectionStructureLevel_i){ 03378 /* SectionStructureLevel denotes the Level of the Section. Example: 3.2.1 has Level 3 */ 03379 int NumOfTables_i //Number of Tables defines in XML 03380 int NumOfSections_i //Number of Sections in this Section 03381 int Iterator_i 03382 string Headline_s //Headline for Chapter/Section 03383 string Text_s //Plaintext 03384 Buffer SectionStructure_s = create //String of Sections Structure 03385 OleAutoObj TableList_ole //List of Tables 03386 OleAutoObj SectionList_ole //List of Section in Chapter 03387 OleAutoObj Table_ole //Table 03388 SectionStructureLevel_i =0 03389 int SectionIterator_i 03390 OleAutoObj TransposeList_ole 03391 OleAutoObj Transpose_ole 03392 int NumOfTranspose_i 03393 03394 bool InitExcel_b = false 03395 SectionStructureLevel_i1 = SectionStructureLevel_i 03396 Level_i =SectionStructureLevel_i1 03397 clear autoArgs 03398 put(autoArgs,"Headline") 03399 oleMethod(Section_ole, "getAttribute", autoArgs, Headline_s) 03400 /* Get Text */ 03401 clear autoArgs 03402 put(autoArgs,"Text") 03403 oleMethod(Section_ole, "getAttribute", autoArgs, Text_s) 03404 /* Get Table List */ 03405 clear autoArgs 03406 put(autoArgs,"Table") 03407 oleMethod(Section_ole, "selectNodes", autoArgs, TableList_ole) 03408 /* get Section List */ 03409 clear autoArgs 03410 put(autoArgs,"Section") 03411 oleMethod(Section_ole, "selectNodes", autoArgs, SectionList_ole) 03412 03413 03414 03415 if (!InitWord_b){ 03416 /* Init Word */ 03417 InitWord() 03418 InitWord_b = true 03419 } 03420 03421 //if (Headline_s != "") 03422 // { 03423 MakeSection(Headline_s, Text_s, stringOf(SectionStructure_s),SectionStructureLevel_i) 03424 // } 03425 03426 /* get Numbers of Tables in Section */ 03427 oleGet(TableList_ole, "Length", NumOfTables_i) 03428 if (NumOfTables_i > 0){ 03429 for (Iterator_i = 0; Iterator_i < NumOfTables_i; Iterator_i++){ 03430 clear autoArgs 03431 put(autoArgs, Iterator_i ) 03432 oleMethod(TableList_ole, "Item", autoArgs, Table_ole) 03433 ProcessTable(Table_ole) 03434 } 03435 } 03436 03437 /* get Number of Transpose in Section */ 03438 03439 /* get Number of Sections */ 03440 oleGet(SectionList_ole, "Length", NumOfSections_i) 03441 if (NumOfSections_i > 0){ 03442 for (SectionIterator_i = 0; SectionIterator_i < NumOfSections_i; SectionIterator_i++){ 03443 clear autoArgs 03444 put(autoArgs, SectionIterator_i ) 03445 oleMethod(SectionList_ole, "Item", autoArgs, Section_ole) 03446 HandleSection(Section_ole, SectionStructureLevel_i + 1) 03447 } 03448 } 03449 } 03450 /* ***************************************************************** 03451 function : GetFilterFromXML () 03452 Description: XMl file reading for fetching the filters, section information 03453 ******************************************************************/ 03454 void GetFilterFromXML(){ 03455 /* local declaration */ 03456 03457 int NumOfSections_i //Number of all Sections in Chapter 03458 int IterateSection_i //Section iterator 03459 OleAutoObj SectionList_ole //List of Section in Chapter 03460 OleAutoObj Section_ole //actual Section 03461 03462 int MacroIterator_i 03463 int NumOfMacros_i 03464 OleAutoObj Macronames_ole 03465 OleAutoObj Macros_ole 03466 OleAutoObj MacrosList_ole 03467 string Macroname_s 03468 OleAutoObj TransposeList_ole 03469 int NumOfTranspose_i 03470 int Iterator_i 03471 OleAutoObj Transpose_ole 03472 bool InitExcel_b = false 03473 03474 /* Get List of Sections */ 03475 clear autoArgs 03476 put(autoArgs, "Section") 03477 oleMethod(Root_ole, "selectNodes", autoArgs, SectionList_ole) 03478 03479 /* Get Number of Sections */ 03480 oleGet(SectionList_ole, "length", NumOfSections_i) 03481 03482 /* iterate over all Sections */ 03483 for (IterateSection_i = 0; IterateSection_i < NumOfSections_i; IterateSection_i++) 03484 { 03485 clear autoArgs 03486 put(autoArgs,IterateSection_i) 03487 oleMethod(SectionList_ole, "Item", autoArgs, Section_ole) 03488 03489 HandleSection(Section_ole,0) 03490 } 03491 03492 clear autoArgs 03493 put(autoArgs,"Transpose") 03494 oleMethod(Root_ole, "selectNodes", autoArgs, TransposeList_ole) 03495 03496 oleGet(TransposeList_ole, "Length", NumOfTranspose_i) 03497 if (NumOfTranspose_i > 0) 03498 { 03499 if (!InitExcel_b){ 03500 ExcelInit(true) 03501 InitExcel_b=true 03502 } 03503 for (Iterator_i = 0; Iterator_i < NumOfTranspose_i; Iterator_i++){ 03504 clear autoArgs 03505 put(autoArgs, Iterator_i ) 03506 oleMethod(TransposeList_ole, "Item", autoArgs, Transpose_ole) 03507 ProcessTranspose(Transpose_ole) 03508 } 03509 } 03510 //GSTCS-445 implementation for call back hook of macros 03511 clear autoArgs 03512 put(autoArgs, "Macros") 03513 oleMethod(Root_ole, "selectSingleNode", autoArgs, Macros_ole) 03514 if (Macros_ole!=null) 03515 { 03516 03517 clear autoArgs 03518 put(autoArgs, "macronames") 03519 oleMethod(Macros_ole, "selectNodes", autoArgs, MacrosList_ole) 03520 if (MacrosList_ole!=null) 03521 { 03522 oleGet(MacrosList_ole, "Length", NumOfMacros_i) 03523 03524 for (MacroIterator_i = 0; MacroIterator_i < NumOfMacros_i;MacroIterator_i++) 03525 { 03526 clear autoArgs 03527 put(autoArgs, MacroIterator_i) 03528 oleMethod(MacrosList_ole, "Item", autoArgs, Macronames_ole) 03529 clear autoArgs 03530 put(autoArgs, "macroname") 03531 oleMethod(Macronames_ole, "getAttribute", autoArgs, Macroname_s) 03532 03533 if (Macroname_s!="" || Macroname_s!=null) 03534 { 03535 clear objArgBlock 03536 put (objArgBlock, "MacroName", Macroname_s) 03537 checkRes (oleMethod (objWord, "Run", objArgBlock)) 03538 03539 } 03540 } 03541 } 03542 } 03543 //clear objArgBlock 03544 //put (objArgBlock, "MacroName", "CreateHyperlinK") 03545 //checkRes (oleMethod (objWord, "Run", objArgBlock)) 03546 03547 UpdateTOC() 03548 } 03549 03550 /* ***************************************************************** 03551 function : initXML () 03552 Description: XMl file reading 03553 ******************************************************************/ 03554 bool initXML(){ 03555 03556 string Template_s 03557 string BaselineEnabled_s 03558 03559 /* Load XML with filter description */ 03560 clear autoArgs 03561 put(autoArgs,ConfigFileName_s) 03562 oleMethod(xmldoc, "Load", autoArgs) 03563 03564 /* Get root element from xmldoc */ 03565 oleGet(xmldoc, "documentElement", Root_ole) 03566 03567 if (null Root_ole) 03568 { 03569 ack "Can not get root element in XML configuration file.\n\nConfig file: "ConfigFileName_s"\n\nPlease check wellformess of XML file and validate it with an XML Editor!" 03570 return false 03571 } 03572 03573 /* get Template File */ 03574 clear autoArgs 03575 put(autoArgs, "Template") 03576 oleMethod(Root_ole, "getAttribute", autoArgs, TemplateFileName_s) 03577 /* check Template */ 03578 if ((TemplateFileName_s != "") and (canOpenFile(TemplateFileName_s, false))) 03579 { 03580 TemplateFileName_s = TemplateFileName_s 03581 } 03582 else 03583 { 03584 ack("Template should be in openable mode\n" ) 03585 halt 03586 return false; 03587 03588 } 03589 03590 clear autoArgs 03591 put(autoArgs, "Target") 03592 oleMethod(Root_ole, "getAttribute", autoArgs, Target_s) 03593 03594 clear autoArgs 03595 put(autoArgs, "BaselineEnabled") 03596 oleMethod(Root_ole, "getAttribute", autoArgs, BaselineEnabled_s) 03597 if (BaselineEnabled_s!=null and ((BaselineEnabled_s == "true") or (BaselineEnabled_s == "True") or (BaselineEnabled_s == "1"))) 03598 { 03599 Baseline_b=true 03600 03601 } 03602 return true 03603 } 03604 03605 /* *********************************************************************** 03606 Function: Export () 03607 Description: Export function triggered when click on "export to word" internally calls different functions to expoprt the object into word and finally gives the message for the user. 03608 ************************************************************************/ 03609 void Export(DB db){ 03610 Module OpenModule_m 03611 Module CurrentModule_m = current 03612 bool bSaved = false 03613 View View_vw 03614 string info_s 03615 03616 istart = getTickCount_ () 03617 03618 /* save current view */ 03619 View_vw = view(currentView(current Module)) 03620 /* get configuration file*/ 03621 ConfigFileName_s = get(dbeConfigFileList) 03622 if (!matches("(xml|XML)$", ConfigFileName_s)) 03623 { 03624 infoBox("Please select a valid XMl configuration file.") 03625 return 03626 } 03627 03628 /* hide GUI */ 03629 //hide dbProjectReportGUI 03630 /* Load XML and Template */ 03631 03632 if (initXML()) 03633 { 03634 //templateName = TemplateFileName_s 03635 03636 03637 GetFilterFromXML() 03638 /* open current view in Module */ 03639 if (!null Target_s) 03640 { 03641 /* Save Word Document */ 03642 clear autoArgs 03643 put(autoArgs, Target_s) 03644 oleMethod(objDoc, "SaveAs", autoArgs) 03645 /*Check if Save was successful */ 03646 oleGet(objDoc, "Saved", bSaved) 03647 if (!bSaved) 03648 { 03649 info_s=Target_s " is write protected. Document not saved.\n" 03650 } 03651 } 03652 current = CurrentModule_m 03653 load(View_vw) 03654 delete autoArgs 03655 int iend = getTickCount_() 03656 //iend = dateOf(intOf(today())) 03657 03658 int iDiff = (iend)-(istart) 03659 ack ("The timespent to generate the report " iDiff "miliseconds\n") 03660 infoBox "Project Report successfully generated.\n" 03661 } 03662 } 03663 03664 /* ***************************************************************************************** 03665 function : GetConfigFile() 03666 description: for testing purpose set the module attribute and the value to be populated on DBE 03667 **************************************************************************** */ 03668 void GetConfigFile(){ 03669 Module Mod = current 03670 if (exists attribute XML_CONFIG_ATTRIBUTE){ 03671 string XmlConfig_s = Mod.XML_CONFIG_ATTRIBUTE 03672 if (! null XmlConfig_s){ 03673 set(dbeConfigFileList, XmlConfig_s) 03674 } 03675 } 03676 } 03677 /* ******************************************************** 03678 Function :initGUI 03679 description: Initial GUI to fetch the config file 03680 *********************************************************** */ 03681 void initGUI() 03682 { 03683 dbProjectReportGUI = create ("Export Sample Project Report", styleCentered | styleFixed) //empty dialogbox creation 03684 03685 dbeConfigFileList = fileName(dbProjectReportGUI, "XML-Configuration-File: ","", "*.xml", "Extended Markup Language", true) //dialog box for capturing a file name 03686 GetConfigFile() 03687 03688 msgDBE = label(dbProjectReportGUI," ") //label in the DB 03689 ok(dbProjectReportGUI, "Export to Word", Export) //Ok button 03690 hide dbProjectReportGUI 03691 show(dbProjectReportGUI) //enable the DB, suspend the dxl 03692 //hide dbProjectReportGUI 03693 } 03694 /* end of functions */ 03695 03696 /**************************************************************/ 03697 /* Start of the script */ 03698 /**************************************************************/ 03699 03700 //istart = intOf(dateAndTime(today)) 03701 03702 /* Create OLE-Object xmldoc - the XML properties are used to initialize the OLE object */ 03703 xmldoc = oleCreateAutoObject("Msxml2.DOMDocument") 03704 olePut(xmldoc, "async", false) //Specifies whether asynchronous download is permitted. 03705 olePut(xmldoc, "resolveExternals", true) //Indicates whether external definitions, resolvable namespaces, document type definition (DTD) external subsets, and external entity references, are to be resolved at parse time, independent of validation. 03706 03707 /*GUI initialization to fetch the configuration file*/ 03708 initGUI()
1.7.4