Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: RichText to MS-Word
Topic Summary:
Created On: 12-Nov-2003 21:50
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Judith Underwood, on Monday, November 24, 2003 5:00 PM

Answer:
It's true that there is a lot of extra junk in Microsoft's RTF files, but for your purposes it might be enough just to wrap your rtf with
{\rtf1 .... }, e.g.
{\rtf1{\strike The}{\ul the} big {\strike red}{\ul blue} fox{\ul }{\ul is}{\ul }{\ul here}}
This works for me (opening in Wordpad).

Judith Underwood
 12-Nov-2003 21:50
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I can generate text "reports" such that I can open them with MS-Word. I can also generate RichText reports such that I can set them to an attribute (obj.NameAttr = richText(Report)) or display them in a column (displayRich(Report)).

Given a RichText Report, doesn anybody know how I can export it such that it reads as rich text in MS-Word. Specifically, if i have a Bolded word in the report, can I make MS-Word bold it? I definately want to avoid the OLE export approach (oleMethod, etc) and prefer simply to put the rich text in a file and open the file in MS-Word.

- Louie
Report this to a Moderator Report this to a Moderator
 13-Nov-2003 16:19
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Not sure if this answers your question, but you can write the richText to a file with a ".rtf" extension and word will read it, as long as you remove the escape characters first.

So replace "\\" with "\".
replace "\{" with "{"
replace "\}" with "}"
replace "\*" with "*"
then write to the file.

the following text is the output from
string s = richText (current Object)."Object Text"
print s

\{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\{\\fonttbl\{\\f0\\fnil\\fprq1\\fcharset0 Times New Roman;\}\{\\f1\\fnil\\fcharset2 Symbol;\}\} \{\\colortbl ;\\red0\\green0\\blue0;\} \\viewkind4\\uc1\\pard\\cf1\\i\\f0\\fs20 this is italic\\i0 \\par \\b this is bold\\b0 \\par \\strike this is strikethrough\\strike0 \\par \\ul this is underlined\\ulnone gfrerewte.\\par \\b\\i this is bold and italic\\b0\\i0 \\par \\pard\{\\pntext\\f1\\'B7\\tab\}\{\\*\\pn\\pnlvlblt\\pnf1\\pnindent0\{\\pntxtb\\'B7\}\}\\li360 fhfgh\\par \{\\pntext\\f1\\'B7\\tab\}sfghsfg\\par \{\\pntext\\f1\\'B7\\tab\}hsfghsfg\\par \{\\pntext\\f1\\'B7\\tab\}sfgh\\par \}

the following has had the escape characters removed and is recognised by MS Word as RTF

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq1\fcharset0 Times New Roman;}{\f1\fnil\fcharset2 Symbol;}} {\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\i\f0\fs20 this is italic\i0 \par \b this is bold\b0 \par \strike this is strikethrough\strike0 \par \ul this is underlined\ulnone
gfrerewte.\par \b\i this is bold and italic\b0\i0 \par \pard{\pntext\f1\'B7\tab}{*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\li360 fhfgh\par
{\pntext\f1\'B7\tab}sfghsfg\par {\pntext\f1\'B7\tab}hsfghsfg\par {\pntext\f1\'B7\tab}sfgh\par }






-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 13-Nov-2003 17:06
User is offline View Users Profile Print this message


Judith Underwood

Posts: 35
Joined: 25-Sep-2002

If you have a module with lots of these things, try the rtf exporter in table mode, with the report column in your view. It looks like the source is readable so if you want to create your own rtf you could start from that. Word sometimes does unpredicable things if you try to just concatenate the "{\rtf1 ..... }" strings.

Judith Underwood

Edited: 13-Nov-2003 at 17:08 by Judith Underwood
Report this to a Moderator Report this to a Moderator
 21-Nov-2003 20:02
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Sorry, but I've been side tracked. The RichText I've actually got doesn't look like your example. For those who are interested, I'm retrieving the raw text from a couple of attributes, calling function deltaText found in Telelogic's 'delta.inc', and displaying the results.
string s1 = "The big red fox"
string s2 = "the big blue fox is here"
string OutString = deltaText(s1, s2, 8, 4)
print OutString.

After applying your changes, what I actually end up with is RichText that looks like this:

{\strike The}{\ul the} big {\strike red}{\ul blue} fox{\ul }{\ul is}{\ul }{\ul here}

If you paste that into a Text attribute, it looks good. If you paste that into an *.rtf file, MS-Word thinks its just text and it looks the same. I want to manipulate the above so it looks good in MS-Word.

- Louie

Edited: 21-Nov-2003 at 20:09 by Louie Landale
Report this to a Moderator Report this to a Moderator
 21-Nov-2003 20:53
User is offline View Users Profile Print this message


Alec Witham Crawford

Posts: 24
Joined: 2-Jul-2003

I think Microsoft puts a lot of extra stuff into their rtf files. You might be better off opening Word as a COM object and adding the info that way.

Alec
Report this to a Moderator Report this to a Moderator
 23-Nov-2003 14:50
User is offline View Users Profile Print this message


Judith Underwood

Posts: 35
Joined: 25-Sep-2002

Answer Answer
It's true that there is a lot of extra junk in Microsoft's RTF files, but for your purposes it might be enough just to wrap your rtf with
{\rtf1 .... }, e.g.
{\rtf1{\strike The}{\ul the} big {\strike red}{\ul blue} fox{\ul }{\ul is}{\ul }{\ul here}}
This works for me (opening in Wordpad).

Judith Underwood
Report this to a Moderator Report this to a Moderator
 24-Nov-2003 17:18
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

This seemed to work, as follows: any end-of-line markers (CRs) need to be "{\\par}". Tabs separating future MS-Word table cells can be normal tabs "\t". Once you build the entire text file, append "{\\rtf1 " to the front and "}" to the end. Write it to a "*.rtf" file. Open it with MS-Word.

Thanks to Goodman and Underwood.

- Louie
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 0 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 0 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.