Paragraph border issue and trimming blank lines

  • If I have a section with a single paragraph and apply a border to it, it is fine in the editor, but when I do a print preview the border is not there. However, if I add new paragraph below that paragraph having the border, then that other paragraph's border now appears in the print preview. Go back and remove that other paragraph, and the paragraph borders no longer shows up.

    The problem has something to do with trimming trailing blank lines that includes the paragraph having a border. If I trim trailing blank lines and only have the one paragraph with a border, this issue shows up. But if I don't trim trailing blank lines then it works fine and the borders show up with or without the extra paragraph. That extra paragraph prevents the trimming of the paragraph having a border.

    I use my own trim function based off yours I think. It is the same one I have been using in my old app for WPT5. The reason why I had to use mine is mentioned in the comment:

    I have not debugged the code yet to see if I am deleting too much of something that might remove the border property. But it works fine in WPTool5, but not in WPTools9 which is why I am posting this. :D

    WPRichEdit 9.1.016

    Eric

  • In trying to create a demo, it turns out it has nothing directly to do with deleting trailing blank lines. It is in how the Contents.options is being handled differently now than it did in WPT5 during a merge. Something about using mmUseFirstLoadedParProps and/or mmUseFirst_AlsoBorders options I suspect, maybe others because for some reason I use different options at different phases of a merge building my final report from a bunch of layouts and other things. So, by still having a blank line after a paragraph with borders doesn't try to wipe out that bordered paragraph's properties with what is being merged in is my guess.

    I seem to remember having a lot of issues with WPT5 in dealing with paragraphs taking on attributes of the merged paragraphs or vice-versa. So maybe something was fixed that I can now back out. I'll have to do some experimenting, not something I'm looking forward to due to the many hours I invested in the report generation over the years with so many different scenarios I had to troubleshoot. Basically the report generation of mine is a house of cards.

    Consider this thread closed.

  • Found what is causing my issue. It is the AppendAsSection operation. If I append a section where the last paragraph has a border, the border is lost. If the paragraph has anything after it, the border is not lost. I will send you an example.

  • Somehow there is more to it than that. Yes, the example I sent you falls into that category, and if I add things in front of that last paragraph in the example, it works OK. However, in my app itself, as long as the last paragraph has a border, it gets lost whether or not there is anything in front of it or not. I guess I need to track it down further and send you a new example once I figure out the process that is failing me. I thought I had it, but unfortunately for me I guess not. In my app it is all constructed during a complicated mailmerge, but my example does not do that, so maybe something there. I'll work on it some more, sigh.

  • I traced it down to the exact statement which is stripping off the attributes of the last paragraph.

    dest.SelectionAsString := src.AsString;

    If I change it to this, it works:

    dest.SelectionAsString := src.AsANSIString('WPTOOLS');

    However, it gives me the warning "Implicit string cast from 'AnsiString' to 'String'

    How to properly avoid that warning?

    Seems I had changed that line during the initial re-write in order to avoid the warning. My bad.

    • Offizieller Beitrag

    a) linked images are blocked because of data protection considerations. It is possible to click the link though.

    b) the code I suggested to modified was the following. I introduced wpUseAttributeEvenIfSingleParagraph for future versions.

    if wpUseAttributeEvenIfSingleParagraph in Options then

    LoadFromStream(mem, 'WPTOOLS', TRUE)

    else LoadFromStream(mem, 'WPTOOLS-overwriteparattr', TRUE);

    c) You can use

    LoadFromString( src.AsANSIString('WPTOOLS'), 'WPTOOLS,-nodefaultfont', false )

    instead of SelectionAsString to avoid conversion to unicode strings.

  • b) Nice. That will most likely come in handy when our customers create what we call RapidRemarks (reusable comments). Single paragraphs with attributes could potentially be used.

    c) Ahh, much better I think! I use LoadFromString and LoadFromStream elsewhere, so this makes it consistent. But still OK for appending? (which is what I'm doing here, not replacing). I'll find out.