Woes with RTF tables

If i use the following DXL:
 

void dbReleaseMe(DB box) {
    hide(box)
    destroy(box);
}
 
void testMe() {
    string rtfString;
    
    rtfString = "{\\rtf1\\ansi\\deff0
\\trowd
\\cellx1000
\\cellx2000
\\cellx3000
cell 1\\intbl\\cell
lots of text in cell two\\intbl\\cell
cell 3\\intbl\\cell
\\row
}";
 
    DB box = centered("RTF Table Test");
    bool readOnly = true;
 
    DBE field1 = richText(box, "Table: ",  richText(rtfString), 400, 200, readOnly);
    close(box, false, dbReleaseMe);
    show(box)
}
 
testMe();

 


to display a RTF table, the content within cell2 is not wrapped within the cell's boundaries. The same is true if this RTF is posted into an Object's text.

Also, editing the resulting table within the Object text is very, very limited.

To top all this, the following slight change in the DXL script hangs my DOORS 9.2.0.1. in an endless loop (well, an old version but i think thats still ridiculous giving the long history of DOORS):

 

 

 

[ ... ]
 
    rtfString = "
{\\rtf1\\ansi\\deff0
\\trowd
\\cellx1000
\\cellx2000
\\cellx3000
cell 1\\intbl\\cell
lots of text in cell two\\intbl\\cell
cell 3\\intbl\\cell
\\row
}";
 
[ ... ]



To wrap this up: Should i better give up on RTF tables and use embedded OLE Objects like anybody else? This feels sooo 1990-ish....

Regards,
Peter



 

 


peter_schaefer - Wed Mar 28 05:59:58 EDT 2012

Re: Woes with RTF tables
llandale - Wed Mar 28 11:18:29 EDT 2012

When I run your code I get "cell 1" on the 1st line. 2nd line is the table, 1st cell is empty, 2nd cell has "lots of text in cell two" correctly wrapped, and "cell 3" in cell 3. When I add more text to cell 2, it wraps and makes the table taller to fit.

When I insert "\\intbl\\cell" above "cell 1" in the code, "cell 1" appears in cell 2, text of 2 in 3, and text of 3 is missing.

I'm guessing MS-Word or Office-2010 has some global setting about word-wrapping.

As for your question, I'm pretty sure you can manipulate these codes to do what you want. When I deal with RTF tables, I just copy them from DOORS, paste and edit in MS-Word, then copy back when done.

-Louie

Re: Woes with RTF tables
SystemAdmin - Mon Apr 02 04:15:26 EDT 2012

The spec for RTF Tables is a mess!

It requires that each paragraph in a cell has the "\intbl" control word (I think it is inherited from the previous paragraph if "\pard" is not set).
This meaans that an rtf string can't just be put in a table cell without first processing it to put the "\intbl" control word in each paragraph. The DXL function richtextFragment can do this.
But in addition, nested tables are a mess! These also require special formatting so if your RTF string already contains a table and you try to put it in another table cell it wont work. You need to change the formatting of the original table to have the nested formatting control words. I've never bothered to look into the details of this because I think I tested and found DOORS 9 dosen't support nested tables anyway - can't remember.

Wish RTF just used the current context of the markup to do it's formatting. It must know it is a nested table if it is already in a table after all! Legacy spec I guess with table bolted on as an after thought and then nested tables after that.

Anyway, for your RTF string to work I put the "\intbl" to the begining of the cell:

rtfString = "{\\rtf1\\ansi\\deff0
\\trowd
\\cellx1000
\\cellx2000
\\cellx3000
\\intbl
cell 1\\cell
\\intbl
lots and lots and lots and lots of text in cell two\\cell
\\intbl
cell 3\\cell
\\row
}";

 


Adam