From 645ceea6ac45727d3036ed03047d6ed534efe10b Mon Sep 17 00:00:00 2001 From: wp Date: Sat, 9 Jan 2021 23:46:03 +0000 Subject: [PATCH] fpVectorial: ODT support of underline and strike-through text, as well as text color. Modified patch by stab (https://forum.lazarus.freepascal.org/index.php/topic,52802.msg390001.html). git-svn-id: trunk@64370 - --- components/fpvectorial/odtvectorialwriter.pas | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/components/fpvectorial/odtvectorialwriter.pas b/components/fpvectorial/odtvectorialwriter.pas index e7ba026b63..711e3ccaf8 100644 --- a/components/fpvectorial/odtvectorialwriter.pas +++ b/components/fpvectorial/odtvectorialwriter.pas @@ -227,7 +227,10 @@ const ('solid', 'dashed', 'solid', 'none', 'default'); // ('solid', 'dashed', 'double', 'none', 'default'); // NOTE: double not supported - +function FPColorToHTML(AColor: TFPColor): String; +begin + Result := Format('#%.2x%.2x%.2x', [AColor.Red shr 8, AColor.Green shr 8, AColor.Blue shr 8]); +end; { TListStyle_StyleList } @@ -619,6 +622,11 @@ begin lTextPropsStr := lTextPropsStr + ' style:font-name-asian="Microsoft YaHei" '; lTextPropsStr := lTextPropsStr + ' style:font-name-complex="Mangal" '; end; + if (spbfFontColor in CurStyle.SetElements) then + begin + lTextPropsStr := lTextPropsStr + Format(' fo:color="%s" loext:opacity="100%%"', + [FPColorToHtml(CurStyle.Font.Color)]); + end; if (spbfFontBold in CurStyle.SetElements) then begin if CurStyle.Font.Bold then @@ -647,7 +655,22 @@ begin // ToDo end; end; - + if (spbfFontUnderline in CurStyle.SetElements) then + begin + if CurStyle.Font.Underline then + begin + lTextPropsStr := lTextPropsStr + ' style:text-underline-style="solid"'; + lTextPropsStr := lTextPropsStr + ' style:text-underline-width="auto"'; + lTextPropsStr := lTextPropsStr + ' style:text-underline-color="font-color"'; + end; + end; + if (spbfFontStrikeThrough in CurStyle.SetElements) then + begin + if CurStyle.Font.StrikeThrough then + begin + lTextPropsStr := lTextPropsStr + ' style:text-line-through-style="solid" '; + end; + end; if CurStyle.GetKind() = vskTextSpan then begin { @@ -1172,11 +1195,13 @@ begin sText := StringReplace(sText, #13, '', [rfReplaceAll]); sText := StringReplace(sText, #10, '', [rfReplaceAll]); - If lStyle<>Nil Then - FContent := FContent + '' + - sText + '' - Else - FContent := FContent + '' + sText + '' + If lStyle <> nil Then + sText := Format('%s', [ + AEntityStyleName, sText]) + else + sText := Format('%s', [sText]); + + FContent := FContent + sText; end; procedure TvODTVectorialWriter.WriteField(AEntity: TvField;