LibreOffice Module xmerge (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
org.openoffice.xmerge.converter.xml.StyleCatalog Class Reference

A StyleCatalog holds a collection of Style objects. More...

Collaboration diagram for org.openoffice.xmerge.converter.xml.StyleCatalog:
[legend]

Public Member Functions

 StyleCatalog (int initialEntries)
 Constructor. More...
 
void add (Node node, String families[], Class<?> classes[], Class<?> defaultClass, boolean alwaysCreateDefault)
 Parse the Document starting from node and working downward, and add all styles found, so long as their family name is listed in families. More...
 
void add (Style s)
 Add a Style to the catalog. More...
 
Style lookup (String name, String family, String parent, Class<?> styleClass)
 Return the first Style matching the specified names. More...
 
Style[] getMatching (Style s)
 Given a Style s return all Style objects that match. More...
 
Element writeNode (org.w3c.dom.Document parentDoc, String name)
 Create a Node named name in Document parentDoc, and write the entire StyleCatalog to it. More...
 

Private Member Functions

void callConstructor (Class<?> cls, Node node)
 Call the constructor of class cls with parameters node, and add the resulting Style to the catalog. More...
 
String getFamilyName (Node node)
 Find the family attribute of a Style Node. More...
 

Private Attributes

final ArrayList< Stylestyles
 

Detailed Description

A StyleCatalog holds a collection of Style objects.

It is intended for use when parsing or building a DOM document.

Each entry in the StyleCatalog represents a Style, and is an object which is a subclass of Style.

See also
Style

Definition at line 40 of file StyleCatalog.java.

Constructor & Destructor Documentation

◆ StyleCatalog()

org.openoffice.xmerge.converter.xml.StyleCatalog.StyleCatalog ( int  initialEntries)
inline

Constructor.

Parameters
initialEntriesExpected number of entries to set for efficiency purposes.

Definition at line 50 of file StyleCatalog.java.

References org.openoffice.xmerge.converter.xml.StyleCatalog.styles.

Member Function Documentation

◆ add() [1/2]

void org.openoffice.xmerge.converter.xml.StyleCatalog.add ( Node  node,
String  families[],
Class<?>  classes[],
Class<?>  defaultClass,
boolean  alwaysCreateDefault 
)
inline

Parse the Document starting from node and working downward, and add all styles found, so long as their family name is listed in families.

For each family name in families there must be a corresponding element in classes, which specifies the class type to use for that family. All of these classes must be subclasses of Style. There can be multiple classes specified for a particular family.

If defaultClass is non-null, then all styles that are found will be added. Any Style whose family is not listed in families will be added using defaultClass, which, of course, must be a subclass of Style. If alwaysCreateDefault is true, then a class of type defaultClass will always be created, regardless of whether there was also a match in families.

DJP ToDo: make it recursive so that node can be higher up in the Document tree.

Parameters
nodeThe node to be searched for Style objects.
familiesAn array of Style families to add.
classesAn array of class types corresponding to the families array.
defaultClassAll Style objects that are found are added to this class.
alwaysCreateDefaultA class of type defaultClass will always be created, regardless of whether there is a match in the families array.

Definition at line 86 of file StyleCatalog.java.

References org.openoffice.xmerge.converter.xml.StyleCatalog.callConstructor(), Class, org.openoffice.xmerge.util.Debug.ERROR, org.openoffice.xmerge.converter.xml.StyleCatalog.getFamilyName(), i, org.openoffice.xmerge.util.Debug.log(), name, and String.

Referenced by org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer.loadStyles(), org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer.processCells(), and org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer.processColumns().

◆ add() [2/2]

void org.openoffice.xmerge.converter.xml.StyleCatalog.add ( Style  s)
inline

Add a Style to the catalog.

Parameters
sThe Style to add.

Definition at line 154 of file StyleCatalog.java.

References org.openoffice.xmerge.converter.xml.StyleCatalog.styles.

◆ callConstructor()

void org.openoffice.xmerge.converter.xml.StyleCatalog.callConstructor ( Class<?>  cls,
Node  node 
)
inlineprivate

Call the constructor of class cls with parameters node, and add the resulting Style to the catalog.

Parameters
clsThe class whose constructor will be called.
nodeThe constructed class will be added to this node.

Definition at line 134 of file StyleCatalog.java.

References Class, org.openoffice.xmerge.util.Debug.ERROR, Exception, getClass(), org.openoffice.xmerge.util.Debug.log(), Object, p, and org.openoffice.xmerge.converter.xml.StyleCatalog.styles.

Referenced by org.openoffice.xmerge.converter.xml.StyleCatalog.add().

◆ getFamilyName()

String org.openoffice.xmerge.converter.xml.StyleCatalog.getFamilyName ( Node  node)
inlineprivate

Find the family attribute of a Style Node.

Parameters
nodeThe Node to check.
Returns
The family attribute, or null if one does not exist.

Definition at line 271 of file StyleCatalog.java.

References i, and String.

Referenced by org.openoffice.xmerge.converter.xml.StyleCatalog.add().

◆ getMatching()

Style[] org.openoffice.xmerge.converter.xml.StyleCatalog.getMatching ( Style  s)
inline

Given a Style s return all Style objects that match.

Parameters
sStyle to match.
Returns
An array of Style objects that match, an empty array if none match.

Definition at line 203 of file StyleCatalog.java.

References matchArray(), p, and org.openoffice.xmerge.converter.xml.StyleCatalog.styles.

Referenced by org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer.processCells(), and org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer.processColumns().

◆ lookup()

Style org.openoffice.xmerge.converter.xml.StyleCatalog.lookup ( String  name,
String  family,
String  parent,
Class<?>  styleClass 
)
inline

Return the first Style matching the specified names.

Parameters
nameName to match, null is considered always match.
familyFamily to match, null is considered always match.
parentParent to match, null is considered always match.
styleClassstyleClass to match, null is considered always match.
Returns
Style value if all parameters match, null otherwise.

Definition at line 173 of file StyleCatalog.java.

References org.openoffice.xmerge.converter.xml.Style.getFamily(), org.openoffice.xmerge.converter.xml.Style.getName(), org.openoffice.xmerge.converter.xml.Style.getParent(), i, name, and org.openoffice.xmerge.converter.xml.StyleCatalog.styles.

Referenced by org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer.traverseCell(), org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer.traverseTableColumn(), and org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer.traverseTableRow().

◆ writeNode()

Element org.openoffice.xmerge.converter.xml.StyleCatalog.writeNode ( org.w3c.dom.Document  parentDoc,
String  name 
)
inline

Create a Node named name in Document parentDoc, and write the entire StyleCatalog to it.

Note that the resulting node is returned, but is not connected into the document. Placing the output node in the document is left to the caller.

Parameters
parentDocThe Document to add the Node.
nameThe name of the Node to add.
Returns
The Element that was created.

Definition at line 237 of file StyleCatalog.java.

References org.openoffice.xmerge.converter.xml.Style.createNode(), org.openoffice.xmerge.converter.xml.Style.getFamily(), org.openoffice.xmerge.converter.xml.Style.getName(), org.openoffice.xmerge.converter.xml.Style.getParent(), name, and org.openoffice.xmerge.converter.xml.StyleCatalog.styles.

Referenced by org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer.processCells().

Member Data Documentation

◆ styles

final ArrayList<Style> org.openoffice.xmerge.converter.xml.StyleCatalog.styles
private

The documentation for this class was generated from the following file: