mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 14:29:31 +02:00
fpvectorial-odt: Implements support for bullet lists
git-svn-id: trunk@42440 -
This commit is contained in:
parent
c3f6ea1d25
commit
fb141c9889
@ -18,6 +18,7 @@ var
|
||||
Vec: TvVectorialDocument;
|
||||
Page: TvTextPageSequence;
|
||||
CurParagraph: TvParagraph;
|
||||
BulletList: TvBulletList;
|
||||
begin
|
||||
Vec := TvVectorialDocument.Create;
|
||||
try
|
||||
@ -57,6 +58,20 @@ begin
|
||||
CurParagraph.Style := Vec.StyleTextBody;
|
||||
// Lazarus provides a highly visual development environment for the creation of rich user interfaces, application logic, and other supporting code artifacts. Along with the customary project management features, the Lazarus IDE also provides features that includes but are not limited to:
|
||||
|
||||
BulletList := Page.AddBulletList();
|
||||
BulletList.AddItem(0, 'A What You See Is What You Get (WYSIWYG) visual windows layout designer');
|
||||
BulletList.AddItem(0, 'An extensive set of GUI widgets or visual components such as edit boxes, buttons, dialogs, menus, etc.');
|
||||
BulletList.AddItem(0, 'An extensive set of non visual components for common behaviors such as persistence of application settings');
|
||||
BulletList.AddItem(0, 'A set of data connectivity components for MySQL, PostgresSQL, FireBird, Oracle, SQL Lite, Sybase, and others');
|
||||
BulletList.AddItem(0, 'Data aware widget set that allows the developer to see data in visual components in the designer to assist with development');
|
||||
BulletList.AddItem(0, 'Interactive code debugger');
|
||||
BulletList.AddItem(0, 'Code completion');
|
||||
BulletList.AddItem(0, 'Code templates');
|
||||
BulletList.AddItem(0, 'Syntax highlighting');
|
||||
BulletList.AddItem(0, 'Context sensitive help');
|
||||
BulletList.AddItem(0, 'Text resource manager for internationalization');
|
||||
BulletList.AddItem(0, 'Automatic code formatting');
|
||||
BulletList.AddItem(0, 'The ability to create custom components');
|
||||
|
||||
Vec.WriteToFile('text_output.odt', vfODT);
|
||||
finally
|
||||
|
@ -835,6 +835,7 @@ type
|
||||
TvParagraph = class(TvEntityWithSubEntities)
|
||||
public
|
||||
Width, Height: Double;
|
||||
Level: Integer; // Only utilized if it is inside a TvBulletList. zero is the first level, 1 the second, and so on
|
||||
AutoExpand: TvRichTextAutoExpand;
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
@ -845,6 +846,27 @@ type
|
||||
function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; override;
|
||||
end;
|
||||
|
||||
{@@
|
||||
TvBulletList represents a list of bullets texts, like:
|
||||
|
||||
* First level
|
||||
- Second level
|
||||
* First level again
|
||||
|
||||
The basic element to build the sequence is TvBulletListText
|
||||
}
|
||||
|
||||
TvBulletList = class(TvEntityWithSubEntities)
|
||||
public
|
||||
{constructor Create; override;
|
||||
destructor Destroy; override;}
|
||||
function AddItem(ALevel: Integer; ASimpleText: string): TvParagraph;
|
||||
{function TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult; override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; override;}
|
||||
end;
|
||||
|
||||
{@@
|
||||
TvRichText represents a sequence of text paragraphs.
|
||||
|
||||
@ -860,7 +882,10 @@ type
|
||||
AutoExpand: TvRichTextAutoExpand;
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
// Data writing methods
|
||||
function AddParagraph: TvParagraph;
|
||||
function AddBulletList: TvBulletList;
|
||||
//
|
||||
function TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult; override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
@ -1068,6 +1093,7 @@ type
|
||||
function AddEntity(AEntity: TvEntity): Integer; override;
|
||||
{ Data writing methods }
|
||||
function AddParagraph: TvParagraph;
|
||||
function AddBulletList: TvBulletList;
|
||||
end;
|
||||
|
||||
{@@ TvVectorialReader class reference type }
|
||||
@ -4370,6 +4396,17 @@ begin
|
||||
Result:=inherited GenerateDebugTree(ADestRoutine, APageItem);
|
||||
end;
|
||||
|
||||
{ TvBulletList }
|
||||
|
||||
function TvBulletList.AddItem(ALevel: Integer; ASimpleText: string): TvParagraph;
|
||||
begin
|
||||
Result := TvParagraph.Create;
|
||||
Result.Level := ALevel;
|
||||
if ASimpleText <> '' then
|
||||
Result.AddText(ASimpleText);
|
||||
AddEntity(Result);
|
||||
end;
|
||||
|
||||
{ TvRichText }
|
||||
|
||||
constructor TvRichText.Create;
|
||||
@ -4388,6 +4425,12 @@ begin
|
||||
AddEntity(Result);
|
||||
end;
|
||||
|
||||
function TvRichText.AddBulletList: TvBulletList;
|
||||
begin
|
||||
Result := TvBulletList.Create;
|
||||
AddEntity(Result);
|
||||
end;
|
||||
|
||||
function TvRichText.TryToSelect(APos: TPoint; var ASubpart: Cardinal
|
||||
): TvFindEntityResult;
|
||||
begin
|
||||
@ -5176,6 +5219,11 @@ begin
|
||||
Result := MainText.AddParagraph();
|
||||
end;
|
||||
|
||||
function TvTextPageSequence.AddBulletList: TvBulletList;
|
||||
begin
|
||||
Result := MainText.AddBulletList();
|
||||
end;
|
||||
|
||||
{ TvVectorialDocument }
|
||||
|
||||
{@@
|
||||
|
@ -79,6 +79,7 @@ type
|
||||
procedure WriteParagraph(AEntity: TvParagraph; ACurPage: TvTextPageSequence; AData: TvVectorialDocument);
|
||||
procedure WriteTextSpan(AEntity: TvText; AParagraph: TvParagraph;
|
||||
ACurPage: TvTextPageSequence; AData: TvVectorialDocument);
|
||||
procedure WriteBulletList(AEntity: TvBulletList; ACurPage: TvTextPageSequence; AData: TvVectorialDocument);
|
||||
// Routines to write parts of those files
|
||||
function WriteStylesXMLAsString: string;
|
||||
//
|
||||
@ -564,8 +565,6 @@ begin
|
||||
}
|
||||
end;
|
||||
|
||||
// up to here done +/-
|
||||
|
||||
FStyles := FStyles +
|
||||
' <text:outline-style style:name="Outline">' + LineEnding +
|
||||
' <text:outline-level-style text:level="1" style:num-format="">' + LineEnding +
|
||||
@ -634,29 +633,24 @@ begin
|
||||
// ----------------------------
|
||||
|
||||
FStyles := FStyles +
|
||||
'<office:automatic-styles>' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' <style:page-layout style:name="Mpm1">' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000" />' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' </style:page-layout-properties>' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' <style:header-style />' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' <style:footer-style />' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' </style:page-layout>' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
'<office:automatic-styles>' + LineEnding +
|
||||
' <style:page-layout style:name="Mpm1">' + LineEnding +
|
||||
' <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">' + LineEnding +
|
||||
' <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000" />' + LineEnding +
|
||||
' </style:page-layout-properties>' + LineEnding +
|
||||
' <style:header-style />' + LineEnding +
|
||||
' <style:footer-style />' + LineEnding +
|
||||
' </style:page-layout>' + LineEnding +
|
||||
' <style:style style:name="List_0" style:family="paragraph" style:parent-style-name="Standard" style:list-style-name="L1">' + LineEnding +
|
||||
// <style:text-properties officeooo:rsid="00072f3e" officeooo:paragraph-rsid="00072f3e" />
|
||||
' </style:style>' + LineEnding +
|
||||
'</office:automatic-styles>' + LineEnding;
|
||||
|
||||
FStyles := FStyles +
|
||||
'<office:master-styles>' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
' <style:master-page style:name="Standard" style:page-layout-name="Mpm1" />' + LineEnding;
|
||||
FStyles := FStyles +
|
||||
'<office:master-styles>' + LineEnding +
|
||||
' <style:master-page style:name="Standard" style:page-layout-name="Mpm1" />' + LineEnding +
|
||||
'</office:master-styles>' + LineEnding;
|
||||
|
||||
FStyles := FStyles +
|
||||
'</office:document-styles>';
|
||||
end;
|
||||
@ -834,9 +828,10 @@ begin
|
||||
begin
|
||||
lCurEntity := ACurPage.GetEntity(i);
|
||||
|
||||
if not (lCurEntity is TvParagraph) then Continue;
|
||||
|
||||
WriteParagraph(TvParagraph(lCurEntity), ACurPage, AData);
|
||||
if (lCurEntity is TvParagraph) then
|
||||
WriteParagraph(TvParagraph(lCurEntity), ACurPage, AData);
|
||||
if (lCurEntity is TvBulletList) then
|
||||
WriteBulletList(TvBulletList(lCurEntity), ACurPage, AData);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -870,9 +865,8 @@ begin
|
||||
begin
|
||||
lCurEntity := AEntity.GetEntity(i);
|
||||
|
||||
if not (lCurEntity is TvText) then Continue;
|
||||
|
||||
WriteTextSpan(TvText(lCurEntity), AEntity, ACurPage, AData);
|
||||
if (lCurEntity is TvText) then
|
||||
WriteTextSpan(TvText(lCurEntity), AEntity, ACurPage, AData);
|
||||
end;
|
||||
|
||||
FContent := FContent +
|
||||
@ -962,6 +956,45 @@ begin
|
||||
'<text:span text:style-name="'+AEntityStyleName+'">'+AEntity.Value.Text+'</text:span>';
|
||||
end;
|
||||
|
||||
procedure TvODTVectorialWriter.WriteBulletList(AEntity: TvBulletList;
|
||||
ACurPage: TvTextPageSequence; AData: TvVectorialDocument);
|
||||
var
|
||||
i, j: Integer;
|
||||
lCurEntity, lCurSubEntity: TvEntity;
|
||||
lCurParagraph: TvParagraph;
|
||||
begin
|
||||
FContent := FContent +
|
||||
' <text:list text:style-name="L1">' + LineEnding; // xml:id="list14840052221"
|
||||
|
||||
for i := 0 to AEntity.GetEntitiesCount()-1 do
|
||||
begin
|
||||
lCurEntity := AEntity.GetEntity(i);
|
||||
|
||||
if (lCurEntity is TvParagraph) then
|
||||
begin
|
||||
lCurParagraph := lCurEntity as TvParagraph;
|
||||
FContent := FContent +
|
||||
' <text:list-item>' + LineEnding +
|
||||
' <text:p text:style-name="List_'+IntToStr(lCurParagraph.Level)+'">';
|
||||
|
||||
|
||||
for j := 0 to lCurParagraph.GetEntitiesCount()-1 do
|
||||
begin
|
||||
lCurSubEntity := lCurParagraph.GetEntity(j);
|
||||
|
||||
if (lCurSubEntity is TvText) then
|
||||
WriteTextSpan(TvText(lCurSubEntity), lCurParagraph, ACurPage, AData);
|
||||
end;
|
||||
|
||||
FContent := FContent + '</text:p>' + LineEnding +
|
||||
' </text:list-item>' + LineEnding;
|
||||
end;
|
||||
end;
|
||||
|
||||
FContent := FContent +
|
||||
' </text:list>' + LineEnding;
|
||||
end;
|
||||
|
||||
function TvODTVectorialWriter.WriteStylesXMLAsString: string;
|
||||
begin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user