public class XWPFRun extends Object
Modifier and Type | Class and Description |
---|---|
static class |
XWPFRun.FontCharRange |
Constructor and Description |
---|
XWPFRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR r,
XWPFParagraph p) |
Modifier and Type | Method and Description |
---|---|
void |
addBreak()
Specifies that a break shall be placed at the current location in the run
content.
|
void |
addBreak(BreakClear clear)
Specifies that a break shall be placed at the current location in the run
content.
|
void |
addBreak(BreakType type)
Specifies that a break shall be placed at the current location in the run
content.
|
void |
addCarriageReturn()
Specifies that a carriage return shall be placed at the
current location in the run content.
|
XWPFPicture |
addPicture(InputStream pictureData,
int pictureType,
String filename,
int width,
int height)
Adds a picture to the run.
|
String |
getColor()
Get text color.
|
org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR |
getCTR()
Get the currently used CTR object
|
XWPFDocument |
getDocument() |
List<XWPFPicture> |
getEmbeddedPictures()
Returns the embedded pictures of the run.
|
String |
getFontFamily()
Specifies the fonts which shall be used to display the text contents of
this run.
|
String |
getFontFamily(XWPFRun.FontCharRange fcr)
Gets the font family for the specified font char range.
|
int |
getFontSize()
Specifies the font size which shall be applied to all non complex script
characters in the contents of this run when displayed.
|
XWPFParagraph |
getParagraph()
Get the currenty referenced paragraph object
|
String |
getPictureText()
Returns text embedded in pictures
|
protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr |
getRunProperties(boolean create)
Get the run properties for the run.
|
VerticalAlign |
getSubscript()
Specifies the alignment which shall be applied to the contents of this
run in relation to the default appearance of the run's text.
|
String |
getText(int pos)
Return the string content of this text run
|
int |
getTextPosition()
This element specifies the amount by which text shall be raised or
lowered for this run in relation to the default baseline of the
surrounding non-positioned text.
|
UnderlinePatterns |
getUnderline()
Specifies that the contents of this run should be displayed along with an
underline appearing directly below the character heigh
|
boolean |
isBold()
Whether the bold property shall be applied to all non-complex script
characters in the contents of this run when displayed in a document
|
boolean |
isItalic()
Whether the italic property should be applied to all non-complex script
characters in the contents of this run when displayed in a document.
|
boolean |
isStrike()
Deprecated.
|
boolean |
isStrikeThrough()
Specifies that the contents of this run shall be displayed with a single
horizontal line through the center of the line.
|
void |
removeBreak() |
void |
removeCarriageReturn() |
void |
setBold(boolean value)
Whether the bold property shall be applied to all non-complex script
characters in the contents of this run when displayed in a document.
|
void |
setColor(String rgbStr)
Set text color.
|
void |
setFontFamily(String fontFamily)
Specifies the fonts which shall be used to display the text contents of
this run.
|
void |
setFontFamily(String fontFamily,
XWPFRun.FontCharRange fcr)
Specifies the fonts which shall be used to display the text contents of
this run.
|
void |
setFontSize(int size)
Specifies the font size which shall be applied to all non complex script
characters in the contents of this run when displayed.
|
void |
setItalic(boolean value)
Whether the bold property shall be applied to all non-complex script
characters in the contents of this run when displayed in a document
This formatting property is a toggle property, which specifies that its
behavior differs between its use within a style definition and its use as
direct formatting.
|
void |
setStrike(boolean value)
Deprecated.
|
void |
setStrikeThrough(boolean value)
Specifies that the contents of this run shall be displayed with a single
horizontal line through the center of the line.
|
void |
setSubscript(VerticalAlign valign)
Specifies the alignment which shall be applied to the contents of this
run in relation to the default appearance of the run's text.
|
void |
setText(String value)
Sets the text of this text run
|
void |
setText(String value,
int pos)
Sets the text of this text run in the
|
void |
setTextPosition(int val)
This element specifies the amount by which text shall be raised or
lowered for this run in relation to the default baseline of the
surrounding non-positioned text.
|
void |
setUnderline(UnderlinePatterns value)
Specifies that the contents of this run should be displayed along with an
underline appearing directly below the character heigh
If this element is not present, the default value is to leave the
formatting applied at previous level in the style hierarchy.
|
String |
toString()
Returns the string version of the text, with tabs and
carriage returns in place of their xml equivalents.
|
public XWPFRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR r, XWPFParagraph p)
r
- the CTR bean which holds the run attributesp
- the parent paragraph@Internal public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR getCTR()
public XWPFParagraph getParagraph()
public XWPFDocument getDocument()
XWPFDocument
instance, this run belongs to, or
null
if parent structure (paragraph > document) is not properly set.public boolean isBold()
true
if the bold property is appliedpublic void setBold(boolean value)
This formatting property is a toggle property, which specifies that its
behavior differs between its use within a style definition and its use as
direct formatting. When used as part of a style definition, setting this
property shall toggle the current state of that property as specified up
to this point in the hierarchy (i.e. applied to not applied, and vice
versa). Setting it to false
(or an equivalent) shall
result in the current setting remaining unchanged. However, when used as
direct formatting, setting this property to true or false shall set the
absolute state of the resulting property.
If this element is not present, the default value is to leave the formatting applied at previous level in the style hierarchy. If this element is never applied in the style hierarchy, then bold shall not be applied to non-complex script characters.
value
- true
if the bold property is applied to
this runpublic String getColor()
public void setColor(String rgbStr)
rgbStr
- - the desired color, in the hex form "RRGGBB".public String getText(int pos)
null
if not setpublic String getPictureText()
public void setText(String value)
value
- the literal text which shall be displayed in the documentpublic void setText(String value, int pos)
value
- the literal text which shall be displayed in the documentpos
- - position in the text array (NB: 0 based)public boolean isItalic()
true
if the italic property is appliedpublic void setItalic(boolean value)
false
(or an equivalent) shall
result in the current setting remaining unchanged. However, when used as
direct formatting, setting this property to true or false shall set the
absolute state of the resulting property.
If this element is not present, the default value is to leave the
formatting applied at previous level in the style hierarchy. If this
element is never applied in the style hierarchy, then bold shall not be
applied to non-complex script characters.
value
- true
if the italic property is applied to
this runpublic UnderlinePatterns getUnderline()
UnderlinePatterns
public void setUnderline(UnderlinePatterns value)
value
- -
underline type: all possible patterns that could be applied
public boolean isStrikeThrough()
true
if the strike property is appliedpublic void setStrikeThrough(boolean value)
This formatting property is a toggle property, which specifies that its behaviour differs between its use within a style definition and its use as direct formatting. When used as part of a style definition, setting this property shall toggle the current state of that property as specified up to this point in the hierarchy (i.e. applied to not applied, and vice versa). Setting it to false (or an equivalent) shall result in the current setting remaining unchanged. However, when used as direct formatting, setting this property to true or false shall set the absolute state of the resulting property.
If this element is not present, the default value is to leave the formatting applied at previous level in the style hierarchy. If this element is never applied in the style hierarchy, then strikethrough shall not be applied to the contents of this run.
value
- true
if the strike property is applied to
this run@Deprecated public boolean isStrike()
@Deprecated public void setStrike(boolean value)
public VerticalAlign getSubscript()
all possible value that could be applyed to this run
public void setSubscript(VerticalAlign valign)
valign
- VerticalAlign
public String getFontFamily()
public void setFontFamily(String fontFamily)
fontFamily
- public String getFontFamily(XWPFRun.FontCharRange fcr)
fcr
- the font char range, defaults to "ansi"public void setFontFamily(String fontFamily, XWPFRun.FontCharRange fcr)
fontFamily
- The font family to applyfcr
- FontCharRange or null for default handlingpublic int getFontSize()
public void setFontSize(int size)
size
- public int getTextPosition()
public void setTextPosition(int val)
val
- public void removeBreak()
public void addBreak()
addCarriageReturn()
public void addBreak(BreakType type)
The behavior of this break character (the location where text shall be restarted after this break) shall be determined by its type values.
BreakType
public void addBreak(BreakClear clear)
The behavior of this break character (the location where text shall be restarted after this break) shall be determined by its type (in this case is BreakType.TEXT_WRAPPING as default) and clear attribute values.
BreakClear
public void addCarriageReturn()
public void removeCarriageReturn()
public XWPFPicture addPicture(InputStream pictureData, int pictureType, String filename, int width, int height) throws InvalidFormatException, IOException
pictureData
- The raw picture datapictureType
- The type of the picture, eg Document.PICTURE_TYPE_JPEG
width
- width in EMUs. To convert to / from points use Units
height
- height in EMUs. To convert to / from points use Units
InvalidFormatException
IOException
InvalidFormatException
Document.PICTURE_TYPE_EMF
,
Document.PICTURE_TYPE_WMF
,
Document.PICTURE_TYPE_PICT
,
Document.PICTURE_TYPE_JPEG
,
Document.PICTURE_TYPE_PNG
,
Document.PICTURE_TYPE_DIB
public List<XWPFPicture> getEmbeddedPictures()
public String toString()
protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr getRunProperties(boolean create)
create
- If true, create the properties, if false, do not.Copyright © 2023. All rights reserved.