Bullets lost from bulleted lists when using FastAppendText

  • I have an app in which I compose a "master" document from a bunch of smaller ones. All of these are WPTools documents. Composing the master document is done using FastAppendText.

    There is a problem that if any of the smaller docs contain bulleted lists, the bullets are lost, i.e. they do not appear in the master document. Numbered lists seem to be ok. The list text is seen as expected, but just the bullet marks are not visible.

    I already got advice from support to use the same RTFDataCollection for both (all) RTF engines, but I'm at loss how to do that, so I would appreciate a sample or any other "for dummies" level help.

    I'm currently using WPTools version 6.05.8 and Delphi 2007.


    TIA,
    Antti Kurenniemi

    • Offizieller Beitrag

    Hi,

    Using "the same RTFDataCollection" requires the use of the event OnInitializeRTFData.

    Please see here:
    https://www.wpcubed.com/manuals/wptool…lizeRTFData.htm

    Here You can create a TWPRTFProps
    or a TWPRTFDataCollection object and assign it to the var parameter. The defaukt is <nil> and means it will create the required object on its own.

    There is a demo under tasks "GlobalStyle" which uses this technique. Alos interesting demo "MailM4".

    Julian

    (Edited: referred to OnInitializedRTFData which was wrong)

  • Hiya,


    thanks, I got a bit further now: it works correctly when all the editors involved are visual, created at design time, but not when there is an editor created dynamically at runtime (i.e. for reading the content from database).

    I added an OnInitializedRTFData event for the dynamically created edit as well, and have checked that it gets called. It is assigning the same WPGlobalRTFProps object as for the other (visual) editors which is created in the form create event.

    What should I do to create the editor dynamically? Right now (for this test anyway) I'm not doing anything except

    Code
    TempEditor := TWPRichText.Create(nil);TempEditor.OnInitializedRTFData := Initialize_Temp;

    And in the Initialize_Temp

    Code
    RTFPropsObject := WPGlobalRTFProps;
  • I have further information about this. Seems the problem comes from where I load the editor content from the database. I load it from a Blob field and assign it to my "temp" editor (non-visual, created dynamically) using AsString - after this the formatting is wrong.

    I tested assigning the text to the "temp" editor using FastAppendText, and then from there on to the "master" editor, and that worked just fine.

    So now the problem is that I need to load the content from a database and assign it to a temp editor, after which the styles formatting is lost.

    The whole thing is like this:


    There are Editor1 and Editor2, both containing a small piece of text with a bulleted list. Editor3 is empty at design time, and these two are merged into it. If I just do FastAppendText with both Editor1 and Editor2, it's ok, but not when the TempEditor is loaded from database using AsString.

    Any ideas? Sorry to nag on about this, but it's pretty important for me to get this working somehow.

  • I'm pretty much trying to do the same thing as you be haven't gotten as far. My situation is a bit simpler.

    I hav two editors Editor1 and Editor2. Editor2 has some text with bullet points in it. I want to copy editor Editor2 in to Editor1 using FastAppendText and keep the bullet points.

    I have hooked both controls up to OnInitializedRTData but I'm not sure what code to put in the event handler.

    Any chance you could post your code for that handler?

    Thanks,

    Jamie

  • Jamier,

    just this one thing:

    Code
    RTFPropsObject := WPGlobalRTFProps;

    The WPGlobalRTFProps object is of type TWPRTFProps and is a public variable in my unit. I initialize it in the form create event as

    Code
    WPGlobalRTFProps := TWPRTFProps.Create;
    WPGlobalRTFProps.Locked := TRUE;

    and then assign the same object to each editor.

    • Offizieller Beitrag

    I am sorry,
    I made this mistake myself.

    please do not use
    OnInitializedRTFData
    (OnInitializedRTFData is called later. It can be used to read and modify the objects but not suitable to exchange the RTFDataProps)

    use
    InitializeRTFDataObject

    I posted a demo here:
    https://www.wpcubed.com/ftp/ex/ShareRTFProps.zip

    If the following event handler is used for all TWPRichText (source and destination) the numbering should survive the FastAppendText call and the bullet dialog should display the same list for all editors.

    Regards,
    Julian Ziersch

  • Hi Julian,


    thanks, but still no go; it works as long as all the editors are inserted on the form at design time, but not if I create one at runtime, then it just messes the formatting. It actually now fails differently: the bullets are there, but bold text "leaks", i.e. everything after a single bold line is still bold.

    This is the whole unit I have, nothing else:

    If I change the line TempEditor.AsString to TempEditor.FastAppendText(Editor2) (obviously clear it first), then it works, but like I said I need to read the content from a database so I cannot do that.

    • Offizieller Beitrag

    Hi,

    The TWPRichText is not designed to be created dynamically. Please use the TWPCUstomRTFEdit and use the constrcutor CreateDynamic.

    Please make sure ALL the editors use the same OnInitializeRTFDataObject event.

    Careful with Clear or implizing Clear (AsString). Use ClearEx instead like in my demo.

    If you need a working TWRichText place it on the form and set Visible to false.

    Julian

  • Thanks for your tips; unfortunately I still can't get this to work. I changed the dynamically created editor to be a TWPCustomRTFEdit, created using CreateDynamic, and that + the visual editor to which the combined document is created in are both using the same OnInitializeRTFDataObject event and are assigned the same TWPRTFProps object.

    Bullets are still lost.

    Am I doing this somehow wrong? My goal is to combine multiple (typically 50 - 100) smaller documents into one big document, and naturally I'd want all the formatting preserved. The smaller ones are created within my app, in WPRTFEdits and stored into a database.

    Is there some other way I could approach this maybe?

    • Offizieller Beitrag

    Thanks for Your demo.

    The problem is the LoadFromFile with clear (second parameter = true).
    As mentioned You need to use ClearEx.

    The code should look like this:

    TempDocument.ClearEx(true, false, true);
    TempDocument.LoadFromFile(ExtractFilePath(Application.Exename) + 'data\' + sr.Name, False);
    MasterDocument.FastAppendText(TempDocument);

  • Just an update: this was solved in an email exchange with the help from Julian (wpsupport). Turned out I was using AsString to load the contents, where I should have been using LoadFromString method. Once I changed to that, all the other help in this thread clicked into place and I'm now a happy camper :-)