Skip to content

Commit

Permalink
Merge pull request #21 from joecare99/Merge_Changes
Browse files Browse the repository at this point in the history
Comments & documentation
  • Loading branch information
joecare99 authored Jun 21, 2024
2 parents e7a4a70 + 635b951 commit 31cb49e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
38 changes: 38 additions & 0 deletions FPdoc/odf_types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,44 @@
</element><element name="TOdfContent.AddLink"><short>appends a link (Hyperlink) to a bookmark</short>
</element><element name="TOdfContent.AddTab"><short>Appends a tabulator</short>
</element>
<element name="TOdfElement.CreateDomElement"><short>creates a DOM element of the specified type</short>
</element><element name="TOdfElement.GetElementType"><short>GetElementType returns the element type based on an index. </short>
</element><element name="TOdfElement.GetDocument"><short>the TOdfDocument associated with this element</short>
</element><element name="TOdfElement.CreateOdfElement"><short>creates an ODF element of the specified type</short>
</element><element name="TOdfElement.OdfGetElementType"><short>Returns the ODF element type for a given DOM element.</short>
</element><element name="TOdfElement.SameType"><short>Checks if two DOM elements have the same type.</short>
</element><element name="TOdfElement.SetAttribute"><short>Sets an attribute value for the parent element.</short>
</element><element name="TOdfElement.OdfGetFirstElement"><short>Returns the first child ODF element of the specified type.</short>
</element><element name="TOdfElement.SetOrDeleteAttributes"><short>Sets or deletes attributes based on the specified array. </short>
</element><element name="TOdfElement.SetAttributes"><short>Sets multiple attributes with corresponding values. </short>
</element><element name="TOdfElement.DeleteAttributes"><short>Deletes multiple attributes specified in the array. </short>
</element><element name="TOdfElement.RemoveAttribute"><short>Removes the attribute of the specified type.</short>
</element><element name="TOdfElement.HasAttribute"><short>Checks if the element has the specified attribute.</short>
</element><element name="TOdfElement.GetAttributeString"><short>Retrieves the attribute value as a string.</short>
</element><element name="TOdfElement.GetAttribute"><short>Retrieves the attribute of the specified type.</short>
</element><element name="TOdfElement.FindStyle"><short>Finds an ODF element with the given style name. </short>
</element><element name="TOdfElement.HasOdfElement"><short>Checks if the ODF element of the specified type exists. </short>
</element><element name="TOdfElement.FindOdfElement"><short>Finds and returns the first ODF element of the specified type.</short>
</element><element name="TTextSequenceDecls"><short>Defines a Delaration for a Text-sequence</short>
</element><element name="TConfigConfigItemSet"><short>Defines a set of Config-Config-items</short>
</element><element name="TConfigConfigItemSet.ConfigName"><short>the name of the config</short>
</element><element name="TOdfColor"><short>A color-record with three base-colors</short>
</element><element name="TOdfFont"><short>Font-definition for odf-files</short>
</element><element name="TOdfSection"><short>Section is collection of Paragraphes of the same formatting</short>
</element><element name="TDefaultStyle"><short>a text-style as default</short>
</element><element name="cCharSpace"><short>The space/blank character</short>
</element><element name="cNone"><short>the None-Tag</short>
</element><element name="cFileContent"><short>Name of the content-file</short>
</element><element name="cFileStyles"><short>name of the style-file</short>
</element><element name="cIsoDateFormat"><short>the date-format in the file</short>
</element><element name="cMetaGenerator"><short>the generator-name and version</short>
</element><element name="cUrnOpenDocument"><short>odf-namespace-definition</short>
</element><element name="cUrlOasis"><short>Url: Oasis</short>
</element><element name="cUriOffice12Meta"><short>url: Office</short>
</element><element name="cUriOdfMeta"><short>Url: Odf-Meta</short>
</element><element name="cUrlW3"><short>Url: W3</short>
</element><element name="cOwnerAttr"><short>The 'Owner' attribute</short>
</element>
</module>
</package>
</fpdoc-descriptions>
29 changes: 24 additions & 5 deletions odf_types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -308,30 +308,37 @@ TOdfElementClass = class of TOdfElement;
TOdfDocument = class;

{ TOdfElement }

// OdfElement: Basedefinition of all Open-Document-Elements
TOdfElement = class(TDOMElement)
private
// GetElementType returns the element type based on an index.
class function GetElementType(AIndex: TElementType): TElementType;

protected
// GetDocument returns the TOdfDocument associated with this element.
function GetDocument: TOdfDocument;

public
// CreateDomElement creates a DOM element of the specified type.
class function CreateDomElement(AType: TElementType;
Doc: TXMLDocument): TDOMElement; overload;
class function CreateDomElement(AType: TElementType; Doc: TXMLDocument;
at: TAttributeType; AttValue: String): TDOMElement; overload;

// CreateOdfElement creates an ODF element of the specified type.
class function CreateOdfElement(AType: TElementType;
Doc: TXMLDocument): TOdfElement; overload;
class function CreateOdfElement(AType: TElementType;
AClass: TOdfElementClass; Doc: TXMLDocument): TOdfElement; overload;

// OdfGetElementType returns the ODF element type for a given DOM element.
class function OdfGetElementType(e: TDOMElement): TElementType;

// SameType checks if two DOM elements have the same type.
class function SameType(e1, e2: TDomElement): boolean;
class function SameType(e: TDomElement; AType: TElementType): boolean;

// SetAttribute sets an attribute value for the parent element.
class procedure SetAttribute(at: TAttributeType;
AParent: TDOMElement;
AValue: string);
Expand All @@ -340,28 +347,40 @@ TOdfElement = class(TDOMElement)
AParent: TDOMElement;
const Values: array of string);


// AppendOdfElement appends a child ODF element of the specified type.
function AppendOdfElement(AType: TElementType): TOdfElement; overload;
function AppendOdfElement(AType: TElementType;AClass: TOdfElementClass): TOdfElement; overload;
function AppendOdfElement(AType: TElementType; at: TAttributeType;
AValue: string;AClass: TOdfElementClass): TOdfElement;
function AppendOdfElement(AType: TElementType; at: TAttributeType;
AValue: string): TOdfElement;

// OdfGetFirstElement returns the first child ODF element of the specified type.
function OdfGetFirstElement: TOdfElement;
// Checks if the ODF element of the specified type exists.
function HasOdfElement(AType: TElementType): boolean;
// Finds and returns the first ODF element of the specified type.
function FindOdfElement(AType: TElementType): TOdfElement;

// Finds an ODF element with the given style name.
function FindStyle(aName: String): TOdfElement;
// Finds an ODF element with the specified name. If 'recursive' is true, searches recursively.
function Find(aName: String;recursive:boolean=false): TOdfElement;
// Retrieves the attribute of the specified type.
function GetAttribute(AType: TAttributeType): TDOMAttr;
// Retrieves the attribute value as a string.
function GetAttributeString(AType: TAttributeType): String;
// Checks if the element has the specified attribute.
function HasAttribute(AType: TAttributeType): boolean;
// Removes the attribute of the specified type.
function RemoveAttribute(AType: TAttributeType): TDOMAttr;
// Deletes multiple attributes specified in the array.
procedure DeleteAttributes(const atts: array of TAttributeType);
// Sets the value of the specified attribute.
procedure SetAttribute(AType: TAttributeType; AValue: string);
// Sets multiple attributes with corresponding values.
procedure SetAttributes(const atts: array of TAttributeType;
const Values: array of String);

// Sets or deletes attributes based on the specified array.
procedure SetOrDeleteAttributes(const atts: array of TAttributeType;
const Value: String = '');

Expand Down Expand Up @@ -1438,7 +1457,7 @@ function TOdfContent.GetStyle: TOdfStyleStyle;
result := nil;
lattr := GetAttribute(oatTextStyleName);
if assigned(lattr) then
result := TOdfTextDocument(OwnerDocument).SearchStyle(lattr.Value);
result := TOdfTextDocument(GetDocument()).SearchStyle(lattr.Value);
end;

function TOdfContent.GetCharacterContent(Recursive: boolean): string;
Expand Down

0 comments on commit 31cb49e

Please sign in to comment.