#64981 - Upgrade OOXML schema to 5th edition (transitional)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884386 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2020-12-13 17:48:31 +00:00
parent 70c9cc874a
commit 9fdda0ed2c
17 changed files with 117 additions and 121 deletions

View File

@ -28,7 +28,7 @@
<version>@VERSION@</version> <version>@VERSION@</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Apache POI - OOXML schemas (full)</name> <name>Apache POI - OOXML schemas (full)</name>
<description>XmlBeans generated from the Ecma supplied xsds (since POI 5.0.0, the 3rd edition is used): <description>XmlBeans generated from the Ecma supplied xsds (since POI 5.0.0, the 5th edition is used):
https://www.ecma-international.org/publications/standards/Ecma-376.htm</description> https://www.ecma-international.org/publications/standards/Ecma-376.htm</description>
<url>https://poi.apache.org/</url> <url>https://poi.apache.org/</url>

View File

@ -107,7 +107,7 @@ public class LinkVideoToPptx {
ctn.setFill(STTLTimeNodeFillType.HOLD); ctn.setFill(STTLTimeNodeFillType.HOLD);
ctn.setDisplay(false); ctn.setDisplay(false);
ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE); ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE);
cmedia.addNewTgtEl().addNewSpTgt().setSpid(""+pic1.getShapeId()); cmedia.addNewTgtEl().addNewSpTgt().setSpid(pic1.getShapeId());
try (FileOutputStream fos = new FileOutputStream("mp4test/mp4test-poi.pptx")) { try (FileOutputStream fos = new FileOutputStream("mp4test/mp4test-poi.pptx")) {

View File

@ -113,7 +113,7 @@ public final class BarChart {
private static void solidFillSeries(XDDFChartData data, int index, PresetColor color) { private static void solidFillSeries(XDDFChartData data, int index, PresetColor color) {
XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color)); XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color));
XDDFChartData.Series series = data.getSeries().get(index); XDDFChartData.Series series = data.getSeries(index);
XDDFShapeProperties properties = series.getShapeProperties(); XDDFShapeProperties properties = series.getShapeProperties();
if (properties == null) { if (properties == null) {
properties = new XDDFShapeProperties(); properties = new XDDFShapeProperties();

View File

@ -117,7 +117,7 @@ public final class LineChart {
XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color)); XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color));
XDDFLineProperties line = new XDDFLineProperties(); XDDFLineProperties line = new XDDFLineProperties();
line.setFillProperties(fill); line.setFillProperties(fill);
XDDFChartData.Series series = data.getSeries().get(index); XDDFChartData.Series series = data.getSeries(index);
XDDFShapeProperties properties = series.getShapeProperties(); XDDFShapeProperties properties = series.getShapeProperties();
if (properties == null) { if (properties == null) {
properties = new XDDFShapeProperties(); properties = new XDDFShapeProperties();

View File

@ -110,7 +110,7 @@ public final class ScatterChart {
XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color)); XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color));
XDDFLineProperties line = new XDDFLineProperties(); XDDFLineProperties line = new XDDFLineProperties();
line.setFillProperties(fill); line.setFillProperties(fill);
XDDFChartData.Series series = data.getSeries().get(index); XDDFChartData.Series series = data.getSeries(index);
XDDFShapeProperties properties = series.getShapeProperties(); XDDFShapeProperties properties = series.getShapeProperties();
if (properties == null) { if (properties == null) {
properties = new XDDFShapeProperties(); properties = new XDDFShapeProperties();

View File

@ -30,7 +30,6 @@ open module org.apache.poi.ooxml.schemas {
exports com.microsoft.schemas.vml; exports com.microsoft.schemas.vml;
exports org.openxmlformats.schemas.drawingml.x2006.chart; exports org.openxmlformats.schemas.drawingml.x2006.chart;
exports org.openxmlformats.schemas.drawingml.x2006.chartDrawing; exports org.openxmlformats.schemas.drawingml.x2006.chartDrawing;
exports org.openxmlformats.schemas.drawingml.x2006.compatibility;
exports org.openxmlformats.schemas.drawingml.x2006.diagram; exports org.openxmlformats.schemas.drawingml.x2006.diagram;
exports org.openxmlformats.schemas.drawingml.x2006.lockedCanvas; exports org.openxmlformats.schemas.drawingml.x2006.lockedCanvas;
exports org.openxmlformats.schemas.drawingml.x2006.main; exports org.openxmlformats.schemas.drawingml.x2006.main;

View File

@ -592,7 +592,7 @@ public class XSSFCellStyle implements CellStyle, Duplicatable {
@Override @Override
public short getRotation() { public short getRotation() {
CTCellAlignment align = _cellXf.getAlignment(); CTCellAlignment align = _cellXf.getAlignment();
return (short)(align == null ? 0 : align.getTextRotation()); return align == null ? 0 : align.getTextRotation().shortValue();
} }
@Override @Override

View File

@ -16,6 +16,8 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xssf.usermodel.extensions; package org.apache.poi.xssf.usermodel.extensions;
import java.math.BigInteger;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.ReadingOrder; import org.apache.poi.ss.usermodel.ReadingOrder;
import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment;
@ -29,7 +31,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignment;
* Cell settings available in the Format/Alignment tab * Cell settings available in the Format/Alignment tab
*/ */
public class XSSFCellAlignment { public class XSSFCellAlignment {
private CTCellAlignment cellAlignement; private final CTCellAlignment cellAlignement;
/** /**
* Creates a Cell Alignment from the supplied XML definition * Creates a Cell Alignment from the supplied XML definition
@ -85,7 +87,7 @@ public class XSSFCellAlignment {
public void setHorizontal(HorizontalAlignment align) { public void setHorizontal(HorizontalAlignment align) {
cellAlignement.setHorizontal(STHorizontalAlignment.Enum.forInt(align.ordinal() + 1)); cellAlignement.setHorizontal(STHorizontalAlignment.Enum.forInt(align.ordinal() + 1));
} }
/** /**
* Set the type of reading order for the cell * Set the type of reading order for the cell
* *
@ -95,7 +97,7 @@ public class XSSFCellAlignment {
public void setReadingOrder(ReadingOrder order) { public void setReadingOrder(ReadingOrder order) {
cellAlignement.setReadingOrder(order.getCode()); cellAlignement.setReadingOrder(order.getCode());
} }
/** /**
* Get the reading order for the cell * Get the reading order for the cell
* *
@ -108,7 +110,7 @@ public class XSSFCellAlignment {
} }
return ReadingOrder.CONTEXT; return ReadingOrder.CONTEXT;
} }
/** /**
* Get the number of spaces to indent the text in the cell * Get the number of spaces to indent the text in the cell
* *
@ -142,7 +144,7 @@ public class XSSFCellAlignment {
* @return rotation degrees (between 0 and 180 degrees) * @return rotation degrees (between 0 and 180 degrees)
*/ */
public long getTextRotation() { public long getTextRotation() {
return cellAlignement.getTextRotation(); return cellAlignement.isSetTextRotation() ? cellAlignement.getTextRotation().longValue() : 0;
} }
/** /**
@ -157,8 +159,8 @@ public class XSSFCellAlignment {
* <code>[degrees below horizon] = 90 - textRotation.</code> * <code>[degrees below horizon] = 90 - textRotation.</code>
* </p> * </p>
* *
* Note: HSSF uses values from -90 to 90 degrees, whereas XSSF * Note: HSSF uses values from -90 to 90 degrees, whereas XSSF
* uses values from 0 to 180 degrees. The implementations of this method will map between these two value-ranges * uses values from 0 to 180 degrees. The implementations of this method will map between these two value-ranges
* accordingly, however the corresponding getter is returning values in the range mandated by the current type * accordingly, however the corresponding getter is returning values in the range mandated by the current type
* of Excel file-format that this CellStyle is applied to. * of Excel file-format that this CellStyle is applied to.
* *
@ -168,7 +170,7 @@ public class XSSFCellAlignment {
if(rotation < 0 && rotation >= -90) { if(rotation < 0 && rotation >= -90) {
rotation = 90 + ((-1)*rotation); rotation = 90 + ((-1)*rotation);
} }
cellAlignement.setTextRotation(rotation); cellAlignement.setTextRotation(BigInteger.valueOf(rotation));
} }
/** /**
@ -192,11 +194,11 @@ public class XSSFCellAlignment {
public boolean getShrinkToFit() { public boolean getShrinkToFit() {
return cellAlignement.getShrinkToFit(); return cellAlignement.getShrinkToFit();
} }
public void setShrinkToFit(boolean shrink) { public void setShrinkToFit(boolean shrink) {
cellAlignement.setShrinkToFit(shrink); cellAlignement.setShrinkToFit(shrink);
} }
/** /**
* Access to low-level data * Access to low-level data
*/ */

View File

@ -18,7 +18,6 @@ package org.apache.poi.xwpf.usermodel;
import org.apache.poi.ooxml.POIXMLDocumentPart; import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
/** /**
* Experimental abstract class that is a base for XWPFSDT and XWPFSDTCell * Experimental abstract class that is a base for XWPFSDT and XWPFSDTCell
@ -33,23 +32,8 @@ public abstract class XWPFAbstractSDT implements ISDTContents {
private final IBody part; private final IBody part;
public XWPFAbstractSDT(CTSdtPr pr, IBody part) { public XWPFAbstractSDT(CTSdtPr pr, IBody part) {
if (pr == null) { title = (pr != null && pr.isSetAlias()) ? pr.getAlias().getVal() : "";
title = ""; tag = (pr != null && pr.isSetTag()) ? pr.getTag().getVal() : "";
tag = "";
} else {
CTString[] aliases = pr.getAliasArray();
if (aliases != null && aliases.length > 0) {
title = aliases[0].getVal();
} else {
title = "";
}
CTString[] tags = pr.getTagArray();
if (tags != null && tags.length > 0) {
tag = tags[0].getVal();
} else {
tag = "";
}
}
this.part = part; this.part = part;
} }

View File

@ -66,8 +66,8 @@ public class XWPFDefaultRunStyle {
} }
private BigDecimal getFontSizeAsBigDecimal(int scale) { private BigDecimal getFontSizeAsBigDecimal(int scale) {
return (rpr != null && rpr.isSetSz()) return (rpr != null && rpr.sizeOfSzArray() > 0)
? BigDecimal.valueOf(Units.toPoints(POIXMLUnits.parseLength(rpr.getSz().xgetVal()))).divide(BigDecimal.valueOf(4), scale, RoundingMode.HALF_UP) ? BigDecimal.valueOf(Units.toPoints(POIXMLUnits.parseLength(rpr.getSzArray(0).xgetVal()))).divide(BigDecimal.valueOf(4), scale, RoundingMode.HALF_UP)
: null; : null;
} }
} }

View File

@ -76,10 +76,10 @@ import org.xml.sax.SAXException;
* XWPFRun object defines a region of text with a common set of properties * XWPFRun object defines a region of text with a common set of properties
*/ */
public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
private CTR run; private final CTR run;
private String pictureText; private final String pictureText;
private IRunBody parent; private final IRunBody parent;
private List<XWPFPicture> pictures; private final List<XWPFPicture> pictures;
/** /**
* @param r the CTR bean which holds the run attributes * @param r the CTR bean which holds the run attributes
@ -238,7 +238,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public String getLang() { public String getLang() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
Object lang = pr == null || !pr.isSetLang() ? null : pr.getLang().getVal(); Object lang = (pr == null || pr.sizeOfLangArray() == 0) ? null : pr.getLangArray(0).getVal();
return (String) lang; return (String) lang;
} }
@ -250,7 +250,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setLang(String lang) { public void setLang(String lang) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTLanguage ctLang = pr.isSetLang() ? pr.getLang() : pr.addNewLang(); CTLanguage ctLang = pr.sizeOfLangArray() > 0 ? pr.getLangArray(0) : pr.addNewLang();
ctLang.setVal(lang); ctLang.setVal(lang);
} }
@ -263,7 +263,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public boolean isBold() { public boolean isBold() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetB() && isCTOnOff(pr.getB()); return pr != null && pr.sizeOfBArray() > 0 && isCTOnOff(pr.getBArray(0));
} }
/** /**
@ -293,7 +293,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public void setBold(boolean value) { public void setBold(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff bold = pr.isSetB() ? pr.getB() : pr.addNewB(); CTOnOff bold = pr.sizeOfBArray() > 0 ? pr.getBArray(0) : pr.addNewB();
bold.setVal(value ? STOnOff1.ON : STOnOff1.OFF); bold.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@ -304,8 +304,8 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
String color = null; String color = null;
if (run.isSetRPr()) { if (run.isSetRPr()) {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
if (pr != null && pr.isSetColor()) { if (pr != null && pr.sizeOfColorArray() > 0) {
CTColor clr = pr.getColor(); CTColor clr = pr.getColorArray(0);
color = clr.xgetVal().getStringValue(); color = clr.xgetVal().getStringValue();
} }
} }
@ -319,7 +319,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setColor(String rgbStr) { public void setColor(String rgbStr) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTColor color = pr.isSetColor() ? pr.getColor() : pr.addNewColor(); CTColor color = pr.sizeOfColorArray() > 0 ? pr.getColorArray(0) : pr.addNewColor();
color.setVal(rgbStr); color.setVal(rgbStr);
} }
@ -373,7 +373,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public boolean isItalic() { public boolean isItalic() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetI() && isCTOnOff(pr.getI()); return pr != null && pr.sizeOfIArray() > 0 && isCTOnOff(pr.getIArray(0));
} }
/** /**
@ -404,7 +404,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public void setItalic(boolean value) { public void setItalic(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff italic = pr.isSetI() ? pr.getI() : pr.addNewI(); CTOnOff italic = pr.sizeOfIArray() > 0 ? pr.getIArray(0) : pr.addNewI();
italic.setVal(value ? STOnOff1.ON : STOnOff1.OFF); italic.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@ -452,11 +452,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
private CTUnderline getCTUnderline(boolean create) { private CTUnderline getCTUnderline(boolean create) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTUnderline underline = pr.getU(); return pr.sizeOfUArray() > 0 ? pr.getUArray(0) : (create ? pr.addNewU() : null);
if (create && underline == null) {
underline = pr.addNewU();
}
return underline;
} }
/** /**
@ -539,7 +535,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public boolean isStrikeThrough() { public boolean isStrikeThrough() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetStrike() && isCTOnOff(pr.getStrike()); return pr != null && pr.sizeOfStrikeArray() > 0 && isCTOnOff(pr.getStrikeArray(0));
} }
/** /**
@ -569,7 +565,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public void setStrikeThrough(boolean value) { public void setStrikeThrough(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike(); CTOnOff strike = pr.sizeOfStrikeArray() > 0 ? pr.getStrikeArray(0) : pr.addNewStrike();
strike.setVal(value ? STOnOff1.ON : STOnOff1.OFF); strike.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@ -592,7 +588,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public boolean isDoubleStrikeThrough() { public boolean isDoubleStrikeThrough() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetDstrike() && isCTOnOff(pr.getDstrike()); return pr != null && pr.sizeOfDstrikeArray() > 0 && isCTOnOff(pr.getDstrikeArray(0));
} }
/** /**
@ -604,72 +600,72 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public void setDoubleStrikethrough(boolean value) { public void setDoubleStrikethrough(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike(); CTOnOff dstrike = pr.sizeOfDstrikeArray() > 0 ? pr.getDstrikeArray(0) : pr.addNewDstrike();
dstrike.setVal(value ? STOnOff1.ON : STOnOff1.OFF); dstrike.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@Override @Override
public boolean isSmallCaps() { public boolean isSmallCaps() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetSmallCaps() && isCTOnOff(pr.getSmallCaps()); return pr != null && pr.sizeOfSmallCapsArray() > 0 && isCTOnOff(pr.getSmallCapsArray(0));
} }
@Override @Override
public void setSmallCaps(boolean value) { public void setSmallCaps(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps(); CTOnOff caps = pr.sizeOfSmallCapsArray() > 0 ? pr.getSmallCapsArray(0) : pr.addNewSmallCaps();
caps.setVal(value ? STOnOff1.ON : STOnOff1.OFF); caps.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@Override @Override
public boolean isCapitalized() { public boolean isCapitalized() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetCaps() && isCTOnOff(pr.getCaps()); return pr != null && pr.sizeOfCapsArray() > 0 && isCTOnOff(pr.getCapsArray(0));
} }
@Override @Override
public void setCapitalized(boolean value) { public void setCapitalized(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff caps = pr.isSetCaps() ? pr.getCaps() : pr.addNewCaps(); CTOnOff caps = pr.sizeOfCapsArray() > 0 ? pr.getCapsArray(0) : pr.addNewCaps();
caps.setVal(value ? STOnOff1.ON : STOnOff1.OFF); caps.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@Override @Override
public boolean isShadowed() { public boolean isShadowed() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetShadow() && isCTOnOff(pr.getShadow()); return pr != null && pr.sizeOfShadowArray() > 0 && isCTOnOff(pr.getShadowArray(0));
} }
@Override @Override
public void setShadow(boolean value) { public void setShadow(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff shadow = pr.isSetShadow() ? pr.getShadow() : pr.addNewShadow(); CTOnOff shadow = pr.sizeOfShadowArray() > 0 ? pr.getShadowArray(0) : pr.addNewShadow();
shadow.setVal(value ? STOnOff1.ON : STOnOff1.OFF); shadow.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@Override @Override
public boolean isImprinted() { public boolean isImprinted() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetImprint() && isCTOnOff(pr.getImprint()); return pr != null && pr.sizeOfImprintArray() > 0 && isCTOnOff(pr.getImprintArray(0));
} }
@Override @Override
public void setImprinted(boolean value) { public void setImprinted(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff imprinted = pr.isSetImprint() ? pr.getImprint() : pr.addNewImprint(); CTOnOff imprinted = pr.sizeOfImprintArray() > 0 ? pr.getImprintArray(0) : pr.addNewImprint();
imprinted.setVal(value ? STOnOff1.ON : STOnOff1.OFF); imprinted.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@Override @Override
public boolean isEmbossed() { public boolean isEmbossed() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return pr != null && pr.isSetEmboss() && isCTOnOff(pr.getEmboss()); return pr != null && pr.sizeOfEmbossArray() > 0 && isCTOnOff(pr.getEmbossArray(0));
} }
@Override @Override
public void setEmbossed(boolean value) { public void setEmbossed(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff emboss = pr.isSetEmboss() ? pr.getEmboss() : pr.addNewEmboss(); CTOnOff emboss = pr.sizeOfEmbossArray() > 0 ? pr.getEmbossArray(0) : pr.addNewEmboss();
emboss.setVal(value ? STOnOff1.ON : STOnOff1.OFF); emboss.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@ -691,33 +687,33 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setSubscript(VerticalAlign valign) { public void setSubscript(VerticalAlign valign) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTVerticalAlignRun ctValign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign(); CTVerticalAlignRun ctValign = pr.sizeOfVertAlignArray() > 0 ? pr.getVertAlignArray(0) : pr.addNewVertAlign();
ctValign.setVal(STVerticalAlignRun.Enum.forInt(valign.getValue())); ctValign.setVal(STVerticalAlignRun.Enum.forInt(valign.getValue()));
} }
@Override @Override
public int getKerning() { public int getKerning() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
if (pr == null || !pr.isSetKern()) { if (pr == null || pr.sizeOfKernArray() == 0) {
return 0; return 0;
} }
return (int)POIXMLUnits.parseLength(pr.getKern().xgetVal()); return (int)POIXMLUnits.parseLength(pr.getKernArray(0).xgetVal());
} }
@Override @Override
public void setKerning(int kern) { public void setKerning(int kern) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTHpsMeasure kernmes = pr.isSetKern() ? pr.getKern() : pr.addNewKern(); CTHpsMeasure kernmes = pr.sizeOfKernArray() > 0 ? pr.getKernArray(0) : pr.addNewKern();
kernmes.setVal(BigInteger.valueOf(kern)); kernmes.setVal(BigInteger.valueOf(kern));
} }
@Override @Override
public boolean isHighlighted() { public boolean isHighlighted() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
if (pr == null || !pr.isSetHighlight()) { if (pr == null || pr.sizeOfHighlightArray() == 0) {
return false; return false;
} }
STHighlightColor.Enum val = pr.getHighlight().getVal(); STHighlightColor.Enum val = pr.getHighlightArray(0).getVal();
if (val == null || val == STHighlightColor.NONE) { if (val == null || val == STHighlightColor.NONE) {
return false; return false;
} }
@ -729,16 +725,16 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
@Override @Override
public int getCharacterSpacing() { public int getCharacterSpacing() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
if (pr == null || !pr.isSetSpacing()) { if (pr == null || pr.sizeOfSpacingArray() == 0) {
return 0; return 0;
} }
return (int)Units.toDXA(POIXMLUnits.parseLength(pr.getSpacing().xgetVal())); return (int)Units.toDXA(POIXMLUnits.parseLength(pr.getSpacingArray(0).xgetVal()));
} }
@Override @Override
public void setCharacterSpacing(int twips) { public void setCharacterSpacing(int twips) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTSignedTwipsMeasure spc = pr.isSetSpacing() ? pr.getSpacing() : pr.addNewSpacing(); CTSignedTwipsMeasure spc = pr.sizeOfSpacingArray() > 0 ? pr.getSpacingArray(0) : pr.addNewSpacing();
spc.setVal(BigInteger.valueOf(twips)); spc.setVal(BigInteger.valueOf(twips));
} }
@ -784,11 +780,11 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public String getFontFamily(FontCharRange fcr) { public String getFontFamily(FontCharRange fcr) {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
if (pr == null || !pr.isSetRFonts()) { if (pr == null || pr.sizeOfRFontsArray() == 0) {
return null; return null;
} }
CTFonts fonts = pr.getRFonts(); CTFonts fonts = pr.getRFontsArray(0);
switch (fcr == null ? FontCharRange.ascii : fcr) { switch (fcr == null ? FontCharRange.ascii : fcr) {
default: default:
case ascii: case ascii:
@ -813,7 +809,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setFontFamily(String fontFamily, FontCharRange fcr) { public void setFontFamily(String fontFamily, FontCharRange fcr) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts(); CTFonts fonts = pr.sizeOfRFontsArray() > 0 ? pr.getRFontsArray(0) : pr.addNewRFonts();
if (fcr == null) { if (fcr == null) {
fonts.setAscii(fontFamily); fonts.setAscii(fontFamily);
@ -875,8 +871,8 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
private BigDecimal getFontSizeAsBigDecimal(int scale) { private BigDecimal getFontSizeAsBigDecimal(int scale) {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return (pr != null && pr.isSetSz()) return (pr != null && pr.sizeOfSzArray() > 0)
? BigDecimal.valueOf(Units.toPoints(POIXMLUnits.parseLength(pr.getSz().xgetVal()))).divide(BigDecimal.valueOf(4), scale, RoundingMode.HALF_UP) ? BigDecimal.valueOf(Units.toPoints(POIXMLUnits.parseLength(pr.getSzArray(0).xgetVal()))).divide(BigDecimal.valueOf(4), scale, RoundingMode.HALF_UP)
: null; : null;
} }
@ -897,7 +893,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
public void setFontSize(int size) { public void setFontSize(int size) {
BigInteger bint = BigInteger.valueOf(size); BigInteger bint = BigInteger.valueOf(size);
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz(); CTHpsMeasure ctSize = pr.sizeOfSzArray() > 0 ? pr.getSzArray(0) : pr.addNewSz();
ctSize.setVal(bint.multiply(BigInteger.valueOf(2))); ctSize.setVal(bint.multiply(BigInteger.valueOf(2)));
} }
@ -919,7 +915,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
public void setFontSize(double size) { public void setFontSize(double size) {
BigDecimal bd = BigDecimal.valueOf(size); BigDecimal bd = BigDecimal.valueOf(size);
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz(); CTHpsMeasure ctSize = pr.sizeOfSzArray() > 0 ? pr.getSzArray(0) : pr.addNewSz();
ctSize.setVal(bd.multiply(BigDecimal.valueOf(2)).setScale(0, RoundingMode.HALF_UP).toBigInteger()); ctSize.setVal(bd.multiply(BigDecimal.valueOf(2)).setScale(0, RoundingMode.HALF_UP).toBigInteger());
} }
@ -933,7 +929,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public int getTextPosition() { public int getTextPosition() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
return (pr != null && pr.isSetPosition()) ? (int)(Units.toPoints(POIXMLUnits.parseLength(pr.getPosition().xgetVal())) / 2.) return (pr != null && pr.sizeOfPositionArray() > 0) ? (int)(Units.toPoints(POIXMLUnits.parseLength(pr.getPositionArray(0).xgetVal())) / 2.)
: -1; : -1;
} }
@ -963,7 +959,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
public void setTextPosition(int val) { public void setTextPosition(int val) {
BigInteger bint = new BigInteger(Integer.toString(val)); BigInteger bint = new BigInteger(Integer.toString(val));
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTSignedHpsMeasure position = pr.isSetPosition() ? pr.getPosition() : pr.addNewPosition(); CTSignedHpsMeasure position = pr.sizeOfPositionArray() > 0 ? pr.getPositionArray(0) : pr.addNewPosition();
position.setVal(bint); position.setVal(bint);
} }
@ -1241,7 +1237,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
if (null == pr) { if (null == pr) {
pr = getCTR().addNewRPr(); pr = getCTR().addNewRPr();
} }
CTString style = pr.getRStyle() != null ? pr.getRStyle() : pr.addNewRStyle(); CTString style = pr.sizeOfRStyleArray() > 0 ? pr.getRStyleArray(0) : pr.addNewRStyle();
style.setVal(styleId); style.setVal(styleId);
} }
@ -1257,7 +1253,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return ""; return "";
} }
CTString style = pr.getRStyle(); CTString style = pr.getRStyleArray(0);
if (style == null) { if (style == null) {
return ""; return "";
} }
@ -1437,7 +1433,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setTextScale(int percentage) { public void setTextScale(int percentage) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTTextScale scale = pr.isSetW() ? pr.getW() : pr.addNewW(); CTTextScale scale = pr.sizeOfWArray() > 0 ? pr.getWArray(0) : pr.addNewW();
scale.setVal(percentage); scale.setVal(percentage);
} }
@ -1449,11 +1445,11 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public int getTextScale() { public int getTextScale() {
CTRPr pr = getRunProperties(false); CTRPr pr = getRunProperties(false);
if (pr == null || !pr.isSetW()) { if (pr == null || pr.sizeOfWArray() == 0) {
return 100; return 100;
} }
int value = POIXMLUnits.parsePercent(pr.getW().xgetVal()); int value = POIXMLUnits.parsePercent(pr.getWArray(0).xgetVal());
// 100% scaling, that is, no change. See 17.3.2.43 w (Expanded/Compressed Text) // 100% scaling, that is, no change. See 17.3.2.43 w (Expanded/Compressed Text)
return value == 0 ? 100 : value / 1000; return value == 0 ? 100 : value / 1000;
} }
@ -1466,7 +1462,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setTextHighlightColor(String colorName) { public void setTextHighlightColor(String colorName) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTHighlight highlight = pr.isSetHighlight() ? pr.getHighlight() : pr.addNewHighlight(); CTHighlight highlight = pr.sizeOfHighlightArray() > 0 ? pr.getHighlightArray(0) : pr.addNewHighlight();
STHighlightColor color = highlight.xgetVal(); STHighlightColor color = highlight.xgetVal();
if (color == null) { if (color == null) {
color = STHighlightColor.Factory.newInstance(); color = STHighlightColor.Factory.newInstance();
@ -1487,7 +1483,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public STHighlightColor.Enum getTextHightlightColor() { public STHighlightColor.Enum getTextHightlightColor() {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTHighlight highlight = pr.isSetHighlight() ? pr.getHighlight() : pr.addNewHighlight(); CTHighlight highlight = pr.sizeOfHighlightArray() > 0 ? pr.getHighlightArray(0) : pr.addNewHighlight();
STHighlightColor color = highlight.xgetVal(); STHighlightColor color = highlight.xgetVal();
if (color == null) { if (color == null) {
color = STHighlightColor.Factory.newInstance(); color = STHighlightColor.Factory.newInstance();
@ -1504,7 +1500,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public boolean isVanish() { public boolean isVanish() {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
return pr != null && pr.isSetVanish() && isCTOnOff(pr.getVanish()); return pr != null && pr.sizeOfVanishArray() > 0 && isCTOnOff(pr.getVanishArray(0));
} }
/** /**
@ -1515,7 +1511,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setVanish(boolean value) { public void setVanish(boolean value) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTOnOff vanish = pr.isSetVanish() ? pr.getVanish() : pr.addNewVanish(); CTOnOff vanish = pr.sizeOfVanishArray() > 0 ? pr.getVanishArray(0) : pr.addNewVanish();
vanish.setVal(value ? STOnOff1.ON : STOnOff1.OFF); vanish.setVal(value ? STOnOff1.ON : STOnOff1.OFF);
} }
@ -1527,7 +1523,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public STVerticalAlignRun.Enum getVerticalAlignment() { public STVerticalAlignRun.Enum getVerticalAlignment() {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTVerticalAlignRun vertAlign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign(); CTVerticalAlignRun vertAlign = pr.sizeOfVertAlignArray() > 0 ? pr.getVertAlignArray(0) : pr.addNewVertAlign();
STVerticalAlignRun.Enum val = vertAlign.getVal(); STVerticalAlignRun.Enum val = vertAlign.getVal();
if (val == null) { if (val == null) {
val = STVerticalAlignRun.BASELINE; val = STVerticalAlignRun.BASELINE;
@ -1543,7 +1539,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setVerticalAlignment(String verticalAlignment) { public void setVerticalAlignment(String verticalAlignment) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTVerticalAlignRun vertAlign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign(); CTVerticalAlignRun vertAlign = pr.sizeOfVertAlignArray() > 0 ? pr.getVertAlignArray(0) : pr.addNewVertAlign();
STVerticalAlignRun align = vertAlign.xgetVal(); STVerticalAlignRun align = vertAlign.xgetVal();
if (align == null) { if (align == null) {
align = STVerticalAlignRun.Factory.newInstance(); align = STVerticalAlignRun.Factory.newInstance();
@ -1565,7 +1561,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public STEm.Enum getEmphasisMark() { public STEm.Enum getEmphasisMark() {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTEm emphasis = pr.isSetEm() ? pr.getEm() : pr.addNewEm(); CTEm emphasis = pr.sizeOfEmArray() > 0 ? pr.getEmArray(0) : pr.addNewEm();
STEm.Enum val = emphasis.getVal(); STEm.Enum val = emphasis.getVal();
if (val == null) { if (val == null) {
@ -1583,7 +1579,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/ */
public void setEmphasisMark(String markType) { public void setEmphasisMark(String markType) {
CTRPr pr = getRunProperties(true); CTRPr pr = getRunProperties(true);
CTEm emphasisMark = pr.isSetEm() ? pr.getEm() : pr.addNewEm(); CTEm emphasisMark = pr.sizeOfEmArray() > 0 ? pr.getEmArray(0) : pr.addNewEm();
STEm mark = emphasisMark.xgetVal(); STEm mark = emphasisMark.xgetVal();
if (mark == null) { if (mark == null) {
mark = STEm.Factory.newInstance(); mark = STEm.Factory.newInstance();

View File

@ -50,7 +50,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
*/ */
public class XWPFStyles extends POIXMLDocumentPart { public class XWPFStyles extends POIXMLDocumentPart {
private CTStyles ctStyles; private CTStyles ctStyles;
private List<XWPFStyle> listStyle = new ArrayList<>(); private final List<XWPFStyle> listStyle = new ArrayList<>();
private XWPFLatentStyles latentStyles; private XWPFLatentStyles latentStyles;
private XWPFDefaultRunStyle defaultRunStyle; private XWPFDefaultRunStyle defaultRunStyle;
@ -234,8 +234,8 @@ public class XWPFStyles extends POIXMLDocumentPart {
ensureDocDefaults(); ensureDocDefaults();
CTLanguage lang = null; CTLanguage lang = null;
if (defaultRunStyle.getRPr().isSetLang()) { if (defaultRunStyle.getRPr().sizeOfLangArray() > 0) {
lang = defaultRunStyle.getRPr().getLang(); lang = defaultRunStyle.getRPr().getLangArray(0);
} else { } else {
lang = defaultRunStyle.getRPr().addNewLang(); lang = defaultRunStyle.getRPr().addNewLang();
} }
@ -273,7 +273,10 @@ public class XWPFStyles extends POIXMLDocumentPart {
ensureDocDefaults(); ensureDocDefaults();
CTRPr runProps = defaultRunStyle.getRPr(); CTRPr runProps = defaultRunStyle.getRPr();
runProps.setRFonts(fonts); if (runProps.sizeOfRFontsArray() == 0) {
runProps.addNewRFonts();
}
runProps.setRFontsArray(0, fonts);
} }
/** /**

View File

@ -109,7 +109,7 @@ public class TestXSLFExamples {
ctn.setFill(STTLTimeNodeFillType.HOLD); ctn.setFill(STTLTimeNodeFillType.HOLD);
ctn.setDisplay(false); ctn.setDisplay(false);
ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE); ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE);
cmedia.addNewTgtEl().addNewSpTgt().setSpid(""+pic1.getShapeId()); cmedia.addNewTgtEl().addNewSpTgt().setSpid(pic1.getShapeId());
// write to file - use FileOutputStream instead // write to file - use FileOutputStream instead

View File

@ -30,7 +30,18 @@ import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.ReadingOrder;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder; import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
@ -716,7 +727,8 @@ public class TestXSSFCellStyle {
@Test @Test
public void testGetSetVerticalAlignment() { public void testGetSetVerticalAlignment() {
assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignment()); assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignment());
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getVertical()); assertFalse(cellStyle.getCellAlignment().getCTCellAlignment().isSetVertical());
assertEquals(STVerticalAlignment.BOTTOM, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
assertEquals(VerticalAlignment.CENTER, cellStyle.getVerticalAlignment()); assertEquals(VerticalAlignment.CENTER, cellStyle.getVerticalAlignment());

View File

@ -139,7 +139,7 @@ public class TestXWPFRun {
run.setBold(false); run.setBold(false);
// Implementation detail: POI natively prefers <w:b w:val="false"/>, // Implementation detail: POI natively prefers <w:b w:val="false"/>,
// but should correctly read val="0" and val="off" // but should correctly read val="0" and val="off"
assertEquals("off", rpr.getB().getVal()); assertEquals("off", rpr.getBArray(0).getVal());
} }
@Test @Test
@ -151,7 +151,7 @@ public class TestXWPFRun {
assertTrue(run.isItalic()); assertTrue(run.isItalic());
run.setItalic(false); run.setItalic(false);
assertEquals("off", rpr.getI().getVal()); assertEquals("off", rpr.getIArray(0).getVal());
} }
@Test @Test
@ -163,7 +163,7 @@ public class TestXWPFRun {
assertTrue(run.isStrikeThrough()); assertTrue(run.isStrikeThrough());
run.setStrikeThrough(false); run.setStrikeThrough(false);
assertEquals("off", rpr.getStrike().getVal()); assertEquals("off", rpr.getStrikeArray(0).getVal());
} }
@Test @Test
@ -176,7 +176,7 @@ public class TestXWPFRun {
.getValue()); .getValue());
run.setUnderline(UnderlinePatterns.NONE); run.setUnderline(UnderlinePatterns.NONE);
assertEquals(STUnderline.NONE.intValue(), rpr.getU().getVal() assertEquals(STUnderline.NONE.intValue(), rpr.getUArray(0).getVal()
.intValue()); .intValue());
} }
@ -189,7 +189,7 @@ public class TestXWPFRun {
assertEquals("Times New Roman", run.getFontFamily()); assertEquals("Times New Roman", run.getFontFamily());
run.setFontFamily("Verdana"); run.setFontFamily("Verdana");
assertEquals("Verdana", rpr.getRFonts().getAscii()); assertEquals("Verdana", rpr.getRFontsArray(0).getAscii());
} }
@Test @Test
@ -202,10 +202,10 @@ public class TestXWPFRun {
assertEquals(7.0, run.getFontSizeAsDouble(), 0.01); assertEquals(7.0, run.getFontSizeAsDouble(), 0.01);
run.setFontSize(24); run.setFontSize(24);
assertEquals("48", rpr.getSz().getVal().toString()); assertEquals("48", rpr.getSzArray(0).getVal().toString());
run.setFontSize(24.5f); run.setFontSize(24.5f);
assertEquals("49", rpr.getSz().getVal().toString()); assertEquals("49", rpr.getSzArray(0).getVal().toString());
assertEquals(25, run.getFontSize()); assertEquals(25, run.getFontSize());
assertEquals(24.5, run.getFontSizeAsDouble(), 0.01); assertEquals(24.5, run.getFontSizeAsDouble(), 0.01);
} }
@ -219,7 +219,7 @@ public class TestXWPFRun {
assertEquals(4000, run.getTextPosition()); assertEquals(4000, run.getTextPosition());
run.setTextPosition(2400); run.setTextPosition(2400);
assertEquals("2400", rpr.getPosition().getVal().toString()); assertEquals("2400", rpr.getPositionArray(0).getVal().toString());
} }
@Test @Test
@ -331,8 +331,8 @@ public class TestXWPFRun {
assertTrue(run.isBold()); assertTrue(run.isBold());
assertTrue(run.isItalic()); assertTrue(run.isItalic());
assertFalse(run.isStrikeThrough()); assertFalse(run.isStrikeThrough());
assertTrue(run.getCTR().getRPr().isSetB()); assertTrue(run.getCTR().getRPr().sizeOfBArray() > 0);
assertFalse(run.getCTR().getRPr().getB().isSetVal()); assertFalse(run.getCTR().getRPr().getBArray(0).isSetVal());
// Back to normal // Back to normal
@ -477,10 +477,10 @@ public class TestXWPFRun {
run.getCTR().addNewRPr().addNewLang().setVal("en-CA"); run.getCTR().addNewRPr().addNewLang().setVal("en-CA");
assertEquals("en-CA", run.getLang()); assertEquals("en-CA", run.getLang());
run.getCTR().getRPr().getLang().setVal("fr-CA"); run.getCTR().getRPr().getLangArray(0).setVal("fr-CA");
assertEquals("fr-CA", run.getLang()); assertEquals("fr-CA", run.getLang());
run.getCTR().getRPr().getLang().setVal(null); run.getCTR().getRPr().getLangArray(0).setVal(null);
assertNull(run.getLang()); assertNull(run.getLang());
} }
@ -734,7 +734,7 @@ public class TestXWPFRun {
XWPFRun run = new XWPFRun(ctRun, irb); XWPFRun run = new XWPFRun(ctRun, irb);
run.setSubscript(VerticalAlign.BASELINE); run.setSubscript(VerticalAlign.BASELINE);
assertEquals(STVerticalAlignRun.BASELINE, rpr.getVertAlign().getVal()); assertEquals(STVerticalAlignRun.BASELINE, rpr.getVertAlignArray(0).getVal());
} }
@Test @Test
@ -787,7 +787,7 @@ public class TestXWPFRun {
String styleId = "bolditalic"; String styleId = "bolditalic";
run.setStyle(styleId); run.setStyle(styleId);
String candStyleId = run.getCTR().getRPr().getRStyle().getVal(); String candStyleId = run.getCTR().getRPr().getRStyleArray(0).getVal();
assertNotNull("Expected to find a run style ID", candStyleId); assertNotNull("Expected to find a run style ID", candStyleId);
assertEquals(styleId, candStyleId); assertEquals(styleId, candStyleId);