OpenOffice.org
XMerge API

org.openoffice.xmerge.converter.xml
Class StyleCatalog

java.lang.Object
  |
  +--org.openoffice.xmerge.converter.xml.StyleCatalog

public class StyleCatalog
extends java.lang.Object

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

Constructor Summary
StyleCatalog(int initialEntries)
          Constructor
 
Method Summary
 void add(org.w3c.dom.Node node, java.lang.String[] families, java.lang.Class[] classes, java.lang.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.
 void add(Style s)
          Add a Style to the catalog.
 void dumpCSV(boolean para)
          Dump the Style table in Comma Separated Value (CSV) format
 Style getBestMatch(Style s)
          Given a Style s, return the style that is the closest match.
 Style[] getMatching(Style s)
          Given a Style s return all Style objects that match.
 Style lookup(java.lang.String name, java.lang.String family, java.lang.String parent, java.lang.Class styleClass)
          Return the first Style matching the specified names.
 org.w3c.dom.Element writeNode(org.w3c.dom.Document parentDoc, java.lang.String name)
          Create a Node named name in Document parentDoc, and write the entire StyleCatalog to it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyleCatalog

public StyleCatalog(int initialEntries)
Constructor
Parameters:
initialEntries - Expected number of entries to set for efficiency purposes.
Method Detail

add

public void add(org.w3c.dom.Node node,
                java.lang.String[] families,
                java.lang.Class[] classes,
                java.lang.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. 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:
node - The node to be searched for Style objects.
families - An array of Style families to add.
classes - An array of class types corresponding to the families array.
defaultClass - All Style objects that are found are added to this class.
alwaysCreateDefault - A class of type defaultClass will always be created, regardless of whether there is a match in the families array.

add

public void add(Style s)
Add a Style to the catalog.
Parameters:
s - The Style to add.

dumpCSV

public void dumpCSV(boolean para)
Dump the Style table in Comma Separated Value (CSV) format
Parameters:
para - If true, dump in paragraph Style, otherwise dump in text style.

getBestMatch

public Style getBestMatch(Style s)
Given a Style s, return the style that is the closest match. Not currently implemented.
Parameters:
s - Style to match.
Returns:
The Style that most closely matches.

getMatching

public Style[] getMatching(Style s)
Given a Style s return all Style objects that match.
Parameters:
s - Style to match.
Returns:
An array of Style objects that match, an empty array if none match.

lookup

public Style lookup(java.lang.String name,
                    java.lang.String family,
                    java.lang.String parent,
                    java.lang.Class styleClass)
Return the first Style matching the specified names.
Parameters:
name - Name to match, null is considered always match.
family - Family to match, null is considered always match.
parent - Parent to match, null is considered always match.
styleClass - styleClass to match, null is considered always match.
Returns:
Style value if all parameters match, null otherwise

writeNode

public org.w3c.dom.Element writeNode(org.w3c.dom.Document parentDoc,
                                     java.lang.String name)

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:
parentDoc - The Document to add the Node.
name - The name of the Node to add.
Returns:
The Element that was created.

OpenOffice.org
XMerge API

Copyright © 2002 OpenOffice.org