poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1831974 - in /poi/trunk/src/ooxml/java/org/apache/poi: openxml4j/opc/ xslf/usermodel/
Date Mon, 21 May 2018 14:20:11 GMT
Author: kiwiwings
Date: Mon May 21 14:20:11 2018
New Revision: 1831974

URL: http://svn.apache.org/viewvc?rev=1831974&view=rev
Log:
#62393 - Inconsistent slide import behavior depending on Mac OS X Version

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java?rev=1831974&r1=1831973&r2=1831974&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java Mon May 21 14:20:11
2018
@@ -458,7 +458,7 @@ public abstract class PackagePart implem
 	 * @see org.apache.poi.openxml4j.opc.RelationshipSource#isRelationshipExists(org.apache.poi.openxml4j.opc.PackageRelationship)
 	 */
 	public boolean isRelationshipExists(PackageRelationship rel) {
-		return _relationships.getRelationshipByID(rel.getId()) != null;
+		return rel != null && _relationships.getRelationshipByID(rel.getId()) != null;
 	}
 
    /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java?rev=1831974&r1=1831973&r2=1831974&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
Mon May 21 14:20:11 2018
@@ -193,6 +193,9 @@ public final class PackageRelationshipCo
      *            The relationship to add.
      */
     public void addRelationship(PackageRelationship relPart) {
+        if (relPart == null || relPart.getId() == null || relPart.getId().isEmpty()) {
+            throw new IllegalArgumentException("invalid relationship part/id");
+        }
         relationshipsByID.put(relPart.getId(), relPart);
         relationshipsByType.put(relPart.getRelationshipType(), relPart);
     }
@@ -227,8 +230,7 @@ public final class PackageRelationshipCo
 
         PackageRelationship rel = new PackageRelationship(container,
                 sourcePart, targetUri, targetMode, relationshipType, id);
-        relationshipsByID.put(rel.getId(), rel);
-        relationshipsByType.put(rel.getRelationshipType(), rel);
+        addRelationship(rel);
         if (targetMode == TargetMode.INTERNAL){
             internalRelationshipsByTargetName.put(targetUri.toASCIIString(), rel);
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java?rev=1831974&r1=1831973&r2=1831974&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java Mon May 21 14:20:11
2018
@@ -50,14 +50,18 @@ public class XSLFHyperlink implements Hy
 
     @Override
     public String getAddress() {
-        String id = _link.getId();
+        final String id = _link.getId();
         if (id == null || id.isEmpty()) {
             return _link.getAction();
         }
 
-        URI targetURI = _sheet.getPackagePart().getRelationship(id).getTargetURI();
-        
-        return targetURI.toASCIIString();
+        final PackageRelationship rel = _sheet.getPackagePart().getRelationship(id);
+        if (rel == null) {
+            return null;
+        }
+
+        final URI targetURI = rel.getTargetURI();
+        return (targetURI == null) ? null : targetURI.toASCIIString();
     }
 
     @Override

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java?rev=1831974&r1=1831973&r2=1831974&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java Mon May 21
14:20:11 2018
@@ -30,6 +30,8 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.sl.usermodel.PictureShape;
 import org.apache.poi.sl.usermodel.Placeholder;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -52,6 +54,8 @@ import org.openxmlformats.schemas.presen
 @Beta
 public class XSLFPictureShape extends XSLFSimpleShape
     implements PictureShape<XSLFShape,XSLFTextParagraph> {
+    private static final POILogger LOG = POILogFactory.getLogger(XSLFPictureShape.class);
+
     private XSLFPictureData _data;
 
     /*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) {
@@ -201,6 +205,11 @@ public class XSLFPictureShape extends XS
 
         XSLFPictureShape p = (XSLFPictureShape)sh;
         String blipId = p.getBlipId();
+        if (blipId == null) {
+            LOG.log(POILogger.WARN, "unable to copy invalid picture shape");
+            return;
+        }
+
         String relId = getSheet().importBlip(blipId, p.getSheet().getPackagePart());
 
         CTPicture ct = (CTPicture)getXmlObject();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1831974&r1=1831973&r2=1831974&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Mon May 21 14:20:11
2018
@@ -658,7 +658,7 @@ implements XSLFShapeContainer, Sheet<XSL
         PackagePart blipPart;
         try {
             blipPart = packagePart.getRelatedPart(blipRel);
-        } catch (InvalidFormatException e){
+        } catch (Exception e){
             throw new POIXMLException(e);
         }
         XSLFPictureData data = new XSLFPictureData(blipPart);

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=1831974&r1=1831973&r2=1831974&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 Mon May 21 14:20:11
2018
@@ -30,6 +30,8 @@ import org.apache.poi.sl.usermodel.Paint
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
 import org.apache.poi.sl.usermodel.TextRun;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.xslf.model.CharacterPropertyFetcher;
 import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;
 import org.apache.xmlbeans.XmlObject;
@@ -40,6 +42,7 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
@@ -54,6 +57,8 @@ import org.openxmlformats.schemas.drawin
  */
 @Beta
 public class XSLFTextRun implements TextRun {
+    private static final POILogger LOG = POILogFactory.getLogger(XSLFTextRun.class);
+
     private final XmlObject _r;
     private final XSLFTextParagraph _p;
 
@@ -107,7 +112,8 @@ public class XSLFTextRun implements Text
     @Override
     public void setFontColor(PaintStyle color) {
         if (!(color instanceof SolidPaint)) {
-            throw new IllegalArgumentException("Currently only SolidPaint is supported!");
+            LOG.log(POILogger.WARN, "Currently only SolidPaint is supported!");
+            return;
         }
         SolidPaint sp = (SolidPaint)color;
         Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
@@ -173,12 +179,18 @@ public class XSLFTextRun implements Text
     @Override
     public Double getFontSize(){
         double scale = 1;
-        CTTextNormalAutofit afit = getParentParagraph().getParentShape().getTextBodyPr().getNormAutofit();
-        if(afit != null) {
-            scale = (double)afit.getFontScale() / 100000;
+        final XSLFTextShape ps = getParentParagraph().getParentShape();
+        if (ps != null) {
+            final CTTextBodyProperties tbp = ps.getTextBodyPr();
+            if (tbp != null) {
+                CTTextNormalAutofit afit = tbp.getNormAutofit();
+                if (afit != null && afit.isSetFontScale()) {
+                    scale = afit.getFontScale() / 100000.;
+                }
+            }
         }
 
-        CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
+        final CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
             @Override
             public boolean fetch(CTTextCharacterProperties props){
                 if (props != null && props.isSetSz()) {



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


Mime
View raw message