Create RTF File Table

Anybody have any luck creating an RTF-file directly, then simply opening it with MS-Word?

I've had some luck with basic RTF heading and color table stuff, but need to add a huge table directly with OLE diagrams in it.  I figure the code would look like this:

  • bufResults += "\{" and other table start commands
  • for each row
    • bufResults += some row commands
    • for each cell
      • bufCell = probeRichAttr_(o, Name1, YesOle)
      • combine(bufResults, bufCell, 0)
      • bufCell += "\cell "   / end of cell
    • bufResults += "\row "  // end of row
  • use a Stream to send bufResults to a file
  • Open word, command to open and display the file

-Louie


llandale - Mon May 20 15:01:11 EDT 2013

Re: Create RTF File Table
adevicq - Wed May 22 03:31:17 EDT 2013

Hi,

I tried this long ago and lost the code. I remember that it was a real nightmare... Mostly about dealing with tables an pictures.

Have you envisaged to export in HTML instead? It is much easier and it is pretty simple to import HTML chunks into MS Word (via "putHTMLFragment").

Regards

Re: Create RTF File Table
llandale - Wed May 22 11:15:10 EDT 2013

adevicq - Wed May 22 03:31:17 EDT 2013

Hi,

I tried this long ago and lost the code. I remember that it was a real nightmare... Mostly about dealing with tables an pictures.

Have you envisaged to export in HTML instead? It is much easier and it is pretty simple to import HTML chunks into MS Word (via "putHTMLFragment").

Regards

HTML?  Gads, I'm struggling something awful with this "OLE" stuff.  I cannot remember anything so I have to write functions for EVERYTHING.

Re: Create RTF File Table
Richard_Good - Thu May 23 12:03:41 EDT 2013

llandale - Wed May 22 11:15:10 EDT 2013

HTML?  Gads, I'm struggling something awful with this "OLE" stuff.  I cannot remember anything so I have to write functions for EVERYTHING.

I am possibly missing something, but why not modify the unencrypted rtf exporter that comes with DOORS. This is how most company exporters are created they tend to be many times faster and more reliable than the exporters that interact with word directly. Make sure you have a copy of the RTF specification when you start, the first step is to create a few standard string constants for your rtf strings, especially if you plan to replicate diff functionality in word.

Re: Create RTF File Table
llandale - Thu May 23 13:12:06 EDT 2013

Richard_Good - Thu May 23 12:03:41 EDT 2013

I am possibly missing something, but why not modify the unencrypted rtf exporter that comes with DOORS. This is how most company exporters are created they tend to be many times faster and more reliable than the exporters that interact with word directly. Make sure you have a copy of the RTF specification when you start, the first step is to create a few standard string constants for your rtf strings, especially if you plan to replicate diff functionality in word.

What you are missing is that ... I forgot about the RTF exporter.  I hate it when that happens.  yes, that should go a long way to help.

Please explain your last sentance.

-Louie

Re: Create RTF File Table
Richard_Good - Wed May 29 08:02:35 EDT 2013

llandale - Thu May 23 13:12:06 EDT 2013

What you are missing is that ... I forgot about the RTF exporter.  I hate it when that happens.  yes, that should go a long way to help.

Please explain your last sentance.

-Louie

Hi Louie,

A few examples attached. I use the headers to produce a diff report in a word table where red and blue indicate deleted and inserted text. I use things like reduced font table to strip out the spurious rtf that can get into DOORS, but can't be seen which can mess up your exports.

Note that these sort of tools will be retired by RPE, which is pretty good and assuming your company has enough bags of gold for IBM is what I reccomend for any fancy export tasks, putting the colour table in your rtf headers is obviously very important for producing coloured markup - hope it helps.

Note that document headers need to define the various fonts that are used, paragraph rtf headers need to define much less. Don't envy you the joys of getting to know the RTF specification - usually best avoided if your sanity is imortant to you ;-)

Richard 

 

const string ReducedFontTable = "\\deff1{\\fonttbl
{\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}
{\\f1\\fswiss\\fcharset0 Arial;}
{\\f2\\froman\\fprq2\\fcharset2 Symbol;}
}"

const string DiffRepHeader = "{\\rtf1\\deff1000{\\fonttbl {\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}
{\\f1\\fswiss\\fcharset0 Arial;}
{\\f2\\froman\\fprq2\\fcharset2 Symbol;}
{\\f3\\fswiss\\fprq2\\fcharset128 Arial Unicode MS;}
{\\f4\\fswiss\\fprq2\\fcharset129 Arial Unicode MS;}
{\\f5\\fswiss\\fprq2\\fcharset130 Arial Unicode MS;}
{\\f6\\fswiss\\fprq2\\fcharset134 Arial Unicode MS;}
{\\f7\\fswiss\\fprq2\\fcharset136 Arial Unicode MS;}
{\\f8\\fswiss\\fcharset161 Arial;}
{\\f9\\fswiss\\fcharset162 Arial;}
{\\f10\\fswiss\\fcharset163 Arial;}
{\\f11\\fswiss\\fcharset177 Arial;}
{\\f12\\fswiss\\fcharset178 Arial;}
{\\f13\\fswiss\\fcharset186 Arial;}
{\\f14\\fswiss\\fcharset204 Arial;}
{\\f15\\fswiss\\fprq2\\fcharset222 Arial Unicode MS;}
{\\f16\\fswiss\\fcharset238 Arial;}
}
{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;}"

///////////////////////////////////////////////////////////
//  Variables
const string RTFHead = "{\\rtf1\\ansi\\deflang1024\\deff1{\\fonttbl
{\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}
{\\f1\\fswiss\\fcharset0 Arial;}
{\\f2\\froman\\fprq2\\fcharset2 Symbol;}
{\\f3\\fswiss\\fprq2\\fcharset128 Arial Unicode MS;}
{\\f4\\fswiss\\fprq2\\fcharset129 Arial Unicode MS;}
{\\f5\\fswiss\\fprq2\\fcharset130 Arial Unicode MS;}
{\\f6\\fswiss\\fprq2\\fcharset134 Arial Unicode MS;}
{\\f7\\fswiss\\fprq2\\fcharset136 Arial Unicode MS;}
{\\f8\\fswiss\\fcharset161 Arial;}
{\\f9\\fswiss\\fcharset162 Arial;}
{\\f10\\fswiss\\fcharset163 Arial;}
{\\f11\\fswiss\\fcharset177 Arial;}
{\\f12\\fswiss\\fcharset178 Arial;}
{\\f13\\fswiss\\fcharset186 Arial;}
{\\f14\\fswiss\\fcharset204 Arial;}
{\\f15\\fswiss\\fprq2\\fcharset222 Arial Unicode MS;}
{\\f16\\fswiss\\fcharset238 Arial;}
}
{\\colortbl;\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0;\\red255\\green255\\blue0;\\red255\\green255\\blue255;\\red0\\green0\\blue128;\\red0\\green128\\blue128;\\red0\\green128\\blue0;
\\red128\\green0\\blue128;\\red128\\green0\\blue0;\\red128\\green128\\blue0;\\red128\\green128\\blue128;\\red192\\green192\\blue192;}\\paperw16840\\paperh11907\\margl1440\\margr1440\\margt1797\\margb1797
\\widowctrl\\ftnbj\\aenddoc\\noxlattoyen\\expshrtn\\noultrlspc\\dntblnsbdb\\nospaceforul\\hyphcaps0\\horzdoc\\dghspace120\\dgvspace120\\dghorigin1701\\dgvorigin1984\\dghshow0\\dgvshow3\\jcompress\\viewkind1\\viewscale84\\viewzk2\\nolnhtadjtbl \\fet0\\sectd
\\lndscpsxn\\psz9\\linex0\\sectdefaultcl"

 

Re: Create RTF File Table
llandale - Wed May 29 12:56:10 EDT 2013

Richard_Good - Wed May 29 08:02:35 EDT 2013

Hi Louie,

A few examples attached. I use the headers to produce a diff report in a word table where red and blue indicate deleted and inserted text. I use things like reduced font table to strip out the spurious rtf that can get into DOORS, but can't be seen which can mess up your exports.

Note that these sort of tools will be retired by RPE, which is pretty good and assuming your company has enough bags of gold for IBM is what I reccomend for any fancy export tasks, putting the colour table in your rtf headers is obviously very important for producing coloured markup - hope it helps.

Note that document headers need to define the various fonts that are used, paragraph rtf headers need to define much less. Don't envy you the joys of getting to know the RTF specification - usually best avoided if your sanity is imortant to you ;-)

Richard 

 

const string ReducedFontTable = "\\deff1{\\fonttbl
{\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}
{\\f1\\fswiss\\fcharset0 Arial;}
{\\f2\\froman\\fprq2\\fcharset2 Symbol;}
}"

const string DiffRepHeader = "{\\rtf1\\deff1000{\\fonttbl {\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}
{\\f1\\fswiss\\fcharset0 Arial;}
{\\f2\\froman\\fprq2\\fcharset2 Symbol;}
{\\f3\\fswiss\\fprq2\\fcharset128 Arial Unicode MS;}
{\\f4\\fswiss\\fprq2\\fcharset129 Arial Unicode MS;}
{\\f5\\fswiss\\fprq2\\fcharset130 Arial Unicode MS;}
{\\f6\\fswiss\\fprq2\\fcharset134 Arial Unicode MS;}
{\\f7\\fswiss\\fprq2\\fcharset136 Arial Unicode MS;}
{\\f8\\fswiss\\fcharset161 Arial;}
{\\f9\\fswiss\\fcharset162 Arial;}
{\\f10\\fswiss\\fcharset163 Arial;}
{\\f11\\fswiss\\fcharset177 Arial;}
{\\f12\\fswiss\\fcharset178 Arial;}
{\\f13\\fswiss\\fcharset186 Arial;}
{\\f14\\fswiss\\fcharset204 Arial;}
{\\f15\\fswiss\\fprq2\\fcharset222 Arial Unicode MS;}
{\\f16\\fswiss\\fcharset238 Arial;}
}
{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;}"

///////////////////////////////////////////////////////////
//  Variables
const string RTFHead = "{\\rtf1\\ansi\\deflang1024\\deff1{\\fonttbl
{\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}
{\\f1\\fswiss\\fcharset0 Arial;}
{\\f2\\froman\\fprq2\\fcharset2 Symbol;}
{\\f3\\fswiss\\fprq2\\fcharset128 Arial Unicode MS;}
{\\f4\\fswiss\\fprq2\\fcharset129 Arial Unicode MS;}
{\\f5\\fswiss\\fprq2\\fcharset130 Arial Unicode MS;}
{\\f6\\fswiss\\fprq2\\fcharset134 Arial Unicode MS;}
{\\f7\\fswiss\\fprq2\\fcharset136 Arial Unicode MS;}
{\\f8\\fswiss\\fcharset161 Arial;}
{\\f9\\fswiss\\fcharset162 Arial;}
{\\f10\\fswiss\\fcharset163 Arial;}
{\\f11\\fswiss\\fcharset177 Arial;}
{\\f12\\fswiss\\fcharset178 Arial;}
{\\f13\\fswiss\\fcharset186 Arial;}
{\\f14\\fswiss\\fcharset204 Arial;}
{\\f15\\fswiss\\fprq2\\fcharset222 Arial Unicode MS;}
{\\f16\\fswiss\\fcharset238 Arial;}
}
{\\colortbl;\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0;\\red255\\green255\\blue0;\\red255\\green255\\blue255;\\red0\\green0\\blue128;\\red0\\green128\\blue128;\\red0\\green128\\blue0;
\\red128\\green0\\blue128;\\red128\\green0\\blue0;\\red128\\green128\\blue0;\\red128\\green128\\blue128;\\red192\\green192\\blue192;}\\paperw16840\\paperh11907\\margl1440\\margr1440\\margt1797\\margb1797
\\widowctrl\\ftnbj\\aenddoc\\noxlattoyen\\expshrtn\\noultrlspc\\dntblnsbdb\\nospaceforul\\hyphcaps0\\horzdoc\\dghspace120\\dgvspace120\\dghorigin1701\\dgvorigin1984\\dghshow0\\dgvshow3\\jcompress\\viewkind1\\viewscale84\\viewzk2\\nolnhtadjtbl \\fet0\\sectd
\\lndscpsxn\\psz9\\linex0\\sectdefaultcl"

 

Something has to exist for it to be important.

Your original idea hit the mark, monkey-see-monkey-do for "rtfexp.exe".

You'd be shocked to notice the difference in the very end of the report between:

Took me 2 days to track that one down.  I'm exporting a table with a header and 2 rows.  The 1st one finally worked.  the 2nd one caused MS-Word to put the header row on each new page, but tried to make an infinite number of pages.  Kept having to cancel MS-Word.

Anyway the basics are now working, thanks.

-Louie