Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Geert Bellekens on August 12, 2009, 11:42:46 pm
-
Hi,
I'm having a bit of a problem with a little tool I'm writing.
At my client we have an xml like form of structured notes.
example:
<Version>1.5.7</Version>
<Description>
Description text
</Description>
... other tags...
I'm writing an editor for these notes so the users don't make mistakes with the tags and stuff.
Since the rich text feature was added EA stores the formatting information also in tags (like <b>bold text</b>). The opening "<" and ">" in the text that are not part of the formatting commands get replaced by "<" and ">".
This is good news because I now have a way to differentiate between our own tags and the tag of the EA formatting allowing me to parse the content of the notes with an xml parser (without taking into account the formatting tags).
The problem is with the notes that have been edited before we upgraded to 7.5. These are all still in plain text with actual "<" and ">" characters.
The moment you touch such a note in EA (UI) the "<" and ">" characters are replaced.
Does anyone have an idea how I could work around this?
I would love to have an option changeToPost7.5Format, but I don't think that is available.
Thanks
Geert
-
Well,
I found a workaround: Converting to RTF and then converting back to the default EA format seems to do the trick.
My code looks like this:
//get the comment as it is stored in EA
string rawComment = Element.getComment();
// convert to RFT and back to let EA make the difference between textual tags <> and formatting tags
string rftComment = Repository.GetFormatFromField("RTF", rawComment);
string defaultComment = Repository.GetFieldFromFormat("RTF", rftComment);
-
I get an internal application when I try this using JScript in the Automation Interface. Has anyone else had this issue?
var Notes = theElement.Notes;
var newRTF = Repository.GetFormatFromField("RTF", Notes);
var internal = Repository.GetFieldFromFormat("RTF ", newRTF);
EDIT: Oops. I had a space after RTF. ::)