DOORS Project reporting V1.0
pr_doxygencommenting _forfunctions.dxl
Go to the documentation of this file.
00001  
00002 /**
00003 * \code clearWordState()
00004 * Description: Controls most display changes on the monitor while a procedure is running and word export will be halted
00005 * \endcode 
00006 */
00007 void clearWordState() 
00008 {
00009     exportEndProgress
00010     checkRes(olePut(objWord,cPropertyScreenUpdating,true))
00011         halt
00012 }
00013 /**
00014 * \code logError()
00015 * Description:Error logging is captured
00016 * \endcode 
00017 */
00018 void logError(string errDescription, string errMessage, Object o) 
00019 {
00020     errorLogBuffer += errDescription
00021     errorLogBuffer += " failed with error message: '"
00022     errorLogBuffer += errMessage
00023     errorLogBuffer += "' for object "
00024     errorLogBuffer += (identifier o)
00025     errorLogBuffer += "\n\n"
00026 }
00027 /**
00028 * \code vbaCheckRes()
00029 * Description:Verification method used for OLE methods
00030 * \endcode 
00031 */
00032 void vbaCheckRes(string res) 
00033 {
00034     if (res != "") 
00035     {
00036 
00037         ack "OLE method failed: " res
00038         clearWordState
00039     }
00040 }
00041 /**
00042 * \code collapseSelection()
00043 * Description: to make the start and end points as same to enter the data
00044 * \endcode 
00045 */
00046 void collapseSelection() 
00047 {
00048     clear objArgBlock
00049     put(objArgBlock, cParamDirection, wdCollapseEnd)
00050     vbaCheckRes(oleMethod(objSel, cMethodCollapse, objArgBlock))
00051 }
00052 /**
00053 * \code collapseSelectionBackwards()
00054 * Description: The direction in which to collapse the range or selection
00055 * \endcode 
00056 */
00057 void collapseSelectionBackwards() 
00058 {
00059     clear objArgBlock
00060     put(objArgBlock, cParamDirection, wdCollapseStart)
00061     vbaCheckRes(oleMethod(objSel, cMethodCollapse, objArgBlock))
00062 }
00063 /**
00064 * \code vbaGetStyleName()
00065 * Description: takes style number as input, resolves the styles, style, style name and returns the same
00066 * \endcode 
00067 */
00068 string vbaGetStyleName(OleAutoObj objDoc, int styleNumber) 
00069 {
00070     OleAutoObj objStyles = null
00071     OleAutoObj objStyle = null
00072     string styleName = null
00073 
00074     vbaCheckRes(oleGet(objDoc, cPropertyStyles, objStyles)) // styles is a collection of all style
00075 
00076     if (null objStyles) 
00077     {
00078         ack "Unable to get handle on styles collection"
00079         clearWordState
00080     }
00081 
00082     clear objArgBlock
00083     put(objArgBlock, styleNumber)
00084         
00085     vbaCheckRes(oleMethod(objStyles, cMethodItem, objArgBlock, objStyle)) // fetch the style number
00086     
00087     if (null objStyle) 
00088     {
00089         ack "Unable to get handle on style"
00090         clearWordState
00091     }
00092 
00093     vbaCheckRes(oleGet(objStyle, cPropertyNameLocal, styleName))// fetch the style name
00094     
00095     if (null styleName) 
00096     {
00097         ack "Unable to get style name"
00098         clearWordState
00099     }
00100 
00101     closeIfNonNull objStyle
00102     closeIfNonNull objStyles
00103     
00104     return styleName
00105 }
00106 /**
00107 * \code wordCheckVersion()
00108 * Description:get the word document's version, either by takingthe existing word, or by creating a new one
00109 * \endcode 
00110 */ 
00111 string wordCheckVersion() 
00112 {
00113     objArgBlock = create
00114 
00115     if (null objArgBlock) 
00116     {
00117         ack "Unable to create argument block.  Low memory?"
00118         return ""
00119     }
00120     // Get Word object
00121     objWord = oleGetAutoObject(cObjWordApplication) // get the word application
00122     
00123     if (null objWord) 
00124     {
00125         objWord = oleCreateAutoObject(cObjWordApplication) // else create a new word object
00126         }
00127   
00128         string versionString
00129         vbaCheckRes(oleGet(objWord,cPropertyVersion, versionString)) //version of the word document
00130         return versionString
00131         
00132 }
00133 /**
00134 * \code wordPreChecksVBA()
00135 * Description:to make the word document visible, active and set the control
00136 * \endcode 
00137 */ 
00138 bool wordPreChecksVBA() 
00139 {
00140     Object curro = current Object
00141     m = current Module
00142 
00143     // Make Word visible
00144     if (!doStyleMapping)
00145     {
00146         makeVisible objWord
00147     }
00148 
00149     // Get documents collection
00150     checkRes(oleGet(objWord,cPropertyDocuments,objDocs)) //get the document
00151     
00152     if (null objDocs) 
00153     {
00154         ack "Unable to get Documents collection"
00155         return false
00156     }
00157         
00158     clear objArgBlock
00159     put(objArgBlock,templateName)
00160     checkRes(oleMethod(objDocs,cMethodAdd,objArgBlock))
00161   
00162    // Get a handle on the document
00163     checkRes(oleGet(objWord,cPropertyActiveDocument,objDoc)) //activate the document
00164     if (null objDoc) 
00165     {
00166         ack "Unable to get active document"
00167         halt
00168     }
00169 
00170     // Get a handle on the selection object
00171     checkRes(oleGet(objWord,cPropertySelection,objSel)) //select the object in the document
00172     
00173     if (null objSel) 
00174     {
00175         ack "Unable to get selection object"
00176         halt
00177     }
00178     // Get a handle on the tables collection
00179     checkRes(oleGet(objDoc,cPropertyTables,objTables)) //defines the set of all tables defined in the document
00180     
00181     if (null objTables) 
00182     {
00183         ack "Unable to get tables collection"
00184         halt
00185     }
00186 
00187     return true
00188 }
00189 /**
00190 * \code getWordStyleNames()
00191 * Description: to get the Fontname, style name etc
00192 * \endcode 
00193 */ 
00194 void getWordStyleNames(OleAutoObj objDoc) 
00195 {
00196     OleAutoObj objStyles = null
00197     OleAutoObj objStyle = null
00198     OleAutoObj objFont = null
00199     OleAutoObj objParaFormat = null
00200     OleAutoObj objListTemplate = null
00201         
00202     string styleName = null
00203     string fontName = null
00204         
00205     int styleType = 0
00206     int leftIndent = 0
00207         int count, stylesToCheck
00208     
00209         wordStyleNames = create
00210     wordStyleFonts = create
00211     
00212     vbaCheckRes(oleGet(objDoc, cPropertyStyles, objStyles))
00213 
00214     if (null objStyles) 
00215     {
00216         ack "Unable to get handle on styles collection"
00217         clearWordState
00218     }
00219 
00220     vbaCheckRes(oleGet(objStyles, cPropertyCount, stylesToCheck))
00221 
00222     for (count = 1; count <= stylesToCheck; count++) 
00223     {
00224         clear objArgBlock
00225         put(objArgBlock, count)
00226 
00227         vbaCheckRes(oleMethod(objStyles, cMethodItem, objArgBlock, objStyle))
00228     
00229         if (null objStyle) 
00230         {
00231             ack "Unable to get handle on style"
00232             clearWordState
00233         }
00234 
00235         // Don't use character styles
00236         vbaCheckRes(oleGet(objStyle, cPropertyType, styleType))
00237         
00238         if (styleType != wdStyleTypeParagraph) 
00239         {
00240             closeIfNonNull objStyle
00241             continue
00242         }
00243 
00244         styleName = ""
00245         fontName = ""
00246         leftIndent = 0
00247 
00248         vbaCheckRes(oleGet(objStyle, cPropertyNameLocal, styleName))
00249 
00250         if (null styleName) 
00251         {
00252             ack "Unable to get style name"
00253             clearWordState
00254         }
00255         put(wordStyleNames,noWordStyles,styleName)
00256                 
00257                 oleGet(objStyle, cPropertyListTemplate, objListTemplate)
00258     
00259         oleGet(objStyle, cPropertyParagraphFormat, objParaFormat)
00260         closeIfNonNull objParaFormat
00261 
00262         // get font name so we can set the correct default font
00263         vbaCheckRes(oleGet(objStyle, cPropertyFont, objFont))
00264 
00265         if (null objFont) 
00266         {
00267             ack "Unable to get handle on font"
00268             clearWordState
00269         }
00270 
00271         vbaCheckRes(oleGet(objFont, cPropertyName, fontName))
00272 
00273         if (null fontName) 
00274         {
00275             ack "Unable to get font name"
00276             clearWordState
00277         }
00278         
00279         closeIfNonNull objFont
00280         closeIfNonNull objStyle
00281 
00282         put(wordStyleFonts,styleName,fontName)
00283 
00284         noWordStyles++
00285     }
00286 
00287     closeIfNonNull objStyles
00288 
00289     string tempWordStyles[noWordStyles]
00290 
00291     for (count = 0; count < noWordStyles; count++) 
00292     {
00293         find(wordStyleNames, count, tempWordStyles[count])
00294     }
00295     
00296     sort tempWordStyles
00297     delete wordStyleNames
00298     wordStyleNames = create
00299     
00300     for (count = 0; count < noWordStyles; count++) 
00301     {
00302         put(wordStyleNames, count, tempWordStyles[count])
00303     }
00304 }
00305 /**
00306 * \code fillStyleNameArrays()
00307 * Description: headingstyle and bodystyle are set in string of arrays
00308 * \endcode 
00309 */ 
00310 void fillStyleNameArrays() 
00311 {
00312     int count
00313     string styleName
00314 
00315     for (count = 0; count < maxWordLevel; count++) 
00316     {
00317         styleName = vbaGetStyleName(objDoc,wordHeadingStyles[count])
00318         headingStyleNames[count] = styleName
00319     }
00320     
00321     styleName = vbaGetStyleName(objDoc,wdStyleNormal)
00322     
00323     for (count = 0; count < maxWordLevel; count++) 
00324     {
00325         bodyStyleNames[count] = styleName
00326     }
00327 }
00328 /**
00329 * \code InitWord()
00330 * Description: Initialize the word document
00331 * \endcode 
00332 */ 
00333 void InitWord()
00334 {
00335         string wordVersion = wordCheckVersion ()
00336     if (wordVersion =="")
00337         {
00338       return
00339     }
00340         wordPreChecksVBA ()
00341         fillStyleNameArrays()
00342         getWordStyleNames objDoc
00343         sStyleNormal = vbaGetStyleName(objDoc, wdStyleNormal)
00344 } 
00345 /**
00346 * \code UpdateTOC()
00347 * Description: To update the table of contents.
00348 * \endcode 
00349 */ 
00350 void UpdateTOC(){
00351     
00352     OleAutoObj              Fields_ole
00353     OleAutoArgs             autoArgs        = create
00354     int                     i
00355     
00356         oleGet(objDoc, "Fields", Fields_ole)
00357     oleMethod(Fields_ole, "Update", autoArgs, i)   
00358 }
00359 /**
00360 * \code makeFontTableFromStyle()
00361 * Description: get the font name from font skiplist using stylename as key and generate a font table
00362 * \endcode 
00363 */ 
00364 string makeFontTableFromStyle(string styleName)
00365 {
00366 // build a font table with the appropriate default font for the style
00367     string fontName = ""
00368     string defaultFontEntry 
00369     string fontTable
00370 
00371     find(wordStyleFonts, styleName, fontName)
00372 
00373     defaultFontEntry = "{\\f0\\fnil " fontName ";}"
00374     fontTable = fontTableBeginning defaultFontEntry fontTableEnd
00375 
00376     return fontTable
00377 }
00378 /**
00379 * \code pasteAndApplyStyle()
00380 * Description: pasting of the data (richtext) from doors to word
00381 * \endcode 
00382 */ 
00383 string pasteAndApplyStyle(OleAutoObj objSelection, RTF_string__ s, string styleName)
00384 {
00385         //styleName = vbaGetStyleName(objDoc,wdStyleNormal)
00386         string fontTable = makeFontTableFromStyle(styleName)
00387     setRichClip(s, styleName,fontTable )
00388     return oleMethod(objSelection, cMethodPaste)
00389     
00390 }
00391 /**
00392 * \code pasteAndApplyStyle()
00393 * Description:pasting of the data (buffer) from doors to word 
00394 * \endcode 
00395 */ 
00396 string pasteAndApplyStyle(OleAutoObj objSelection, Buffer b, string styleName)
00397 {
00398         //styleName = vbaGetStyleName(objDoc,wdStyleNormal)
00399         string fontTable = makeFontTableFromStyle(styleName)
00400     setRichClip(b, styleName,fontTable)
00401     return oleMethod(objSelection, cMethodPaste)
00402 }
00403 /**
00404 * \code endKey()
00405 * Description:able of contents will be stored in the begining without this it will be at the end of the document
00406 * \endcode 
00407 */ 
00408 void endKey() 
00409 {
00410     // move past the object
00411     clear objArgBlock
00412     put(objArgBlock, wdStory)
00413     vbaCheckRes(oleMethod(objSel,cMethodEndKey,objArgBlock))
00414 }
00415 /**
00416 * \code MakeSection()
00417 * Description:make different sections in the document (like headlines, text etc)
00418 * \endcode 
00419 */ 
00420 void MakeSection(string Headline_s, string Text_s, string SectionStructure_s, int SectionStructureLevel_i){
00421         /* local declaration */
00422         string              TitleText_s = ""
00423         OleAutoObj          TableOfContents_ole
00424         OleAutoObj          Range_ole
00425         OleAutoArgs         autoArgs                = create
00426         int                 SelStart_i              = 0
00427         int                 SelEnd_i                = 0
00428         string styleName = vbaGetStyleName(objDoc,wdStyleNormal) 
00429         oleGet(objDoc, "TablesOfContents", TableOfContents_ole) 
00430         
00431         /* make Section Headline */
00432         if (Headline_s != ""){
00433         TitleText_s = SectionStructure_s " " Headline_s
00434         pasteAndApplyStyle(objSel, richText Headline_s, styleName)
00435     }
00436     oleMethod(objSel, "TypeParagraph")
00437         oleGet(objSel, "Range", Range_ole)
00438     clear autoArgs
00439     put (autoArgs, "Range", Range_ole)
00440     put (autoArgs, "Level", SectionStructureLevel_i + 1)
00441     put (autoArgs, "Entry", TitleText_s)
00442     oleMethod(TableOfContents_ole, "MarkEntry", autoArgs)         
00443     endKey()
00444         if (Text_s != ""){
00445         pasteAndApplyStyle(objSel, richText Text_s, bodyStyleNames[0])
00446         oleMethod(objSel, "TypeParagraph")        
00447     }
00448     
00449 }
00450 /**
00451 * \code printFilterError (),parseSimpleFilter(),parseFilter(),parseFilter()
00452 * Description:Complete section for filtering processing
00453 * \endcode 
00454 */ 
00455 void printFilterError (string input, string err)
00456   {
00457     error "ERROR on parsing filter string '"input"' : \n"err"\n"
00458   }
00459 // function to parse a "simple" Filter, that means, which is not combined of other Filters
00460 Filter parseSimpleFilter (string input)
00461   {
00462 //    print "\t parse simple filter : >>"input"<<\n"
00463     if (REcolumnFilter input)
00464       { // any type of "Coulumn" filters
00465         string params  = input[match 3]
00466         string colName = input[match 1]
00467         string val     = input[match 2]
00468         if (null params)                                         return column (colName, val, false, false)
00469         else if (params == " (with regexps and case sensitive)") return column (colName, val, true, true)
00470         else if (params == " (with regexps)")                    return column (colName, val, false, true)
00471         else if (params == " (case sensitive)")                  return column (colName, val, true, false)
00472         else
00473           {
00474             printFilterError (input,  "unrecognized parameter to Column Filter >>"params"<<\n"//-
00475                   "possible values are : '(with regexps)', '(case sensitive)', '(with regexps and case sensitive)' or nothing")
00476           }
00477       }
00478     else if (REcontainsFilter input)
00479       { // any type of Attribute contains filter
00480         if (input[match 4] == "[with regexps]") return contains (attribute input[match 1], input[match 3])
00481         else if (null input[match 4])
00482                 return contains (attribute input[match 1], input[match 3], input[match 2] == "Contains")
00483         else
00484           {
00485             printFilterError (input, "unrecognized parameter to Contains Filter >>"input[match 4]"<<\n"//-
00486                   "possible values are : '[with regexps]' or nothing")
00487           }
00488       }
00489     else if (REcontentsFilter input)
00490       { // any type of "Any Text Attribute" contains filter
00491         if (input[match 3]  == " [with regexps]") return contents (input[match 2])
00492         else if (null input[match 3])            return contents (input[match 2], input[match 1] == "Contains")
00493         else
00494           {
00495             printFilterError (input, "unrecognized parameter to Contains in any Text Attribute Filter >>"input[match 3]"<<\n"//-
00496                   "possible values are : '[with regexps]' or nothing")
00497           }
00498       }
00499     else if (REmultiValueFilter input)
00500       { // both types of filter for multivalued attributes
00501         if (input[match 2] == "excludes")
00502           return excludes (attribute input[match 1], input[match 3])
00503         else return includes (attribute input[match 1], input[match 3])
00504       }
00505     else if (REemptyFilter input)
00506       { // is Empty and is not Empty filters
00507         if (null input[match 2])
00508           return isNull (attribute input[match 1])
00509         else return notNull (attribute input[match 1])
00510       }
00511     else if (REcompareFilter input)
00512       { // any type of comarison filters
00513         string cmd = input[match 2]
00514         if      (cmd == ">=") return (attribute input[match 1] >= input[match 3])
00515         else if (cmd == ">")  return (attribute input[match 1] >  input[match 3])
00516         else if (cmd == "<=") return (attribute input[match 1] <= input[match 3])
00517         else if (cmd == "<")  return (attribute input[match 1] <  input[match 3])
00518         else if (cmd == "!=") return (attribute input[match 1] != input[match 3])
00519         else if (cmd == "==") return (attribute input[match 1] == input[match 3])
00520       }
00521     else if (REcurrentObjectFilter input)
00522       { // filter that includes/excludes current Object  respectively any Object
00523         current = object (intOf (input[match 2]))
00524        if (input[match 1] == "Exclude") return excludeCurrent
00525         else return includeCurrent
00526       }
00527     else if (REleavesFilter input)
00528       { // filter to show only leaves
00529         if (null input[match 1]) return includeLeaves
00530         else return excludeLeaves
00531       }
00532     else if (RElinksFilter input)
00533       { // any Link related filters
00534         LinkFilter lf
00535         if (input[match 2] == "in-") lf = linkFilterIncoming
00536         else if(input[match 2] == "out-") lf = linkFilterOutgoing
00537         else lf = linkFilterBoth
00538         if (null input[match 1]) return hasLinks (lf, input[match 3])
00539         else return hasNoLinks (lf, input[match 3])
00540       }
00541     else printFilterError (input, "unrecognized Filter string")
00542 }
00543   
00544 Filter parseFilter (Buffer b, int startAt, stopAt)
00545 {
00546 //    print "parseFilter (>>"b[startAt:stopAt-1]"<<)\n"
00547     int bCount = 0, i, j, notStarted = -1
00548     bool isInString = false
00549     Filter leftFilter = null
00550     int start_match
00551     int end_match
00552 
00553     i = startAt
00554     while ((i<stopAt) && (b[i] == ' ' || b[i] == '\n'))
00555         i++
00556     startAt = i
00557 
00558     i = stopAt-1
00559     while ((i>= startAt) && (b[i] == ' ' || b[i] == '\n'))
00560         i--
00561      stopAt = i+1
00562 
00563     for (i = startAt; i < stopAt; i++)
00564       {
00565         if (b[i] == '\'' && (i == 0 || b[i-1] != '\\')) isInString = !isInString
00566         if (!isInString)
00567           {
00568             if (b[i] == '(')
00569               { // found brackets  --> highest priority 1
00570 //                print "************** () ************\n"
00571                 bCount++
00572                 j = i+1
00573                 while (bCount>0 && j < stopAt)
00574                   {
00575                     if (b[j] == '\'' && (j == 0 || b[j-1] != '\\')) isInString = !isInString
00576                     if (!isInString)
00577                       {
00578                         if (b[j] == '(') bCount++
00579                         if (b[j] == ')') bCount--
00580                       }
00581                     j++
00582                   }
00583                 if (j >= stopAt && bCount > 0) printFilterError (tempStringOf b, "j >= stopAt!")
00584                 if (notStarted > 0)
00585                   {
00586                     if (notStarted != i) printFilterError (tempStringOf b, "invalid NOT statement")
00587                     leftFilter = !parseFilter (b, i, j)
00588                   }
00589                 else
00590                   leftFilter = parseFilter (b, i+1, j-1)
00591                 i = j
00592               }
00593             //if (i < stopAt-3 && b[i:i+2] == "NOT")
00594             if (i < stopAt-3 && matches("[Nn][Oo][Tt]", b[i:i+2]))
00595               { // a NOT statement has started --> will be evaluated at net other statement or at end
00596                 // priority 2
00597                 if (null leftFilter)
00598                   notStarted = i+4
00599                 else printFilterError (tempStringOf b, "NOT Filter statement can not be placed between Filter parts!")
00600                 i = notStarted
00601               }
00602             if (matches("^[Aa][Nn][Dd] ", b[i:]) )
00603               { // AND statement --> priority 3
00604                 int start_match = start 0
00605                 int end_match = end 0
00606 //              print "********* AND **********\n"
00607                 if (null leftFilter)
00608                   {
00609                    if (notStarted > 0)
00610                      leftFilter = !parseFilter (b, notStarted, i-1)
00611                    else
00612                      leftFilter = parseFilter (b, startAt, i-1)
00613                   }
00614         return leftFilter && parseFilter (b, i+end_match+1, stopAt)
00615               }
00616 
00617             if (matches("^[Oo][Rr] ", b[i:] ))
00618               { // priority 4
00619                 int start_match = start 0
00620                 int end_match = end 0
00621 //              print "******** OR *******\n"
00622 //              print "i=" i  " start= " start_match " end=" end_match "\n"
00623                 if (null leftFilter)
00624                   {
00625                    if (notStarted > 0)
00626                      leftFilter = !parseFilter (b, notStarted, i-1)
00627                    else
00628                      leftFilter = parseFilter (b, startAt, i-1)
00629                   }
00630         return leftFilter || parseFilter (b, i+end_match+1, stopAt)
00631               }
00632            } // if instring
00633       } // for
00634     if (!null leftFilter)
00635       {
00636         if (i <= stopAt) printFilterError (tempStringOf b, "The Filter is not correct!")
00637         else return leftFilter
00638       }
00639     if (matches("^[Nn][Oo][Tt]", b[startAt:]))
00640             return !parseFilter (b, startAt+4, stopAt)
00641     else       
00642             return  parseSimpleFilter (b[startAt:stopAt-1]"")
00643   }
00644 // parses a any Filter, that means every string that contains a Filter definition
00645 Filter parseFilter (string input)
00646   {
00647     Buffer b = create
00648     b = input
00649     Filter result = parseFilter (b, 0, length b)
00650     delete b
00651     return result
00652   }
00653 
00654 
00655 /**
00656 * \code CheckModuleOpen ()
00657 * Description:to verify the module selected is opened or not
00658 * \endcode 
00659 */
00660 bool CheckModuleOpen(string ModuleName_s)
00661 {      
00662     ModName_ ModuleName_mn = module(ModuleName_s)
00663     if (open module ModuleName_s){
00664         m = data(moduleVersion(ModuleName_mn))
00665         current = m 
00666         /*print "Module " ModuleName_s " is already open.\n"*/
00667         return true
00668     }
00669     else{
00670         m = read(ModuleName_s, false)
00671         put(OpenModules_sk, ModuleName_s, m)
00672         if (null m){
00673             return false
00674         }
00675         else{
00676             current = m
00677             return true
00678         }
00679     }
00680 }
00681 /**
00682 * \code getRange ()
00683 * Description:portion of a document that's contained in the specified object
00684 * \endcode 
00685 */
00686 OleAutoObj getRange(OleAutoObj obj) 
00687 {
00688     OleAutoObj objRange = null
00689     vbaCheckRes(oleGet(obj,cPropertyRange,objRange))//Range object that represents the portion of a document that's contained in the specified object
00690 
00691     if (null objRange) 
00692     {
00693         ack "Unable to get range object"
00694         clearWordState
00695     }
00696     
00697     return objRange
00698 }
00699 /**
00700 * \code wordMakeSizedTableVBA ()
00701 * Description:create table with no.of rows and columns
00702 * \endcode 
00703 */
00704 OleAutoObj wordMakeSizedTableVBA(int noRows, int noCols,bool TableBookMarking_b) 
00705 {
00706     OleAutoObj objTable = null
00707     OleAutoObj objRange = null
00708         
00709         // make a table maxCols,rows
00710     collapseSelection
00711 
00712     if (noRows == 0 || noCols == 0) 
00713     { 
00714         return
00715     }
00716 
00717     objRange = getRange objSel
00718 
00719     clear objArgBlock
00720     put(objArgBlock, objRange)
00721     put(objArgBlock, noRows)
00722     put(objArgBlock, noCols)
00723         if (noRows!=null && noCols!=null)
00724         {
00725                 vbaCheckRes(oleMethod(objTables, cMethodAdd, objArgBlock,objTable))
00726         }
00727   
00728     if (null objTable) 
00729     {
00730         ack "Failed to make table"
00731         clearWordState
00732     }
00733         
00734         i_Count1++
00735         /* table book-marking created */
00736         if(TableBookMarking_b == true)
00737         {
00738                 OleAutoObj objBookMarks = null
00739                 oleGet(objDoc, "Bookmarks", objBookmarks)    
00740                 clear objArgBlock
00741                 //insert the bookmark
00742                 string s_Bookmarking ="Table""_"i_Count1""
00743                 s_Tablename=s_Bookmarking
00744                 put(objArgBlock, s_Bookmarking)
00745                 vbaCheckRes(oleMethod(objBookmarks, cMethodAdd, objArgBlock))
00746         }
00747         
00748     closeIfNonNull objRange
00749     collapseSelection
00750 
00751     return objTable
00752 }
00753 /**
00754 * \code styleIndex ()
00755 * Description:the style levels are called in wordSetCellContentsVBA, getStyleForAttribute functions
00756 * \endcode 
00757 */
00758 int styleIndex(Object o) 
00759 {
00760     int styleLevel = (level o)
00761 
00762     if (styleLevel > maxWordLevel)
00763     {
00764         styleLevel = maxWordLevel
00765     }
00766     
00767     styleLevel--
00768     
00769     return styleLevel
00770 }
00771 /**
00772 * \code wordGetNumberedCellVBA ()
00773 * Description:eading style and body styles are defined and assigned for attributes in different levels
00774 * \endcode 
00775 */
00776 OleAutoObj wordGetNumberedCellVBA(OleAutoObj objTable, int rowNo, int cellNo) 
00777 {
00778     OleAutoObj objCell = null
00779     clear objArgBlock
00780     put(objArgBlock, rowNo)
00781     put(objArgBlock, cellNo)
00782 
00783     vbaCheckRes(oleMethod(objTable, cMethodCell, objArgBlock, objCell))
00784 
00785     if (null objCell) 
00786     {
00787         ack "Failed to get cell handle"
00788         clearWordState
00789     }
00790     
00791     return objCell
00792 }
00793 /**
00794 * \code getStyleForAttribute ()
00795 * Description:Heading style and body styles are defined and assigned for attributes in different levels (currently the default style is taken for all)
00796 * \endcode 
00797 */
00798 string getStyleForAttribute(Object o, string aName) 
00799 {
00800         //string styleName = paraStyleGetAttributeMap_(o, aName)
00801     if (null o) 
00802     {
00803         return bodyStyleNames[0]
00804     }
00805         string styleName = paraStyleGetAttributeMap_(o, aName)
00806     if (!null styleName) 
00807         {
00808                 return styleName
00809         }
00810     int styleLevel 
00811     if (cell o) 
00812     {
00813         styleLevel = cellHeadingLevel - 1
00814     } 
00815     else 
00816     {
00817         styleLevel = styleIndex o
00818     }
00819     
00820     if (aName == AHeading) 
00821     {
00822         return headingStyleNames[styleLevel]
00823     } 
00824     else 
00825     {
00826         return bodyStyleNames[styleLevel]
00827     } 
00828 
00829 }
00830 
00831 /**
00832 * \code wordSetCellContentsVBA ()
00833 * Description:sets the table cells with the data from the selected object attribute from the selected module and the view.
00834 * \endcode 
00835 */
00836 void wordSetCellContentsVBA(OleAutoObj objCell, Object o, string s) 
00837 {
00838     if (null s) 
00839     {
00840         return
00841     }
00842 
00843     int styleLevel
00844     
00845     if (null o) 
00846     {
00847         styleLevel = 0
00848     }
00849     else 
00850     {
00851         styleLevel = styleIndex o
00852     }
00853 
00854     vbaCheckRes(oleMethod(objCell, cMethodSelect))
00855     collapseSelectionBackwards
00856 
00857     pasteAndApplyStyle(objSel, richText s, getStyleForAttribute(o,""))
00858     
00859     //This removes a carriage return from the table cell
00860     collapseSelection                                                    
00861     vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace))        
00862 }
00863 /**
00864 * \code nextCellVBA ()
00865 * Description:control will be moved to the next row of the table
00866 * \endcode 
00867 */
00868 OleAutoObj nextCellVBA(OleAutoObj objTable, objCell) 
00869 {
00870     OleAutoObj nextCell = null
00871 
00872     if (null objCell) 
00873     {
00874        
00875                 nextCell = wordGetNumberedCellVBA(objTable,1,1)
00876                 
00877     } 
00878     else 
00879     {
00880         vbaCheckRes(oleGet(objCell, cPropertyNext, nextCell))
00881     }
00882     
00883     if (null nextCell) 
00884     {
00885         ack "Unable to get handle on next cell"
00886         clearWordState
00887     }
00888     
00889     closeIfNonNull objCell
00890     
00891     return nextCell
00892 }
00893 /**
00894 * \code insertBlankRow ()
00895 * Description:rows will be inserted in table format one after the other
00896 * \endcode 
00897 */
00898 OleAutoObj insertBlankRow(OleAutoObj objTable, OleAutoObj objCell)
00899 {
00900         Column c
00901 
00902         for c in m do
00903     {
00904         objCell = nextCellVBA(objTable,objCell) 
00905             vbaCheckRes(oleMethod(objCell, cMethodSelect))
00906     }
00907     
00908     return objCell
00909 }
00910 
00911 /**
00912 * \code pasteHeading ()
00913 * Description:to paste the heading informations
00914 * \endcode 
00915 */
00916 string pasteHeading(OleAutoObj objSelection, Object o, bool doNumbers)
00917 {
00918     string styleName = getStyleForAttribute(o,AHeading)
00919         string errmess = null
00920     if (doNumbers) 
00921     {
00922         string s = (number o) "  "
00923         errmess = pasteAndApplyStyle(objSelection, richText s, styleName)
00924         if (null errmess)
00925         {
00926             collapseSelection
00927             vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace))
00928             vbaCheckRes(olePut(objSel, cPropertyStyle, wdStyleNormal))
00929             errmess = pasteAndApplyStyle(objSelection, richTextWithOle o.AHeading, styleName)
00930         }
00931         return errmess
00932     } 
00933     else 
00934     {
00935       
00936         return pasteAndApplyStyle(objSelection, richTextWithOle o.AHeading, styleName)
00937     }
00938 }
00939 /**
00940 * \code wordDumpBodyVBA ()
00941 * Description:actual data will be dumped into word(output file) from DOORS module (input)
00942 * \endcode 
00943 */
00944 void wordDumpBodyVBA(Object o, string ObjValue) 
00945 {
00946     string errMess
00947 
00948     if (!hasCopyableText o) 
00949     {
00950         return
00951     }
00952 
00953     collapseSelection
00954 
00955     Buffer textBuffer = create
00956     if (issueWarnings && containsUnregisteredOle(o.ALongText)) {
00957         warningBox "Object " (identifier o) " contains one or more unregistered OLE objects in '" ALongText "'.\n\nThese OLE objects will be exported as pictures."
00958     }
00959         
00960         if (ObjValue!=null)
00961         {
00962                 textBuffer = ObjValue
00963                 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o, ""))
00964 
00965         }
00966         else
00967         {
00968                 textBuffer = richTextWithOle o.ALongText
00969                 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o, ALongText))
00970         }
00971 
00972     delete(textBuffer)
00973     if (!null errMess)
00974     {
00975         logError("Error pasting object text", errMess, o)
00976     }
00977     
00978     collapseSelection
00979 }
00980 /**
00981 * \code wordDumpCellVBA ()
00982 * Description:actual data will be dumped into word(output file) from DOORS module (input)
00983 * \endcode 
00984 */
00985 void wordDumpCellVBA(OleAutoObj objCell, Object o, bool doNumber,string ObjValue) 
00986 {
00987     string errMess = ""
00988     //Check cell access
00989     if (!canRead(o))
00990     {
00991         return
00992     }
00993     vbaCheckRes(oleMethod(objCell, cMethodSelect))
00994     collapseSelectionBackwards
00995     
00996     //Get the attribute associated with the table (main column attribute)
00997     string attributeName = o.(reserved AMainColumnAttribute)
00998     if (null attributeName)
00999     {
01000         bool isPicture = hasPicture o
01001         bool hasText = hasCopyableText o
01002         bool hasHead = hasCopyableHeading o
01003      
01004         if (isPicture) 
01005         {
01006             hasText = false
01007         }
01008 
01009         if (!hasText && !hasHead && !isPicture)
01010         {
01011             if (doNumber) 
01012             {
01013                 string s = number o
01014 
01015                 pasteAndApplyStyle(objSel, richText s,
01016                       getStyleForAttribute(o,AHeading))
01017                 collapseSelection
01018                 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace))
01019             }
01020 
01021             return
01022         }
01023 
01024 
01025         if (hasHead) 
01026         {
01027             errMess = pasteHeading(objSel, o, doNumber)    
01028 
01029             if (!null errMess)
01030             {
01031                 logError("Error pasting object heading of cell", errMess, o)
01032             }
01033         
01034             collapseSelection
01035         
01036             if (!hasText) 
01037             {
01038                 vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace))    
01039             }
01040         }
01041 
01042         if (hasText) 
01043         {
01044                         if (ObjValue!=null)
01045                         {
01046                                 wordDumpBodyVBA(o, ObjValue)
01047                         }
01048                         else
01049                         {
01050                                 wordDumpBodyVBA(o,null)
01051                         }
01052             vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace))            
01053         }
01054     }
01055    
01056 }
01057 
01058 /**
01059 * \code exportTableLayoutRowHeader ()
01060 * Description: 
01061 * \endcode 
01062 */
01063 OleAutoObj exportTableLayoutRowHeader(Object o, OleAutoObj objTable, objCell) 
01064 {
01065     Column c
01066     string s
01067 
01068     for c in m do 
01069     {
01070         objCell = nextCellVBA(objTable, objCell)
01071     
01072         // Only export Main column for objects marked as Heading
01073         if (main c) 
01074         {
01075             if (!canRead o) 
01076             {
01077                  // insert read locked string, as per DOORS display
01078                 wordSetCellContentsVBA(objCell,o,cReadLockedDataMarker)
01079             } 
01080             else 
01081             {
01082                          wordDumpCellVBA(objCell,o,includeHeadingNumbers && (!cell o),null)
01083             }
01084         }
01085         else
01086         {
01087                 // print a tab (invisible char) to replace the evt bullets of the previous line
01088                         wordSetCellContentsVBA(objCell, null , "\t")
01089                 }
01090     }
01091 
01092     return objCell
01093 }
01094 /**
01095 * \code wordDumpNamedCellVBA ()
01096 * Description: 
01097 * \endcode 
01098 */
01099 
01100 void wordDumpNamedCellVBA(OleAutoObj objCell, Object o, string attrInCell, string ObjValue) 
01101 {
01102         Buffer textBuffer = create
01103     if (!canRead(o.attrInCell)) 
01104     {   
01105         return
01106     }
01107 
01108     if (null (richTextWithOle o.attrInCell)) 
01109     {
01110         return
01111     }
01112 
01113     string errMess
01114 
01115     vbaCheckRes(oleMethod(objCell, cMethodSelect))
01116     collapseSelectionBackwards
01117         if (ObjValue==null)
01118         {
01119                 
01120                 fullAttributeValueWithOle_(o,attrInCell,true,textBuffer)
01121                 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o,attrInCell))
01122         }
01123         else
01124         {
01125                 textBuffer =ObjValue
01126                 errMess = pasteAndApplyStyle(objSel, textBuffer, getStyleForAttribute(o,attrInCell))
01127                 
01128         }
01129     delete(textBuffer)
01130     if (!null errMess)
01131     {
01132         logError("Error pasting column attribute into table cell", errMess, o)
01133     }
01134 
01135     collapseSelection
01136     vbaCheckRes(oleMethod(objSel, cMethodTypeBackspace))
01137 }
01138 /**
01139 * \code GetValue ()
01140 * Description: to fetch the value from the selected object and with the attribute name 
01141 * \endcode 
01142 */
01143 
01144 string GetValue(Object obj,string AttributeName_s, string s_Scriptpath)
01145 {
01146         string tsSub2 = null
01147         string tsSub = null
01148 
01149         if(AttributeName_s == "Main")
01150         {
01151                 if( obj."Object Heading""" == null)
01152                 {
01153                         tsSub2 = richTextWithOle obj."Object Text"""
01154                 }
01155                 else
01156                 {
01157                         tsSub2 = richTextWithOle obj."Object Heading"""
01158                 }
01159                 
01160         }
01161         else if(AttributeName_s == "Object ID" || AttributeName_s == "Object Identifier")
01162         {
01163                 tsSub2 = identifier(obj)
01164         }       
01165         else 
01166         {
01167                 AttrDef ad = find(current Module, AttributeName_s)
01168                 if(ad != null)
01169                 {
01170                         tsSub2  =  obj.AttributeName_s""
01171                 }
01172         }       
01173         if (s_Scriptpath!=null)
01174         {
01175 
01176                 tsSub2 = identifier(obj)
01177                 s_Scriptpath = "\nattrDXLName3="tsSub2"" s_Scriptpath
01178                 tsSub2 = eval_(s_Scriptpath)
01179         }
01180                 
01181         return  tsSub2  
01182 }
01183 /**
01184 * \code exportTableLayoutRow ()
01185 * Description: 
01186 * \endcode 
01187 */
01188 
01189 OleAutoObj exportTableLayoutRow(Object o, OleAutoObj objTable, objCell, string StrColumnBookMarking_s[],int NumOfColumns_i,string StrColumn_s1[],bool b_FPresent) 
01190 {
01191     Column                      c
01192     string                      s
01193         string                  ObjValue 
01194         string                  colName_s
01195     string                      s_ParamsValue
01196     int                         i = 0
01197         
01198     for c in m do 
01199     {
01200         ObjValue =""
01201                 string s_Bookmarking = ""
01202         if(StrColumnBookMarking_s[i] == "true" || StrColumnBookMarking_s[i] == "True")
01203         {
01204                 for s_ParamsValue in BookMarking do
01205                         {
01206                                 if (main c) 
01207                         {
01208                                 colName_s = "Main"
01209                         }
01210                         else
01211                         {
01212                                 if (StrColumn_s1[i]!=null) // check the field name is present or not before creating the bookmark
01213                                         {
01214                                                 colName_s = StrColumn_s1[i]
01215                                         }
01216                                         else
01217                                         {
01218                                                 colName_s = attrName c
01219                                         }
01220                         }
01221                                 string s_key = key(BookMarking)
01222                                 
01223                                 bool keyMatches_b=  matches(colName_s,s_key) 
01224                                 
01225                                 if(keyMatches_b ==  true)
01226                                 {
01227                                         if(reg2 s_ParamsValue)
01228                                         {
01229                                                 string s_ParamsValue1 = s_ParamsValue[match 1]
01230                                                 s_ParamsValue = GetValue(o,s_ParamsValue1,null)
01231                                         }       
01232                                         if (StrColumn_s1[i]==null)
01233                                         {                                               
01234                                                 if(s_Bookmarking != null)
01235                                                 {
01236                                                         s_Bookmarking = s_Bookmarking"_"s_ParamsValue
01237                                                 }
01238                                                 else
01239                                                 {
01240                                                         s_Bookmarking = s_ParamsValue
01241                                                 }
01242                                         }
01243                                         else
01244                                         {
01245                                                 // the bookmark has to be created by taking the field name for bookmark name
01246                                                 s_Bookmarking= StrColumn_s1[i]
01247                                                 if(s_Bookmarking != null)
01248                                                 {
01249                                                         s_Bookmarking = s_Bookmarking"_"s_ParamsValue
01250                                                 }
01251                                                 else
01252                                                 {
01253                                                         s_Bookmarking = s_ParamsValue
01254                                                 }
01255                                         
01256                                         }
01257                                 }
01258                         }
01259                         
01260         } 
01261         i++
01262                 
01263                 objCell = nextCellVBA(objTable, objCell)
01264                 string  FunctionList_s
01265                 if (b_FPresent ==true)
01266                 {
01267                         string s_FunctionList1 = null
01268                         string attrInCol = attrName c
01269                         for FunctionList_s in FunctionList do
01270                         {
01271                                 string AttributeName_s = key(FunctionList)
01272                                 if(attrInCol== AttributeName_s)
01273                                 {
01274                                         s_FunctionList1 = FunctionList_s
01275                                         ObjValue = GetValue(o,AttributeName_s,s_FunctionList1)
01276                                         break
01277                                 }
01278                 
01279                         }
01280                 
01281                 }
01282         if (main c) 
01283         {
01284             if (!canRead o) 
01285             {
01286                                 wordSetCellContentsVBA(objCell,o,cReadLockedDataMarker)
01287                                 
01288             } 
01289             else 
01290             {
01291                                 if (ObjValue!=null)
01292                                 {
01293                                         wordDumpCellVBA(objCell,o,includeHeadingNumbers && (!cell o),ObjValue)
01294                                 }
01295                                 wordDumpCellVBA(objCell,o,includeHeadingNumbers && (!cell o),null)
01296             }
01297         } 
01298         else 
01299         {
01300             string attrInCol = attrName c
01301                         if (isDumpableAttribute attrInCol) 
01302             {
01303                                 if (ObjValue!=null)
01304                                 {
01305                                         wordDumpNamedCellVBA(objCell,o,attrInCol,ObjValue)
01306                                 }
01307                                 else
01308                                 {
01309                                         wordDumpNamedCellVBA(objCell,o,attrInCol,null)
01310                                 }
01311                         }
01312             else 
01313             {
01314                 if (attrInCol == "Object Identifier")
01315                 {
01316                     s = text(c,o)
01317                 }
01318                 else
01319                 {
01320                     if (issueWarnings && containsUnregisteredOle(c, o)) {
01321                             warningBox "Object " (identifier o) " contains one or more unregistered OLE objects.\n\nThese OLE objects will be exported as pictures."
01322                     }
01323                     s = richTextWithOle(c,o)
01324                 }
01325             
01326                 if (null s) 
01327                 {
01328                     continue
01329                 }
01330 
01331                 wordSetCellContentsVBA(objCell,o,s)
01332             }
01333         }
01334                 if(s_Bookmarking != null)
01335                 {
01336                 
01337                         vbaCheckRes(oleGet(objCell, "Range", objCellRange))
01338                         OleAutoObj objBookMarks = null
01339                         oleGet(objDoc, "Bookmarks", objBookmarks)    
01340                         clear objArgBlock
01341                         put(objArgBlock, s_Bookmarking)
01342                         vbaCheckRes(oleMethod(objBookmarks, cMethodAdd, objArgBlock))
01343                 }
01344     }
01345 
01346     return objCell
01347 }
01348 /**
01349 * \code convertMillimetersToPoints ()
01350 * Description:conversion of data 
01351 * \endcode 
01352 */
01353 int convertMillimetersToPoints( int milliMeters ) {
01354    // points = mm * ( 72.0 Points per Inch ) / ( 25.4 mm per Inch )
01355    return intOf( realOf( milliMeters ) * ( 72.0 / 25.4 ) )
01356 }
01357 /**
01358 * \code SetColumnWidth ()
01359 * Description: to set the column width as defined by the user in the XML configuration file
01360 * \endcode 
01361 */
01362 void SetColumnWidth(OleAutoObj objColumn, int ColumnWidth_i){
01363     clear objArgBlock
01364     put (objArgBlock, ColumnWidth_i)
01365   //  put (objArgBlock, 0)
01366     oleMethod(objColumn, "SetWidth", objArgBlock) // setwidth is a method used to set the column or cell width in a table
01367 }
01368 /**
01369 * \code AutoFitBehavior ()
01370 * Description: based on table cells contents or based on width of the document window, it resizes the table
01371 * \endcode 
01372 */ 
01373 void AutoFitBehavior(OleAutoObj Table_ole){
01374     clear objArgBlock
01375     put (objArgBlock, 1)
01376     checkRes (oleMethod (Table_ole, "AutoFitBehavior", objArgBlock))
01377 }
01378 /**
01379 * \code create_View ()
01380 * Description: if the Type=view this function is called and it will export the columns /attribute data into the word document
01381 * \endcode 
01382 */ 
01383 void create_View(string StrColumn_s[],string StrColumn_s1[], bool TableBookMarking_b,int ColWidth_i[], int NumOfColumns_i, bool AutoWidth_b, string StrColumnBookMarking_s[], string StrColHyperLinking_s[], bool b_FPresent){
01384     
01385     /* local Declarations */
01386     int                 i                                   //iterator
01387     string              sErrorMessage               = ""    //Error Message
01388         string                  currObjType
01389         string              nextObjType
01390     Column              c                                   //Column
01391     int                 NumberOfColumns_i                   //Number of Columns in Module
01392     int                 NumOfRows_i                 = 1     //Number of Rows
01393     int                 n                           = 0     //actual number of columns in view    
01394     int                 ColWidth_ai[NumOfColumns_i]         //Array of Column Widths
01395     int                 CountObjects_i              = 0
01396     bool                IsResetFormat_b                     
01397     OleAutoObj          ViewTable_ole                       //OLE Object of ViewTable
01398     OleAutoObj          Rows_ole                            //OLE Object of Rows
01399     OleAutoObj          ActualCell_ole                      //OLE Object of actual cell
01400     OleAutoObj          Columns_ole                         //OLE Object of Columns
01401     OleAutoObj          Column_ole                          //OLE Object of Column
01402         
01403     OleAutoArgs         autoArgs                 =create    //create autoArgs
01404         string                          StrColumn_s2[100]
01405         string                  s_FunctionList1
01406         string                          FunctionList_s
01407         string                          ObjValue
01408         
01409         Object o = current Object
01410     m = current Module 
01411         
01412     if (NumOfColumns_i < 1){
01413             return "No Column match!"
01414     }
01415         
01416         
01417         
01418     if ( sErrorMessage != ""){
01419         ack sErrorMessage   
01420         halt
01421     }
01422     
01423     /* delete all Columns in Moduleview */
01424     for c in current Module do{
01425         n++ 
01426     }
01427     for i in 0:n do{
01428         delete(column 0)
01429     }
01430     
01431     /* Show selected Columns */
01432     for (i = 0; i < NumOfColumns_i; i++){
01433         c = insert(column i)        
01434         if (StrColumn_s[i] != "Main")
01435                 {  
01436             attribute(c, StrColumn_s[i])
01437                         // GSTCS 442 implementation
01438                         if (StrColumn_s1[i]!= null)                             
01439                         {
01440                                 StrColumn_s2[i] = StrColumn_s1[i]
01441                         }
01442                         
01443                         else
01444                         {
01445                                 StrColumn_s2[i] = StrColumn_s[i]
01446                         }
01447                 
01448         }
01449         else
01450                 {
01451                         main(c)
01452                         StrColumn_s2[i] = "Main"
01453                       
01454         }
01455     }
01456    
01457    
01458     /* Create Table with x Colums an y rows */
01459     ViewTable_ole = wordMakeSizedTableVBA(1, NumOfColumns_i,TableBookMarking_b)
01460    
01461     oleGet(ViewTable_ole, cPropertyRows, Rows_ole)
01462     oleGet(ViewTable_ole, cPropertyColumns, Columns_ole)
01463  
01464     ActualCell_ole = wordGetNumberedCellVBA (ViewTable_ole, 1, 1)
01465     
01466     if ( bMultipleHeader == false)
01467         {
01468         /* Add new Row */
01469         oleMethod (Rows_ole, cMethodAdd)
01470         NumOfRows_i++
01471             
01472         /* Generate Title Row */      
01473             for (i = 0; i < NumOfColumns_i; i++){
01474                 ActualCell_ole = wordGetNumberedCellVBA(ViewTable_ole, 1, i+1)
01475                 wordSetCellContentsVBA(ActualCell_ole, null, StrColumn_s2[i])
01476                         if(StrColHyperLinking_s[i] == "true")
01477                 {
01478                         
01479                         vbaCheckRes(oleMethod(ActualCell_ole, cMethodSelect))
01480                                 collapseSelectionBackwards       
01481                         //This removes a carriage return from the table cell
01482                                 collapseSelection     
01483                         OleAutoObj objCellRange = null
01484                                 vbaCheckRes(oleGet(ActualCell_ole, "Range", objCellRange))
01485                                 //delete(autoArgs)
01486                                 //Retrieve the bookmarks collection
01487                                 OleAutoObj objBookMarks = null
01488                                 oleGet(objDoc, "Bookmarks", objBookmarks)    
01489                                 clear objArgBlock
01490                                 //insert the bookmark, with a specified tablebookmark name and the column count concatenated 
01491                                 string s_Bookmarking=s_Tablename"Column"i_Count""
01492                                 put(objArgBlock, s_Bookmarking)
01493                                 vbaCheckRes(oleMethod(objBookmarks, cMethodAdd, objArgBlock))
01494                                 i_Count++
01495                                 
01496                 }
01497         }  
01498     
01499             IsResetFormat_b = true
01500     }
01501     for o in m do{
01502         CountObjects_i++
01503     }
01504    
01505     if (CountObjects_i == 0)
01506         {
01507                 oleMethod(objSel,"MoveRight")
01508                 oleMethod(objSel,"MoveDown")                  
01509                 return
01510     }
01511     /* reset CountObject */
01512     CountObjects_i = 0
01513     
01514   
01515     for o in m do
01516         {
01517         /* increase CountObject */
01518         CountObjects_i++
01519                 
01520         if (CountObjects_i > MAXROWNUMBER)
01521                 {           
01522             break
01523             }           
01524         
01525                 if (exportCheckProgress)
01526                 {
01527             break
01528         }  
01529         exportStepProgress
01530                 
01531                 if (row o)
01532                 {
01533                         continue
01534                 }
01535                 if (tableContents m)
01536                 {
01537                         if (table o)
01538                         {
01539                                 continue
01540                         }
01541                 } 
01542                 else 
01543                 {
01544                         if (cell o)
01545                         {
01546                                 continue
01547                         }
01548                 }
01549                 if ( (exists attribute ("ObjType")) == false)
01550                 {
01551                         currObjType = "R"
01552                         nextObjType = "X"
01553 
01554                         if ((!null next o) and (level(o) < level(next o)))
01555                         {
01556                                 currObjType = "H"
01557                                 if (!null next next o)
01558                                 {
01559                                         nextObjType = "H"
01560                                 }
01561                         }
01562                 }
01563            else
01564            {
01565                         currObjType = o."ObjType"""
01566                         if (!null next o)
01567                         {
01568                                 nextObjType = (next o)."ObjType"""
01569                         }
01570                         else
01571                         {
01572                                 nextObjType = "X"
01573                         }
01574                 }
01575                         // Check if current object is a Header
01576                 if (currObjType == "H")
01577                 {
01578                         ActualCell_ole = exportTableLayoutRowHeader(o, ViewTable_ole, ActualCell_ole) 
01579                 }
01580                 else
01581                 {
01582                         // export the cell contents
01583                         if (b_FPresent == true)
01584                         {
01585                                 ActualCell_ole = exportTableLayoutRow(o, ViewTable_ole, ActualCell_ole,StrColumnBookMarking_s,NumOfColumns_i,StrColumn_s1,b_FPresent)
01586                         }
01587                         
01588                         else
01589                         {
01590                                 ActualCell_ole = exportTableLayoutRow(o, ViewTable_ole, ActualCell_ole,StrColumnBookMarking_s,NumOfColumns_i,StrColumn_s1,b_FPresent)
01591                         }
01592                 }
01593                 if ((!null next o) and (nextObjType == "H") and (level(next(o)) == 1))
01594                 {
01595                         
01596                         oleMethod (Rows_ole, cMethodAdd)
01597                         NumOfRows_i++
01598                         ActualCell_ole = insertBlankRow(ViewTable_ole, ActualCell_ole)
01599                 
01600                 }
01601                  // Add new Row (Do not add row if last object (of the current set))
01602                 if (!null next o)
01603                 {
01604                         oleMethod (Rows_ole, cMethodAdd)
01605                         NumOfRows_i++
01606                         
01607                 }
01608                         
01609                     
01610     } // End loop over all objects of current Module
01611     
01612         if (AutoWidth_b)
01613         {
01614                 clear autoArgs
01615                 put (autoArgs, 1)
01616                 oleMethod(ViewTable_ole, "AutoFitBehavior", autoArgs)   
01617     }
01618         else
01619         {
01620            for (i = NumOfColumns_i -1; i >= 0; i--)
01621                 {
01622                         clear autoArgs
01623                         put(autoArgs, i+1)        
01624                         oleMethod(Columns_ole, cMethodItem, autoArgs, Column_ole)                              
01625                         if (ColWidth_i[i] > 0)
01626                         {                
01627                                 /* Convert Millimeters input to points */
01628                                 ColWidth_i[i] = convertMillimetersToPoints(ColWidth_i[i]) 
01629                                 SetColumnWidth(Column_ole, ColWidth_i[i])      
01630                                 
01631                         }
01632                         else 
01633                         {                
01634                                 clear autoArgs
01635                                 put(autoArgs, 1)
01636                                 oleMethod(Column_ole, "AutoFit")          
01637                         }        
01638                 }
01639     }
01640         oleMethod(objSel,"MoveRight")
01641     oleMethod(objSel,"MoveDown")           
01642     
01643   // To close the tables array
01644   closeIfNonNull ViewTable_ole
01645 }
01646 /**
01647 * \code FunctionforParam ()
01648 * Description: the function to read the parameters mentioned for the function evocation(function post processing node) 
01649 * \endcode 
01650 */ 
01651 string FunctionforParam(OleAutoObj FParamList_ole, int NumOfParams_i)
01652 {
01653         OleAutoObj Params_ole=null
01654         int ParamIterator_i =0 
01655 
01656         string Param_s=""
01657         string sParameters =""
01658         Buffer bParam= create
01659         
01660         
01661         if(NumOfParams_i != null)
01662         {
01663                 for (ParamIterator_i = 0; ParamIterator_i < NumOfParams_i; ParamIterator_i++)
01664                 {
01665                         clear autoArgs
01666                         put(autoArgs, ParamIterator_i)
01667                         oleMethod(FParamList_ole, "Item", autoArgs, Params_ole)
01668                         clear autoArgs
01669                         put(autoArgs, "Param")        
01670                         oleMethod(Params_ole, "getAttribute", autoArgs, Param_s)
01671                         
01672                         if(bParam ""!=null)
01673                         {
01674                                 bParam = bParam"@#$%"Param_s
01675                         }
01676                         
01677                         else
01678                         {
01679                         
01680                                 bParam =Param_s
01681                         }
01682                         sParameters = stringOf bParam
01683                         
01684                 }
01685                 delete bParam   
01686         }
01687         
01688         return sParameters
01689                 
01690 }
01691 /**
01692 * \code ProcessTable ()
01693 * Description: the table attribute and the elements init will be processed like column text, width etc
01694 * \endcode 
01695 */ 
01696 void ProcessTable(OleAutoObj Table_ole)
01697 {
01698     /* local declarations */
01699     string              ModuleName_s
01700     string              Filtertext_s    
01701    
01702     string              Type_s
01703     string              StrColumn_s[100]
01704         string                          StrColumn_s1[100]
01705 
01706         string                          TableStyle_s
01707         string              Module_s
01708     string              Filter_s    
01709     string              AutoWidth_s
01710     string              Ancestors_s
01711     string              Descendants_s
01712     OleAutoObj          Columns_ole
01713     OleAutoObj          ColumnList_ole
01714     OleAutoObj          Column_ole    
01715         string                  PrintTableInfo_s 
01716         OleAutoObj                      FParamList_ole
01717     int                 NumOfColumns_i
01718     int                 ColWidth_i[100]
01719     bool                AutoWidth_b
01720         int                             ColumnsIterator_i
01721         string                          Columnwidth_s   //GSTCS 442
01722         int                             Columnwidth_i   //GSTCS 442
01723         int                             NumOfParams_i
01724         string                          Attrname_s
01725         string                          Fieldname_s
01726         string                          ColHyperLinking_s
01727         string                          StrColHyperLinking_s[100]
01728         string                          ParamValue_s
01729         OleAutoObj                      BookMarkingAttr_ole
01730         OleAutoObj                      ParamList_ole
01731         int                             Param_i =0
01732         int                             ParamsIterator_i
01733         OleAutoObj                      Params_ole
01734         string                          Param_s
01735         string                          ColBookMarking[100]
01736         string                          TableBookMarking_s
01737         bool                            TableBookMarking_b = false
01738         OleAutoObj              FileList_ole
01739         OleAutoObj                      FunctionList_ole
01740         string                          sParamstr
01741         string                          FilePath_s =""
01742         string                          FunctionList_s
01743         string                          s_FunctionList
01744         string                          ObjValue
01745         
01746         styleName = vbaGetStyleName(objDoc,wdStyleNormal)
01747  
01748     /* get Path of Module */
01749     clear autoArgs
01750     put( autoArgs, "Module")
01751     oleMethod(Table_ole, "getAttribute", autoArgs, ModuleName_s)
01752         clear autoArgs
01753     put( autoArgs, "Filtertext")
01754     oleMethod(Table_ole, "getAttribute", autoArgs, Filtertext_s)
01755     clear autoArgs
01756     put( autoArgs, "Ancestors")
01757     oleMethod(Table_ole, "getAttribute", autoArgs, Ancestors_s)
01758         
01759     clear autoArgs
01760     put( autoArgs, "Descendants")
01761     oleMethod(Table_ole, "getAttribute", autoArgs, Descendants_s)
01762     clear autoArgs
01763     put( autoArgs, "Description")
01764     oleMethod(Table_ole, "getAttribute", autoArgs, Description_s)
01765     clear autoArgs
01766     put( autoArgs, "Type")
01767     oleMethod(Table_ole, "getAttribute", autoArgs, Type_s)
01768     
01769         
01770         clear autoArgs
01771         put( autoArgs, "PrintTableInfo")
01772     oleMethod(Table_ole, "getAttribute", autoArgs, PrintTableInfo_s)
01773         
01774         clear autoArgs
01775         put( autoArgs, "TableBookmarking")
01776     oleMethod(Table_ole, "getAttribute", autoArgs, TableBookMarking_s)
01777         
01778         /*currently the tablestyle is not used*/
01779         clear autoArgs
01780     put(autoArgs, "Style")
01781     oleMethod(Table_ole, "getAttribute", autoArgs, TableStyle_s)
01782     
01783         if(!null TableBookMarking_s)
01784         {
01785                 
01786           if (TableBookMarking_s == "True" || TableBookMarking_s == "true")
01787                   {
01788             TableBookMarking_b = true
01789                         
01790                   }
01791         }
01792     /* get autoStyle for table */
01793      
01794     clear autoArgs
01795     put(autoArgs, "Columns")
01796     oleMethod(Table_ole, "selectSingleNode", autoArgs, Columns_ole)
01797     
01798         clear autoArgs
01799     put (autoArgs, "Autowidth")
01800     oleMethod(Columns_ole, "getAttribute", autoArgs, AutoWidth_s)
01801 
01802    
01803         clear autoArgs
01804     put(autoArgs, "Column")
01805     oleMethod(Columns_ole, "selectNodes", autoArgs, ColumnList_ole)
01806     
01807         oleGet(ColumnList_ole, "Length", NumOfColumns_i)
01808  
01809         
01810     if (!CheckModuleOpen(ModuleName_s))
01811         {
01812         print "Can not open Module " ModuleName_s ".\n"
01813         return    
01814     }
01815        
01816    
01817     filtering off
01818      
01819     /* get Filter */   
01820     if (!null Filtertext_s || Filtertext_s != "")
01821         {  
01822         f = parseFilter(Filtertext_s) 
01823         if ((Ancestors_s == "true") || (Ancestors_s == "True") || (Ancestors_s == "1"))
01824                 {
01825             ancestors(true)
01826         }
01827         else
01828                 {
01829             ancestors(false)
01830         }
01831         if ((Descendants_s == "true") || (Descendants_s == "True") || (Descendants_s == "1"))
01832                 {
01833             descendants(true)
01834         }
01835         else
01836                 {
01837             descendants(false)
01838         }
01839         /* activate Filter */
01840         set (m,f,accepted,rejected)
01841         filtering on
01842     }
01843     else
01844         {
01845         Filtertext_s = "No Filter defined"
01846     }
01847     if ( PrintTableInfo_s =="true")
01848         {
01849                 /* print Modulename */
01850                 Module_s = "Module: " ModuleName_s "\n"
01851                 pasteAndApplyStyle(objSel, richText Module_s, bodyStyleNames[0])
01852                 /* print Filtername */
01853                 Filter_s = "Filter: " Filtertext_s "\t Ancestors: " Ancestors_s "\t Descendants: " Descendants_s "\n"
01854                 pasteAndApplyStyle(objSel, richText Filter_s, bodyStyleNames[0])
01855                 
01856         }
01857         else
01858         {
01859                 string s_errmess = "PrintTableinfo is false \n"
01860                 pasteAndApplyStyle(objSel, richText s_errmess, bodyStyleNames[0])
01861         }
01862    
01863     if ((!null AutoWidth_s) and ((AutoWidth_s == "true") or (AutoWidth_s == "True") or (AutoWidth_s == "1"))){
01864         AutoWidth_b = true
01865     }
01866     else{
01867         AutoWidth_b = false    
01868     }
01869     /* get Columns */
01870     for (ColumnsIterator_i = 0; ColumnsIterator_i < NumOfColumns_i; ColumnsIterator_i++)
01871         {        
01872         clear autoArgs
01873         put(autoArgs, ColumnsIterator_i)
01874         oleMethod(ColumnList_ole, "Item", autoArgs, Column_ole)
01875         clear autoArgs
01876     
01877                 put(autoArgs, "Attributename")        
01878         oleMethod(Column_ole, "getAttribute", autoArgs,Attrname_s)
01879             StrColumn_s[ColumnsIterator_i] = Attrname_s
01880                 
01881                 clear autoArgs
01882                 put(autoArgs, "FieldName")        
01883                 oleMethod(Column_ole, "getAttribute", autoArgs, Fieldname_s)  //GSTCS 442
01884         StrColumn_s1[ColumnsIterator_i] = Fieldname_s
01885                 
01886                 clear autoArgs
01887                 put(autoArgs, "Columnwidth")        
01888                 oleMethod(Column_ole, "getAttribute", autoArgs, Columnwidth_s)  //GSTCS 442
01889                 if (Columnwidth_s!=null)
01890                 {
01891                         Columnwidth_i = intOf(Columnwidth_s)
01892                         ColWidth_i[ColumnsIterator_i] = Columnwidth_i
01893                 }
01894                 clear autoArgs
01895         put(autoArgs, "ColHyperLinking")        
01896         oleMethod(Column_ole, "getAttribute", autoArgs, ColHyperLinking_s)
01897                                 
01898                 clear autoArgs
01899                 put(autoArgs, "Function_Post_Processing")
01900                 oleMethod(Column_ole, "selectSingleNode", autoArgs, FunctionList_ole)           
01901                 
01902                 if (FunctionList_ole != null)
01903                 {
01904                 
01905                         b_FPresent = true
01906                         clear autoArgs
01907                         put(autoArgs, "Params")
01908                         oleMethod(FunctionList_ole, "selectNodes", autoArgs, FParamList_ole)
01909                 if(FParamList_ole != null)
01910                 {
01911                                 
01912                         oleGet(FParamList_ole, "Length", NumOfParams_i)
01913                                 sParamstr= FunctionforParam(FParamList_ole,NumOfParams_i)
01914                 }
01915                         
01916                 
01917                         clear autoArgs
01918                         put(autoArgs, "Filepath")
01919                         oleMethod(FunctionList_ole, "selectSingleNode", autoArgs, FileList_ole)
01920                         oleGet(FileList_ole, "text", FilePath_s)
01921                         FunctionList_s = "\nattrDXLName1 = \"" sParamstr "\"\nattrDXLName2 = \"" Attrname_s "\" \n#include  <"FilePath_s">"
01922                         put(FunctionList,Attrname_s,FunctionList_s)
01923                         
01924                 }
01925         if(!null ColHyperLinking_s)
01926         {
01927                 StrColHyperLinking_s[ColumnsIterator_i] = ColHyperLinking_s
01928         }
01929         else
01930         {
01931                 StrColHyperLinking_s[ColumnsIterator_i] = "false"
01932         }
01933                 
01934                 clear autoArgs
01935         put(autoArgs, "BookMarkingAttr")
01936         oleMethod(Column_ole, "selectSingleNode", autoArgs, BookMarkingAttr_ole)
01937         if(BookMarkingAttr_ole != null)
01938         {
01939                 
01940                         clear autoArgs
01941                         put(autoArgs, "Params")
01942                         oleMethod(BookMarkingAttr_ole, "selectNodes", autoArgs, ParamList_ole)
01943                 if(ParamList_ole != null)
01944                 {
01945                                 
01946                         oleGet(ParamList_ole, "Length", Param_i)
01947                 }
01948         }
01949         
01950                 if(Param_i != 0)
01951                 {
01952                 for (ParamsIterator_i = 0; ParamsIterator_i < Param_i; ParamsIterator_i++)      
01953                 {
01954                         
01955                                 clear autoArgs
01956                                 put(autoArgs, ParamsIterator_i)
01957                                 oleMethod(ParamList_ole, "Item", autoArgs, Params_ole)
01958                                 clear autoArgs
01959                                 put(autoArgs, "Param")        
01960                                 oleMethod(Params_ole, "getAttribute", autoArgs, Param_s)
01961                                 if (Fieldname_s != null)
01962                                 {
01963                                         put(BookMarking,Fieldname_s"_"ParamsIterator_i"",Param_s)
01964                                 }
01965                                 else
01966                                 {
01967                                         put(BookMarking,Attrname_s"_"ParamsIterator_i"",Param_s)
01968                                 }
01969                                 
01970                 }
01971                 ColBookMarking[ColumnsIterator_i] = "true"
01972                 }
01973                 else
01974                 {
01975                         ColBookMarking[ColumnsIterator_i] = "false"
01976                 }
01977                                 
01978     }
01979     if ((Type_s == "View") || (Type_s == "V") || (Type_s == "v"))
01980         {
01981         create_View(StrColumn_s,StrColumn_s1,TableBookMarking_b,ColWidth_i,NumOfColumns_i,AutoWidth_b,ColBookMarking,StrColHyperLinking_s,b_FPresent)
01982     }    
01983     
01984 }
01985 
01986 /**  
01987 * \code HandleSection ()
01988 * Description:  XMl file reading for looping of sections information and table etc
01989 * \endcode
01990 */
01991 void HandleSection(OleAutoObj Section_ole, int SectionStructureLevel_i){
01992     /* SectionStructureLevel denotes the Level of the Section. Example: 3.2.1 has Level 3 */
01993     int             NumOfTables_i                           //Number of Tables defines in XML
01994     int             NumOfSections_i                         //Number of Sections in this Section
01995     int             Iterator_i    
01996     string          Headline_s                              //Headline for Chapter/Section
01997         string          Text_s                                  //Plaintext
01998         Buffer          SectionStructure_s          = create    //String of Sections Structure
01999     OleAutoObj      TableList_ole                           //List of Tables
02000     OleAutoObj      SectionList_ole                         //List of Section in Chapter
02001     OleAutoObj      Table_ole                               //Table
02002     SectionStructureLevel_i      =0
02003         int SectionIterator_i
02004   
02005   // to have table of contents we need the section structure
02006   
02007    SectionStructure_i[SectionStructureLevel_i]++
02008     
02009     SectionStructure_s += (SectionStructure_i[0] "")
02010     for (SectionIterator_i = 1; SectionIterator_i <= SectionStructureLevel_i; SectionIterator_i++){
02011         SectionStructure_s+= "."
02012         SectionStructure_s += (SectionStructure_i[SectionIterator_i] "")
02013     }
02014         clear autoArgs
02015         put(autoArgs,"Headline")
02016         oleMethod(Section_ole, "getAttribute", autoArgs, Headline_s)
02017         /* Get Text */
02018         clear autoArgs
02019         put(autoArgs,"Text")
02020         oleMethod(Section_ole, "getAttribute", autoArgs, Text_s)
02021         /* Get Table List */
02022         clear autoArgs
02023         put(autoArgs,"Table")
02024         oleMethod(Section_ole, "selectNodes", autoArgs, TableList_ole)
02025         /* get Section List */
02026         clear autoArgs
02027         put(autoArgs,"Section")
02028         oleMethod(Section_ole, "selectNodes", autoArgs, SectionList_ole)
02029         
02030         if (!InitWord_b){ 
02031             /* Init Word */
02032             InitWord()
02033             InitWord_b = true
02034     }
02035         
02036         MakeSection(Headline_s, Text_s, stringOf(SectionStructure_s),SectionStructureLevel_i)
02037         
02038         /* get Numbers of Tables in Section */
02039         oleGet(TableList_ole, "Length", NumOfTables_i)
02040         if (NumOfTables_i > 0){
02041         for (Iterator_i = 0; Iterator_i < NumOfTables_i; Iterator_i++){
02042                 clear autoArgs
02043                 put(autoArgs, Iterator_i )
02044                 oleMethod(TableList_ole, "Item", autoArgs, Table_ole)
02045                 ProcessTable(Table_ole)
02046         }
02047         }
02048         /* get Number of Sections */
02049         oleGet(SectionList_ole, "Length", NumOfSections_i)
02050         if (NumOfSections_i > 0){
02051         for (SectionIterator_i = 0; SectionIterator_i < NumOfSections_i; SectionIterator_i++){
02052                 clear autoArgs
02053             put(autoArgs, SectionIterator_i )
02054             oleMethod(SectionList_ole, "Item", autoArgs, Section_ole)               
02055             HandleSection(Section_ole, SectionStructureLevel_i + 1)
02056             }
02057     }
02058 }
02059 
02060 
02061 /**  
02062 * \code GetFilterFromXML ()
02063 * Description: XMl file reading for fetching the filters, section information
02064 * \endcode
02065 */
02066 void GetFilterFromXML(){
02067         /* local declaration */
02068                      
02069         int             NumOfSections_i                         //Number of all Sections in Chapter
02070         int             IterateSection_i                       //Section iterator       
02071         OleAutoObj      SectionList_ole                         //List of Section in Chapter
02072         OleAutoObj      Section_ole                             //actual Section
02073         
02074     /* Get List of Sections */
02075         clear autoArgs
02076         put(autoArgs, "Section")
02077         oleMethod(Root_ole, "selectNodes", autoArgs, SectionList_ole)
02078         
02079         /* Get Number of Sections */
02080         oleGet(SectionList_ole, "length", NumOfSections_i)
02081         
02082         /* iterate over all Sections */
02083         for (IterateSection_i = 0; IterateSection_i < NumOfSections_i; IterateSection_i++)
02084         {
02085         clear autoArgs
02086         put(autoArgs,IterateSection_i)
02087         oleMethod(SectionList_ole, "Item", autoArgs, Section_ole)
02088                 
02089                 for (i = 1; i < 10; i++){
02090             SectionStructure_i[i] = 0
02091             }
02092         
02093         HandleSection(Section_ole,0)
02094         }       
02095         
02096         clear objArgBlock
02097         put (objArgBlock, "MacroName", "CreateHyperlinK")
02098         checkRes (oleMethod (objWord, "Run", objArgBlock))
02099         
02100         UpdateTOC()
02101 }
02102 
02103 /**  
02104 * \code initXML ()
02105 * Description: XMl file reading
02106 * \endcode
02107 */
02108 bool initXML(){
02109     
02110     string          Template_s     
02111         
02112         /* Load XML with filter description */  
02113         clear autoArgs
02114         put(autoArgs,ConfigFileName_s)
02115         oleMethod(xmldoc, "Load", autoArgs)
02116     
02117     /* Get root element from xmldoc */
02118         oleGet(xmldoc, "documentElement", Root_ole)
02119 
02120    if (null Root_ole)
02121    {
02122                 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!"
02123                 return false
02124    }
02125         
02126     /* get Template File */
02127         clear autoArgs
02128         put(autoArgs, "Template")
02129         oleMethod(Root_ole, "getAttribute", autoArgs, Template_s)
02130         /* check Template */
02131         if ((Template_s != "") and (canOpenFile(Template_s, false)))
02132         {
02133             TemplateFileName_s = Template_s
02134     }      
02135     else
02136         {
02137         ack("Template should be in openable mode\n" )   
02138     }  
02139         
02140         clear autoArgs
02141     put(autoArgs, "Target")
02142     oleMethod(Root_ole, "getAttribute", autoArgs, Target_s)
02143     return true;
02144  }  
02145 
02146 /** 
02147 * \code Export () 
02148 * 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.
02149 * \endcode
02150 */
02151 
02152 void Export(DB db){
02153     Module      OpenModule_m    
02154     Module      CurrentModule_m = current
02155     bool        bSaved          = false
02156     View        View_vw
02157     string      info_s
02158  
02159     /* save current view */
02160     View_vw = view(currentView(current Module))
02161     /* get configuration file*/
02162     ConfigFileName_s = get(dbeConfigFileList)
02163         if (!matches("(xml|XML)$", ConfigFileName_s))
02164         {
02165             infoBox("Please select a valid XMl configuration file.")        
02166             return
02167     }
02168         
02169         /* hide GUI */
02170         hide dbProjectReportGUI
02171         /* Load XML and Template */
02172 
02173   if (initXML())
02174   {
02175         templateName = TemplateFileName_s
02176         
02177         for (i = 0; i < 10; i++){
02178         SectionStructure_i[i] = 0
02179         }
02180         GetFilterFromXML()      
02181         /* open current view in Module */
02182         if (!null Target_s)
02183         {
02184             /* Save Word Document */
02185             clear autoArgs
02186             put(autoArgs, Target_s)
02187             oleMethod(objDoc, "SaveAs", autoArgs)       
02188             /*Check if Save was successful */
02189             oleGet(objDoc, "Saved", bSaved)
02190         if (!bSaved)
02191                 {
02192            info_s=Target_s " is write protected. Document not saved.\n"         
02193             }
02194     }
02195         current = CurrentModule_m       
02196         load(View_vw)
02197         delete autoArgs
02198         infoBox  "Project Report successfully generated.\n"
02199   }
02200 }
02201 
02202 /** 
02203 * \code GetConfigFile()
02204 * Description: for testing purpose set the module attribute and the value to be populated on DBE
02205 * \endcode
02206  */ 
02207 void GetConfigFile(){
02208     Module Mod = current
02209     if (exists attribute XML_CONFIG_ATTRIBUTE){
02210         string XmlConfig_s = Mod.XML_CONFIG_ATTRIBUTE
02211         if (! null XmlConfig_s){
02212             set(dbeConfigFileList, XmlConfig_s)
02213         }
02214     }
02215 }
02216 /**
02217 * \code initGUI()
02218 * Description: Initial GUI to fetch the config file 
02219 * initiate the XMl file before calling this function 
02220 * \endcode 
02221 */
02222 void initGUI()
02223 {
02224         mod =current
02225         string sModValue
02226         dbProjectReportGUI      = create ("Export Sample Project Report", styleCentered | styleFixed) //empty dialogbox creation
02227         
02228         dbeConfigFileList   = fileName(dbProjectReportGUI, "XML-Configuration-File: ","", "*.xml", "Extended Markup Language", true) //dialog box for capturing a file name
02229         GetConfigFile()
02230         
02231         msgDBE              = label(dbProjectReportGUI," ") //label in the DB
02232         ok(dbProjectReportGUI, "Export to Word", Export)        //Ok button 
02233         show(dbProjectReportGUI)        //enable the DB, suspend the dxl
02234 }
02235 /* end of functions */
02236 
02237 
02238 
02239 /**
02240 * \XML file initialization 
02241 * \create auto object....
02242 * \Specifies whether asynchronous download is permitted...........
02243 * \Indicates whether external definitions, resolvable namespaces, document type definition (DTD) external subsets, and external entityreferences,are * to be resolved at parse time, independent of validation....
02244 */
02245 /* Create OLE-Object xmldoc - the XML properties are used to initialize the OLE object */
02246 xmldoc = oleCreateAutoObject("Msxml2.DOMDocument") 
02247 olePut(xmldoc, "async", false) //Specifies whether asynchronous download is permitted.
02248 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.
02249 
02250 ///GUI initialization to fetch the configuration file
02251 initGUI()