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:

    Code
    TextReader.load_par.align := paralCenter;

    In WPTools5 I tried both:

    Code
    TextReader.CurrentParagraph.align := paralCenter;

    and:

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

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

    /Fredrik

    • Offizieller Beitrag

    This is how it should be done:

    Code
    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.

  • Zitat von wpsupport

    This is how it should be done:

    Code
    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