LoadRTF don't import parastyle

General TRichView support forum. Please post your questions here
Post Reply
christophevigneault
Posts: 2
Joined: Fri Jul 31, 2015 1:28 pm

LoadRTF don't import parastyle

Post by christophevigneault »

Why does my parastyle disappear when i'm importing this text with LoadRTF() ?

Code: Select all

{\rtf1\fbidis\ansi\ansicpg0\uc0\deff0\deflang0\deflangfe0{\fonttbl{\f0\fnil Arial;}}{\colortbl;\red0\green0\blue255;\red0\green0\blue128;\red128\green0\blue0;\red0\green128\blue0;}{\stylesheet{\s0\fi0\li0\ql\ri0\sb0\sa0 Paragraph Style;}{\s1\fi0\li0\qc\ri0\sb0\sa0 Centered;}{\s2\fi0\li0\ql\ri0\sb0\sa0 SignatureElectronique;}{\*\cs3\f0\fs18 Normal;}{\*\cs4\f0\b\fs20\cf1 Heading;}{\*\cs5\f0\b\fs20\cf2 Subheading;}{\*\cs6\f0\i\fs20\cf3 Keywords;}{\*\cs7\f0\ul\fs20\cf4 Jump 1;}{\*\cs8\f0\ul\fs20\cf4 Jump 2;}}
\pard\s2\fi0\li0\ql\ri0\sb0\sa0\itap0 \plain \cs3\f0\fs18 _____________________
\par 
\par Signature
\par 
\par _____________________\par}
Sergey Tkachenko
Site Admin
Posts: 17306
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

When you export to RTF and then import it, the list of TextStyles and ParaStyles is not the same as it was initially.
When importing RTF, TRichView fills TextStyles and ParaStyles basing on text and paragraph attributes that are actually used in RTF. Style sheet is not imported in TextStyles and ParaStyles.
When exporting RTF, there is an option to export TextStyles and ParaStyles as a style sheet, but there is no option for importing it back. Why? Because a style sheet entry, in general case, may contain both properties of text and paragraphs, and only a subset of them, and it cannot be represented in TextStyles and ParaStyles.
To make sure that text and paragraph attributes from RTF are imported, right click TRichView at designtime, choose "Settings" in the context menu, select "Allow adding styles dynamically"
---
There is a way for both exporting and importing style sheet in RTF, but in TRichView it must be stored not in TextStyles and ParaStyles, but in StyleTemplates. This mode can be activated from "Settings" as well, choose "Allow adding styles dynamically + style templates".
More about styles: http://www.trichview.com/help/styles_an ... lates.html
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

I had the same challenge. So I had to decide:

1. Get my text back exactly as saved
or
2. Stay compatible with other software as Word, OO aso.

The solution for 1 is to save files as RVF instead of RTF. In this case all text- and para-properties are stored in the file, including the style numbers. Only in this case you can be sure to have the same text after reopening.

The problem is that rtf only contains the style properties (color, size, font name ...) but not the style number the item is made with. In case of reloading the file you may have a lot of auto-defined styles, if TRichView can't assign an item to text- or para-style because of exact - or nearest - similarity.
Sergey Tkachenko
Site Admin
Posts: 17306
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, it's not possible to get exactly the same document after exporting and then importing from RTF (it may be the same only by a coincidence). A document may look exactly the same as original, but internally it is different.

But if you use StyleTemplates ("real styles"), they will be the same after exporting and then importing from RTF.

---

RichView Format (RVF) is more or less direct representation of TRichView document, so saving RVF and then loading it produces the same document.
Post Reply