I am having a bit of an issue with displaying the requirements in M2Doc. I’m using the VP Requirements add-on and I’ve tried using the following query for the M2Doc code:
It seems that when I use “ReqIFText”, the word size and style isn’t taken over from the ones used to write the m2doc query. Instead, it uses the style from how the requirements themselves were written.
I’ve found that when I use “getText()” instead of “ReqIFText”, the word size and style are taken from the written m2doc query. However, it doesn’t do a line break, and when the text is too long for one line, it just shortens the text by the last words and replaces them with “…”
Is there a way to change the style/size manually in m2doc or to express the full text while using “getText()”?
The static style applied to the MS Word field that contains the AQL query should be applied in the generated document. It might be a bug, which version of M2Doc are you using ?
An other thing, you have a collection as the result of your query, you could try to use it with a for loop or to convert it as a String by adding ->toString(). It might help.
For the text being truncated with ... I don’t understand where it can come from…
You can also apply styles dynamically for text and table but you will need to create a Java service and import it to your template using the template properties wizard. Your service need to return a MText with a MStyle (see special return types).
Let me know if any of this helps. Also if you can create a small example so I can reproduce the issue it would be nice. This looks like a bug.
Unfortunately adding “->toSting” did not solve the problem.
I have created a small example which is attached to this message. In my original version I only used the term “ReqIFText” (as mentioned in my last message). Now I had to add “fromHTMLBodyString” because otherwise the HTML expressions would also be printed as text, which wasn’t the case before (I don’t know what I changed there).
However, the problem remains that “getText()” does not print the full text and “ReqIFText.fromHTMLBodyString” does not have the same word style and size as the M2Doc query statement.
It seems like all the text is styled with title1 but only the first line use the style of title1. I don’t know why, but I tried to apply the normal style and after that the first call using the from HTML service inserted the style from the requirement. Let me know if it’s working for you as well ?
The getText() service is used by Capella to display any EObject as a string and it truncate the resulting string if it’s too long. I have no idea why it was using the style from the requirement… There is probably something to investigate.
Right, I didn’t realise that for some reason all the sentences were styled as title1.
However, were you able to change the style in the result file to the style used for the M2Doc expression or did you change the style/size of the requirements themselves?
Because unfortunately using the ReqIfText I only get the style of the requirement and not the one used for the AQL expressen or is there another way perhabs?
My question arises from the fact that I am importing several different requirements from Doors which do not have the same text style. Therefore, I would like to print them in my M2Doc document with the same uniform style as the rest of the file.
I removed the style title1 for the AQL expression and it applied the HTML style from the requirement. Yes, the applied style in the template is applied in the generated document. Note that the style can also be overridden by the HTML code. For instance if you change the background color in the template and HTML/CSS code also change the background color the background color from HTML/CSS will be applied.
The modified template with a background color applied:
For your need, you might need to write a service to remove all MStyle attached to MElement returned by the from HTML service. You can find an example of service that change the target of HTML link to give you an idea of how to walk MElement.