WpTools 6.13.1
In our application we have started using the (relatively new) AsWebPage property. This could finally enable us to use wptools as a html viewer for email. Prior to this we could only use wptools for composing an email, but when we our application for example received a newsletter we relied on different components to view them.
So, a big thank you for this.
So this week i have started implementing and testing the feature and found a few problems with it.
Problem 1:
Painting before line text seems to occur after the line text is drawn. For us this only seems to go wrong with certain tables. (If needed i can provide a demo)
I do not yet understand why wpFormatAsWebpage influences the behavior, but i did find the following in the code that seems wrong.
if assigned( _OnInternPaintPar ) then begin _OnInternPaintPar(_EditBox, wpBeforeLineText, Self, LineData, rtfpage, LineData.Par, LineData.LineNr, DestCanvas, ParColorOverride, TextColorOverride, AnyObject, StandardIgnore); end;.....if assigned( _OnInternPaintPar ) then begin _OnInternPaintPar(_EditBox, wpAfterLineText, Self, LineData, rtfpage, LineData.Par, LineData.LineNr, DestCanvas, ParColorOverride, TextColorOverride, AnyObject, StandardIgnore); end; {$ENDIF}..... {$IFDEF WP6} ParColorOverride := clNone; TextColorOverride:= clNone; AnyObject := nil; StandardIgnore := false; if assigned( _OnInternPaintPar ) then begin _OnInternPaintPar(_EditBox, wpBeforeLineText, Self, LineData, rtfpage, LineData.Par, LineData.LineNr, DestCanvas, ParColorOverride, TextColorOverride, AnyObject, StandardIgnore); end; {$ENDIF}if ...elsebegin .... if ... begin end else try ... PaintLine if assigned( _OnInternPaintPar ) then begin _OnInternPaintPar(_EditBox, wpAfterLineText, Self, LineData, rtfpage, LineData.Par, LineData.LineNr, DestCanvas, ParColorOverride, TextColorOverride, AnyObject, StandardIgnore); end; except end;
It seems the second call to _OnInternPaintPar with parameter wpBeforeLineText should be within the same compound statement as the call with PaintLine and the last _OnInternPaintPar. Now it is possible "wpBeforeLineText" is executed without a following call to "LineText" and "wpAfterLineText"
Problem 2:
Hiding paragraphs with paragraph property paprHidden doesn't work anymore.
Tracing this in the code was difficult, but it seems wpFormatAsWebPage calls a different format routine for the paragraph, which means that it differs on several thousands lines of code. This does make me wonder how much more paragraph functionality is now lost, but maybe i'm looking at it the wrong way.
I did find a way to "solve" this in the code. See below. Change has been marked with {$IFDEF OBEC}
procedure TWPLineList.Format
if (paprIsTable in par.Prop) and (par.CharCount = 0) then
begin
w := 1;
end else
begin
par.Reformat(true, maxw, 1);
{$IFDEF OBEC}
if (par.ParagraphType <> wpIsTable) and (not par.hidden) then
{$ELSE}
if par.ParagraphType <> wpIsTable then
{$ENDIF}
begin
if (par.ParagraphType = wpIsStdPar) and
not (wplNoMinHeight in MMode) and
not (paprIsTable in par.prop) then
begin
if (Length(par.Lines) = 1) and (par.Lines[0].Height = 0) then
par.Lines[0].Height := yres div 6;
end;
while linecount < Length(par.Lines) do
AddLine(true);
end;
w := 0;
end;
Alles anzeigen
It is difficult to see if there is a downside to this fix. And i'm not sure it will prove strong enough.