Copying paragraphs (with objects) between TWPRichText's

  • Good luck on understanding me on this one...<g>.

    I have one <TWPRichText> component that has text and mergefields in it. I go to copy it over to another <TWPRichText> component with:

    Code
    destWPRichTex.ActiveText.AppendParCopy( srcWPRichText.ActiveParagraph );

    I'm copying it this way because there are certain paragraphs (which I can identify via code) that I don't want to send over to the destination.

    This is where I'm not 100% sure. I'm starting to get the impression the mergefield objects in srcWPRichText, when they're copied over to destWPRichtext, are no longer marked as of type wpObjMergeField, but instead are now marked as type wpObjCustom (plus I think they're having some of their other TextObject properties reset, and not brought over).

    If I do a MergeText on srcWPRichText, all is well. If I do a MergeText on destWPRichText, that component's WPRichTextStorageFormMailMergeGetText is never triggered.

    In tracing through, I ran across this WPRTEDefs line, in TParagraph.Assign, that suggests to me I'm doing something wrong (or not at all):

    Code
    bDifferentRTFProps := (Source.FRTFProps <> nil) and (FRTFProps <> nil) and (Source.FRTFProps <> FRTFProps);


    So if my guess is right, I should somehow be associating destWPRichText with srcWPRichText's RTFDataProps. If that's the case, how do I do this? If that's not the problem, what else I might try?

    And am I right that the objects of type wpObjMergeField are being copied over as type wpObjCustom?

    Actually, I just noticed that objects of type wpobjTextObject aren't appearing in the copied over TWPRichText component (destWPRichText), so my guess is they're being set to type wpObjCustom, as are possibly any objects, during the copy due to my not having RTFProps shared between the two <TWPRichText> components?

    I feel like I'm getting closer, but I'm definitely not there yet...:)

    diamond

    • Offizieller Beitrag

    Hi Diamond,

    The problem is solved in R5.1 - you were right, the OBJ props have been forgotten do to change in the logic.
    They are now all copied.

    Accoding to different RTFProps -

    RTFProps hold the value arrays for the RTF-Text, such as font table, color table etc.

    For special cases the engine supports the use of the same RTFProps for different editors. This is used by the WPReporter since it hewre makes sense that the template AND the destination text use the same font, Style, numbering styles and color table.

    This makes it possible to make a change to a text style and the change will be visible at once in the template AND the destination text, the report which already have been created.

    I do not reccomend to you to use this technology, the copying code takes care of different RTFProps, this means if you assign a style or paragraph to a paragagraph or style in a different editor it should always work, no matter if they are using the same RTFProps or the same RTFDataCollection AND RTFProps.

    Julian

  • Just as you described, with R5.1 my mergefield code is now working like a charm! Thank you!!! I didn't even have to lift a finger..:)

    I have a bit of a variation on this issue of things not coming over quite right when copying paragraphs:

    An embedded image in the document kind of gets copied over to the destination paragraph. When I copy over the paragraph, the "bounding box" outline that the image sits inside of is shown on the destination TWPRichText, but there's no actual image inside of the rectangular frame.

    Does my description makes sense (and can you reproduce this)?

    diamond

  • Julian,

    Have you had an opportunity to look into this yet?

    As of the most recent version, R5.5, this behavior is still there. The object's frame comes over, but the image is not inside the "bounding box".

    diamond

  • Greetings...:)

    Just as you promised, this problem is fixed with R6. Thank you!!!

    I saw a number of variations on this, both in this Forum, and in the newsgroup, about "the graphic's box appears, but no image". They'll all be happy with the latest and greatest release of WPTools 5...:)

    diamond