You've already forked lazarus-ccr
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:
@ -770,6 +770,7 @@ var
|
||||
numFmtIndex: Integer;
|
||||
numFmtIndexDefault: Integer;
|
||||
wrap: Boolean;
|
||||
txtRot: TsTextRotation;
|
||||
borders: TsCellBorders;
|
||||
borderStyles: TsCellBorderStyles;
|
||||
bkClr: TsColorValue;
|
||||
@ -866,6 +867,7 @@ begin
|
||||
borders := [];
|
||||
wrap := false;
|
||||
bkClr := TsColorValue(-1);
|
||||
txtRot := trHorizontal;
|
||||
|
||||
styleChildNode := styleNode.FirstChild;
|
||||
while Assigned(styleChildNode) do begin
|
||||
@ -907,6 +909,17 @@ begin
|
||||
// Text wrap
|
||||
s := GetAttrValue(styleChildNode, 'fo:wrap-option');
|
||||
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
|
||||
if styleChildNode.NodeName = 'style:paragraph-properties' then begin
|
||||
//
|
||||
@ -921,7 +934,7 @@ begin
|
||||
style.HorAlignment := haDefault;
|
||||
style.VertAlignment := vaDefault;
|
||||
style.WordWrap := wrap;
|
||||
style.TextRotation := trHorizontal;
|
||||
style.TextRotation := txtRot;
|
||||
style.Borders := borders;
|
||||
style.BorderStyles := borderStyles;
|
||||
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:table-cell-properties
|
||||
if (FFormattingStyles[i].UsedFormattingFields <> []) then begin
|
||||
{
|
||||
if (uffBorder in FFormattingStyles[i].UsedFormattingFields) or
|
||||
(uffBackgroundColor in FFormattingStyles[i].UsedFormattingFields) or
|
||||
(uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then
|
||||
begin
|
||||
(uffWordWrap in FFormattingStyles[i].UsedFormattingFields) or
|
||||
(uffTextRotation in FFormattingStyles[i].UsedFormattingFields)
|
||||
then begin
|
||||
}
|
||||
Result := Result + ' <style:table-cell-properties ';
|
||||
|
||||
if (uffBorder in FFormattingStyles[i].UsedFormattingFields) then
|
||||
@ -1242,8 +1259,13 @@ begin
|
||||
// + Workbook.FPSColorToHexString(FFormattingStyles[i].BackgroundColor, FFormattingStyles[i].RGBBackgroundColor) +'" ';
|
||||
|
||||
if (uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then
|
||||
begin
|
||||
Result := Result + 'fo:wrap-option="wrap" ';
|
||||
|
||||
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;
|
||||
|
@ -1286,6 +1286,7 @@ begin
|
||||
|
||||
Result^.Row := ARow;
|
||||
Result^.Col := ACol;
|
||||
Result^.ContentType := cctEmpty;
|
||||
Result^.BorderStyles := DEFAULT_BORDERSTYLES;
|
||||
|
||||
Cells.Add(Result);
|
||||
|
@ -106,6 +106,7 @@ type
|
||||
{ ODS Tests }
|
||||
procedure TestWriteRead_ODS_Border;
|
||||
procedure TestWriteRead_ODS_BorderStyles;
|
||||
procedure TestWriteRead_ODS_TextRotation;
|
||||
procedure TestWriteRead_ODS_WordWrap;
|
||||
end;
|
||||
|
||||
@ -883,6 +884,11 @@ begin
|
||||
TestWriteReadTextRotation(sfExcel8);
|
||||
end;
|
||||
|
||||
procedure TSpreadWriteReadFormatTests.TestWriteRead_ODS_TextRotation;
|
||||
begin
|
||||
TestWriteReadTextRotation(sfOpenDocument);
|
||||
end;
|
||||
|
||||
|
||||
{ --- Wordwrap tests --- }
|
||||
|
||||
|
Reference in New Issue
Block a user