WPCubed Product Support

Custom text reader and current paragraph

Hi!

I'm porting my custom text reader from WPTools4 to WPTools5 and can't understand how it's suppose to work.

In WPTools4 I used to do for example:

TextReader.load_par.align := paralCenter;

In WPTools5 I tried both:

TextReader.CurrentParagraph.align := paralCenter;

and:

TextReader.CurrentParagraph.ASet(WPAT_Alignment, Integer(paralCenter));

But none of this works. What am I doing wrong?

/Fredrik

#1 ♥ 0
5.6k Views 2 users read 2 min
support

This is how it should be done:

CurrentParagraph.ASet(WPAT_Alignment, Integer(paralCenter));

Usually you do this somehwre in the Parse() function of your custom reader. You can also use FCurrentParagraph for for optimation.

Maybe the attributes are not set at all or cleared later?

Julian Ziersch

BTW: TextReader.CurrentParagraph.align := paralCenter; should not be used in new code. "align" has been implemented only to improve compatibility.

#2 ♥ 0

@wpsupport:
This is how it should be done:

CurrentParagraph.ASet(WPAT_Alignment, Integer(paralCenter));

Usually you do this somehwre in the Parse() function of your custom reader.

I do this in the Parse() function. But I found out that when I set WithClear to true it works (in the LoadFromStream function). If WithClear is set to false it does not work.

The problem now is that when WithClear is true all my styles gets deleted.

I saw that the TWPCustomRtfEdit.LoadFromStream calls TWPCustomRtfEdit.Clear which calls TWPRTFDataCollection.Clear with no parameters which means delete all styles.

To delete the RTFProps.Locked must be false. Is that something I can use to avoid all my styles getting deleted? Or do you have any other ideas?

This seems to have changed a lot since version 4.

/Fredrik

#3 ♥ 0
support

Hi,

You can do a
Clear(false);
and then
LoadFromFile

Or, as you said, use RTFProps.Locked
(When property Locked is set to TRUE clearing the RTFDataCollection
will not clear the styles and tables)

Julian

#4 ♥ 0
This category is archived. No new posts are possible.