OpenOffice.org
XMerge API

org.openoffice.xmerge.converter.xml
Class TextStyle

java.lang.Object
  |
  +--org.openoffice.xmerge.converter.xml.Style
        |
        +--org.openoffice.xmerge.converter.xml.TextStyle
All Implemented Interfaces:
java.lang.Cloneable

public class TextStyle
extends Style
implements java.lang.Cloneable

Represents a text Style in an OpenOffice document.


Field Summary
protected  java.awt.Color bgColor
          Background Color.
static int BOLD
          Indicates bold text.
protected static int FIRST_ATTR
           
protected  java.awt.Color fontColor
          Font Color.
protected  java.lang.String fontName
          Font name.
static int ITALIC
          Indicates italic text.
protected static int LAST_ATTR
          Indicates the last attribute.
protected  int mask
          Bitwise mask of text attributes.
protected  int sizeInPoints
          Font size in points.
static int STRIKETHRU
          Indicates strike-through in the text.
static int SUBSCRIPT
          Indicates subscripted text.
static int SUPERSCRIPT
          Indicates superscripted text.
static int UNDERLINE
          Indicates underlined text.
protected  int values
          Values of text attributes.
 
Fields inherited from class org.openoffice.xmerge.converter.xml.Style
family, name, parent, sc
 
Constructor Summary
TextStyle(org.w3c.dom.Node node, StyleCatalog sc)
          Constructor for use when going from DOM to client device format.
TextStyle(java.lang.String name, java.lang.String family, java.lang.String parent, int mask, int values, int fontSize, java.lang.String fontName, StyleCatalog sc)
          Constructor for use when going from client device format to DOM
 
Method Summary
 org.w3c.dom.Node createNode(org.w3c.dom.Document parentDoc, java.lang.String name)
          Create a new Node in the Document, and write this Style to it.
 void dumpCSV()
          Dump this Style as a Comma Separated Value (CSV) line.
static void dumpHdr()
          Print a Comma Separated Value (CSV) header line for the spreadsheet dump.
 boolean getAttribute(int attribute)
          Return true if the attribute is set to on
 java.awt.Color getBackgroundColor()
          Return the background Color for this Style.
 java.awt.Color getFontColor()
          Return the font Color for this Style.
 java.lang.String getFontName()
          Return the name of the font for this Style.
 int getFontSize()
          Return the font size for this Style.
 Style getResolved()
          Return a Style object corresponding to this one, but with all of the inherited information from parent Style objects filled in.
 boolean isSet(int attribute)
          Return true if text attribute is set in this Style.
 boolean isSubset(Style style)
          Return true if style specifies as much or less than this Style, and nothing it specifies contradicts this Style.
 void setColors(java.awt.Color fontColor, java.awt.Color backgroundColor)
          Set the font and/or background Color for this Style.
 void writeAttributes(org.w3c.dom.Element node)
          Write this Style object's attributes to a Node in the Document.
 
Methods inherited from class org.openoffice.xmerge.converter.xml.Style
getFamily, getName, getParent, setCatalog, setName, writeAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bgColor

protected java.awt.Color bgColor
Background Color.

BOLD

public static final int BOLD
Indicates bold text.

FIRST_ATTR

protected static final int FIRST_ATTR

fontColor

protected java.awt.Color fontColor
Font Color.

fontName

protected java.lang.String fontName
Font name.

ITALIC

public static final int ITALIC
Indicates italic text.

LAST_ATTR

protected static final int LAST_ATTR
Indicates the last attribute.

mask

protected int mask
Bitwise mask of text attributes.

sizeInPoints

protected int sizeInPoints
Font size in points.

STRIKETHRU

public static final int STRIKETHRU
Indicates strike-through in the text.

SUBSCRIPT

public static final int SUBSCRIPT
Indicates subscripted text.

SUPERSCRIPT

public static final int SUPERSCRIPT
Indicates superscripted text.

UNDERLINE

public static final int UNDERLINE
Indicates underlined text.

values

protected int values
Values of text attributes.
Constructor Detail

TextStyle

public TextStyle(org.w3c.dom.Node node,
                 StyleCatalog sc)
Constructor for use when going from DOM to client device format.
Parameters:
Node - The style:style Node containing the Style. (This Node is assumed have a family attribute of text).
sc - The StyleCatalog, which is used for looking up ancestor Style objects.

TextStyle

public TextStyle(java.lang.String name,
                 java.lang.String family,
                 java.lang.String parent,
                 int mask,
                 int values,
                 int fontSize,
                 java.lang.String fontName,
                 StyleCatalog sc)
Constructor for use when going from client device format to DOM
Parameters:
name - Name of text Style. Can be null.
family - Family of text Style (usually text). Can be null.
parent - Name of parent text Style, or null for none.
mask - Bitwise mask of text attributes that this text Style will specify. Can be any combination of the following, or'ed together: BOLD, ITALIC, UNDERLINE, STRIKETHRU, SUPERSCRIPT, SUBSCRIPT. This parameter determines what attributes this Style will specify. When an attribute is specified in a Style, its value can be either on or off. The on/off value for each attribute is controlled by the values parameter.
values - Values of text attributes that this text Style will be setting. Any of the attributes (BOLD, etc) listed for mask can be used for this.
fontSize - Font size in points.
fontName - Name of font.
sc - The StyleCatalog, which is used for looking up ancestor Style objects.
Method Detail

createNode

public org.w3c.dom.Node createNode(org.w3c.dom.Document parentDoc,
                                   java.lang.String name)
Create a new Node in the Document, and write this Style to it.
Overrides:
createNode in class Style
Parameters:
parentDoc - Parent Document of the Node to create.
name - Name to use for the new Node (e.g. style:style)
Returns:
Created Node.

dumpCSV

public void dumpCSV()
Dump this Style as a Comma Separated Value (CSV) line.

dumpHdr

public static void dumpHdr()
Print a Comma Separated Value (CSV) header line for the spreadsheet dump.

getAttribute

public boolean getAttribute(int attribute)
Return true if the attribute is set to on
Parameters:
attribute - Attribute to check (BOLD, ITALIC, etc.)
Returns:
true if attribute is set to on, otherwise false.

getBackgroundColor

public java.awt.Color getBackgroundColor()
Return the background Color for this Style. Can be null if none was specified.
Returns:
Background Color value for this Style. Can be null.

getFontColor

public java.awt.Color getFontColor()
Return the font Color for this Style. Can be null if none was specified.
Returns:
Color value for this Style. Can be null.

getFontName

public java.lang.String getFontName()
Return the name of the font for this Style.
Returns:
Name of font, or null if no font is specified by this Style.

getFontSize

public int getFontSize()
Return the font size for this Style.
Returns:
The font size in points

getResolved

public Style getResolved()
Return a Style object corresponding to this one, but with all of the inherited information from parent Style objects filled in. The object returned will be a new object, not a reference to this object, even if it does not need any information added.
Overrides:
getResolved in class Style
Returns:
The StyleCatalog in which to look up ancestors.

isSet

public boolean isSet(int attribute)
Return true if text attribute is set in this Style. An attribute that is set may have a value of on or off.
Parameters:
attribute - The attribute to check (BOLD, ITALIC, etc.).
Returns:
true if text attribute is set in this Style, false otherwise.

isSubset

public boolean isSubset(Style style)
Return true if style specifies as much or less than this Style, and nothing it specifies contradicts this Style.
Overrides:
isSubset in class Style
Parameters:
style - The Style to check.
Returns:
true if style is a subset, false otherwise.

setColors

public void setColors(java.awt.Color fontColor,
                      java.awt.Color backgroundColor)
Set the font and/or background Color for this Style.
Parameters:
fontColor - The font Color to set.
backgroundColor - The background Color to set.

writeAttributes

public void writeAttributes(org.w3c.dom.Element node)
Write this Style object's attributes to a Node in the Document.
Parameters:
node - The Node to add Style attributes.

OpenOffice.org
XMerge API

Copyright © 2002 OpenOffice.org