org.apache.poi.hslf.usermodel
Class HSLFTextParagraph

java.lang.Object
  extended by org.apache.poi.hslf.usermodel.HSLFTextParagraph
All Implemented Interfaces:
java.lang.Iterable<HSLFTextRun>, TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

public final class HSLFTextParagraph
extends java.lang.Object
implements TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

This class represents a run of text in a powerpoint document. That run could be text on a sheet, or text in a note. It is only a very basic class for now


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextParagraph
TextParagraph.BulletStyle, TextParagraph.FontAlign, TextParagraph.TextAlign
 
Field Summary
protected  HSLFTextShape _parentShape
           
protected  TextRulerAtom _ruler
           
protected  java.util.List<HSLFTextRun> _runs
           
protected static POILogger logger
           
 
Method Summary
 void addTextRun(HSLFTextRun run)
           
protected static HSLFTextRun appendText(java.util.List<HSLFTextParagraph> paragraphs, java.lang.String text, boolean newParagraph)
          Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.
protected static void applyCharacterStyles(java.util.List<HSLFTextParagraph> paragraphs, java.util.List<TextPropCollection> charStyles)
           
protected static void applyHyperlinks(java.util.List<HSLFTextParagraph> paragraphs)
           
protected static void applyParagraphIndents(java.util.List<HSLFTextParagraph> paragraphs, java.util.List<IndentProp> paraStyles)
           
protected static void applyParagraphStyles(java.util.List<HSLFTextParagraph> paragraphs, java.util.List<TextPropCollection> paraStyles)
           
 TextRulerAtom createTextRuler()
           
protected static java.util.List<HSLFTextParagraph> findTextParagraphs(EscherTextboxWrapper wrapper, HSLFSheet sheet)
          Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom.
static java.util.List<java.util.List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing, HSLFSheet sheet)
          For a given PPDrawing, grab all the TextRuns
protected static java.util.List<java.util.List<HSLFTextParagraph>> findTextParagraphs(Record[] records)
          Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom.
protected static void fixLineEndings(java.util.List<HSLFTextParagraph> paragraphs)
          Check and add linebreaks to text runs leading other paragraphs
 AutoNumberingScheme getAutoNumberingScheme()
           
 java.lang.Integer getAutoNumberingStartAt()
           
 java.lang.Character getBulletChar()
          Returns the bullet character
 java.awt.Color getBulletColor()
          Returns the bullet color
 java.lang.String getBulletFont()
          Returns the bullet font
 java.lang.Double getBulletSize()
          Returns the bullet size, null if unset
 TextParagraph.BulletStyle getBulletStyle()
           
protected static java.awt.Color getColorFromColorIndexStruct(int rgb, HSLFSheet sheet)
           
 java.lang.String getDefaultFontFamily()
           
 java.lang.Double getDefaultFontSize()
           
 java.lang.Double getDefaultTabSize()
           
 TextParagraph.FontAlign getFontAlign()
           
 java.lang.Double getIndent()
           
 int getIndentLevel()
           
protected  int getIndex()
           
 java.lang.Double getLeftMargin()
           
 java.lang.Double getLineSpacing()
           
 TextPropCollection getParagraphStyle()
           
 HSLFTextShape getParentShape()
           
protected  TextProp getPropVal(TextPropCollection props, TextPropCollection masterProps, java.lang.String propName)
          Fetch the value of the given Paragraph related TextProp.
static java.lang.String getRawText(java.util.List<HSLFTextParagraph> paragraphs)
           
 Record[] getRecords()
          Returns records that make up the list of text paragraphs (there can be misc InteractiveInfo, TxInteractiveInfo and other records)
 java.lang.Double getRightMargin()
           
 int getRunType()
          Returns the type of the text, from the TextHeaderAtom.
protected  int getShapeId()
           
 HSLFSheet getSheet()
           
 java.lang.Double getSpaceAfter()
           
 java.lang.Double getSpaceBefore()
           
 StyleTextProp9Atom getStyleTextProp9Atom()
          Numbered List info
static java.lang.String getText(java.util.List<HSLFTextParagraph> paragraphs)
           
 TextParagraph.TextAlign getTextAlign()
           
 EscherTextboxWrapper getTextboxWrapper()
           
 TextRulerAtom getTextRuler()
           
 java.util.List<HSLFTextRun> getTextRuns()
           
 boolean isBullet()
          Returns whether this rich text run has bullets
 boolean isDirty()
           
 boolean isDrawingBased()
          Is this Text Run one from a PPDrawing, or is it one from the SlideListWithText?
 boolean isHeaderOrFooter()
          
 java.util.Iterator<HSLFTextRun> iterator()
           
 void setBullet(boolean flag)
          Sets whether this rich text run has bullets
 void setBulletChar(java.lang.Character c)
          Sets the bullet character
 void setBulletColor(java.awt.Color color)
          Sets the bullet color
 void setBulletFont(java.lang.String typeface)
          Sets the bullet font
 void setBulletSize(java.lang.Double size)
          Sets the bullet size
 void setBulletStyle(java.lang.Object... styles)
           
 void setDirty()
          marks this paragraph dirty, so its records will be renewed on save
 void setIndent(java.lang.Double indent)
           
 void setIndentLevel(int level)
           
protected  void setIndex(int index)
          Sets the index of the paragraph in the SLWT container
 void setLeftMargin(java.lang.Double leftMargin)
           
 void setLineSpacing(java.lang.Double lineSpacing)
           
 void setParagraphStyle(TextPropCollection paragraphStyle)
           
 void setParagraphTextPropVal(java.lang.String propName, java.lang.Integer val)
          Sets the value of the given Paragraph TextProp, add if required
 void setParentShape(HSLFTextShape parentShape)
           
protected  void setPropVal(TextPropCollection props, TextPropCollection masterProps, java.lang.String name, java.lang.Integer val)
          Returns the named TextProp, either by fetching it (if it exists) or adding it (if it didn't)
 void setRightMargin(java.lang.Double rightMargin)
           
 void setRunType(int runType)
           
protected  void setShapeId(int id)
           
 void setSpaceAfter(java.lang.Double spaceAfter)
           
 void setSpaceBefore(java.lang.Double spaceBefore)
           
 void setStyleTextProp9Atom(StyleTextProp9Atom styleTextProp9Atom)
          Numbered List info
static HSLFTextRun setText(java.util.List<HSLFTextParagraph> paragraphs, java.lang.String text)
          Sets (overwrites) the current text.
 void setTextAlign(TextParagraph.TextAlign align)
           
protected static void storeText(java.util.List<HSLFTextParagraph> paragraphs)
          Saves the modified paragraphs/textrun to the records.
static void supplySheet(java.util.List<HSLFTextParagraph> paragraphs, HSLFSheet sheet)
          Supply the Sheet we belong to, which might have an assigned SlideShow Also passes it on to our child RichTextRuns
static java.lang.String toExternalString(java.lang.String rawText, int runType)
          Converts raw text from the text paragraphs to a formatted string, i.e.
protected static java.lang.String toInternalString(java.lang.String s)
          Returns a new string with line breaks converted into internal ppt representation
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final POILogger logger

_ruler

protected TextRulerAtom _ruler

_runs

protected final java.util.List<HSLFTextRun> _runs

_parentShape

protected HSLFTextShape _parentShape
Method Detail

addTextRun

public void addTextRun(HSLFTextRun run)

getTextRuns

public java.util.List<HSLFTextRun> getTextRuns()
Specified by:
getTextRuns in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getParagraphStyle

public TextPropCollection getParagraphStyle()

setParagraphStyle

public void setParagraphStyle(TextPropCollection paragraphStyle)

supplySheet

public static void supplySheet(java.util.List<HSLFTextParagraph> paragraphs,
                               HSLFSheet sheet)
Supply the Sheet we belong to, which might have an assigned SlideShow Also passes it on to our child RichTextRuns


getSheet

public HSLFSheet getSheet()

getShapeId

protected int getShapeId()
Returns:
Shape ID

setShapeId

protected void setShapeId(int id)
Parameters:
id - Shape ID

getIndex

protected int getIndex()
Returns:
0-based index of the text run in the SLWT container

setIndex

protected void setIndex(int index)
Sets the index of the paragraph in the SLWT container

Parameters:
index -

getRunType

public int getRunType()
Returns the type of the text, from the TextHeaderAtom. Possible values can be seen from TextHeaderAtom

See Also:
TextHeaderAtom

setRunType

public void setRunType(int runType)

isDrawingBased

public boolean isDrawingBased()
Is this Text Run one from a PPDrawing, or is it one from the SlideListWithText?


getTextRuler

public TextRulerAtom getTextRuler()

createTextRuler

public TextRulerAtom createTextRuler()

getRecords

public Record[] getRecords()
Returns records that make up the list of text paragraphs (there can be misc InteractiveInfo, TxInteractiveInfo and other records)

Returns:
text run records

setStyleTextProp9Atom

public void setStyleTextProp9Atom(StyleTextProp9Atom styleTextProp9Atom)
Numbered List info


getStyleTextProp9Atom

public StyleTextProp9Atom getStyleTextProp9Atom()
Numbered List info


iterator

public java.util.Iterator<HSLFTextRun> iterator()
Specified by:
iterator in interface java.lang.Iterable<HSLFTextRun>

getLeftMargin

public java.lang.Double getLeftMargin()
Specified by:
getLeftMargin in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setLeftMargin

public void setLeftMargin(java.lang.Double leftMargin)
Specified by:
setLeftMargin in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getRightMargin

public java.lang.Double getRightMargin()
Specified by:
getRightMargin in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setRightMargin

public void setRightMargin(java.lang.Double rightMargin)
Specified by:
setRightMargin in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getIndent

public java.lang.Double getIndent()
Specified by:
getIndent in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setIndent

public void setIndent(java.lang.Double indent)
Specified by:
setIndent in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getDefaultFontFamily

public java.lang.String getDefaultFontFamily()
Specified by:
getDefaultFontFamily in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getDefaultFontSize

public java.lang.Double getDefaultFontSize()
Specified by:
getDefaultFontSize in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setTextAlign

public void setTextAlign(TextParagraph.TextAlign align)
Specified by:
setTextAlign in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getTextAlign

public TextParagraph.TextAlign getTextAlign()
Specified by:
getTextAlign in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getFontAlign

public TextParagraph.FontAlign getFontAlign()
Specified by:
getFontAlign in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getAutoNumberingScheme

public AutoNumberingScheme getAutoNumberingScheme()

getAutoNumberingStartAt

public java.lang.Integer getAutoNumberingStartAt()

getBulletStyle

public TextParagraph.BulletStyle getBulletStyle()
Specified by:
getBulletStyle in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setBulletStyle

public void setBulletStyle(java.lang.Object... styles)
Specified by:
setBulletStyle in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getParentShape

public HSLFTextShape getParentShape()
Specified by:
getParentShape in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setParentShape

public void setParentShape(HSLFTextShape parentShape)

getIndentLevel

public int getIndentLevel()
Specified by:
getIndentLevel in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setIndentLevel

public void setIndentLevel(int level)
Specified by:
setIndentLevel in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setBullet

public void setBullet(boolean flag)
Sets whether this rich text run has bullets


isBullet

public boolean isBullet()
Returns whether this rich text run has bullets


setBulletChar

public void setBulletChar(java.lang.Character c)
Sets the bullet character


getBulletChar

public java.lang.Character getBulletChar()
Returns the bullet character


setBulletSize

public void setBulletSize(java.lang.Double size)
Sets the bullet size


getBulletSize

public java.lang.Double getBulletSize()
Returns the bullet size, null if unset


setBulletColor

public void setBulletColor(java.awt.Color color)
Sets the bullet color


getBulletColor

public java.awt.Color getBulletColor()
Returns the bullet color


setBulletFont

public void setBulletFont(java.lang.String typeface)
Sets the bullet font


getBulletFont

public java.lang.String getBulletFont()
Returns the bullet font


setLineSpacing

public void setLineSpacing(java.lang.Double lineSpacing)
Specified by:
setLineSpacing in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getLineSpacing

public java.lang.Double getLineSpacing()
Specified by:
getLineSpacing in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setSpaceBefore

public void setSpaceBefore(java.lang.Double spaceBefore)
Specified by:
setSpaceBefore in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getSpaceBefore

public java.lang.Double getSpaceBefore()
Specified by:
getSpaceBefore in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

setSpaceAfter

public void setSpaceAfter(java.lang.Double spaceAfter)
Specified by:
setSpaceAfter in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getSpaceAfter

public java.lang.Double getSpaceAfter()
Specified by:
getSpaceAfter in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getDefaultTabSize

public java.lang.Double getDefaultTabSize()
Specified by:
getDefaultTabSize in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>

getPropVal

protected TextProp getPropVal(TextPropCollection props,
                              TextPropCollection masterProps,
                              java.lang.String propName)
Fetch the value of the given Paragraph related TextProp. Returns null if that TextProp isn't present. If the TextProp isn't present, the value from the appropriate Master Sheet will apply. The propName can be a comma-separated list, in case multiple equivalent values are queried


setPropVal

protected void setPropVal(TextPropCollection props,
                          TextPropCollection masterProps,
                          java.lang.String name,
                          java.lang.Integer val)
Returns the named TextProp, either by fetching it (if it exists) or adding it (if it didn't)

Parameters:
props - the TextPropCollection to fetch from / add into
name - the name of the TextProp to fetch/add
val - the value, null if unset

fixLineEndings

protected static void fixLineEndings(java.util.List<HSLFTextParagraph> paragraphs)
Check and add linebreaks to text runs leading other paragraphs

Parameters:
paragraphs -

storeText

protected static void storeText(java.util.List<HSLFTextParagraph> paragraphs)
Saves the modified paragraphs/textrun to the records. Also updates the styles to the correct text length.


appendText

protected static HSLFTextRun appendText(java.util.List<HSLFTextParagraph> paragraphs,
                                        java.lang.String text,
                                        boolean newParagraph)
Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.

Parameters:
text - the text string used by this object.

setText

public static HSLFTextRun setText(java.util.List<HSLFTextParagraph> paragraphs,
                                  java.lang.String text)
Sets (overwrites) the current text. Uses the properties of the first paragraph / textrun

Parameters:
text - the text string used by this object.

getText

public static java.lang.String getText(java.util.List<HSLFTextParagraph> paragraphs)

getRawText

public static java.lang.String getRawText(java.util.List<HSLFTextParagraph> paragraphs)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toInternalString

protected static java.lang.String toInternalString(java.lang.String s)
Returns a new string with line breaks converted into internal ppt representation


toExternalString

public static java.lang.String toExternalString(java.lang.String rawText,
                                                int runType)
Converts raw text from the text paragraphs to a formatted string, i.e. it converts certain control characters used in the raw txt

Parameters:
rawText - the raw text
runType - the run type of the shape, paragraph or headerAtom. use -1 if unknown
Returns:
the formatted string

findTextParagraphs

public static java.util.List<java.util.List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing,
                                                                                   HSLFSheet sheet)
For a given PPDrawing, grab all the TextRuns


findTextParagraphs

protected static java.util.List<HSLFTextParagraph> findTextParagraphs(EscherTextboxWrapper wrapper,
                                                                      HSLFSheet sheet)
Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom. Builds up TextRuns from these

Parameters:
wrapper - an EscherTextboxWrapper

findTextParagraphs

protected static java.util.List<java.util.List<HSLFTextParagraph>> findTextParagraphs(Record[] records)
Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom. Builds up TextRuns from these

Parameters:
records - the records to build from

applyHyperlinks

protected static void applyHyperlinks(java.util.List<HSLFTextParagraph> paragraphs)

applyCharacterStyles

protected static void applyCharacterStyles(java.util.List<HSLFTextParagraph> paragraphs,
                                           java.util.List<TextPropCollection> charStyles)

applyParagraphStyles

protected static void applyParagraphStyles(java.util.List<HSLFTextParagraph> paragraphs,
                                           java.util.List<TextPropCollection> paraStyles)

applyParagraphIndents

protected static void applyParagraphIndents(java.util.List<HSLFTextParagraph> paragraphs,
                                            java.util.List<IndentProp> paraStyles)

getTextboxWrapper

public EscherTextboxWrapper getTextboxWrapper()

getColorFromColorIndexStruct

protected static java.awt.Color getColorFromColorIndexStruct(int rgb,
                                                             HSLFSheet sheet)

setParagraphTextPropVal

public void setParagraphTextPropVal(java.lang.String propName,
                                    java.lang.Integer val)
Sets the value of the given Paragraph TextProp, add if required

Parameters:
propName - The name of the Paragraph TextProp
val - The value to set for the TextProp

setDirty

public void setDirty()
marks this paragraph dirty, so its records will be renewed on save


isDirty

public boolean isDirty()

isHeaderOrFooter

public boolean isHeaderOrFooter()

Specified by:
isHeaderOrFooter in interface TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
See Also:
RoundTripHFPlaceholder12