poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1832131 - in /poi/trunk/src/ooxml/java/org/apache/poi: xddf/usermodel/chart/XDDFChart.java xslf/usermodel/XSLFGraphicFrame.java xslf/usermodel/XSLFNotes.java xslf/usermodel/XSLFTableCell.java xslf/usermodel/XSLFTextRun.java
Date Wed, 23 May 2018 22:29:40 GMT
Author: kiwiwings
Date: Wed May 23 22:29:40 2018
New Revision: 1832131

URL: http://svn.apache.org/viewvc?rev=1832131&view=rev
Log:
sonar fixes

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java?rev=1832131&r1=1832130&r2=1832131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java Wed May 23
22:29:40 2018
@@ -74,7 +74,6 @@ import org.openxmlformats.schemas.spread
 
 @Beta
 public abstract class XDDFChart extends POIXMLDocumentPart {
-
     /**
      * Underlying workbook
      */
@@ -456,6 +455,8 @@ public abstract class XDDFChart extends
                 && chartWorkbookRelation != null
                 && chartFactory != null) {
                 worksheetPart = createWorksheetPart(chartRelation, chartWorkbookRelation,
chartFactory);
+            } else {
+                throw new InvalidFormatException("unable to determine chart relations");
             }
         }
         try (OutputStream xlsOut = worksheetPart.getOutputStream()) {
@@ -610,7 +611,8 @@ public abstract class XDDFChart extends
      * @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);
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java?rev=1832131&r1=1832130&r2=1832131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java Wed May 23
22:29:40 2018
@@ -87,7 +87,8 @@ public class XSLFGraphicFrame extends XS
 
 
     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:

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java?rev=1832131&r1=1832130&r2=1832131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java Wed May 23 22:29:40
2018
@@ -82,7 +82,8 @@ implements Notes<XSLFShape,XSLFTextParag
 
     @Override
     public XSLFTheme getTheme(){
-    	return getMasterSheet().getTheme();
+        final XSLFNotesMaster m = getMasterSheet();
+    	return (m != null) ? m.getTheme() : null;
     }
 
     @Override

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java?rev=1832131&r1=1832130&r2=1832131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java Wed May 23 22:29:40
2018
@@ -258,12 +258,19 @@ public class XSLFTableCell extends XSLFT
 
     @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();
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java?rev=1832131&r1=1832130&r2=1832131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java Wed May 23 22:29:40
2018
@@ -605,6 +605,9 @@ public class XSLFTextRun implements Text
 
         void copyFrom(FontInfo fontInfo) {
             CTTextFont tf = getXmlObject(true);
+            if (tf == null) {
+                return;
+            }
             setTypeface(fontInfo.getTypeface());
             setCharset(fontInfo.getCharset());
             FontPitch pitch = fontInfo.getPitch();
@@ -638,7 +641,10 @@ public class XSLFTextRun implements Text
         @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;
             }
             
@@ -681,6 +687,9 @@ public class XSLFTextRun implements Text
         @Override
         public void setCharset(FontCharset charset) {
             CTTextFont tf = getXmlObject(true);
+            if (tf == null) {
+                return;
+            }
             if (charset != null) {
                 tf.setCharset((byte)charset.getNativeId());
             } else {
@@ -699,7 +708,7 @@ public class XSLFTextRun implements Text
         @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())
@@ -718,7 +727,7 @@ public class XSLFTextRun implements Text
         @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())



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message