@Beta
public abstract class XDDFChart extends POIXMLDocumentPart {
-
/**
* Underlying workbook
*/
&& chartWorkbookRelation != null
&& chartFactory != null) {
worksheetPart = createWorksheetPart(chartRelation, chartWorkbookRelation, chartFactory);
+ } else {
+ throw new InvalidFormatException("unable to determine chart relations");
}
}
try (OutputStream xlsOut = worksheetPart.getOutputStream()) {
* @since POI 4.0.0
*/
public String formatRange(CellRangeAddress range) {
- return range.formatAsString(getSheet().getSheetName(), true);
+ final XSSFSheet sheet = getSheet();
+ return (sheet == null) ? null : range.formatAsString(sheet.getSheetName(), true);
}
/**
static XSLFGraphicFrame create(CTGraphicalObjectFrame shape, XSLFSheet sheet){
- switch (getUri(shape)) {
+ final String uri = getUri(shape);
+ switch (uri == null ? "" : uri) {
case XSLFTable.TABLE_URI:
return new XSLFTable(shape, sheet);
case XSLFObjectShape.OLE_URI:
@Override
public XSLFTheme getTheme(){
- return getMasterSheet().getTheme();
+ final XSLFNotesMaster m = getMasterSheet();
+ return (m != null) ? m.getTheme() : null;
}
@Override
@Override
public void setBorderWidth(BorderEdge edge, double width) {
- CTLineProperties ln = getCTLine(edge, true);
+ final CTLineProperties ln = getCTLine(edge, true);
+ if (ln == null) {
+ return;
+ }
ln.setW(Units.toEMU(width));
}
private CTLineProperties setBorderDefaults(BorderEdge edge) {
- CTLineProperties ln = getCTLine(edge, true);
+ final CTLineProperties ln = getCTLine(edge, true);
+ if (ln == null) {
+ return null;
+ }
+
if (ln.isSetNoFill()) {
ln.unsetNoFill();
}
void copyFrom(FontInfo fontInfo) {
CTTextFont tf = getXmlObject(true);
+ if (tf == null) {
+ return;
+ }
setTypeface(fontInfo.getTypeface());
setCharset(fontInfo.getCharset());
FontPitch pitch = fontInfo.getPitch();
@Override
public void setTypeface(String typeface) {
if (typeface != null) {
- getXmlObject(true).setTypeface(typeface);
+ final CTTextFont tf = getXmlObject(true);
+ if (tf != null) {
+ tf.setTypeface(typeface);
+ }
return;
}
@Override
public void setCharset(FontCharset charset) {
CTTextFont tf = getXmlObject(true);
+ if (tf == null) {
+ return;
+ }
if (charset != null) {
tf.setCharset((byte)charset.getNativeId());
} else {
@Override
public void setFamily(FontFamily family) {
CTTextFont tf = getXmlObject(true);
- if (family == null && !tf.isSetPitchFamily()) {
+ if (tf == null || (family == null && !tf.isSetPitchFamily())) {
return;
}
FontPitch pitch = (tf.isSetPitchFamily())
@Override
public void setPitch(FontPitch pitch) {
CTTextFont tf = getXmlObject(true);
- if (pitch == null && !tf.isSetPitchFamily()) {
+ if (tf == null || (pitch == null && !tf.isSetPitchFamily())) {
return;
}
FontFamily family = (tf.isSetPitchFamily())