You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ab...@apache.org on 2018/08/27 19:25:34 UTC
svn commit: r1839369 [2/2] - in /poi/trunk/src/ooxml/java/org/apache/poi:
openxml4j/opc/internal/ xddf/usermodel/chart/ xddf/usermodel/text/
xslf/usermodel/
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java Mon Aug 27 19:25:34 2018
@@ -40,8 +40,8 @@ import org.openxmlformats.schemas.drawin
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing;
/**
- * Represents a paragraph of text within the containing text body.
- * The paragraph is the highest level text separation mechanism.
+ * Represents a paragraph of text within the containing text body. The paragraph
+ * is the highest level text separation mechanism.
*/
@Beta
public class XDDFTextParagraph {
@@ -55,9 +55,7 @@ public class XDDFTextParagraph {
this._p = paragraph;
this._parent = parent;
- final int count = paragraph.sizeOfBrArray()
- + paragraph.sizeOfFldArray()
- + paragraph.sizeOfRArray();
+ final int count = paragraph.sizeOfBrArray() + paragraph.sizeOfFldArray() + paragraph.sizeOfRArray();
this._runs = new ArrayList<>(count);
for (XmlObject xo : _p.selectChildren(QNameSet.ALL)) {
@@ -83,11 +81,11 @@ public class XDDFTextParagraph {
return _parent;
}
- public List<XDDFTextRun> getTextRuns(){
+ public List<XDDFTextRun> getTextRuns() {
return _runs;
}
- public Iterator<XDDFTextRun> iterator(){
+ public Iterator<XDDFTextRun> iterator() {
return _runs.iterator();
}
@@ -96,10 +94,10 @@ public class XDDFTextParagraph {
*
* @return text run representing this line break ('\n').
*/
- public XDDFTextRun appendLineBreak(){
+ public XDDFTextRun appendLineBreak() {
CTTextLineBreak br = _p.addNewBr();
// by default, line break has the font properties of the last text run
- for (int i = _runs.size() - 1; i <= 0; i--){
+ for (int i = _runs.size() - 1; i <= 0; i--) {
CTTextCharacterProperties prevProps = _runs.get(i).getProperties();
// let's find one that is not undefined
if (prevProps != null) {
@@ -117,7 +115,7 @@ public class XDDFTextParagraph {
*
* @return the new text field.
*/
- public XDDFTextRun appendField(String id, String type, String text){
+ public XDDFTextRun appendField(String id, String type, String text) {
CTTextField f = _p.addNewFld();
f.setId(id);
f.setType(type);
@@ -134,7 +132,7 @@ public class XDDFTextParagraph {
*
* @return the new run of text.
*/
- public XDDFTextRun appendRegularRun(String text){
+ public XDDFTextRun appendRegularRun(String text) {
CTRegularTextRun r = _p.addNewR();
r.setT(text);
CTTextCharacterProperties rPr = r.addNewRPr();
@@ -148,19 +146,20 @@ public class XDDFTextParagraph {
* Returns the alignment that is applied to the paragraph.
*
* If this attribute is omitted, then a value of left is implied.
+ *
* @return alignment that is applied to the paragraph
*/
public TextAlignment getTextAlignment() {
return findDefinedParagraphProperty(props -> props.isSetAlgn(), props -> props.getAlgn())
- .map(align -> TextAlignment.valueOf(align))
- .orElse(null);
+ .map(align -> TextAlignment.valueOf(align)).orElse(null);
}
/**
- * Specifies the alignment that is to be applied to the paragraph.
- * Possible values for this include left, right, centered, justified and distributed,
+ * Specifies the alignment that is to be applied to the paragraph. Possible
+ * values for this include left, right, centered, justified and distributed,
*
- * @param align text alignment
+ * @param align
+ * text alignment
*/
public void setTextAlignment(TextAlignment align) {
if (align != null || _p.isSetPPr()) {
@@ -169,25 +168,27 @@ public class XDDFTextParagraph {
}
/**
- * Returns where vertically on a line of text the actual words are positioned. This deals
- * with vertical placement of the characters with respect to the baselines.
+ * Returns where vertically on a line of text the actual words are
+ * positioned. This deals with vertical placement of the characters with
+ * respect to the baselines.
*
* If this attribute is omitted, then a value of baseline is implied.
+ *
* @return alignment that is applied to the paragraph
*/
public FontAlignment getFontAlignment() {
return findDefinedParagraphProperty(props -> props.isSetFontAlgn(), props -> props.getFontAlgn())
- .map(align -> FontAlignment.valueOf(align))
- .orElse(null);
+ .map(align -> FontAlignment.valueOf(align)).orElse(null);
}
/**
- * Determines where vertically on a line of text the actual words are positioned. This deals
- * with vertical placement of the characters with respect to the baselines. For instance
- * having text anchored to the top baseline, anchored to the bottom baseline, centered in
- * between, etc.
+ * Determines where vertically on a line of text the actual words are
+ * positioned. This deals with vertical placement of the characters with
+ * respect to the baselines. For instance having text anchored to the top
+ * baseline, anchored to the bottom baseline, centered in between, etc.
*
- * @param align text font alignment
+ * @param align
+ * text font alignment
*/
public void setFontAlignment(FontAlignment align) {
if (align != null || _p.isSetPPr()) {
@@ -197,27 +198,31 @@ public class XDDFTextParagraph {
/**
*
- * @return the indentation, in points, applied to the first line of text in the paragraph.
+ * @return the indentation, in points, applied to the first line of text in
+ * the paragraph.
*/
public Double getIndentation() {
return findDefinedParagraphProperty(props -> props.isSetIndent(), props -> props.getIndent())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
- * Specifies the indentation size that will be applied to the first line of text in the paragraph.
+ * Specifies the indentation size that will be applied to the first line of
+ * text in the paragraph.
*
- * @param points the indentation in points.
- * The value <code>null</code> unsets the indentation for this paragraph.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>-4032</dd>
- * <dt>Maximum inclusive =</dt><dd>4032</dd>
- * </dt>
+ * @param points
+ * the indentation in points. The value <code>null</code> unsets
+ * the indentation for this paragraph.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>-4032</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4032</dd></dt>
*/
public void setIndentation(Double points) {
if (points != null || _p.isSetPPr()) {
- getOrCreateProperties().setIndentation(points);;
+ getOrCreateProperties().setIndentation(points);
+ ;
}
}
@@ -227,21 +232,23 @@ public class XDDFTextParagraph {
*/
public Double getMarginLeft() {
return findDefinedParagraphProperty(props -> props.isSetMarL(), props -> props.getMarL())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
- * Specifies the left margin of the paragraph. This is specified in addition to the text body
- * inset and applies only to this text paragraph. That is the text body inset and the LeftMargin
- * attributes are additive with respect to the text position.
- *
- * @param points the margin in points.
- * The value <code>null</code> unsets the left margin for this paragraph.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>0</dd>
- * <dt>Maximum inclusive =</dt><dd>4032</dd>
- * </dt>
+ * Specifies the left margin of the paragraph. This is specified in addition
+ * to the text body inset and applies only to this text paragraph. That is
+ * the text body inset and the LeftMargin attributes are additive with
+ * respect to the text position.
+ *
+ * @param points
+ * the margin in points. The value <code>null</code> unsets the
+ * left margin for this paragraph.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>0</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4032</dd></dt>
*/
public void setMarginLeft(Double points) {
if (points != null || _p.isSetPPr()) {
@@ -255,21 +262,23 @@ public class XDDFTextParagraph {
*/
public Double getMarginRight() {
return findDefinedParagraphProperty(props -> props.isSetMarR(), props -> props.getMarR())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
- * Specifies the right margin of the paragraph. This is specified in addition to the text body
- * inset and applies only to this text paragraph. That is the text body inset and the RightMargin
- * attributes are additive with respect to the text position.
- *
- * @param points the margin in points.
- * The value <code>null</code> unsets the right margin for this paragraph.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>0</dd>
- * <dt>Maximum inclusive =</dt><dd>4032</dd>
- * </dt>
+ * Specifies the right margin of the paragraph. This is specified in
+ * addition to the text body inset and applies only to this text paragraph.
+ * That is the text body inset and the RightMargin attributes are additive
+ * with respect to the text position.
+ *
+ * @param points
+ * the margin in points. The value <code>null</code> unsets the
+ * right margin for this paragraph.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>0</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4032</dd></dt>
*/
public void setMarginRight(Double points) {
if (points != null || _p.isSetPPr()) {
@@ -279,19 +288,20 @@ public class XDDFTextParagraph {
/**
*
- * @return the default size for a tab character within this paragraph in points.
+ * @return the default size for a tab character within this paragraph in
+ * points.
*/
public Double getDefaultTabSize() {
return findDefinedParagraphProperty(props -> props.isSetDefTabSz(), props -> props.getDefTabSz())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
* Specifies the default size for a tab character within this paragraph.
*
- * @param points the default tab size in points.
- * The value <code>null</code> unsets the default tab size for this paragraph.
+ * @param points
+ * the default tab size in points. The value <code>null</code>
+ * unsets the default tab size for this paragraph.
*/
public void setDefaultTabSize(Double points) {
if (points != null || _p.isSetPPr()) {
@@ -301,30 +311,35 @@ public class XDDFTextParagraph {
/**
* Returns the vertical line spacing that is to be used within a paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * This may be specified in two different ways, percentage spacing or font
+ * points spacing:
* <p>
- * If line spacing is a percentage of normal line height, result is instance of XDDFSpacingPercent.
- * If line spacing is expressed in points, result is instance of XDDFSpacingPoints.
+ * If line spacing is a percentage of normal line height, result is instance
+ * of XDDFSpacingPercent. If line spacing is expressed in points, result is
+ * instance of XDDFSpacingPoints.
* </p>
*
* @return the vertical line spacing.
*/
public XDDFSpacing getLineSpacing() {
return findDefinedParagraphProperty(props -> props.isSetLnSpc(), props -> props.getLnSpc())
- .map(spacing -> extractSpacing(spacing))
- .orElse(null);
+ .map(spacing -> extractSpacing(spacing)).orElse(null);
}
/**
- * This element specifies the vertical line spacing that is to be used within a paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * This element specifies the vertical line spacing that is to be used
+ * within a paragraph. This may be specified in two different ways,
+ * percentage spacing or font points spacing:
* <p>
- * If spacing is instance of XDDFSpacingPercent, then line spacing is a percentage of normal line height.
- * If spacing is instance of XDDFSpacingPoints, then line spacing is expressed in points.
+ * If spacing is instance of XDDFSpacingPercent, then line spacing is a
+ * percentage of normal line height. If spacing is instance of
+ * XDDFSpacingPoints, then line spacing is expressed in points.
* </p>
* Examples:
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* // spacing will be 120% of the size of the largest text on each line
* paragraph.setLineSpacing(new XDDFSpacingPercent(120));
*
@@ -333,9 +348,11 @@ public class XDDFTextParagraph {
*
* // spacing will be 48 points
* paragraph.setLineSpacing(new XDDFSpacingPoints(48.0));
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param linespacing the vertical line spacing
+ * @param linespacing
+ * the vertical line spacing
*/
public void setLineSpacing(XDDFSpacing linespacing) {
if (linespacing != null || _p.isSetPPr()) {
@@ -344,39 +361,46 @@ public class XDDFTextParagraph {
}
/**
- * The amount of vertical white space before the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * The amount of vertical white space before the paragraph. This may be
+ * specified in two different ways, percentage spacing or font points
+ * spacing:
* <p>
- * If spacing is a percentage of normal line height, result is instance of XDDFSpacingPercent.
- * If spacing is expressed in points, result is instance of XDDFSpacingPoints.
+ * If spacing is a percentage of normal line height, result is instance of
+ * XDDFSpacingPercent. If spacing is expressed in points, result is instance
+ * of XDDFSpacingPoints.
* </p>
*
* @return the vertical white space before the paragraph.
*/
public XDDFSpacing getSpaceBefore() {
return findDefinedParagraphProperty(props -> props.isSetSpcBef(), props -> props.getSpcBef())
- .map(spacing -> extractSpacing(spacing))
- .orElse(null);
+ .map(spacing -> extractSpacing(spacing)).orElse(null);
}
/**
- * Set the amount of vertical white space that will be present before the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * Set the amount of vertical white space that will be present before the
+ * paragraph. This may be specified in two different ways, percentage
+ * spacing or font points spacing:
* <p>
- * If spacing is instance of XDDFSpacingPercent, then spacing is a percentage of normal line height.
- * If spacing is instance of XDDFSpacingPoints, then spacing is expressed in points.
+ * If spacing is instance of XDDFSpacingPercent, then spacing is a
+ * percentage of normal line height. If spacing is instance of
+ * XDDFSpacingPoints, then spacing is expressed in points.
* </p>
* Examples:
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* // The paragraph will be formatted to have a spacing before the paragraph text.
* // The spacing will be 200% of the size of the largest text on each line
* paragraph.setSpaceBefore(new XDDFSpacingPercent(200));
*
* // The spacing will be a size of 48 points
* paragraph.setSpaceBefore(new XDDFSpacingPoints(48.0));
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param spaceBefore the vertical white space before the paragraph.
+ * @param spaceBefore
+ * the vertical white space before the paragraph.
*/
public void setSpaceBefore(XDDFSpacing spaceBefore) {
if (spaceBefore != null || _p.isSetPPr()) {
@@ -385,39 +409,46 @@ public class XDDFTextParagraph {
}
/**
- * The amount of vertical white space after the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * The amount of vertical white space after the paragraph. This may be
+ * specified in two different ways, percentage spacing or font points
+ * spacing:
* <p>
- * If spacing is a percentage of normal line height, result is instance of XDDFSpacingPercent.
- * If spacing is expressed in points, result is instance of XDDFSpacingPoints.
+ * If spacing is a percentage of normal line height, result is instance of
+ * XDDFSpacingPercent. If spacing is expressed in points, result is instance
+ * of XDDFSpacingPoints.
* </p>
*
* @return the vertical white space after the paragraph.
*/
public XDDFSpacing getSpaceAfter() {
return findDefinedParagraphProperty(props -> props.isSetSpcAft(), props -> props.getSpcAft())
- .map(spacing -> extractSpacing(spacing))
- .orElse(null);
+ .map(spacing -> extractSpacing(spacing)).orElse(null);
}
/**
- * Set the amount of vertical white space that will be present after the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * Set the amount of vertical white space that will be present after the
+ * paragraph. This may be specified in two different ways, percentage
+ * spacing or font points spacing:
* <p>
- * If spacing is instance of XDDFSpacingPercent, then spacing is a percentage of normal line height.
- * If spacing is instance of XDDFSpacingPoints, then spacing is expressed in points.
+ * If spacing is instance of XDDFSpacingPercent, then spacing is a
+ * percentage of normal line height. If spacing is instance of
+ * XDDFSpacingPoints, then spacing is expressed in points.
* </p>
* Examples:
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* // The paragraph will be formatted to have a spacing after the paragraph text.
* // The spacing will be 200% of the size of the largest text on each line
* paragraph.setSpaceAfter(new XDDFSpacingPercent(200));
*
* // The spacing will be a size of 48 points
* paragraph.setSpaceAfter(new XDDFSpacingPoints(48.0));
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param spaceAfter the vertical white space after the paragraph.
+ * @param spaceAfter
+ * the vertical white space after the paragraph.
*/
public void setSpaceAfter(XDDFSpacing spaceAfter) {
if (spaceAfter != null || _p.isSetPPr()) {
@@ -427,20 +458,19 @@ public class XDDFTextParagraph {
/**
*
- * @return the color of bullet characters within a given paragraph.
- * A <code>null</code> value means to use the text font color.
+ * @return the color of bullet characters within a given paragraph. A
+ * <code>null</code> value means to use the text font color.
*/
- public XDDFColor getBulletColor(){
- return findDefinedParagraphProperty(
- props -> props.isSetBuClr() || props.isSetBuClrTx(),
- props -> new XDDFParagraphBulletProperties(props).getBulletColor()
- ).orElse(null);
+ public XDDFColor getBulletColor() {
+ return findDefinedParagraphProperty(props -> props.isSetBuClr() || props.isSetBuClrTx(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletColor()).orElse(null);
}
/**
* Set the color to be used on bullet characters within a given paragraph.
*
- * @param color the bullet color
+ * @param color
+ * the bullet color
*/
public void setBulletColor(XDDFColor color) {
if (color != null || _p.isSetPPr()) {
@@ -449,7 +479,8 @@ public class XDDFTextParagraph {
}
/**
- * Specifies the color to be used on bullet characters has to follow text color within a given paragraph.
+ * Specifies the color to be used on bullet characters has to follow text
+ * color within a given paragraph.
*/
public void setBulletColorFollowText() {
getOrCreateBulletProperties().setBulletColorFollowText();
@@ -457,20 +488,19 @@ public class XDDFTextParagraph {
/**
*
- * @return the font of bullet characters within a given paragraph.
- * A <code>null</code> value means to use the text font font.
+ * @return the font of bullet characters within a given paragraph. A
+ * <code>null</code> value means to use the text font font.
*/
- public XDDFFont getBulletFont(){
- return findDefinedParagraphProperty(
- props -> props.isSetBuFont() || props.isSetBuFontTx(),
- props -> new XDDFParagraphBulletProperties(props).getBulletFont()
- ).orElse(null);
+ public XDDFFont getBulletFont() {
+ return findDefinedParagraphProperty(props -> props.isSetBuFont() || props.isSetBuFontTx(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletFont()).orElse(null);
}
/**
* Set the font to be used on bullet characters within a given paragraph.
*
- * @param font the bullet font
+ * @param font
+ * the bullet font
*/
public void setBulletFont(XDDFFont font) {
if (font != null || _p.isSetPPr()) {
@@ -479,40 +509,46 @@ public class XDDFTextParagraph {
}
/**
- * Specifies the font to be used on bullet characters has to follow text font within a given paragraph.
+ * Specifies the font to be used on bullet characters has to follow text
+ * font within a given paragraph.
*/
public void setBulletFontFollowText() {
getOrCreateBulletProperties().setBulletFontFollowText();
}
/**
- * Returns the bullet size that is to be used within a paragraph.
- * This may be specified in three different ways, follows text size, percentage size and font points size:
+ * Returns the bullet size that is to be used within a paragraph. This may
+ * be specified in three different ways, follows text size, percentage size
+ * and font points size:
* <p>
- * If returned value is instance of XDDFBulletSizeFollowText, then bullet size is text size;
- * If returned value is instance of XDDFBulletSizePercent, then bullet size is a percentage of the font size;
- * If returned value is instance of XDDFBulletSizePoints, then bullet size is specified in points.
+ * If returned value is instance of XDDFBulletSizeFollowText, then bullet
+ * size is text size; If returned value is instance of
+ * XDDFBulletSizePercent, then bullet size is a percentage of the font size;
+ * If returned value is instance of XDDFBulletSizePoints, then bullet size
+ * is specified in points.
* </p>
*
* @return the bullet size
*/
- public XDDFBulletSize getBulletSize(){
+ public XDDFBulletSize getBulletSize() {
return findDefinedParagraphProperty(
- props -> props.isSetBuSzPct() || props.isSetBuSzPts() || props.isSetBuSzTx(),
- props -> new XDDFParagraphBulletProperties(props).getBulletSize()
- ).orElse(null);
+ props -> props.isSetBuSzPct() || props.isSetBuSzPts() || props.isSetBuSzTx(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletSize()).orElse(null);
}
/**
- * Sets the bullet size that is to be used within a paragraph.
- * This may be specified in three different ways, follows text size, percentage size and font points size:
+ * Sets the bullet size that is to be used within a paragraph. This may be
+ * specified in three different ways, follows text size, percentage size and
+ * font points size:
* <p>
- * If given value is instance of XDDFBulletSizeFollowText, then bullet size is text size;
- * If given value is instance of XDDFBulletSizePercent, then bullet size is a percentage of the font size;
- * If given value is instance of XDDFBulletSizePoints, then bullet size is specified in points.
+ * If given value is instance of XDDFBulletSizeFollowText, then bullet size
+ * is text size; If given value is instance of XDDFBulletSizePercent, then
+ * bullet size is a percentage of the font size; If given value is instance
+ * of XDDFBulletSizePoints, then bullet size is specified in points.
* </p>
*
- * @param size the bullet size specification
+ * @param size
+ * the bullet size specification
*/
public void setBulletSize(XDDFBulletSize size) {
if (size != null || _p.isSetPPr()) {
@@ -520,11 +556,10 @@ public class XDDFTextParagraph {
}
}
- public XDDFBulletStyle getBulletStyle(){
+ public XDDFBulletStyle getBulletStyle() {
return findDefinedParagraphProperty(
- props -> props.isSetBuAutoNum() || props.isSetBuBlip() || props.isSetBuChar() || props.isSetBuNone(),
- props -> new XDDFParagraphBulletProperties(props).getBulletStyle()
- ).orElse(null);
+ props -> props.isSetBuAutoNum() || props.isSetBuBlip() || props.isSetBuChar() || props.isSetBuNone(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletStyle()).orElse(null);
}
public void setBulletStyle(XDDFBulletStyle style) {
@@ -534,8 +569,7 @@ public class XDDFTextParagraph {
}
public boolean hasEastAsianLineBreak() {
- return findDefinedParagraphProperty(props -> props.isSetEaLnBrk(), props -> props.getEaLnBrk())
- .orElse(false);
+ return findDefinedParagraphProperty(props -> props.isSetEaLnBrk(), props -> props.getEaLnBrk()).orElse(false);
}
public void setEastAsianLineBreak(Boolean value) {
@@ -567,8 +601,7 @@ public class XDDFTextParagraph {
}
public boolean isRightToLeft() {
- return findDefinedParagraphProperty(props -> props.isSetRtl(), props -> props.getRtl())
- .orElse(false);
+ return findDefinedParagraphProperty(props -> props.isSetRtl(), props -> props.getRtl()).orElse(false);
}
public void setRightToLeft(Boolean value) {
@@ -641,6 +674,13 @@ public class XDDFTextParagraph {
}
}
+ public XDDFRunProperties addAfterLastRunProperties() {
+ if (!_p.isSetEndParaRPr()) {
+ _p.addNewEndParaRPr();
+ }
+ return getAfterLastRunProperties();
+ }
+
public XDDFRunProperties getAfterLastRunProperties() {
if (_p.isSetEndParaRPr()) {
return new XDDFRunProperties(_p.getEndParaRPr());
@@ -651,7 +691,9 @@ public class XDDFTextParagraph {
public void setAfterLastRunProperties(XDDFRunProperties properties) {
if (properties == null) {
- _p.unsetEndParaRPr();
+ if (_p.isSetEndParaRPr()) {
+ _p.unsetEndParaRPr();
+ }
} else {
_p.setEndParaRPr(properties.getXmlObject());
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java Mon Aug 27 19:25:34 2018
@@ -22,8 +22,8 @@ import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
-import org.apache.poi.POIXMLRelation;
import org.apache.poi.common.usermodel.fonts.FontGroup;
+import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship;
@@ -88,9 +88,9 @@ public class XDDFTextRun {
public String getText() {
if (isLineBreak()) {
return "\n";
- } else if (isField()) {
+ } else if (isField()) {
return _tf.getT();
- } else {
+ } else {
return _rtr.getT();
}
}
@@ -151,7 +151,8 @@ public class XDDFTextRun {
/**
* Specifies whether this run of text will be formatted as bold text.
*
- * @param bold whether this run of text will be formatted as bold text.
+ * @param bold
+ * whether this run of text will be formatted as bold text.
*/
public void setBold(Boolean bold) {
getOrCreateProperties().setBold(bold);
@@ -166,7 +167,8 @@ public class XDDFTextRun {
}
/**
- * @param italic whether this run of text is formatted as italic text.
+ * @param italic
+ * whether this run of text is formatted as italic text.
*/
public void setItalic(Boolean italic) {
getOrCreateProperties().setItalic(italic);
@@ -181,7 +183,8 @@ public class XDDFTextRun {
}
/**
- * @param strike which strike style this run of text is formatted with.
+ * @param strike
+ * which strike style this run of text is formatted with.
*/
public void setStrikeThrough(StrikeType strike) {
getOrCreateProperties().setStrikeThrough(strike);
@@ -206,7 +209,8 @@ public class XDDFTextRun {
}
/**
- * @param underline which underline style this run of text is formatted with.
+ * @param underline
+ * which underline style this run of text is formatted with.
*/
public void setUnderline(UnderlineType underline) {
getOrCreateProperties().setUnderline(underline);
@@ -231,7 +235,8 @@ public class XDDFTextRun {
}
/**
- * @param caps which caps style this run of text is formatted with.
+ * @param caps
+ * which caps style this run of text is formatted with.
*/
public void setCapitals(CapsType caps) {
getOrCreateProperties().setCapitals(caps);
@@ -256,7 +261,8 @@ public class XDDFTextRun {
}
/**
- * @return whether a run of text will be formatted as a subscript text. Default is false.
+ * @return whether a run of text will be formatted as a subscript text.
+ * Default is false.
*/
public boolean isSubscript() {
return findDefinedProperty(props -> props.isSetBaseline(), props -> props.getBaseline())
@@ -265,7 +271,8 @@ public class XDDFTextRun {
}
/**
- * @return whether a run of text will be formatted as a superscript text. Default is false.
+ * @return whether a run of text will be formatted as a superscript text.
+ * Default is false.
*/
public boolean isSuperscript() {
return findDefinedProperty(props -> props.isSetBaseline(), props -> props.getBaseline())
@@ -282,31 +289,35 @@ public class XDDFTextRun {
*
* @param offset
*/
- public void setBaseline(Double offset){
- getOrCreateProperties().setBaseline((int)(offset * 1000));
+ public void setBaseline(Double offset) {
+ if (offset == null) {
+ getOrCreateProperties().setBaseline(null);
+ } else {
+ getOrCreateProperties().setBaseline((int) (offset * 1000));
+ }
}
/**
* Set whether the text in this run is formatted as superscript.
- * <p>
- * The size is specified using a percentage.
- * </p>
+ * <p>
+ * The size is specified using a percentage.
+ * </p>
*
* @param offset
*/
- public void setSuperscript(Double offset){
+ public void setSuperscript(Double offset) {
setBaseline(offset == null ? null : Math.abs(offset));
}
/**
* Set whether the text in this run is formatted as subscript.
- * <p>
- * The size is specified using a percentage.
- * </p>
+ * <p>
+ * The size is specified using a percentage.
+ * </p>
*
* @param offset
*/
- public void setSubscript(Double offset){
+ public void setSubscript(Double offset) {
setBaseline(offset == null ? null : -Math.abs(offset));
}
@@ -331,7 +342,8 @@ public class XDDFTextRun {
* <em>Note</em>: In order to get fonts to unset the property for a given font family use
* {@link XDDFFont#unsetFontForGroup(FontGroup)}
*
- * @param fonts to set or unset on the run.
+ * @param fonts
+ * to set or unset on the run.
*/
public void setFonts(XDDFFont[] fonts) {
getOrCreateProperties().setFonts(fonts);
@@ -357,12 +369,14 @@ public class XDDFTextRun {
}
/**
- * @param size font size in points.
- * The value <code>null</code> unsets the size for this run.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>1</dd>
- * <dt>Maximum inclusive =</dt><dd>400</dd>
- * </dt>
+ * @param size
+ * font size in points. The value <code>null</code> unsets the
+ * size for this run.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>1</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>400</dd></dt>
*
*/
public void setFontSize(Double size) {
@@ -371,7 +385,7 @@ public class XDDFTextRun {
public Double getFontSize() {
Integer size = findDefinedProperty(props -> props.isSetSz(), props -> props.getSz())
- .orElse(100 * XSSFFont.DEFAULT_FONT_SIZE); // default font size
+ .orElse(100 * XSSFFont.DEFAULT_FONT_SIZE); // default font size
double scale = _parent.getParentBody().getBodyProperties().getAutoFit().getFontScale() / 10_000_000.0;
return size * scale;
}
@@ -382,13 +396,15 @@ public class XDDFTextRun {
* The value <code>null</code> unsets the kerning for this run.
* </p>
*
- * @param kerning character kerning in points.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>0</dd>
- * <dt>Maximum inclusive =</dt><dd>4000</dd>
- * </dt>
+ * @param kerning
+ * character kerning in points.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>0</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4000</dd></dt>
*/
- public void setCharacterKerning(Double kerning){
+ public void setCharacterKerning(Double kerning) {
getOrCreateProperties().setCharacterKerning(kerning);
}
@@ -413,13 +429,15 @@ public class XDDFTextRun {
* The value <code>null</code> unsets the spacing for this run.
* </p>
*
- * @param spacing character spacing in points.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>-4000</dd>
- * <dt>Maximum inclusive =</dt><dd>4000</dd>
- * </dt>
+ * @param spacing
+ * character spacing in points.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>-4000</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4000</dd></dt>
*/
- public void setCharacterSpacing(Double spacing){
+ public void setCharacterSpacing(Double spacing) {
getOrCreateProperties().setCharacterSpacing(spacing);
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java Mon Aug 27 19:25:34 2018
@@ -77,8 +77,10 @@ public class XSLFAutoShape extends XSLFT
CTShape shape = (CTShape) getXmlObject();
CTTextBody txBody = shape.getTxBody();
if (txBody == null && create) {
- txBody = shape.addNewTxBody();
- initTextBody(txBody);
+ XDDFTextBody body = new XDDFTextBody(this);
+ initTextBody(body);
+ shape.setTxBody(body.getXmlObject());
+ txBody = shape.getTxBody();
}
return txBody;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org