fpspreadsheet: Reading and writing of text rotation in ods files. Add test case. Passed.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3110 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-28 07:53:50 +00:00
parent 99f6a6f1d1
commit 44072f2629
3 changed files with 34 additions and 5 deletions

View File

@ -770,6 +770,7 @@ var
numFmtIndex: Integer; numFmtIndex: Integer;
numFmtIndexDefault: Integer; numFmtIndexDefault: Integer;
wrap: Boolean; wrap: Boolean;
txtRot: TsTextRotation;
borders: TsCellBorders; borders: TsCellBorders;
borderStyles: TsCellBorderStyles; borderStyles: TsCellBorderStyles;
bkClr: TsColorValue; bkClr: TsColorValue;
@ -866,6 +867,7 @@ begin
borders := []; borders := [];
wrap := false; wrap := false;
bkClr := TsColorValue(-1); bkClr := TsColorValue(-1);
txtRot := trHorizontal;
styleChildNode := styleNode.FirstChild; styleChildNode := styleNode.FirstChild;
while Assigned(styleChildNode) do begin while Assigned(styleChildNode) do begin
@ -907,6 +909,17 @@ begin
// Text wrap // Text wrap
s := GetAttrValue(styleChildNode, 'fo:wrap-option'); s := GetAttrValue(styleChildNode, 'fo:wrap-option');
wrap := (s='wrap'); wrap := (s='wrap');
// Test rotation
s := GetAttrValue(styleChildNode, 'style:rotation-angle');
if s = '90' then
txtRot := rt90DegreeCounterClockwiseRotation
else if s = '270' then
txtRot := rt90DegreeClockwiseRotation;
s := GetAttrValue(styleChildNode, 'style:direction');
if s = 'ttb' then
txtRot := rtStacked;
end else end else
if styleChildNode.NodeName = 'style:paragraph-properties' then begin if styleChildNode.NodeName = 'style:paragraph-properties' then begin
// //
@ -921,7 +934,7 @@ begin
style.HorAlignment := haDefault; style.HorAlignment := haDefault;
style.VertAlignment := vaDefault; style.VertAlignment := vaDefault;
style.WordWrap := wrap; style.WordWrap := wrap;
style.TextRotation := trHorizontal; style.TextRotation := txtRot;
style.Borders := borders; style.Borders := borders;
style.BorderStyles := borderStyles; style.BorderStyles := borderStyles;
style.BackgroundColor := IfThen(bkClr = TsColorValue(-1), scNotDefined, style.BackgroundColor := IfThen(bkClr = TsColorValue(-1), scNotDefined,
@ -1179,10 +1192,14 @@ begin
' <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>' + LineEnding; ' <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>' + LineEnding;
// style:table-cell-properties // style:table-cell-properties
if (FFormattingStyles[i].UsedFormattingFields <> []) then begin
{
if (uffBorder in FFormattingStyles[i].UsedFormattingFields) or if (uffBorder in FFormattingStyles[i].UsedFormattingFields) or
(uffBackgroundColor in FFormattingStyles[i].UsedFormattingFields) or (uffBackgroundColor in FFormattingStyles[i].UsedFormattingFields) or
(uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then (uffWordWrap in FFormattingStyles[i].UsedFormattingFields) or
begin (uffTextRotation in FFormattingStyles[i].UsedFormattingFields)
then begin
}
Result := Result + ' <style:table-cell-properties '; Result := Result + ' <style:table-cell-properties ';
if (uffBorder in FFormattingStyles[i].UsedFormattingFields) then if (uffBorder in FFormattingStyles[i].UsedFormattingFields) then
@ -1242,9 +1259,14 @@ begin
// + Workbook.FPSColorToHexString(FFormattingStyles[i].BackgroundColor, FFormattingStyles[i].RGBBackgroundColor) +'" '; // + Workbook.FPSColorToHexString(FFormattingStyles[i].BackgroundColor, FFormattingStyles[i].RGBBackgroundColor) +'" ';
if (uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then if (uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then
begin
Result := Result + 'fo:wrap-option="wrap" '; Result := Result + 'fo:wrap-option="wrap" ';
end;
if (uffTextRotation in FFormattingStyles[i].UsedFormattingFields) then
case FFormattingStyles[i].TextRotation of
rt90DegreeClockwiseRotation: Result := Result + 'style:rotation-angle="270" ';
rt90DegreeCounterClockwiseRotation: Result := Result + 'style:rotation-angle="90" ';
rtStacked: Result := Result + 'style:direction="ttb" ';
end;
Result := Result + '/>' + LineEnding; Result := Result + '/>' + LineEnding;
end; end;

View File

@ -1286,6 +1286,7 @@ begin
Result^.Row := ARow; Result^.Row := ARow;
Result^.Col := ACol; Result^.Col := ACol;
Result^.ContentType := cctEmpty;
Result^.BorderStyles := DEFAULT_BORDERSTYLES; Result^.BorderStyles := DEFAULT_BORDERSTYLES;
Cells.Add(Result); Cells.Add(Result);

View File

@ -106,6 +106,7 @@ type
{ ODS Tests } { ODS Tests }
procedure TestWriteRead_ODS_Border; procedure TestWriteRead_ODS_Border;
procedure TestWriteRead_ODS_BorderStyles; procedure TestWriteRead_ODS_BorderStyles;
procedure TestWriteRead_ODS_TextRotation;
procedure TestWriteRead_ODS_WordWrap; procedure TestWriteRead_ODS_WordWrap;
end; end;
@ -883,6 +884,11 @@ begin
TestWriteReadTextRotation(sfExcel8); TestWriteReadTextRotation(sfExcel8);
end; end;
procedure TSpreadWriteReadFormatTests.TestWriteRead_ODS_TextRotation;
begin
TestWriteReadTextRotation(sfOpenDocument);
end;
{ --- Wordwrap tests --- } { --- Wordwrap tests --- }