Author Topic: docGenerator & Diagram captions with document section number prefixing the Figur  (Read 67 times)


  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
I have copied paragraphs from a large MS-Word document and pasted them into Artifact Document Linked Documents. Each Artifact Document element contains one or more paragraphs. Each Artifact Document element is contained in a package. In the Sparx project browser, there are also Sparx diagrams nestling between the Artifact Document elements.
My automation script prints the selected package as an RTF document. My Jscript includes recursive function recursiveDocGen that drills through the package hierarchy and prints paragraphs and diagrams e.g.
•   docGenerator.InsertLinkedDocument(currentElement.ElementGUID);
•   docGenerator.DocumentDiagram( currentDiagram.DiagramID, 0, "my_diagram_rtf_fragment");

"my_diagram_rtf_fragment" generates a caption by including fields Diagram.Figure and Diagram.Name that were inserted from the Sparx RTF template editor.

The original MS-Word document includes the section number in the diagram caption e.g. Figure 5-1: Solution Strategy

The customer wants to see the same Figure numbering (section number prefix) in the caption beneath each diagram in the Sparx-generated document.

I have tried copying the MS-Word style reference codes from the caption of the MS-Word document into "my_diagram_rtf_fragment", but docGenerator prints the style reference code as a literal when printing the diagram caption. The printed document contains the printed literal 'STYLEREF' e.g. STYLEREF 1 \s- Figure  «STYLEREF» 1:Component Diagram Example.

The old trick of copying MS-Word style reference codes into an RTF Fragment works well for some MS-Word style reference codes but not for these codes.

I almost have a way round it.

My function recursiveDocGen can track & calculate which document section number is being generated. How can I insert a custom field (section number) into "my_diagram_rtf_fragment" as a prefix to Diagram.Figure?