org.apache.poi.xwpf.usermodel
Class XWPFParagraph

java.lang.Object
  extended by org.apache.poi.xwpf.usermodel.XWPFParagraph

public class XWPFParagraph
extends java.lang.Object

Sketch of XWPF paragraph class


Field Summary
protected  XWPFDocument document
           
 
Constructor Summary
  XWPFParagraph(CTP prgrph)
           
protected XWPFParagraph(CTP prgrph, XWPFDocument docRef)
           
 
Method Summary
 XWPFRun createRun()
          Appends a new run to this paragraph
 ParagraphAlignment getAlignment()
          Returns the paragraph alignment which shall be applied to text in this paragraph.
 Borders getBorderBetween()
          Specifies the border which shall be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings.
 Borders getBorderBottom()
          Specifies the border which shall be displayed below a set of paragraphs which have the same set of paragraph border settings.
 Borders getBorderLeft()
          Specifies the border which shall be displayed on the left side of the page around the specified paragraph.
 Borders getBorderRight()
          Specifies the border which shall be displayed on the right side of the page around the specified paragraph.
 Borders getBorderTop()
          Specifies the border which shall be displayed above a set of paragraphs which have the same set of paragraph border settings.
 CTP getCTP()
           
 XWPFDocument getDocument()
           
 java.lang.String getFootnoteText()
          Returns the footnote text of the paragraph
 int getIndentationFirstLine()
          Specifies the additional indentation which shall be applied to the first line of the parent paragraph.
 int getIndentationHanging()
          Specifies the indentation which shall be removed from the first line of the parent paragraph, by moving the indentation on the first line back towards the beginning of the direction of text flow.
 int getIndentationLeft()
          Specifies the indentation which shall be placed between the left text margin for this paragraph and the left edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero.

 int getIndentationRight()
          Specifies the indentation which shall be placed between the right text margin for this paragraph and the right edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero.

 java.lang.String getParagraphText()
          Returns the text of the paragraph, but not of any objects in the paragraph
 java.lang.String getPictureText()
          Returns any text from any suitable pictures in the paragraph
 int getSpacingAfter()
          Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.
 int getSpacingAfterLines()
          Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.
 int getSpacingBefore()
          Specifies the spacing that should be added above the first line in this paragraph in the document in absolute units.
 int getSpacingBeforeLines()
          Specifies the spacing that should be added before the first line in this paragraph in the document in line units.
 LineSpacingRule getSpacingLineRule()
          Specifies how the spacing between lines is calculated as stored in the line attribute.
 java.lang.String getStyle()
          Gets the style of the paragraph
 java.lang.String getText()
          Return the textual content of the paragraph, including text from pictures in it.
 TextAlignment getVerticalAlignment()
          Returns the text vertical alignment which shall be applied to text in this paragraph.
 boolean isEmpty()
           
 boolean isPageBreak()
          Specifies that when rendering this document in a paginated view, the contents of this paragraph are rendered on the start of a new page in the document.
 boolean isWordWrap()
          This element specifies whether a consumer shall break Latin text which exceeds the text extents of a line by breaking the word across two lines (breaking on the character level) or by moving the word to the following line (breaking on the word level).
 void setAlignment(ParagraphAlignment align)
          Specifies the paragraph alignment which shall be applied to text in this paragraph.
 void setBorderBetween(Borders border)
          Specifies the border which shall be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings.
 void setBorderBottom(Borders border)
          Specifies the border which shall be displayed below a set of paragraphs which have the same set of paragraph border settings.
 void setBorderLeft(Borders border)
          Specifies the border which shall be displayed on the left side of the page around the specified paragraph.
 void setBorderRight(Borders border)
          Specifies the border which shall be displayed on the right side of the page around the specified paragraph.
 void setBorderTop(Borders border)
          Specifies the border which shall be displayed above a set of paragraphs which have the same set of paragraph border settings.
 void setIndentationFirstLine(int indentation)
          Specifies the additional indentation which shall be applied to the first line of the parent paragraph.
 void setIndentationHanging(int indentation)
          Specifies the indentation which shall be removed from the first line of the parent paragraph, by moving the indentation on the first line back towards the beginning of the direction of text flow.
 void setIndentationLeft(int indentation)
          Specifies the indentation which shall be placed between the left text margin for this paragraph and the left edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero.

 void setIndentationRight(int indentation)
          Specifies the indentation which shall be placed between the right text margin for this paragraph and the right edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero.

 void setPageBreak(boolean pageBreak)
          Specifies that when rendering this document in a paginated view, the contents of this paragraph are rendered on the start of a new page in the document.
 void setSpacingAfter(int spaces)
          Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.
 void setSpacingAfterLines(int spaces)
          Specifies the spacing that should be added after the last line in this paragraph in the document in line units.
 void setSpacingBefore(int spaces)
          Specifies the spacing that should be added above the first line in this paragraph in the document in absolute units.
 void setSpacingBeforeLines(int spaces)
          Specifies the spacing that should be added before the first line in this paragraph in the document in line units.
 void setSpacingLineRule(LineSpacingRule rule)
          Specifies how the spacing between lines is calculated as stored in the line attribute.
 void setStyle(java.lang.String newStyle)
          This method provides a style to the paragraph This is useful when, e.g.
 void setVerticalAlignment(TextAlignment valign)
          Specifies the text vertical alignment which shall be applied to text in this paragraph.
 void setWordWrap(boolean wrap)
          This element specifies whether a consumer shall break Latin text which exceeds the text extents of a line by breaking the word across two lines (breaking on the character level) or by moving the word to the following line (breaking on the word level).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

protected XWPFDocument document
Constructor Detail

XWPFParagraph

public XWPFParagraph(CTP prgrph)

XWPFParagraph

protected XWPFParagraph(CTP prgrph,
                        XWPFDocument docRef)
Method Detail

getCTP

@Internal
public CTP getCTP()

isEmpty

public boolean isEmpty()

getDocument

public XWPFDocument getDocument()

getText

public java.lang.String getText()
Return the textual content of the paragraph, including text from pictures in it.


getParagraphText

public java.lang.String getParagraphText()
Returns the text of the paragraph, but not of any objects in the paragraph


getPictureText

public java.lang.String getPictureText()
Returns any text from any suitable pictures in the paragraph


getFootnoteText

public java.lang.String getFootnoteText()
Returns the footnote text of the paragraph

Returns:
the footnote text or empty string if the paragraph does not have footnotes

createRun

public XWPFRun createRun()
Appends a new run to this paragraph

Returns:
a new text run

getAlignment

public ParagraphAlignment getAlignment()
Returns the paragraph alignment which shall be applied to text in this paragraph.

If this element is not set on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no alignment is applied to the paragraph.

Returns:
the paragraph alignment of this paragraph.

setAlignment

public void setAlignment(ParagraphAlignment align)
Specifies the paragraph alignment which shall be applied to text in this paragraph.

If this element is not set on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no alignment is applied to the paragraph.

Parameters:
align - the paragraph alignment to apply to this paragraph.

getVerticalAlignment

public TextAlignment getVerticalAlignment()
Returns the text vertical alignment which shall be applied to text in this paragraph.

If the line height (before any added spacing) is larger than one or more characters on the line, all characters will be aligned to each other as specified by this element.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then the vertical alignment of all characters on the line shall be automatically determined by the consumer.

Returns:
the vertical alignment of this paragraph.

setVerticalAlignment

public void setVerticalAlignment(TextAlignment valign)
Specifies the text vertical alignment which shall be applied to text in this paragraph.

If the line height (before any added spacing) is larger than one or more characters on the line, all characters will be aligned to each other as specified by this element.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then the vertical alignment of all characters on the line shall be automatically determined by the consumer.

Parameters:
valign - the paragraph vertical alignment to apply to this paragraph.

setBorderTop

public void setBorderTop(Borders border)
Specifies the border which shall be displayed above a set of paragraphs which have the same set of paragraph border settings.

To determine if any two adjoining paragraphs shall have an individual top and bottom border or a between border, the set of borders on the two adjoining paragraphs are compared. If the border information on those two paragraphs is identical for all possible paragraphs borders, then the between border is displayed. Otherwise, the final paragraph shall use its bottom border and the following paragraph shall use its top border, respectively. If this border specifies a space attribute, that value determines the space above the text (ignoring any spacing above) which should be left before this border is drawn, specified in points.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no between border shall be applied above identical paragraphs.

This border can only be a line border.

Parameters:
border -
See Also:
for a list of all types of borders

getBorderTop

public Borders getBorderTop()
Specifies the border which shall be displayed above a set of paragraphs which have the same set of paragraph border settings.

Returns:
paragraphBorder - the top border for the paragraph
See Also:
setBorderTop(Borders), a list of all types of borders

setBorderBottom

public void setBorderBottom(Borders border)
Specifies the border which shall be displayed below a set of paragraphs which have the same set of paragraph border settings.

To determine if any two adjoining paragraphs shall have an individual top and bottom border or a between border, the set of borders on the two adjoining paragraphs are compared. If the border information on those two paragraphs is identical for all possible paragraphs borders, then the between border is displayed. Otherwise, the final paragraph shall use its bottom border and the following paragraph shall use its top border, respectively. If this border specifies a space attribute, that value determines the space after the bottom of the text (ignoring any space below) which should be left before this border is drawn, specified in points.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no between border shall be applied below identical paragraphs.

This border can only be a line border.

Parameters:
border -
See Also:
a list of all types of borders

getBorderBottom

public Borders getBorderBottom()
Specifies the border which shall be displayed below a set of paragraphs which have the same set of paragraph border settings.

Returns:
paragraphBorder - the bottom border for the paragraph
See Also:
setBorderBottom(Borders), a list of all types of borders

setBorderLeft

public void setBorderLeft(Borders border)
Specifies the border which shall be displayed on the left side of the page around the specified paragraph.

To determine if any two adjoining paragraphs should have a left border which spans the full line height or not, the left border shall be drawn between the top border or between border at the top (whichever would be rendered for the current paragraph), and the bottom border or between border at the bottom (whichever would be rendered for the current paragraph).

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no left border shall be applied.

This border can only be a line border.

Parameters:
border -
See Also:
for a list of all possible borders

getBorderLeft

public Borders getBorderLeft()
Specifies the border which shall be displayed on the left side of the page around the specified paragraph.

Returns:
ParagraphBorder - the left border for the paragraph
See Also:
setBorderLeft(Borders), for a list of all possible borders

setBorderRight

public void setBorderRight(Borders border)
Specifies the border which shall be displayed on the right side of the page around the specified paragraph.

To determine if any two adjoining paragraphs should have a right border which spans the full line height or not, the right border shall be drawn between the top border or between border at the top (whichever would be rendered for the current paragraph), and the bottom border or between border at the bottom (whichever would be rendered for the current paragraph).

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no right border shall be applied.

This border can only be a line border.

Parameters:
border -
See Also:
for a list of all possible borders

getBorderRight

public Borders getBorderRight()
Specifies the border which shall be displayed on the right side of the page around the specified paragraph.

Returns:
ParagraphBorder - the right border for the paragraph
See Also:
setBorderRight(Borders), for a list of all possible borders

setBorderBetween

public void setBorderBetween(Borders border)
Specifies the border which shall be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings.

To determine if any two adjoining paragraphs should have a between border or an individual top and bottom border, the set of borders on the two adjoining paragraphs are compared. If the border information on those two paragraphs is identical for all possible paragraphs borders, then the between border is displayed. Otherwise, each paragraph shall use its bottom and top border, respectively. If this border specifies a space attribute, that value is ignored - this border is always located at the bottom of each paragraph with an identical following paragraph, taking into account any space after the line pitch.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no between border shall be applied between identical paragraphs.

This border can only be a line border.

Parameters:
border -
See Also:
for a list of all possible borders

getBorderBetween

public Borders getBorderBetween()
Specifies the border which shall be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings.

Returns:
ParagraphBorder - the between border for the paragraph
See Also:
setBorderBetween(Borders), for a list of all possible borders

setPageBreak

public void setPageBreak(boolean pageBreak)
Specifies that when rendering this document in a paginated view, the contents of this paragraph are rendered on the start of a new page in the document.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then this property shall not be applied. Since the paragraph is specified to start on a new page, it begins page two even though it could have fit on page one.

Parameters:
pageBreak - - boolean value

isPageBreak

public boolean isPageBreak()
Specifies that when rendering this document in a paginated view, the contents of this paragraph are rendered on the start of a new page in the document.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then this property shall not be applied. Since the paragraph is specified to start on a new page, it begins page two even though it could have fit on page one.

Returns:
boolean - if page break is set

setSpacingAfter

public void setSpacingAfter(int spaces)
Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.

If the afterLines attribute or the afterAutoSpacing attribute is also specified, then this attribute value is ignored.

Parameters:
spaces - - a positive whole number, whose contents consist of a measurement in twentieths of a point.

getSpacingAfter

public int getSpacingAfter()
Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.

Returns:
int - value representing the spacing after the paragraph

setSpacingAfterLines

public void setSpacingAfterLines(int spaces)
Specifies the spacing that should be added after the last line in this paragraph in the document in line units. The value of this attribute is specified in one hundredths of a line.

If the afterAutoSpacing attribute is also specified, then this attribute value is ignored. If this setting is never specified in the style hierarchy, then its value shall be zero (if needed)

Parameters:
spaces - - a positive whole number, whose contents consist of a measurement in twentieths of a

getSpacingAfterLines

public int getSpacingAfterLines()
Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.

Returns:
bigInteger - value representing the spacing after the paragraph
See Also:
setSpacingAfterLines(int)

setSpacingBefore

public void setSpacingBefore(int spaces)
Specifies the spacing that should be added above the first line in this paragraph in the document in absolute units.

If the beforeLines attribute or the beforeAutoSpacing attribute is also specified, then this attribute value is ignored.

Parameters:
spaces -

getSpacingBefore

public int getSpacingBefore()
Specifies the spacing that should be added above the first line in this paragraph in the document in absolute units.

Returns:
the spacing that should be added above the first line
See Also:
setSpacingBefore(int)

setSpacingBeforeLines

public void setSpacingBeforeLines(int spaces)
Specifies the spacing that should be added before the first line in this paragraph in the document in line units. The value of this attribute is specified in one hundredths of a line.

If the beforeAutoSpacing attribute is also specified, then this attribute value is ignored. If this setting is never specified in the style hierarchy, then its value shall be zero.

Parameters:
spaces -

getSpacingBeforeLines

public int getSpacingBeforeLines()
Specifies the spacing that should be added before the first line in this paragraph in the document in line units. The value of this attribute is specified in one hundredths of a line.

Returns:
the spacing that should be added before the first line in this paragraph
See Also:
setSpacingBeforeLines(int)

setSpacingLineRule

public void setSpacingLineRule(LineSpacingRule rule)
Specifies how the spacing between lines is calculated as stored in the line attribute. If this attribute is omitted, then it shall be assumed to be of a value auto if a line attribute value is present.

Parameters:
rule -
See Also:
LineSpacingRule

getSpacingLineRule

public LineSpacingRule getSpacingLineRule()
Specifies how the spacing between lines is calculated as stored in the line attribute. If this attribute is omitted, then it shall be assumed to be of a value auto if a line attribute value is present.

Returns:
rule
See Also:
LineSpacingRule, setSpacingLineRule(LineSpacingRule)

setIndentationLeft

public void setIndentationLeft(int indentation)
Specifies the indentation which shall be placed between the left text margin for this paragraph and the left edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero. Negative values are defined such that the text is moved past the text margin, positive values move the text inside the text margin.

Parameters:
indentation -

getIndentationLeft

public int getIndentationLeft()
Specifies the indentation which shall be placed between the left text margin for this paragraph and the left edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero. Negative values are defined such that the text is moved past the text margin, positive values move the text inside the text margin.

Returns:
indentation or null if indentation is not set

setIndentationRight

public void setIndentationRight(int indentation)
Specifies the indentation which shall be placed between the right text margin for this paragraph and the right edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero. Negative values are defined such that the text is moved past the text margin, positive values move the text inside the text margin.

Parameters:
indentation -

getIndentationRight

public int getIndentationRight()
Specifies the indentation which shall be placed between the right text margin for this paragraph and the right edge of that paragraph's content in a left to right paragraph, and the right text margin and the right edge of that paragraph's text in a right to left paragraph

If this attribute is omitted, its value shall be assumed to be zero. Negative values are defined such that the text is moved past the text margin, positive values move the text inside the text margin.

Returns:
indentation or null if indentation is not set

setIndentationHanging

public void setIndentationHanging(int indentation)
Specifies the indentation which shall be removed from the first line of the parent paragraph, by moving the indentation on the first line back towards the beginning of the direction of text flow. This indentation is specified relative to the paragraph indentation which is specified for all other lines in the parent paragraph.

The firstLine and hanging attributes are mutually exclusive, if both are specified, then the firstLine value is ignored.

Parameters:
indentation -

getIndentationHanging

public int getIndentationHanging()
Specifies the indentation which shall be removed from the first line of the parent paragraph, by moving the indentation on the first line back towards the beginning of the direction of text flow. This indentation is specified relative to the paragraph indentation which is specified for all other lines in the parent paragraph. The firstLine and hanging attributes are mutually exclusive, if both are specified, then the firstLine value is ignored.

Returns:
indentation or null if indentation is not set

setIndentationFirstLine

public void setIndentationFirstLine(int indentation)
Specifies the additional indentation which shall be applied to the first line of the parent paragraph. This additional indentation is specified relative to the paragraph indentation which is specified for all other lines in the parent paragraph. The firstLine and hanging attributes are mutually exclusive, if both are specified, then the firstLine value is ignored. If the firstLineChars attribute is also specified, then this value is ignored. If this attribute is omitted, then its value shall be assumed to be zero (if needed).

Parameters:
indentation -

getIndentationFirstLine

public int getIndentationFirstLine()
Specifies the additional indentation which shall be applied to the first line of the parent paragraph. This additional indentation is specified relative to the paragraph indentation which is specified for all other lines in the parent paragraph. The firstLine and hanging attributes are mutually exclusive, if both are specified, then the firstLine value is ignored. If the firstLineChars attribute is also specified, then this value is ignored. If this attribute is omitted, then its value shall be assumed to be zero (if needed).

Returns:
indentation or null if indentation is not set

setWordWrap

public void setWordWrap(boolean wrap)
This element specifies whether a consumer shall break Latin text which exceeds the text extents of a line by breaking the word across two lines (breaking on the character level) or by moving the word to the following line (breaking on the word level).

Parameters:
wrap - - boolean

isWordWrap

public boolean isWordWrap()
This element specifies whether a consumer shall break Latin text which exceeds the text extents of a line by breaking the word across two lines (breaking on the character level) or by moving the word to the following line (breaking on the word level).

Returns:
boolean

setStyle

public void setStyle(java.lang.String newStyle)
This method provides a style to the paragraph This is useful when, e.g. an Heading style has to be assigned

Parameters:
newStyle -

getStyle

public java.lang.String getStyle()
Gets the style of the paragraph

Returns:


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