Copy Paragraph with formatting and bullets/numbering

  • I cannot get a paragraph with all formatting and bullet/numbering to copy from one WPRichText to another.

    Apar = The paragraph I want to copy to the NewEditor.
    NewEditor = TWPRichText I wan't to copy to

    Try 1:
    NewEditor.CheckHasBody;
    Style:= APar.AGetWPSS(false, true, true);
    NewPar:= NewEditor.ActiveText.AppendParCopy(APar);
    NewPar.ASetWPSS(Style);

    Try 2:
    NewEditor.CheckHasBody;
    NewPar:= NewEditor.ActiveText.AppendNewPar;
    NewPar.SetText(APar.GetText(False,True));
    APar.AGet(WPAT_IndentLeft,Indent);
    NewPar.ASet(WPAT_IndentLeft,Indent);
    Number:= APar.Number;
    NewPar.ASet(WPAT_NumberStart,Number);


    The "NewPar" with each of these attempts are missing the bullet and numbering information. What am I missing?

    • Offizieller Beitrag

    Hi,

    AppendParCopy should be fine - but both editors must use the same RTFProps object. Please refer to demo "GlobalStyle" to see how that is initialized.

    This is the key event handler:

    Code
    procedure TWPGlobalStyleChild.WPRichText1InitializeRTFDataObject(
      Sender: TObject; var RTFDataObject: TWPRTFDataCollection;
      var RTFPropsObject: TWPRTFProps);
    begin
       RTFPropsObject := WPGlobalRTFProps;
       // Don't forget to DETACH the object later!
    end;