public class XWPFRun extends java.lang.Object implements ISDTContents, IRunElement, CharacterRun
Modifier and Type | Class and Description |
---|---|
static class |
XWPFRun.FontCharRange |
Constructor and Description |
---|
XWPFRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR r,
IRunBody p) |
XWPFRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR r,
XWPFParagraph p)
Deprecated.
|
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.
|
org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline |
addChart(java.lang.String chartRelId)
this method add chart template into document
|
XWPFPicture |
addPicture(java.io.InputStream pictureData,
int pictureType,
java.lang.String filename,
int width,
int height)
Adds a picture to the run.
|
XWPFPicture |
addPicture(java.io.InputStream pictureData,
PictureType pictureType,
java.lang.String filename,
int width,
int height)
Adds a picture to the run.
|
void |
addTab()
Specifies that a tab shall be placed at the current location in
the run content.
|
int |
getCharacterSpacing() |
java.lang.String |
getColor()
Get text color.
|
org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR |
getCTR()
Get the currently used CTR object
|
XWPFDocument |
getDocument() |
java.util.List<XWPFPicture> |
getEmbeddedPictures()
Returns the embedded pictures of the run.
|
org.openxmlformats.schemas.wordprocessingml.x2006.main.STEm.Enum |
getEmphasisMark()
Get the emphasis mark value for the run.
|
java.lang.String |
getFontFamily()
Gets the fonts which shall be used to display the text contents of
this run.
|
java.lang.String |
getFontFamily(XWPFRun.FontCharRange fcr)
Gets the font family for the specified font char range.
|
java.lang.String |
getFontName()
Alias for
getFontFamily() |
int |
getFontSize()
Deprecated.
|
java.lang.Double |
getFontSizeAsDouble()
Specifies the font size which shall be applied to all non complex script
characters in the contents of this run when displayed.
|
int |
getKerning() |
java.lang.String |
getLang()
Get the language tag associated with this run, if any.
|
XWPFParagraph |
getParagraph()
Deprecated.
use
getParent() instead |
IRunBody |
getParent()
Get the currently referenced paragraph/SDT object
|
java.lang.String |
getPhonetic() |
java.lang.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.
|
java.lang.String |
getStyle()
Return this run's style ID.
|
java.lang.String |
getText(int pos)
Return the string content of this text run
|
org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor.Enum |
getTextHighlightColor()
Gets the highlight color for the run
|
org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor.Enum |
getTextHightlightColor()
Deprecated.
use
getTextHighlightColor() instead |
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.
|
int |
getTextScale()
Gets the current text scale value.
|
UnderlinePatterns |
getUnderline()
Get the underline setting for the run.
|
java.lang.String |
getUnderlineColor()
Get the underline color for the run's underline, if any.
|
org.openxmlformats.schemas.wordprocessingml.x2006.main.STThemeColor.Enum |
getUnderlineThemeColor()
Get the underline theme color for the run's underline, if any.
|
org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STVerticalAlignRun.Enum |
getVerticalAlignment()
Get the vertical alignment value
|
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 |
isCapitalized() |
boolean |
isDoubleStrikeThrough()
Specifies that the contents of this run shall be displayed with a double
horizontal line through the center of the line.
|
boolean |
isEmbossed() |
boolean |
isHighlighted() |
boolean |
isImprinted() |
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 |
isShadowed() |
boolean |
isSmallCaps() |
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.
|
boolean |
isVanish()
Get the vanish (hidden text) value
|
void |
removeBreak()
Not yet implemented.
|
void |
removeCarriageReturn() |
void |
removeTab() |
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 |
setCapitalized(boolean value) |
void |
setCharacterSpacing(int twips) |
void |
setColor(java.lang.String rgbStr)
Set text color.
|
void |
setDoubleStrikethrough(boolean value)
Specifies that the contents of this run shall be displayed with a
double horizontal line through the center of the line.
|
void |
setEmbossed(boolean value) |
void |
setEmphasisMark(java.lang.String markType)
Set the emphasis mark for the run.
|
void |
setFontFamily(java.lang.String fontFamily)
Specifies the fonts which shall be used to display the text contents of
this run.
|
void |
setFontFamily(java.lang.String fontFamily,
XWPFRun.FontCharRange fcr)
Specifies the fonts which shall be used to display the text contents of
this run.
|
void |
setFontSize(double size)
Specifies the font size which shall be applied to all non complex script
characters in the contents of this run when displayed.
|
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 |
setImprinted(boolean value) |
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
|
void |
setKerning(int kern) |
void |
setLang(java.lang.String lang)
Set the language tag associated with this run.
|
void |
setShadow(boolean value) |
void |
setSmallCaps(boolean value) |
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 |
setStyle(java.lang.String styleId)
Set the style ID for the run.
|
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(java.lang.String value)
Sets the text of this text run
|
void |
setText(java.lang.String value,
int pos)
Sets the text of this text run in the
|
void |
setTextHighlightColor(java.lang.String colorName)
Set the highlight color for the run.
|
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 |
setTextScale(int percentage)
Set the text expand/collapse scale value.
|
void |
setUnderline(UnderlinePatterns value)
Specifies that the contents of this run should be displayed along with an
underline appearing directly below the character height.
|
void |
setUnderlineColor(java.lang.String color)
Set the underline color for the run's underline, if any.
|
void |
setUnderlineThemeColor(java.lang.String themeColor)
Set the underline theme color for the run's underline, if any.
|
void |
setVanish(boolean value)
The vanish (hidden text) property for the run.
|
void |
setVerticalAlignment(java.lang.String verticalAlignment)
Set the vertical alignment of the run.
|
java.lang.String |
text()
Returns the string version of the text, with tabs and
carriage returns in place of their xml equivalents.
|
java.lang.String |
toString()
Returns the string version of the text and the phonetic string
|
public XWPFRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR r, IRunBody p)
r
- the CTR bean which holds the run attributesp
- the parent paragraph@Deprecated public XWPFRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR r, XWPFParagraph p)
XWPFRun(CTR, IRunBody)
@Internal public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR getCTR()
public IRunBody getParent()
@Deprecated public XWPFParagraph getParagraph()
getParent()
insteadpublic XWPFDocument getDocument()
XWPFDocument
instance, this run belongs to, or
null
if parent structure (paragraph > document) is not properly set.public java.lang.String getLang()
public void setLang(java.lang.String lang)
lang
- the language tag associated with this runpublic boolean isBold()
isBold
in interface CharacterRun
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.
setBold
in interface CharacterRun
value
- true
if the bold property is applied to
this runpublic java.lang.String getColor()
null
.public void setColor(java.lang.String rgbStr)
rgbStr
- - the desired color, in the hex form "RRGGBB".public java.lang.String getText(int pos)
null
if not setpublic java.lang.String getPictureText()
public void setText(java.lang.String value)
value
- the literal text which shall be displayed in the documentpublic void setText(java.lang.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()
isItalic
in interface CharacterRun
true
if the italic property is appliedpublic void setItalic(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.
setItalic
in interface CharacterRun
value
- true
if the italic property is applied to
this runpublic UnderlinePatterns getUnderline()
UnderlinePatterns
public void setUnderline(UnderlinePatterns value)
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 an underline shall not be applied to the contents of this run.
value
- -
underline typeUnderlinePatterns
public void setUnderlineColor(java.lang.String color)
color
- An RGB color value (e.g, "a0C6F3") or "auto".public void setUnderlineThemeColor(java.lang.String themeColor)
themeColor
- A theme color name (see STThemeColor.Enum
).public org.openxmlformats.schemas.wordprocessingml.x2006.main.STThemeColor.Enum getUnderlineThemeColor()
STThemeColor.Enum
.public java.lang.String getUnderlineColor()
public boolean isStrikeThrough()
isStrikeThrough
in interface CharacterRun
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.
setStrikeThrough
in interface CharacterRun
value
- true
if the strike property is applied to
this run@Deprecated public boolean isStrike()
@Deprecated public void setStrike(boolean value)
public boolean isDoubleStrikeThrough()
isDoubleStrikeThrough
in interface CharacterRun
true
if the double strike property is appliedpublic void setDoubleStrikethrough(boolean value)
setDoubleStrikethrough
in interface CharacterRun
for the rules about this
public boolean isSmallCaps()
isSmallCaps
in interface CharacterRun
public void setSmallCaps(boolean value)
setSmallCaps
in interface CharacterRun
public boolean isCapitalized()
isCapitalized
in interface CharacterRun
public void setCapitalized(boolean value)
setCapitalized
in interface CharacterRun
public boolean isShadowed()
isShadowed
in interface CharacterRun
public void setShadow(boolean value)
setShadow
in interface CharacterRun
public boolean isImprinted()
isImprinted
in interface CharacterRun
public void setImprinted(boolean value)
setImprinted
in interface CharacterRun
public boolean isEmbossed()
isEmbossed
in interface CharacterRun
public void setEmbossed(boolean value)
setEmbossed
in interface CharacterRun
public void setSubscript(VerticalAlign valign)
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 the text shall not be subscript or superscript relative to the default baseline location for the contents of this run.
valign
- Type of vertical align to applyVerticalAlign
public int getKerning()
getKerning
in interface CharacterRun
public void setKerning(int kern)
setKerning
in interface CharacterRun
public boolean isHighlighted()
isHighlighted
in interface CharacterRun
public int getCharacterSpacing()
getCharacterSpacing
in interface CharacterRun
public void setCharacterSpacing(int twips)
setCharacterSpacing
in interface CharacterRun
public java.lang.String getFontFamily()
public void setFontFamily(java.lang.String fontFamily)
Also sets the other font ranges, if they haven't been set before
fontFamily
- The font family to applyXWPFRun.FontCharRange
public java.lang.String getFontName()
getFontFamily()
getFontName
in interface CharacterRun
public java.lang.String getFontFamily(XWPFRun.FontCharRange fcr)
fcr
- the font char range, defaults to "ansi"public void setFontFamily(java.lang.String fontFamily, XWPFRun.FontCharRange fcr)
fontFamily
- The font family to applyfcr
- FontCharRange or null for default handling@Deprecated @Removal(version="6.0.0") public int getFontSize()
getFontSizeAsDouble()
getFontSize
in interface CharacterRun
public java.lang.Double getFontSizeAsDouble()
getFontSizeAsDouble
in interface CharacterRun
public void setFontSize(int size)
If this element is not present, the default value is to leave the value applied at previous level in the style hierarchy. If this element is never applied in the style hierarchy, then any appropriate font size may be used for non complex script characters.
setFontSize
in interface CharacterRun
size
- The font size as number of point measurements.setFontSize(double)
public void setFontSize(double size)
If this element is not present, the default value is to leave the value applied at previous level in the style hierarchy. If this element is never applied in the style hierarchy, then any appropriate font size may be used for non complex script characters.
setFontSize
in interface CharacterRun
size
- The font size as number of point measurements.setFontSize(int)
public int getTextPosition()
public void setTextPosition(int val)
If the val attribute is positive, then the parent run shall be raised above the baseline of the surrounding text by the specified number of half-points. If the val attribute is negative, then the parent run shall be lowered below the baseline of the surrounding text by the specified number of half-points.
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 the text shall not be raised or lowered relative to the default baseline location for the contents of this run.
val
- Positive values will raise the baseline of the text, negative
values will lower it.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 addTab()
public void removeTab()
public void addCarriageReturn()
public void removeCarriageReturn()
public XWPFPicture addPicture(java.io.InputStream pictureData, int pictureType, java.lang.String filename, int width, int height) throws InvalidFormatException, java.io.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
- If the format of the picture is not known.java.io.IOException
- If reading the picture-data from the stream fails.Document.PICTURE_TYPE_EMF
,
Document.PICTURE_TYPE_WMF
,
Document.PICTURE_TYPE_PICT
,
Document.PICTURE_TYPE_JPEG
,
Document.PICTURE_TYPE_PNG
,
Document.PICTURE_TYPE_GIF
,
Document.PICTURE_TYPE_DIB
,
addPicture(InputStream, PictureType, String, int, int)
public XWPFPicture addPicture(java.io.InputStream pictureData, PictureType pictureType, java.lang.String filename, int width, int height) throws InvalidFormatException, java.io.IOException
pictureData
- The raw picture datapictureType
- The PictureType
of the picturewidth
- width in EMUs. To convert to / from points use Units
height
- height in EMUs. To convert to / from points use Units
InvalidFormatException
- If the format of the picture is not known.java.io.IOException
- If reading the picture-data from the stream fails.@Internal public org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline addChart(java.lang.String chartRelId) throws InvalidFormatException, java.io.IOException
chartRelId
- relation id of chart in document relation fileInvalidFormatException
java.io.IOException
public java.util.List<XWPFPicture> getEmbeddedPictures()
public void setStyle(java.lang.String styleId)
styleId
- ID (not name) of the style to set for the run, e.g. "BoldItalic" (not "Bold Italic").public java.lang.String getStyle()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String text()
text
in interface CharacterRun
public java.lang.String getPhonetic()
public void setTextScale(int percentage)
percentage
- The percentage to expand or compress the textpublic int getTextScale()
public void setTextHighlightColor(java.lang.String colorName)
colorName
- The name of the color as defined in the ST_HighlightColor simple type (STHighlightColor
)@Deprecated @Removal(version="7.0.0") public org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor.Enum getTextHightlightColor()
getTextHighlightColor()
insteadSTHighlightColor
for the run.public org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor.Enum getTextHighlightColor()
STHighlightColor
for the run. The default is NONE
;public boolean isVanish()
public void setVanish(boolean value)
value
- Set to true to make the run hidden text.public org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STVerticalAlignRun.Enum getVerticalAlignment()
STVerticalAlignRun.Enum
value (see 22.9.2.17 ST_VerticalAlignRun (Vertical Positioning Location)).
The default is BASELINE
.public void setVerticalAlignment(java.lang.String verticalAlignment)
verticalAlignment
- Vertical alignment value, one of "baseline", "superscript", or "subscript".public org.openxmlformats.schemas.wordprocessingml.x2006.main.STEm.Enum getEmphasisMark()
STEm.Enum
emphasis mark type enumeration. See 17.18.24 ST_Em (Emphasis Mark Type).
The default is NONE
.public void setEmphasisMark(java.lang.String markType)
markType
- Emphasis mark type name, e.g., "dot" or "none". See 17.18.24 ST_Em (Emphasis Mark Type)protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr getRunProperties(boolean create)
create
- If true, create the properties, if false, do not.Copyright 2022 The Apache Software Foundation or its licensors, as applicable.