TRichViewEdit - RTF - Read file

General TRichView support forum. Please post your questions here
Post Reply
Graham
Posts: 64
Joined: Sun Jan 27, 2013 7:51 pm
Location: Berkshire U.K.

TRichViewEdit - RTF - Read file

Post by Graham »

I create 3 new text and 3 new paragraph styles in my TRVStyle component.

Create some text using these styles and save the file as RTF.

When I load the file back I get, what appears to be a conflicting set of requirements.

If I have the TextStyleMode and ParaStyleMode set to rvrsAddIfNeeded it seems to always add the styles to my list. It doesn't use the existing styles. So the colours of the text are correct but the style numbers are different.

If I set the StyleModes to rvrsClosest, it is now correct and is using the preset styles I have created.

But the problem now is that if I have some "Hidden" text or just some randomly coloured text (not one of my 3 predefined styles), I cannot load this back.

So I am forced to use rvrsAddIfNeeded. So what do I have to do to make this work and not behave as if it is rvrsAddAlways.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please create a simple test project and send it to richviewgmailcom
Graham
Posts: 64
Joined: Sun Jan 27, 2013 7:51 pm
Location: Berkshire U.K.

Post by Graham »

Demo created and sent. let me know if you don't get it.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I confirm the problem, it happens because of saving BiDiMode. Your document is LTR, so TRichView saves LTR text direction in RTF (except for RTL paragraphs).
And all text styles loaded from RTF become LTR instead of Unspecified.

I implemented resetting BiDiMode of text to Unspecified if it has the same BiDiMode as the parent paragraph/document. Additionally, some correction for saving is required.
It will be included in the next update. Let me know if you need this fix urgently.

PS: small correction to you demo: do not call Format after Clear before loading. It adds an empty line, you can see it before the loaded RTF content.
Post Reply