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:
function TfrmGenerateReport.MyIsNonSpace(par: TParagraph): Boolean;
var
i: Integer;
begin
if par.HasChildren then
Result := TRUE
else
begin
Result := FALSE;
for i := 0 to par.CharCount - 1 do
begin
if (not MyIsSpace(par, i)) then // (par.CharItem[i] > #32) then
begin
Result := TRUE;
break;
end;
end;
end;
end;
function TfrmGenerateReport.MyDeleteTrailingSpace(pWPRichText: TWPRichText; pParStop: TParagraph = nil): Boolean;
var
vPar, vPrevPar: TParagraph;
i: Integer;
begin
// MyDeleteTrailingSpace was added primarily to prevent WPTools'
// DeleteTrailingSpace from removing ending signature lines in the WDI report.
vPar := pWPRichText.LastPar;
Result := FALSE;
while (vPar <> nil) and (vPar <> pParStop) do
begin
vPrevPar := vPar.PrevPar;
if (vPar.ParagraphType = wpIsSTDPar) and
(not (paprNewPage in vPar.prop)) and
(not MyIsNonSpace(vPar)) then
begin
vPar.DeleteParagraph;
Result := TRUE;
end else
begin
// Truncate that last line ....
if vPar.ParagraphType = wpIsSTDPar then
begin
i := vPar.CharCount - 1;
while (i >= 0) and MyIsSpace(vPar, i) do
dec(i);
vPar.CharCount := i + 1;
if (pWPRichText.TextCursor.active_paragraph = vPar) and
(pWPRichText.TextCursor.active_posinpar > vPar.CharCount) then
begin
pWPRichText.TextCursor.active_posinpar := vPar.CharCount;
pWPRichText.ShowCursor;
end;
end;
break;
end;
vPar := vPrevPar;
end;
if Result then
pWPRichText.DelayedReformat;
end;
Alles anzeigen
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