Bug found in RecalcText function

  • Hi Julian,

    Since releasing a version of our product that now has calculation support, customers are complaining that they are getting syntax errors in their formulas when saving (we do a Recalc when saving changes), however, they are not even using calculation formulas!

    Turns out that linked images in some cases are causing the issue. Seeing how these are text objects, I had to add code to your RecalcText function in WPRTEDefs unit to confirm that the text object is actually named "CALC" before trying to actually do the calculation (we use the name property in image text objects):

    Code
    if fields and par.HasObjects(false, [wpobjTextObject]) then
            begin
              for i := 0 to par.CharCount - 1 do
              begin
                obj := par.ObjectRef[i];
                if (obj <> nil) and (obj.ObjType = wpobjTextObject) and
                   (obj.Source <> '') and SameText(obj.Name, 'CALC') then
                begin

    The added check for 'CALC' above solves the problem my customers have been having.

    Hope this is a reasonable fix since your documentation states that formula text objects must be named "CALC".
    Eric

  • On a similar note to my original post...

    I believe these somehow came from a customer pasting in text from Word, but they have always been hidden until I added a RecalcText function when saving a WPRichText, and they now become visible and show up as 0.00 (note the "fldrslt{0.00}" as part of the MACROBUTTON field).

    It starts off as:

    Code
    {\field{\*\fldinst{MACROBUTTON CheckIt }}{\*\fldrslt{}}}

    and is hidden. But after a RecalcText, it looks like this and shows up as 0.00:

    Code
    {\field{\*\fldinst{MACROBUTTON CheckIt }}{\*\fldrslt{0.00}}}


    My "fix" described in my original post to prevent calculations on any object but those named "CALC" resolved this issue.

    Please add the "fix" to your release :)

    Eric