fpspreadsheet: Refactor style reading in ODS reader

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7559 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-07-24 14:45:30 +00:00
parent e191dd00e5
commit 16ba7692c2
2 changed files with 34 additions and 2 deletions

View File

@ -142,6 +142,7 @@ type
procedure ReadShapes(ATableNode: TDOMNode);
procedure ReadSheetProtection(ANode: TDOMNode; ASheet: TsBasicWorksheet);
procedure ReadSheets(ANode: TDOMNode);
procedure ReadStyle_ParagraphProperties(ANode: TDOMNode; var AFormat: TsCellFormat);
procedure ReadTableStyle(AStyleNode: TDOMNode);
protected
@ -4736,6 +4737,32 @@ begin
end;
end;
procedure TsSpreadOpenDocReader.ReadStyle_ParagraphProperties(ANode: TDOMNode;
var AFormat: TsCellFormat);
var
s: String;
begin
// Horizontal text alignment
s := GetAttrValue(ANode, 'fo:text-align');
if s = 'start' then
AFormat.HorAlignment := haLeft
else if s = 'end' then
AFormat.HorAlignment := haRight
else if s = 'center' then
AFormat.HorAlignment := haCenter;
if AFormat.HorAlignment <> haDefault then
Include(AFormat.UsedFormattingFields, uffHorAlign);
// BiDi mode
s := GetAttrValue(ANode, 'style:writing-mode');
if s = 'lr-tb' then
AFormat.BiDiMode := bdRTL
else if s = 'rl-tb' then
AFormat.BiDiMode := bdRTL;
if AFormat.BiDiMode <> bdDefault then
Include(AFormat.UsedFormattingFields, uffBiDi);
end;
procedure TsSpreadOpenDocReader.ReadStyles(AStylesNode: TDOMNode);
var
styleNode: TDOMNode;
@ -5097,6 +5124,8 @@ begin
else
if nodeName = 'style:paragraph-properties' then
begin
ReadStyle_ParagraphProperties(styleChildNode, fmt);
(*
// Horizontal text alignment
s := GetAttrValue(styleChildNode, 'fo:text-align');
if s = 'start' then
@ -5115,6 +5144,7 @@ begin
fmt.BiDiMode := bdRTL;
if fmt.BiDiMode <> bdDefault then
Include(fmt.UsedFormattingFields, uffBiDi);
*)
end;
styleChildNode := styleChildNode.NextSibling;
end;

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="spreadtestgui"/>
<ResourceType Value="res"/>
</General>