org.jopendocument.dom
Class Style

java.lang.Object
  extended by org.jopendocument.dom.ODNode
      extended by org.jopendocument.dom.Style
Direct Known Subclasses:
DataStyle, PageLayoutStyle, StyleStyle

public class Style
extends ODNode

A style, see section 16 of v1.2-part1. Maintains a map of family to classes.

Author:
Sylvain

Constructor Summary
Style(ODPackage pkg, org.jdom.Element styleElem)
           
 
Method Summary
protected  void checkElemName()
           
 Style dup()
          Make a copy of this style and add it to its document.
 boolean equals(Object obj)
           
protected  StyleDesc<?> getDesc()
           
 org.jdom.Element getFormattingProperties()
           
 org.jdom.Element getFormattingProperties(String family)
          Create if necessary and return the wanted properties.
 org.jdom.Element getFormattingProperties(String family, boolean create)
           
 String getName()
           
protected static
<S extends Style>
StyleDesc<S>
getNonNullStyleDesc(Class<S> clazz, XMLVersion version, org.jdom.Element styleElem, String styleName)
           
 XMLVersion getNS()
           
protected  ODPackage getPackage()
           
static Style getReferencedStyle(ODPackage pkg, org.jdom.Attribute styleAttr)
           
static org.jdom.Element getReferencedStyleElement(ODPackage pkg, org.jdom.Attribute styleAttr)
          Return the style element referenced by the passed attribute.
 List<org.jdom.Element> getReferences()
          Return the elements referring to this style.
protected  org.jdom.Namespace getSTYLE()
           
static
<S extends Style>
S
getStyle(ODPackage pkg, Class<S> clazz, String name)
           
static
<S extends Style>
StyleDesc<S>
getStyleDesc(Class<S> clazz, XMLVersion version)
           
static
<S extends StyleStyle>
StyleStyleDesc<S>
getStyleStyleDesc(Class<S> clazz, XMLVersion version)
           
 int hashCode()
           
 boolean isReferencedAtMostOnce()
           
static boolean isStandardStyleResolution()
           
static void register(StyleDesc<?> desc)
           
static void registerAllVersions(StyleDesc<? extends Style> desc)
           
static void setStandardStyleResolution(boolean std)
          Whether to search styles according to the standard or to LibreOffice.
static Style warp(ODPackage pkg, org.jdom.Element styleElem)
          Create the most specific instance for the passed element.
 
Methods inherited from class org.jopendocument.dom.ODNode
getElement, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Style

public Style(ODPackage pkg,
             org.jdom.Element styleElem)
Method Detail

setStandardStyleResolution

public static void setStandardStyleResolution(boolean std)
Whether to search styles according to the standard or to LibreOffice.

Parameters:
std - true to search like the standard, false to search like LibreOffice.

isStandardStyleResolution

public static boolean isStandardStyleResolution()

registerAllVersions

public static void registerAllVersions(StyleDesc<? extends Style> desc)

register

public static void register(StyleDesc<?> desc)

warp

public static Style warp(ODPackage pkg,
                         org.jdom.Element styleElem)
Create the most specific instance for the passed element.

Parameters:
pkg - the package where the style is defined.
styleElem - a style:style XML element.
Returns:
the most specific instance, e.g. a new ColumnStyle.

getStyle

public static <S extends Style> S getStyle(ODPackage pkg,
                                           Class<S> clazz,
                                           String name)

getReferencedStyleElement

public static org.jdom.Element getReferencedStyleElement(ODPackage pkg,
                                                         org.jdom.Attribute styleAttr)
Return the style element referenced by the passed attribute.

Parameters:
pkg - the package where styleAttr is defined.
styleAttr - any attribute in pkg, e.g. style:page-layout-name="pm1" of a style:master-page.
Returns:
the referenced element if styleAttr is an attribute pointing to a style in the passed package, null otherwise, e.g. .

getReferencedStyle

public static Style getReferencedStyle(ODPackage pkg,
                                       org.jdom.Attribute styleAttr)

getStyleDesc

public static <S extends Style> StyleDesc<S> getStyleDesc(Class<S> clazz,
                                                          XMLVersion version)

getStyleStyleDesc

public static <S extends StyleStyle> StyleStyleDesc<S> getStyleStyleDesc(Class<S> clazz,
                                                                         XMLVersion version)

getNonNullStyleDesc

protected static <S extends Style> StyleDesc<S> getNonNullStyleDesc(Class<S> clazz,
                                                                    XMLVersion version,
                                                                    org.jdom.Element styleElem,
                                                                    String styleName)

checkElemName

protected void checkElemName()

getPackage

protected final ODPackage getPackage()

getSTYLE

protected final org.jdom.Namespace getSTYLE()

getNS

public final XMLVersion getNS()

getName

public final String getName()

getDesc

protected StyleDesc<?> getDesc()

getFormattingProperties

public org.jdom.Element getFormattingProperties()

getFormattingProperties

public final org.jdom.Element getFormattingProperties(String family)
Create if necessary and return the wanted properties.

Parameters:
family - type of properties, eg "text".
Returns:
the matching properties, eg <text-properties>.

getFormattingProperties

public final org.jdom.Element getFormattingProperties(String family,
                                                      boolean create)

getReferences

public final List<org.jdom.Element> getReferences()
Return the elements referring to this style.

Returns:
the list of elements referring to this.

isReferencedAtMostOnce

public final boolean isReferencedAtMostOnce()

dup

public final Style dup()
Make a copy of this style and add it to its document.

Returns:
the new style with an unused name.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2010 jOpenDocument All Rights Reserved.