fpvectorial: Fix odt and docx writers truncating the last two characters of each paragraph.

This commit is contained in:
wp_xyz 2023-01-31 00:06:41 +01:00
parent 8a67172c03
commit f823854588
4 changed files with 5 additions and 17 deletions

View File

@ -700,13 +700,6 @@ Var
Begin
sTemp := TvText(oEntity).Value.Text;
// Strip out the trailing line break
// added by TStringList.Text
If DefaultTextLineBreakStyle = tlbsCRLF Then
sTemp := Copy(sTemp, 1, Length(sTemp) - 2)
Else
sTemp := Copy(sTemp, 1, Length(sTemp) - 1);
AddTextRun(sTemp, TvText(oEntity).Style);
End
Else If oEntity is TvField Then

View File

@ -10,7 +10,7 @@ program fpvtextwritetest;
{$mode objfpc}{$H+}
uses
fpvectorial, odtvectorialwriter, fpvutils, fpvectorialpkg;
fpvectorial, odtvectorialwriter, docxvectorialwriter, fpvutils;
{$R *.res}
@ -76,6 +76,7 @@ begin
CurList.AddParagraph('The ability to create custom components');
Vec.WriteToFile('text_output.odt', vfODT);
Vec.WriteToFile('text_output.docx', vfDOCX);
finally
Vec.Free;
end;

View File

@ -493,13 +493,13 @@ Begin
dtTime := Now;
Vec.WriteToFile('text_output_docx', vfDOCX);
WriteLn('Native docx writer: '+Format('%.1f msec', [24*60*60*1000*(Now-dtTime)]));
dtTime := Now;
Vec.WriteToFile('text_output_odt', vfODT);
WriteLn('Native odt writer: '+Format('%.1f msec', [24*60*60*1000*(Now-dtTime)]));
Finally
Vec.Free;
End;

View File

@ -1125,12 +1125,6 @@ begin
// Note that here we write only text spans!
sText := EscapeHTML(AEntity.Value.Text);
// Trim extra CRLF appended by TStringList.Text
If DefaultTextLineBreakStyle = tlbsCRLF Then
sText := Copy(sText, 1, Length(sText) - 2)
Else
sText := Copy(sText, 1, Length(sText) - 1);
sText := StringReplace(sText, ' ', ' <text:s/>', [rfReplaceAll]);
sText := StringReplace(sText, #09, '<text:tab/>', [rfReplaceAll]);
sText := StringReplace(sText, #13, '<text:line-break/>', [rfReplaceAll]);