org.apache.poi.hslf.model
Class TextRun

java.lang.Object
  extended by org.apache.poi.hslf.model.TextRun

public final class TextRun
extends java.lang.Object

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

Author:
Nick Burch

Field Summary
protected  TextBytesAtom _byteAtom
           
protected  TextCharsAtom _charAtom
           
protected  TextHeaderAtom _headerAtom
           
protected  boolean _isUnicode
           
protected  Record[] _records
          all text run records that follow TextHeaderAtom.
protected  RichTextRun[] _rtRuns
           
protected  TextRulerAtom _ruler
           
protected  StyleTextPropAtom _styleAtom
           
 
Constructor Summary
TextRun(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta)
          Constructs a Text Run from a Ascii text block
TextRun(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta)
          Constructs a Text Run from a Unicode text block
 
Method Summary
 RichTextRun appendText(java.lang.String s)
          Adds the supplied text onto the end of the TextRun, creating a new RichTextRun (returned) for it to sit in.
 void buildRichTextRuns(java.util.LinkedList pStyles, java.util.LinkedList cStyles, java.lang.String runRawText)
           
 void changeTextInRichTextRun(RichTextRun run, java.lang.String s)
          Handles an update to the text stored in one of the Rich Text Runs
 TextRulerAtom createTextRuler()
           
 void ensureStyleAtomPresent()
          Ensure a StyleTextPropAtom is present for this run, by adding if required.
 Hyperlink[] getHyperlinks()
          Returns the array of all hyperlinks in this text run
protected  int getIndex()
           
 java.lang.String getRawText()
          Returns the raw text content of the run.
 Record[] getRecords()
          Returns records that make up this text run
 RichTextRun getRichTextRunAt(int pos)
          Fetch RichTextRun at a given position
 RichTextRun[] getRichTextRuns()
          Fetch the rich text runs (runs of text with the same styling) that are contained within this block of text
 int getRunType()
          Returns the type of the text, from the TextHeaderAtom.
protected  int getShapeId()
           
 Sheet getSheet()
           
 java.lang.String getText()
          Returns the text content of the run, which has been made safe for printing and other use.
 TextRulerAtom getTextRuler()
           
 java.lang.String normalize(java.lang.String s)
          Returns a new string with line breaks converted into internal ppt representation
protected  void setIndex(int id)
           
 void setRawText(java.lang.String s)
          Changes the text, and sets it all to have the same styling as the the first character has.
 void setRunType(int type)
          Changes the type of the text.
protected  void setShapeId(int id)
           
 void setSheet(Sheet sheet)
           
 void setText(java.lang.String s)
          Changes the text.
 void supplySlideShow(SlideShow ss)
          Supply the SlideShow we belong to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_headerAtom

protected TextHeaderAtom _headerAtom

_byteAtom

protected TextBytesAtom _byteAtom

_charAtom

protected TextCharsAtom _charAtom

_styleAtom

protected StyleTextPropAtom _styleAtom

_ruler

protected TextRulerAtom _ruler

_isUnicode

protected boolean _isUnicode

_rtRuns

protected RichTextRun[] _rtRuns

_records

protected Record[] _records
all text run records that follow TextHeaderAtom. (there can be misc InteractiveInfo, TxInteractiveInfo and other records)

Constructor Detail

TextRun

public TextRun(TextHeaderAtom tha,
               TextCharsAtom tca,
               StyleTextPropAtom sta)
Constructs a Text Run from a Unicode text block

Parameters:
tha - the TextHeaderAtom that defines what's what
tca - the TextCharsAtom containing the text
sta - the StyleTextPropAtom which defines the character stylings

TextRun

public TextRun(TextHeaderAtom tha,
               TextBytesAtom tba,
               StyleTextPropAtom sta)
Constructs a Text Run from a Ascii text block

Parameters:
tha - the TextHeaderAtom that defines what's what
tba - the TextBytesAtom containing the text
sta - the StyleTextPropAtom which defines the character stylings
Method Detail

buildRichTextRuns

public void buildRichTextRuns(java.util.LinkedList pStyles,
                              java.util.LinkedList cStyles,
                              java.lang.String runRawText)

appendText

public RichTextRun appendText(java.lang.String s)
Adds the supplied text onto the end of the TextRun, creating a new RichTextRun (returned) for it to sit in. In many cases, before calling this, you'll want to add a newline onto the end of your last RichTextRun


changeTextInRichTextRun

public void changeTextInRichTextRun(RichTextRun run,
                                    java.lang.String s)
Handles an update to the text stored in one of the Rich Text Runs

Parameters:
run -
s -

setRawText

public void setRawText(java.lang.String s)
Changes the text, and sets it all to have the same styling as the the first character has. If you care about styling, do setText on a RichTextRun instead


setText

public void setText(java.lang.String s)
Changes the text. Converts '\r' into '\n'


ensureStyleAtomPresent

public void ensureStyleAtomPresent()
Ensure a StyleTextPropAtom is present for this run, by adding if required. Normally for internal TextRun use.


getText

public java.lang.String getText()
Returns the text content of the run, which has been made safe for printing and other use.


getRawText

public java.lang.String getRawText()
Returns the raw text content of the run. This hasn't had any changes applied to it, and so is probably unlikely to print out nicely.


getRichTextRuns

public RichTextRun[] getRichTextRuns()
Fetch the rich text runs (runs of text with the same styling) that are contained within this block of text


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 type)
Changes the type of the text. Values should be taken from TextHeaderAtom. No checking is done to ensure you set this to a valid value!

See Also:
TextHeaderAtom

supplySlideShow

public void supplySlideShow(SlideShow ss)
Supply the SlideShow we belong to. Also passes it on to our child RichTextRuns


setSheet

public void setSheet(Sheet sheet)

getSheet

public Sheet 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 id)
Parameters:
id - 0-based index of the text run in the SLWT container

getHyperlinks

public Hyperlink[] getHyperlinks()
Returns the array of all hyperlinks in this text run

Returns:
the array of all hyperlinks in this text run or null if not found.

getRichTextRunAt

public RichTextRun getRichTextRunAt(int pos)
Fetch RichTextRun at a given position

Parameters:
pos - 0-based index in the text
Returns:
RichTextRun or null if not found

getTextRuler

public TextRulerAtom getTextRuler()

createTextRuler

public TextRulerAtom createTextRuler()

normalize

public java.lang.String normalize(java.lang.String s)
Returns a new string with line breaks converted into internal ppt representation


getRecords

public Record[] getRecords()
Returns records that make up this text run

Returns:
text run records


Copyright 2012 The Apache Software Foundation or its licensors, as applicable.