/* ExtractRequirementFromTables.dxl Ce script est a utiliser sur un Module formel apres importation d'un document Word où les exigences sont décrites chacune dans une table de quatre cellules, le style attribué au contenu de chaque cellule permettant de définir : - la référence de l'exigence - sa description (texte) - la ou les références des exigences amont (origine) - la conformité à ces exigences d'origine. This script must be used on a Formal Module after export from Word document where requirements are each defined in a 4 cells table. In Word document, Style is used in each cell to define - Requirement identification - Requirement description - Target Requirement - Conformity with this (or these) target requirements V1.0 Pierre Dubarry ELTA 22 octobre 2009 */ Module CeModule = current Object ObjetEnCours = current int offset = null int length = null bool matchCase = false bool reverse = false string ReferenceStyle = "" string ReferenceAttri = "" string TexteStyle = "" string TexteAttri = "" string OrigineStyle = "" string OrigineAttri = "" string ConformStyle = "" string ConformAttri = "" bool ExigenceTrouvee = false string StyleParagrapheCellule = "" string Ex_Nom = "" string Ex_Texte = "" string Ex_Origine = "" string Ex_ConformiteOrigine = "" // verification si l'attribut 'WEXP Template' existe // verification if 'WEXP Template' attribut exist if ((ad = find(CeModule, "WEXP Template")) == null) { bool reponse reponse = confirm ( "Before execute this script, you can : \n \ - import attributs in this module from a template module\n \ - export from a template module some views.\n\n\n \ If you clic on 'Cancel', this script stop \n \ If you clic on 'Confirm', this script continue, \n and 'WEXP Template' attribut is created", msgError) if (reponse == false) { halt } } // creation si necessaire de l'attribut 'WEXP Template' if ((ad = find(CeModule, "WEXP Template")) == null) { /***** this if 'WEXP Template' attribut must be an enumeration if ((at = find(CeModule, "YOUR Object Type")) == null) { setRealColorOptionForTypes(true) string names_99[] = {"Requirement", "DeletedRequirement", "Information"} int values_99[] = {1,2,3} int colors_99[] = {realColor_Red, realColor_Grey66, realColor_Black} mess = "" atttributType = create("YOUR Object Type", names_99, values_99, colors_99, mess) if (!null mess) print "Type creation failed\n" } create object type "YOUR Object Type" attribute "WEXP Template" *****/ /***** this if 'WEXP Template' attribut must be Text */ create object type "Text" attribute "WEXP Template" } // definition du panneau de saisie /********************* DB AttributsExigencesDB = create("Saisie des attributs des exigences en regard des styles Word", styleCentered) label (AttributsExigencesDB, "Les exigences, importees depuis WORD, sont dans des tableaux de 4 cellules contenant :") label (AttributsExigencesDB, " - la reference de l'exigence,") label (AttributsExigencesDB, " - sa description, qui ira dans l'attribut 'Object Text',") label (AttributsExigencesDB, " - la reference de l'exigence d'origine,") label (AttributsExigencesDB, " - la conformite a cette exigence d'origine") separator AttributsExigencesDB label (AttributsExigencesDB, " Saisir SOIGNEUSEMENT les chaînes correspondant aux Styles Word et aux attributs") label (AttributsExigencesDB, " Prendre en comptge le template .dot pour le nom des attributs a definir") separator AttributsExigencesDB label (AttributsExigencesDB, " Style WORD Attribut correspondant") *******************************/ // panel inputs DB AttributsExigencesDB = create("WORD style facing DOORS attributs", styleCentered) label (AttributsExigencesDB, "Requirements imported from Word are in 4 cells tables with inside:") label (AttributsExigencesDB, " - Requirement identification,") label (AttributsExigencesDB, " - Requirement description, which will go in attribut 'Object Text',") label (AttributsExigencesDB, " - Identification of target requirement,") label (AttributsExigencesDB, " - Conformity of this requirement with target requirement") separator AttributsExigencesDB label (AttributsExigencesDB, " Please define CAREFULLY strings for Word styme names and attributs names") separator AttributsExigencesDB label (AttributsExigencesDB, " WORD Style DOORS Attribut") separator AttributsExigencesDB // référence label (AttributsExigencesDB, "REFERENCE") DBE ReferenceStyleDBE = field(AttributsExigencesDB, "Style", "", 30, false) DBE ReferenceAttriDBE = field(AttributsExigencesDB, "Attribut", "", 30, false) ReferenceStyleDBE->"right"->"unattached" ReferenceAttriDBE->"left"->"flush"->ReferenceStyleDBE ReferenceAttriDBE->"top"->"aligned"->ReferenceStyleDBE // texte label (AttributsExigencesDB, "TEXT") DBE TexteStyleDBE = field(AttributsExigencesDB, "Style", "", 30, false) DBE TexteAttriDBE = field(AttributsExigencesDB, "Attribut", "Object Text", 30, true) TexteStyleDBE->"right"->"unattached" TexteAttriDBE->"left"->"flush"->TexteStyleDBE TexteAttriDBE->"top"->"aligned"->TexteStyleDBE // origine label (AttributsExigencesDB, "ORIGINE") DBE OrigineStyleDBE = field(AttributsExigencesDB, "Style", "", 30, false) DBE OrigineAttriDBE = field(AttributsExigencesDB, "Attribut", "", 30, false) OrigineStyleDBE->"right"->"unattached" OrigineAttriDBE->"left"->"flush"->OrigineStyleDBE OrigineAttriDBE->"top"->"aligned"->OrigineStyleDBE // conformité label (AttributsExigencesDB, "CONFORMITY") DBE ConformStyleDBE = field(AttributsExigencesDB, "Style", "", 30, false) DBE ConformAttriDBE = field(AttributsExigencesDB, "Attribut", "", 30, false) ConformStyleDBE->"right"->"unattached" ConformAttriDBE->"left"->"flush"->ConformStyleDBE ConformAttriDBE->"top"->"aligned"->ConformStyleDBE separator AttributsExigencesDB /****************** label (AttributsExigencesDB, "Pour valider et lancer la transformation, cliquer sur VALIDER") label (AttributsExigencesDB, "Si non, cliquer sur Close") *******************/ label (AttributsExigencesDB, "If you are OK, clic on EXECUTE") label (AttributsExigencesDB, "In other case, clic on Close") //###TransformationExigences() void TransformationExigences(void) { // creation des chaines recherchees ensuite dans l'attribut 'Paragraph Style' string ReferenceParagraphStyle = "" string TexteParagraphStyle = "" string OrigineParagraphStyle = "" string ConformParagraphStyle = "" // creation des attributs create object type "Text" attribute ReferenceAttri create object type "Text" attribute OrigineAttri create object type "Text" attribute ConformAttri //creation VUE : 90_ExigencesImportees ######### Column c int i, n = 0 // delete existing columns for c in current Module do n++ for i in 1:n do delete(column 0) // create columns c = insert column 0 title(c, "Reference") attribute(c, ReferenceAttri) width(c, 85) justify(c, left) c = insert column 1 title(c, "Description") main(c) graphics(c) info(c) width(c, 535) justify(c, left) c = insert column 2 title(c, "Type") attribute(c, "WEXP Template") width(c, 85) justify(c, left) c = insert column 3 title(c, "Origin") attribute(c, OrigineAttri) width(c, 93) justify(c, left) c = insert column 4 title(c, "Origin Conformity") attribute(c, ConformAttri) width(c, 62) justify(c, left) // module settings level(0) graphics(false) outlining(false) showTables(true) showDeletedObjects(false) showExplorer(current Module) // save view save(view("90_ImportedRequirements")) // transformation des exigences sous forme de table en exigence Objet avec attributs for ObjetEnCours in all CeModule do { //print ObjetEnCours."Absolute Number" " --> " (table ObjetEnCours) "\n" if (table ObjetEnCours) { Object rowHead ExigenceTrouvee = false StyleParagrapheCellule = "" Ex_Nom = "" Ex_Texte = "" Ex_Origine = "" Ex_ConformiteOrigine = "" for rowHead in table ObjetEnCours do { Object cell for cell in row rowHead do { StyleParagrapheCellule = cell."Paragraph Style" "" if (findPlainText (StyleParagrapheCellule, ReferenceParagraphStyle, offset, length, matchCase, reverse) ) { Ex_Nom = cell."Object Text" "" ExigenceTrouvee = true } else if (findPlainText (StyleParagrapheCellule, TexteParagraphStyle, offset, length, matchCase, reverse) ) { Ex_Texte = cell."Object Text" "" } else if (findPlainText (StyleParagrapheCellule, OrigineParagraphStyle, offset, length, matchCase, reverse) ) { Ex_Origine = cell."Object Text" "" } else if (findPlainText (StyleParagrapheCellule, ConformParagraphStyle, offset, length, matchCase, reverse) ) { Ex_ConformiteOrigine = cell."Object Text" "" } else { // continue } } } if (ExigenceTrouvee == true) { // creation de l'objet qui va contenir l'exigence Object NouveauObjet = create after ObjetEnCours // report des informations de l'exigence NouveauObjet.ReferenceAttri = Ex_Nom NouveauObjet."Object Text" = Ex_Texte NouveauObjet.OrigineAttri = Ex_Origine NouveauObjet.ConformAttri = Ex_ConformiteOrigine NouveauObjet."WEXP Template" = "Requirement" // destruction definitive du tableau ayant contenu l'exigence deleteTable (ObjetEnCours) } continue } } // print "FIN\n" } //### TransformationExigences() void SaisieAttributsExigences(DB winDB) { ReferenceStyle = get(ReferenceStyleDBE) ReferenceAttri = get(ReferenceAttriDBE) TexteStyle = get(TexteStyleDBE) TexteAttri = get(TexteAttriDBE) OrigineStyle = get(OrigineStyleDBE) OrigineAttri = get(OrigineAttriDBE) ConformStyle = get(ConformStyleDBE) ConformAttri = get(ConformAttriDBE) TransformationExigences() destroy(winDB) } apply(AttributsExigencesDB, "EXECUTE", SaisieAttributsExigences) show(AttributsExigencesDB) s) sh