SaveToStream with a custom writer

  • In version 4 you had methods SaveToStreamWithWriter and LoadFromStreamWithReader

    Now you seem to need to use SaveToStream(stream, classNameOfWriter)

    Do you have to have registered this writer in some way?

    Later...

    Yes it seems you do - here's the bit of code that does this from WPIOHTML.pas

    if GlobalWPToolsCustomEnviroment <> nil then
    begin
    GlobalWPToolsCustomEnviroment.RegisterReader([TWPHTMLReader]);
    GlobalWPToolsCustomEnviroment.RegisterWriter([TWPHTMLWriter]);
    end;

    The problem I have now is - how do I set any properties of the writer at runtime if I don't create it? I can't see any events that would let me do this.

  • Zitat von wpsupport


    I could add an event which lets you do this, sonmething like BeforeLoadWithReader

    A BeforeSaveWithReader event would also be helpful since I have the same problem. I need to set some properties to my custom reader and writer.

    Will this change be included in the upcoming release 10?

    /Fredrik

    • Offizieller Beitrag

    This has been already added but it is no event of the TWPRichText.

    It is an event of the TWPRTFDataCollection (= WPRichText1.HeaderFooter) and must be assigned in code:

    The event definitions are:

    The TWPRTFDataCollection event properties are:

    property BeforeLoadFromStream: TWPIOLoadWithReader;
    property AfterLoadFromStream: TWPIOAfterLoadWithReader;
    property BeforeSaveToStream: TWPIOSaveWithWriter;

    Julian

    • Offizieller Beitrag

    Hi,

    WPTools 5.10 now allows appending of options for the reader and writer to the format string, example: "WPTOOLS-onlybody"

    The additional parameters are parsed by the procedure SetOptions(optstr: string) which can be overriden in the reader and writer classes.

    This is the default implementation:

    Julian Ziersch