Mailmerge field inside table not showing first space

  • The following doesn't work anymore in 5.24.3.

    Property settings:
    InsertPointAttr.hidden = true
    AutomatictextAttr.BackGroundColor = clGreen
    AutomatictextAttr.UseBackGroundColor = true

    When a mergefield starts with a space (' ') and is located at the first position inside a table cell the first space is no longer visible. If i don't hide the insert points, or if i put 1 space before the mergefield inside the same cell, or if i start the mergefield with any other character then the background color is there.

    Since i fill the mergefields from edit controls and display a single space when the edit control is empty this is a problem for me, because it now looks like no mergefields are present when creating a new message.

    This problem wasn't present in 5.20.9 (and earlier releases), but does occur in version 5.24.3.

    Einmal editiert, zuletzt von Leander (25. Juli 2007 um 11:49)

  • Done some debugging, but can't find the exact problem yet.

    unit WPRTEPaint.pas

    Code
    if cp < cp_lend then
        OptCharWidth[OptBufferCount] := lineData.par.CharPos[cp + 1].xoff
    else OptCharWidth[OptBufferCount] := lineData.par.CharPos[cp].width;
                            inc(OptBufferCount);

    lineData.par.CharPos[cp + 1].xoff returns 0, if i set xoff to 32 (lineData.par.CharPos[cp].width) then everything paints fine, but i have no idea why the xoff has an incorrect value.

  • xoff seems to be set here:

    WPRTEDefs.pas
    (around line nr. 39900)

    Code
    if lastxoff < xoff then
       Par.CharPos[i].xoff := xoff - lastxoff
    else Par.CharPos[i].xoff := 0;
    lastxoff := xoff;
    inc(xoff, w);

    the local variable "xoff" however does'n't get increased because w remains 0.

    I still can't figure out what changed between 5.20.9 and 5.24.3 that could have caused this behavior.

  • Final post, this is about as far as i can get with debugging:

    WPRtedefs.pas

    Code
    if FLastWasNL or ((not FLastWasSPC or (endx = 0)) and
          ((w > 0)
           or (xoff = 0)
           ) and 
          (((x  > endx) and (not bLastWasRightTab or (i <par> maxy)))

    If this returns False then everything does seem to work, to get it to return false i've changed (w > 0) to (w = 0), but to be honest i'm just guessing here. I have no idea what the code is supposed to do so at this point i'm stuck. (EDIT: Warning: The change i made in the code "(w = 0)" is not correct!)

    If this is fixed i can upgrade to the newest release.

    Thanks in advance.

    Einmal editiert, zuletzt von Leander (25. Juli 2007 um 11:21)

    • Offizieller Beitrag

    Hi,

    Can you please post a sample text since the one below does not show the problem:

    Julian

  • Your sample text gives me the problem i'm trying to describe.
    The first space is not visible inside the mergefield if the following condition is set:

    WPRichText1.InsertPointAttr.Hidden := True;

    Instead of showing " FIELD1", it shows "FIELD1".

    This is in V5.0 Release 24.3a

  • Problem is still there in release 5.25

    I have added this to the code though, which seems to fix it (indicated in bold).

    WPRTEDefs.pas (around line nr 39550)

    if FLastWasNL or ((not FLastWasSPC or (endx = 0)) and
    ((w > 0)
    or (xoff = 0)
    ) and
    (((x > endx) and (not bLastWasRightTab or (i <par> maxy)))
    and ((i = 0) or (par.ObjectRef[i - 1] = nil) or
    (par.ObjectRef[i-1].ObjType <> wpobjMergeField))

    • Offizieller Beitrag

    Hi,

    I assume the code was truncated and you mean

    (((x > endx) and (not bLastWasRightTab or (i < par.CharCount - 1)))
    or ((y + h + startprop.footerheight) > maxy)))
    and ((i = 0) or (par.ObjectRef[i - 1] = nil) or
    (par.ObjectRef[i-1].ObjType <> wpobjMergeField))

    - but I wonder why I don't have that problem even without that mode.

    Julian

  • That's right, i'm still not used to posting code on a forum (i must have edited my post at least 3 times)

    I'm getting this problem on a new TWPRichText component, with all properties except insertpointattr.hidden set to default values, and all defines (WPInc.inc) also set to default.

    Perhaps it is related to the Delphi version (i still use Delphi 5), i'll try this on Delphi 2006 to see if it makes any difference.

    It might just be one of those programming mysteries.

    Thanks anyway for all your help!