Page 1 of 1

TRichViewEdit - RTF - Read file

Posted: Wed Feb 27, 2013 4:47 pm
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.

Posted: Wed Feb 27, 2013 5:20 pm
by Sergey Tkachenko
Please create a simple test project and send it to richviewgmailcom

Posted: Thu Feb 28, 2013 10:08 am
by Graham
Demo created and sent. let me know if you don't get it.

Posted: Fri Mar 01, 2013 9:27 pm
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.