diff --git a/components/fpvectorial/examples/fpvtextwritetest.pas b/components/fpvectorial/examples/fpvtextwritetest.pas
index 4afdd976f2..52802302b5 100644
--- a/components/fpvectorial/examples/fpvtextwritetest.pas
+++ b/components/fpvectorial/examples/fpvtextwritetest.pas
@@ -24,7 +24,7 @@ begin
// A4 -> 210mm x 297mm
Vec.Width := 210;
Vec.Height := 297;
- Vec.AddStandardODTTextDocumentStyles();
+ Vec.AddStandardTextDocumentStyles(vfODT);
// First page sequence
Page := Vec.AddTextPageSequence();
diff --git a/components/fpvectorial/fpvectorial.pas b/components/fpvectorial/fpvectorial.pas
index 6e0adfd211..990bc5a144 100644
--- a/components/fpvectorial/fpvectorial.pas
+++ b/components/fpvectorial/fpvectorial.pas
@@ -39,6 +39,7 @@ uses
type
TvVectorialFormat = (
+ vfUnknown,
{ Multi-purpose document formats }
vfPDF, vfSVG, vfSVGZ, vfCorelDrawCDR, vfWindowsMetafileWMF, vfODG,
{ CAD formats }
@@ -131,13 +132,20 @@ type
StrikeThrough: boolean;
end;
- TvSetPenBrushAndFontElement = (
+ TvSetStyleElement = (
+ // Pen, Brush and Font
spbfPenColor, spbfPenStyle, spbfPenWidth,
spbfBrushColor, spbfBrushStyle, spbfBrushGradient,
spbfFontColor, spbfFontSize, spbfFontName, spbfFontBold, spbfFontItalic,
- spbfFontUnderline, spbfFontStrikeThrough, spbfAlignment);
+ spbfFontUnderline, spbfFontStrikeThrough, spbfAlignment,
+ //
+ sseMarginTop, sseMarginBottom, sseMarginLeft, sseMarginRight
+ );
- TvSetPenBrushAndFontElements = set of TvSetPenBrushAndFontElement;
+ TvSetStyleElements = set of TvSetStyleElement;
+ // for backwards compatibility, obsolete
+ TvSetPenBrushAndFontElement = TvSetStyleElement;
+ TvSetPenBrushAndFontElements = TvSetStyleElements;
TvStyleKind = (
// Paragraph kinds
@@ -158,14 +166,16 @@ type
Pen: TvPen;
Brush: TvBrush;
Font: TvFont;
- SetElements: TvSetPenBrushAndFontElements;
//
MarginTop, MarginBottom, MarginLeft, MarginRight: Double; // in mm
//
+ SetElements: TvSetStyleElements;
+ //
function GetKind: TvStyleKind; // takes care of parenting
procedure Clear();
procedure CopyFrom(AFrom: TvStyle);
procedure ApplyOver(AFrom: TvStyle);
+ function CreateStyleCombinedWithParent: TvStyle;
end;
{ Coordinates and polyline segments }
@@ -907,7 +917,7 @@ type
function AddTextPageSequence(): TvTextPageSequence;
{ Style methods }
function AddStyle(): TvStyle;
- procedure AddStandardODTTextDocumentStyles();
+ procedure AddStandardTextDocumentStyles(AFormat: TvVectorialFormat);
function GetStyleCount: Integer;
function GetStyle(AIndex: Integer): TvStyle;
function FindStyleIndex(AStyle: TvStyle): Integer;
@@ -1249,18 +1259,26 @@ procedure TvStyle.ApplyOver(AFrom: TvStyle);
begin
if AFrom = nil then Exit;
+ // Pen
+
if spbfPenColor in AFrom.SetElements then
Pen.Color := AFrom.Pen.Color;
if spbfPenStyle in AFrom.SetElements then
Pen.Style := AFrom.Pen.Style;
if spbfPenWidth in AFrom.SetElements then
Pen.Width := AFrom.Pen.Width;
+
+ // Brush
+
if spbfBrushColor in AFrom.SetElements then
Brush.Color := AFrom.Brush.Color;
if spbfBrushStyle in AFrom.SetElements then
Brush.Style := AFrom.Brush.Style;
{if spbfBrushGradient in AFrom.SetElements then
Brush.Gra := AFrom.Brush.Style;}
+
+ // Font
+
if spbfFontColor in AFrom.SetElements then
Font.Color := AFrom.Font.Color;
if spbfFontSize in AFrom.SetElements then
@@ -1278,7 +1296,25 @@ begin
If spbfAlignment in AFrom.SetElements then
Alignment := AFrom.Alignment;
- SetElements:=AFrom.SetElements;
+ // Style
+
+ if sseMarginTop in AFrom.SetElements then
+ MarginTop := AFrom.MarginTop;
+ If sseMarginBottom in AFrom.SetElements then
+ MarginBottom := AFrom.MarginBottom;
+ If sseMarginLeft in AFrom.SetElements then
+ MarginLeft := AFrom.MarginLeft;
+ If sseMarginRight in AFrom.SetElements then
+ MarginRight := AFrom.MarginRight;
+
+ SetElements := AFrom.SetElements + SetElements;
+end;
+
+function TvStyle.CreateStyleCombinedWithParent: TvStyle;
+begin
+ Result := TvStyle.Create;
+ Result.CopyFrom(Self);
+ if Parent <> nil then Result.ApplyOver(Parent);
end;
{ T2DEllipticalArcSegment }
@@ -5487,7 +5523,7 @@ begin
FStyles.Add(Result);
end;
-procedure TvVectorialDocument.AddStandardODTTextDocumentStyles();
+procedure TvVectorialDocument.AddStandardTextDocumentStyles(AFormat: TvVectorialFormat);
var
lTextBody, lBaseHeading, lCurStyle: TvStyle;
begin
@@ -5516,7 +5552,7 @@ begin
lBaseHeading.Kind := vskHeading;
lBaseHeading.Font.Size := 14;
lBaseHeading.Font.Name := 'Arial';
- lBaseHeading.SetElements := [spbfFontSize, spbfFontName];
+ lBaseHeading.SetElements := [spbfFontSize, spbfFontName, sseMarginTop, sseMarginBottom];
lBaseHeading.MarginTop := 4.23;
lBaseHeading.MarginBottom := 2.12;
diff --git a/components/fpvectorial/odtvectorialwriter.pas b/components/fpvectorial/odtvectorialwriter.pas
index 304c4b92ab..78b983269f 100644
--- a/components/fpvectorial/odtvectorialwriter.pas
+++ b/components/fpvectorial/odtvectorialwriter.pas
@@ -376,7 +376,8 @@ procedure TvODTVectorialWriter.WriteStyles(AData: TvVectorialDocument);
var
i: Integer;
CurStyle: TvStyle;
- lTextPropsStr, lParagraphPropsStr, lCurStyleTmpStr, CurStyleParent: string;
+ lTextPropsStr, lParagraphPropsStr, lCurStyleTmpStr, CurStyleParent,
+ lMarginStr: string;
begin
FStyles :=
XML_HEADER + LineEnding +
@@ -419,56 +420,33 @@ begin
' ' + LineEnding +
' ' + LineEnding +
' ' + LineEnding +
- '' + LineEnding +
+ '';
- // up to here done +/-
-
- '' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- '' + LineEnding +
- '' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- '' + LineEnding +
- '' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- ' ' + LineEnding +
- '' + LineEnding;
+ // ----------------------------
+ // Styles
+ // ----------------------------
FStyles := FStyles +
'' + LineEnding;
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
+
+ FStyles := FStyles +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding;
FStyles := FStyles +
' ' + LineEnding;
@@ -539,9 +517,15 @@ begin
// Paragraph kind
else
begin
+ lMarginStr := '';
+ if sseMarginTop in CurStyle.SetElements then
+ lMarginStr := lMarginStr + 'fo:margin-top="'+FloatToODTText(CurStyle.MarginTop)+'mm" ';
+ if sseMarginBottom in CurStyle.SetElements then
+ lMarginStr := lMarginStr + 'fo:margin-bottom="'+FloatToODTText(CurStyle.MarginTop)+'mm" ';
+
lCurStyleTmpStr := // tmp string to help see the text in the debugger
' ' + LineEnding +
- ' ' + LineEnding +
+ ' ' + LineEnding +
' ' + LineEnding +
' ' + LineEnding;
FStyles := FStyles + lCurStyleTmpStr;
@@ -580,60 +564,62 @@ begin
}
end;
-{
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
+ // up to here done +/-
+
+ FStyles := FStyles +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + LineEnding;
+
FStyles := FStyles +
' ' + LineEnding;
FStyles := FStyles +
@@ -642,6 +628,11 @@ begin
' ' + LineEnding;
FStyles := FStyles +
'' + LineEnding;
+
+ // ----------------------------
+ // Automatic Styles
+ // ----------------------------
+
FStyles := FStyles +
'' + LineEnding;
FStyles := FStyles +