diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
index 4c302b83e7..f86d217470 100644
--- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
+++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
@@ -46,14 +46,9 @@ import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
-import org.apache.poi.xslf.usermodel.XSLFChart;
-import org.apache.poi.xslf.usermodel.XSLFFactory;
-import org.apache.poi.xslf.usermodel.XSLFRelation;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xwpf.usermodel.XWPFFactory;
-import org.apache.poi.xwpf.usermodel.XWPFRelation;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
@@ -403,7 +398,7 @@ public abstract class XDDFChart extends POIXMLDocumentPart {
* @since POI 4.0.0
*/
private PackagePart createWorksheetPart(POIXMLRelation chartRelation, POIXMLRelation chartWorkbookRelation, POIXMLFactory chartFactory) throws InvalidFormatException {
- PackageRelationship xlsx = createRelationshipInChart(XSLFRelation.WORKBOOK_RELATIONSHIP, XSLFFactory.getInstance(), chartIndex);
+ PackageRelationship xlsx = createRelationshipInChart(chartWorkbookRelation, chartFactory, chartIndex);
this.setExternalId(xlsx.getId());
return getTargetPart(xlsx);
}
@@ -419,25 +414,41 @@ public abstract class XDDFChart extends POIXMLDocumentPart {
public void saveWorkbook(XSSFWorkbook workbook) throws IOException, InvalidFormatException {
PackagePart worksheetPart = getWorksheetPart(true);
if (worksheetPart == null) {
- POIXMLRelation chartRelation = null;
- POIXMLRelation chartWorkbookRelation = null;
- POIXMLFactory chartFactory = null;
- if (this instanceof XSLFChart) {
- chartRelation = XSLFRelation.CHART;
- chartWorkbookRelation = XSLFRelation.WORKBOOK_RELATIONSHIP;
- chartFactory = XSLFFactory.getInstance();
- } else {
- chartRelation = XWPFRelation.CHART;
- chartRelation = XWPFRelation.WORKBOOK_RELATIONSHIP;
- chartFactory = XWPFFactory.getInstance();
+ POIXMLRelation chartRelation = getChartRelation();
+ POIXMLRelation chartWorkbookRelation = getChartWorkbookRelation();
+ POIXMLFactory chartFactory = getChartFactory();
+ if (chartRelation != null
+ && chartWorkbookRelation != null
+ && chartFactory != null) {
+ worksheetPart = createWorksheetPart(chartRelation, chartWorkbookRelation, chartFactory);
}
- worksheetPart = createWorksheetPart(chartRelation, chartWorkbookRelation, chartFactory);
}
try (OutputStream xlsOut = worksheetPart.getOutputStream()) {
workbook.write(xlsOut);
}
}
+ /**
+ *
+ * @return the chart relation in the implementing subclass.
+ * @since POI 4.0.0
+ */
+ protected abstract POIXMLRelation getChartRelation();
+
+ /**
+ *
+ * @return the chart workbook relation in the implementing subclass.
+ * @since POI 4.0.0
+ */
+ protected abstract POIXMLRelation getChartWorkbookRelation();
+
+ /**
+ *
+ * @return the chart factory in the implementing subclass.
+ * @since POI 4.0.0
+ */
+ protected abstract POIXMLFactory getChartFactory();
+
/**
* this method writes the data into sheet
*
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java
index a04b61e14e..a24812132f 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java
@@ -21,12 +21,11 @@ package org.apache.poi.xslf.usermodel;
import java.io.IOException;
-import org.apache.poi.POIXMLDocument;
+import org.apache.poi.POIXMLFactory;
import org.apache.poi.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.util.Beta;
import org.apache.poi.xddf.usermodel.chart.XDDFChart;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
@@ -55,6 +54,21 @@ public final class XSLFChart extends XDDFChart {
super(part);
}
+ @Override
+ protected POIXMLRelation getChartRelation() {
+ return XSLFRelation.CHART;
+ }
+
+ @Override
+ protected POIXMLRelation getChartWorkbookRelation() {
+ return XSLFRelation.WORKBOOK;
+ }
+
+ @Override
+ protected POIXMLFactory getChartFactory() {
+ return XSLFFactory.getInstance();
+ }
+
public XSLFTextShape getTitle() {
if (!chart.isSetTitle()) {
chart.addNewTitle();
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
index 77c91b62d6..38b28dfe6d 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
@@ -139,7 +139,7 @@ public class XSLFRelation extends POIXMLRelation {
null
);
- public static final XSLFRelation WORKBOOK_RELATIONSHIP = new XSLFRelation(
+ public static final XSLFRelation WORKBOOK = new XSLFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
POIXMLDocument.PACK_OBJECT_REL_TYPE,
"/ppt/embeddings/Microsoft_Excel_Worksheet#.xlsx",
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
index 8470f23c21..df49cc94c0 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
@@ -26,6 +26,8 @@ import java.util.List;
import javax.xml.namespace.QName;
+import org.apache.poi.POIXMLFactory;
+import org.apache.poi.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
@@ -96,6 +98,21 @@ public final class XSSFChart extends XDDFChart implements Chart, ChartAxisFactor
super(part);
}
+ @Override
+ protected POIXMLRelation getChartRelation() {
+ return null;
+ }
+
+ @Override
+ protected POIXMLRelation getChartWorkbookRelation() {
+ return null;
+ }
+
+ @Override
+ protected POIXMLFactory getChartFactory() {
+ return null;
+ }
+
/**
* Construct a new CTChartSpace bean. By default, it's just an empty placeholder for chart objects.
*/
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFChart.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
index b48a3e02ce..f68039fcd5 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
@@ -21,6 +21,9 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.POIXMLException;
+import org.apache.poi.POIXMLFactory;
+import org.apache.poi.POIXMLRelation;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
@@ -72,6 +75,21 @@ public class XWPFChart extends XDDFChart {
super(part);
}
+ @Override
+ protected POIXMLRelation getChartRelation() {
+ return XWPFRelation.CHART;
+ }
+
+ @Override
+ protected POIXMLRelation getChartWorkbookRelation() {
+ return XWPFRelation.WORKBOOK;
+ }
+
+ @Override
+ protected POIXMLFactory getChartFactory() {
+ return XWPFFactory.getInstance();
+ }
+
public Long getChecksum() {
if (this.checksum == null) {
InputStream is = null;
@@ -129,13 +147,19 @@ public class XWPFChart extends XDDFChart {
}
/**
- * initialize in line object
+ * Attach this chart known by its relation id to the given text run.
*
- * @param inline this object is used to adjust the margin and dimension of chart
+ * @param chartRelId the relation id of this chart in its parent document.
+ * @param run the text run to which this chart will be inlined.
+ * @throws InvalidFormatException
+ * @throws IOException
* @since POI 4.0.0
*/
- protected void setAttachTo(CTInline ctInline) {
- this.ctInline = ctInline;
+ protected void attach(String chartRelId, XWPFRun run)
+ throws InvalidFormatException, IOException {
+ ctInline = run.addChart(chartRelId);
+ ctInline.addNewExtent();
+ setChartBoundingBox(DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
index 824bdb00f6..6a0a49f6cc 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
@@ -63,7 +63,6 @@ import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComment;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1;
@@ -1638,28 +1637,17 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
public XWPFChart createChart(int width, int height) throws InvalidFormatException, IOException {
//get chart number
- int chartNumber = getPackagePart().getPackage().
- getPartsByContentType(XWPFRelation.CHART.getContentType()).size() + 1;
+ int chartNumber = getNextPartNumber(XWPFRelation.CHART, charts.size() + 1);
//create relationship in document for new chart
RelationPart rp = createRelationship(
XWPFRelation.CHART, XWPFFactory.getInstance(), chartNumber, false);
- //get chart relationship id
- String chartId = rp.getRelationship().getId();
-
- //create paragraph and run object
- XWPFRun xRun = this.createParagraph().createRun();
-
- CTInline inline = xRun.addChart(width, height, chartId);
-
- //get package part of xwpfchart object
+ // initialize xwpfchart object
XWPFChart xwpfChart = rp.getDocumentPart();
-
xwpfChart.setChartIndex(chartNumber);
-
- //set in line object into xwpfchart object
- xwpfChart.setAttachTo(inline);
+ xwpfChart.attach(rp.getRelationship().getId(), createParagraph().createRun());
+ xwpfChart.setChartBoundingBox(width, height);
//add chart object to chart list
charts.add(xwpfChart);
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
index d0d44e398f..b10f57a364 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
@@ -115,7 +115,7 @@ public final class XWPFRelation extends POIXMLRelation {
null
);
- public static final XWPFRelation WORKBOOK_RELATIONSHIP = new XWPFRelation(
+ public static final XWPFRelation WORKBOOK = new XWPFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
POIXMLDocument.PACK_OBJECT_REL_TYPE,
"/word/embeddings/Microsoft_Excel_Worksheet#.xlsx",
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
index 9c2d79ee07..c6dd9bb508 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
@@ -40,7 +40,6 @@ import org.apache.xmlbeans.XmlString;
import org.apache.xmlbeans.XmlToken;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTRelId;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject;
@@ -134,8 +133,9 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
NodeList kids = t.getDomNode().getChildNodes();
for (int n = 0; n < kids.getLength(); n++) {
if (kids.item(n) instanceof Text) {
- if (text.length() > 0)
+ if (text.length() > 0) {
text.append("\n");
+ }
text.append(kids.item(n).getNodeValue());
}
}
@@ -157,6 +157,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* @deprecated Use {@link XWPFRun#XWPFRun(CTR, IRunBody)}
*/
+ @Deprecated
public XWPFRun(CTR r, XWPFParagraph p) {
this(r, (IRunBody) p);
}
@@ -219,9 +220,11 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @deprecated use {@link XWPFRun#getParent()} instead
*/
+ @Deprecated
public XWPFParagraph getParagraph() {
- if (parent instanceof XWPFParagraph)
+ if (parent instanceof XWPFParagraph) {
return (XWPFParagraph) parent;
+ }
return null;
}
@@ -240,8 +243,9 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* For isBold, isItalic etc
*/
private static boolean isCTOnOff(CTOnOff onoff) {
- if (!onoff.isSetVal())
+ if (!onoff.isSetVal()) {
return true;
+ }
final STOnOff.Enum val = onoff.getVal();
return (
(STOnOff.TRUE == val) ||
@@ -267,6 +271,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @return true
if the bold property is applied
*/
+ @Override
public boolean isBold() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetB() && isCTOnOff(pr.getB());
@@ -296,6 +301,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* @param value true
if the bold property is applied to
* this run
*/
+ @Override
public void setBold(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff bold = pr.isSetB() ? pr.getB() : pr.addNewB();
@@ -361,8 +367,9 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* @param pos - position in the text array (NB: 0 based)
*/
public void setText(String value, int pos) {
- if (pos > run.sizeOfTArray())
+ if (pos > run.sizeOfTArray()) {
throw new ArrayIndexOutOfBoundsException("Value too large for the parameter position in XWPFRun.setText(String value,int pos)");
+ }
CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT();
t.setStringValue(value);
preserveSpaces(t);
@@ -374,6 +381,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @return true
if the italic property is applied
*/
+ @Override
public boolean isItalic() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetI() && isCTOnOff(pr.getI());
@@ -404,6 +412,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* @param value true
if the italic property is applied to
* this run
*/
+ @Override
public void setItalic(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff italic = pr.isSetI() ? pr.getI() : pr.addNewI();
@@ -451,6 +460,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @return true
if the strike property is applied
*/
+ @Override
public boolean isStrikeThrough() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetStrike() && isCTOnOff(pr.getStrike());
@@ -480,6 +490,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* @param value true
if the strike property is applied to
* this run
*/
+ @Override
public void setStrikeThrough(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
@@ -502,6 +513,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @return true
if the double strike property is applied
*/
+ @Override
public boolean isDoubleStrikeThrough() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetDstrike() && isCTOnOff(pr.getDstrike());
@@ -513,61 +525,72 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @see #setStrikeThrough(boolean) for the rules about this
*/
+ @Override
public void setDoubleStrikethrough(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike();
dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
+ @Override
public boolean isSmallCaps() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetSmallCaps() && isCTOnOff(pr.getSmallCaps());
}
+ @Override
public void setSmallCaps(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps();
caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
+ @Override
public boolean isCapitalized() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetCaps() && isCTOnOff(pr.getCaps());
}
+ @Override
public void setCapitalized(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff caps = pr.isSetCaps() ? pr.getCaps() : pr.addNewCaps();
caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
+ @Override
public boolean isShadowed() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetShadow() && isCTOnOff(pr.getShadow());
}
+ @Override
public void setShadow(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff shadow = pr.isSetShadow() ? pr.getShadow() : pr.addNewShadow();
shadow.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
+ @Override
public boolean isImprinted() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetImprint() && isCTOnOff(pr.getImprint());
}
+ @Override
public void setImprinted(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff imprinted = pr.isSetImprint() ? pr.getImprint() : pr.addNewImprint();
imprinted.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
+ @Override
public boolean isEmbossed() {
CTRPr pr = run.getRPr();
return pr != null && pr.isSetEmboss() && isCTOnOff(pr.getEmboss());
}
+ @Override
public void setEmbossed(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff emboss = pr.isSetEmboss() ? pr.getEmboss() : pr.addNewEmboss();
@@ -610,37 +633,46 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
ctValign.setVal(STVerticalAlignRun.Enum.forInt(valign.getValue()));
}
+ @Override
public int getKerning() {
CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetKern())
+ if (pr == null || !pr.isSetKern()) {
return 0;
+ }
return pr.getKern().getVal().intValue();
}
+ @Override
public void setKerning(int kern) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTHpsMeasure kernmes = pr.isSetKern() ? pr.getKern() : pr.addNewKern();
kernmes.setVal(BigInteger.valueOf(kern));
}
+ @Override
public boolean isHighlighted() {
CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetHighlight())
+ if (pr == null || !pr.isSetHighlight()) {
return false;
- if (pr.getHighlight().getVal() == STHighlightColor.NONE)
+ }
+ if (pr.getHighlight().getVal() == STHighlightColor.NONE) {
return false;
+ }
return true;
}
// TODO Provide a wrapper round STHighlightColor, then expose getter/setter
// for the highlight colour. Ideally also then add to CharacterRun interface
+ @Override
public int getCharacterSpacing() {
CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetSpacing())
+ if (pr == null || !pr.isSetSpacing()) {
return 0;
+ }
return pr.getSpacing().getVal().intValue();
}
+ @Override
public void setCharacterSpacing(int twips) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTSignedTwipsMeasure spc = pr.isSetSpacing() ? pr.getSpacing() : pr.addNewSpacing();
@@ -675,6 +707,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Alias for {@link #getFontFamily()}
*/
+ @Override
public String getFontName() {
return getFontFamily();
}
@@ -688,7 +721,9 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/
public String getFontFamily(FontCharRange fcr) {
CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetRFonts()) return null;
+ if (pr == null || !pr.isSetRFonts()) {
+ return null;
+ }
CTFonts fonts = pr.getRFonts();
switch (fcr == null ? FontCharRange.ascii : fcr) {
@@ -752,6 +787,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @return value representing the font size
*/
+ @Override
public int getFontSize() {
CTRPr pr = run.getRPr();
return (pr != null && pr.isSetSz()) ? pr.getSz().getVal().divide(new BigInteger("2")).intValue() : -1;
@@ -769,6 +805,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @param size The font size as number of point measurements.
*/
+ @Override
public void setFontSize(int size) {
BigInteger bint = new BigInteger("" + size);
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
@@ -1030,15 +1067,13 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* this method add chart template into document
*
- * @param width set width of chart object
- * @param height set height of chart object
* @param chartRelId relation id of chart in document relation file
* @throws InvalidFormatException
* @throws IOException
* @since POI 4.0.0
*/
@Internal
- public CTInline addChart(int width, int height, String chartRelId)
+ public CTInline addChart(String chartRelId)
throws InvalidFormatException, IOException {
try {
CTInline inline = run.addNewDrawing().addNewInline();
@@ -1069,11 +1104,6 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
//This name is not visible in Word anywhere.
docPr.setName("chart " + id);
- CTPositiveSize2D extent = inline.addNewExtent();
- //set hegiht and width of drawaing object;
- extent.setCx(width);
- extent.setCy(height);
-
return inline;
} catch (XmlException e) {
throw new IllegalStateException(e);
@@ -1095,6 +1125,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Returns the string version of the text and the phonetic string
*/
+ @Override
public String toString() {
String phonetic = getPhonetic();
if (phonetic.length() > 0) {
@@ -1108,6 +1139,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Returns the string version of the text, with tabs and
* carriage returns in place of their xml equivalents.
*/
+ @Override
public String text() {
StringBuilder text = new StringBuilder(64);