Author Topic: Difference between pre/post RTF notes  (Read 3977 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Difference between pre/post RTF notes
« 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:
Code: [Select]
<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 "&lt;" and "&gt;".
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


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Difference between pre/post RTF notes
« Reply #1 on: August 14, 2009, 05:06:44 pm »
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:
Code: [Select]
//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);

Shawn Stepper

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: Difference between pre/post RTF notes
« Reply #2 on: December 19, 2009, 09:14:20 am »
I get an internal application when I try this using JScript in the Automation Interface. Has anyone else had this issue?

Code: [Select]
var Notes = theElement.Notes;
var newRTF = Repository.GetFormatFromField("RTF", Notes);
var internal = Repository.GetFieldFromFormat("RTF ", newRTF);

EDIT: Oops. I had a space after RTF.  ::)
« Last Edit: December 22, 2009, 06:52:03 am by shawn.e.stepper »