Insertion of legends for images embedded in Capella description

64 Views Asked by At

M2doc already provides several services on the descriptions of Capella elements. For example substitutions of hypertext links, autosize of images, etc.

I need to be able to insert legends under each image or table coming with a Capella description. I believe this would require the development of a specific service, but I would like to have a first feedback on the feasibility.

One of the difficulty I see is the following one: I am thinking for example that for such legends to appear in a consolidated table of figures at the end of the generated document, the legends would need to have a specific style. Would a Java M2Doc service be able to take a style as a parameter?

Thank you very much,

Stéphane

1

There are 1 best solutions below

1
Yvan Lussaud On

You can apply an existing style to a text or a table with the asStyle() service. You can apply the style in a comment block to make sure it's present in the template. You can also use availableTextStyles() and availableTableStyles() on any object to get the list of available styles in your template.

But for what you want to do, you will need to create a service that works on a List of MElement and find and change the style of wanted MText elements. You might also need to create new MText to get sub parts of existing MText. Then you can creat a MParagraph containing the wanted MText with the wanted style ID:

new MParagraphImpl(new MTextImpl(text, null), styleID)

I'm not sure it will be enough to have the numbering working since it might not be included in the style itself. For the numbering, you can use the availableNumberingIDs() service on any object to get a list of available numbering IDs in your template. you can the use the setNumbering() on a MParagraph to set the numbering and level. Programmatically, you can use:

paragraph.setNumberingID(Long.valueOf(numberingID));
paragraph.setNumberingLevel(Long.valueOf(level));