Package org.apache.poi.xslf.usermodel
Class XSLFTextShape
- java.lang.Object
-
- org.apache.poi.xslf.usermodel.XSLFShape
-
- org.apache.poi.xslf.usermodel.XSLFSimpleShape
-
- org.apache.poi.xslf.usermodel.XSLFTextShape
-
- All Implemented Interfaces:
Iterable<XSLFTextParagraph>,IAdjustableShape,PlaceableShape<XSLFShape,XSLFTextParagraph>,Shape<XSLFShape,XSLFTextParagraph>,SimpleShape<XSLFShape,XSLFTextParagraph>,TextShape<XSLFShape,XSLFTextParagraph>,TextContainer
- Direct Known Subclasses:
XSLFAutoShape,XSLFTableCell
@Beta public abstract class XSLFTextShape extends XSLFSimpleShape implements TextContainer, TextShape<XSLFShape,XSLFTextParagraph>
Represents a shape that can hold text.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.xslf.usermodel.XSLFShape
XSLFShape.ReparseFactory<T extends XmlObject>
-
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextShape
TextShape.TextAutofit, TextShape.TextDirection, TextShape.TextPlaceholder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description XSLFTextParagraphaddNewTextParagraph()add a new paragraph run to this shapeXSLFTextRunappendText(String text, boolean newParagraph)voidclearText()unset text from this shape<R> Optional<R>findDefinedParagraphProperty(Predicate<org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties> isSet, Function<org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties,R> getter)<R> Optional<R>findDefinedRunProperty(Predicate<org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties> isSet, Function<org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties,R> getter)doublegetBottomInset()Returns the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.Insets2DgetInsets()doublegetLeftInset()Returns the distance (in points) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.doublegetRightInset()Returns the distance (in points) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.StringgetText()TextShape.TextAutofitgetTextAutofit()XDDFTextBodygetTextBody()protected abstract org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodygetTextBody(boolean create)protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyPropertiesgetTextBodyPr()protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyPropertiesgetTextBodyPr(boolean create)TextShape.TextDirectiongetTextDirection()doublegetTextHeight()doublegetTextHeight(Graphics2D graphics)List<XSLFTextParagraph>getTextParagraphs()Get the TextParagraphs for this text box.TextShape.TextPlaceholdergetTextPlaceholder()DoublegetTextRotation()PlaceholdergetTextType()doublegetTopInset()Returns the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.VerticalAlignmentgetVerticalAlignment()booleangetWordWrap()booleanisHorizontalCentered()Iterator<XSLFTextParagraph>iterator()protected XSLFTextParagraphnewTextParagraph(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph p)Helper method to allow subclasses to provide their own text paragraphbooleanremoveTextParagraph(XSLFTextParagraph paragraph)Rectangle2DresizeToFitText()Rectangle2DresizeToFitText(Graphics2D graphics)voidsetBottomInset(double margin)Sets the bottom margin.voidsetHorizontalCentered(Boolean isCentered)voidsetInsets(Insets2D insets)voidsetLeftInset(double margin)Sets the left margin.voidsetPlaceholder(Placeholder placeholder)voidsetRightInset(double margin)Sets the right margin.XSLFTextRunsetText(String text)voidsetTextAutofit(TextShape.TextAutofit value)Specifies that a shape should be auto-fit to fully contain the text described within it.voidsetTextDirection(TextShape.TextDirection orientation)voidsetTextPlaceholder(TextShape.TextPlaceholder placeholder)voidsetTextRotation(Double rotation)voidsetTopInset(double margin)Sets the top margin.voidsetVerticalAlignment(VerticalAlignment anchor)voidsetWordWrap(boolean wrap)Spliterator<XSLFTextParagraph>spliterator()-
Methods inherited from class org.apache.poi.xslf.usermodel.XSLFSimpleShape
createHyperlink, getAdjustValue, getAnchor, getFillColor, getFillStyle, getFlipHorizontal, getFlipVertical, getGeometry, getHyperlink, getLineCap, getLineColor, getLineCompound, getLineDash, getLineDecoration, getLineHeadDecoration, getLineHeadLength, getLineHeadWidth, getLinePaint, getLineTailDecoration, getLineTailLength, getLineTailWidth, getLineWidth, getRotation, getShadow, getShapeType, getStrokeStyle, getXfrm, setAnchor, setFillColor, setFlipHorizontal, setFlipVertical, setLineCap, setLineColor, setLineCompound, setLineDash, setLineHeadDecoration, setLineHeadLength, setLineHeadWidth, setLineTailDecoration, setLineTailLength, setLineTailWidth, setLineWidth, setRotation, setShapeType, setStrokeStyle
-
Methods inherited from class org.apache.poi.xslf.usermodel.XSLFShape
draw, fetchShapeProperty, getBgPr, getBgRef, getChild, getCNvPr, getFillPaint, getGrpSpPr, getParent, getPlaceholder, getPlaceholderDetails, getShapeId, getShapeName, getShapeProperties, getSheet, getSpStyle, getXmlObject, isPlaceholder, selectPaint, selectPaint, selectPaint, selectPaint, selectPaint, selectPaint, selectProperty, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.poi.sl.draw.geom.IAdjustableShape
getAdjustValue
-
Methods inherited from interface org.apache.poi.sl.usermodel.PlaceableShape
getAnchor, getFlipHorizontal, getFlipVertical, getParent, getRotation, getSheet, setAnchor, setFlipHorizontal, setFlipVertical, setRotation
-
Methods inherited from interface org.apache.poi.sl.usermodel.Shape
draw, getAnchor, getParent, getShapeId, getShapeName, getSheet
-
Methods inherited from interface org.apache.poi.sl.usermodel.SimpleShape
createHyperlink, getFillColor, getFillStyle, getGeometry, getHyperlink, getLineDecoration, getPlaceholder, getPlaceholderDetails, getShadow, getShapeType, getStrokeStyle, isPlaceholder, setFillColor, setShapeType, setStrokeStyle
-
-
-
-
Method Detail
-
getTextBody
@Beta public XDDFTextBody getTextBody()
-
iterator
public Iterator<XSLFTextParagraph> iterator()
- Specified by:
iteratorin interfaceIterable<XSLFTextParagraph>
-
spliterator
public Spliterator<XSLFTextParagraph> spliterator()
- Specified by:
spliteratorin interfaceIterable<XSLFTextParagraph>- Since:
- POI 5.2.0
-
getText
public String getText()
- Specified by:
getTextin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
clearText
public void clearText()
unset text from this shape
-
setText
public XSLFTextRun setText(String text)
- Specified by:
setTextin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
appendText
public XSLFTextRun appendText(String text, boolean newParagraph)
- Specified by:
appendTextin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getTextParagraphs
public List<XSLFTextParagraph> getTextParagraphs()
Get the TextParagraphs for this text box. Removing an item from this list will not reliably remove the item from the underlying document. UseremoveTextParagraphfor that.- Specified by:
getTextParagraphsin interfaceTextShape<XSLFShape,XSLFTextParagraph>- Returns:
- the TextParagraphs for this text box
-
addNewTextParagraph
public XSLFTextParagraph addNewTextParagraph()
add a new paragraph run to this shape- Returns:
- created paragraph run
-
removeTextParagraph
public boolean removeTextParagraph(XSLFTextParagraph paragraph)
- Parameters:
paragraph- paragraph to remove- Returns:
- whether the paragraph was removed
- Since:
- POI 5.2.2
-
setVerticalAlignment
public void setVerticalAlignment(VerticalAlignment anchor)
- Specified by:
setVerticalAlignmentin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getVerticalAlignment
public VerticalAlignment getVerticalAlignment()
- Specified by:
getVerticalAlignmentin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setHorizontalCentered
public void setHorizontalCentered(Boolean isCentered)
- Specified by:
setHorizontalCenteredin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
isHorizontalCentered
public boolean isHorizontalCentered()
- Specified by:
isHorizontalCenteredin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setTextDirection
public void setTextDirection(TextShape.TextDirection orientation)
- Specified by:
setTextDirectionin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getTextDirection
public TextShape.TextDirection getTextDirection()
- Specified by:
getTextDirectionin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getTextRotation
public Double getTextRotation()
- Specified by:
getTextRotationin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setTextRotation
public void setTextRotation(Double rotation)
- Specified by:
setTextRotationin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getBottomInset
public double getBottomInset()
Returns the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.- Returns:
- the bottom inset in points
-
getLeftInset
public double getLeftInset()
Returns the distance (in points) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.- Returns:
- the left inset in points
-
getRightInset
public double getRightInset()
Returns the distance (in points) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.- Returns:
- the right inset in points
-
getTopInset
public double getTopInset()
Returns the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.- Returns:
- the top inset in points
-
setBottomInset
public void setBottomInset(double margin)
Sets the bottom margin.- Parameters:
margin- the bottom margin- See Also:
getBottomInset()
-
setLeftInset
public void setLeftInset(double margin)
Sets the left margin.- Parameters:
margin- the left margin- See Also:
getLeftInset()
-
setRightInset
public void setRightInset(double margin)
Sets the right margin.- Parameters:
margin- the right margin- See Also:
getRightInset()
-
setTopInset
public void setTopInset(double margin)
Sets the top margin.- Parameters:
margin- the top margin- See Also:
getTopInset()
-
getInsets
public Insets2D getInsets()
- Specified by:
getInsetsin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setInsets
public void setInsets(Insets2D insets)
- Specified by:
setInsetsin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getWordWrap
public boolean getWordWrap()
- Specified by:
getWordWrapin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setWordWrap
public void setWordWrap(boolean wrap)
- Specified by:
setWordWrapin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setTextAutofit
public void setTextAutofit(TextShape.TextAutofit value)
Specifies that a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside- Parameters:
value- type of autofit
-
getTextAutofit
public TextShape.TextAutofit getTextAutofit()
- Returns:
- type of autofit
-
getTextBodyPr
protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties getTextBodyPr()
-
getTextBodyPr
protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties getTextBodyPr(boolean create)
-
getTextBody
protected abstract org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody getTextBody(boolean create)
-
setPlaceholder
public void setPlaceholder(Placeholder placeholder)
- Specified by:
setPlaceholderin interfaceSimpleShape<XSLFShape,XSLFTextParagraph>- Overrides:
setPlaceholderin classXSLFShape- See Also:
PlaceholderDetails.setPlaceholder(Placeholder)
-
getTextType
public Placeholder getTextType()
-
getTextHeight
public double getTextHeight()
- Specified by:
getTextHeightin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getTextHeight
public double getTextHeight(Graphics2D graphics)
- Specified by:
getTextHeightin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
resizeToFitText
public Rectangle2D resizeToFitText()
- Specified by:
resizeToFitTextin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
resizeToFitText
public Rectangle2D resizeToFitText(Graphics2D graphics)
- Specified by:
resizeToFitTextin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
setTextPlaceholder
public void setTextPlaceholder(TextShape.TextPlaceholder placeholder)
- Specified by:
setTextPlaceholderin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
getTextPlaceholder
public TextShape.TextPlaceholder getTextPlaceholder()
- Specified by:
getTextPlaceholderin interfaceTextShape<XSLFShape,XSLFTextParagraph>
-
newTextParagraph
protected XSLFTextParagraph newTextParagraph(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph p)
Helper method to allow subclasses to provide their own text paragraph- Parameters:
p- the xml reference- Returns:
- a new text paragraph
- Since:
- POI 3.15-beta2
-
findDefinedParagraphProperty
public <R> Optional<R> findDefinedParagraphProperty(Predicate<org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties> isSet, Function<org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties,R> getter)
- Specified by:
findDefinedParagraphPropertyin interfaceTextContainer
-
findDefinedRunProperty
public <R> Optional<R> findDefinedRunProperty(Predicate<org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties> isSet, Function<org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties,R> getter)
- Specified by:
findDefinedRunPropertyin interfaceTextContainer
-
-