com.aspose.words
Class StyleCollection

java.lang.Object
    extended by com.aspose.words.StyleCollection
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Iterable

public class StyleCollection 
extends java.lang.Object

A collection of Style objects that represent both the built-in and user-defined styles in a document.

Property Getters/Setters Summary
intgetCount()
           Gets the number of styles in the collection.
FontgetDefaultFont()
           Gets document default text formatting.
ParagraphFormatgetDefaultParagraphFormat()
           Gets document default paragraph formatting.
DocumentBasegetDocument()
           Gets the owner document.
Styleget(int index)
           Gets a style by index.
Styleget(java.lang.String name)
           Gets a style by name or alias.
StylegetByStyleIdentifier(int sti)
           Gets a built-in style by its locale independent identifier.
 
Method Summary
Styleadd(int type, java.lang.String name)
           Creates a new user defined style and adds it the collection.
StyleaddCopy(Style style)
           Copies a style into this collection.
java.util.Iteratoriterator()
           Gets an enumerator object that will enumerate styles in the alphabetical order of their names.
 

Property Getters/Setters Detail

getCount

public int getCount()
Gets the number of styles in the collection.

getDefaultFont

public Font getDefaultFont()
Gets document default text formatting.

Note that document-wide defaults were introduced in Microsoft Word 2007 and are fully supported in OOXML formats (#Error Cref: F:Aspose.FileFormat.Docx) only. Earlier document formats have limited support for this feature and only font names can be stored.


getDefaultParagraphFormat

public ParagraphFormat getDefaultParagraphFormat()
Gets document default paragraph formatting.

Note that document-wide defaults were introduced in Microsoft Word 2007 and are fully supported in OOXML formats (#Error Cref: F:Aspose.FileFormat.Docx) only. Earlier document formats have no support for document default paragraph formatting.


getDocument

public DocumentBase getDocument()
Gets the owner document.

get

public Style get(int index)
Gets a style by index.

get

public Style get(java.lang.String name)
Gets a style by name or alias.

Case sensitive, returns null if the style with the given name is not found.

If this is an English name of a built in style that does not yet exist, automatically creates it.


getByStyleIdentifier

public Style getByStyleIdentifier(int sti)
Gets a built-in style by its locale independent identifier.

When accessing a style that does not yet exist, automatically creates it.

Parameters:
sti - A StyleIdentifier value. A StyleIdentifier value that specifies the built in style to retrieve.

Method Detail

add

public Style add(int type, java.lang.String name)
Creates a new user defined style and adds it the collection.

You can create character, paragraph or a list style.

When creating a list style, the style is created with default numbered list formatting (1 \ a \ i).

Throws an exception if a style with this name already exists.

Parameters:
type - A StyleType value that specifies the type of the style to create.
name - Case sensitive name of the style to create.

addCopy

public Style addCopy(Style style)
Copies a style into this collection.

Style to be copied can belong to the same document as well as to different document.

Linked style is copied.

This method does doesn't copy base styles.

If collection already contains a style with the same name, then new name is automatically generated by adding "_number" suffix starting from 0 e.g. "Normal_0", "Heading 1_1" etc. Use Style.Name setter for changing the name of the imported style.

Parameters:
style - Style to be copied.
Returns:
Copied style ready for usage.

iterator

public java.util.Iterator iterator()
Gets an enumerator object that will enumerate styles in the alphabetical order of their names.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.