]> source.dussan.org Git - poi.git/commitdiff
Add a temporary workaround for bug #49934, while we wait for a proper xmlbeans fix
authorNick Burch <nick@apache.org>
Tue, 21 Sep 2010 11:43:36 +0000 (11:43 +0000)
committerNick Burch <nick@apache.org>
Tue, 21 Sep 2010 11:43:36 +0000 (11:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@999339 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java

index 4f9a68b2b4aa22d9ea69bcffc73dfafacd7cf3b4..c26cbf322d9ee0f8449cf58b2c64f3ea7b1574e2 100644 (file)
@@ -22,10 +22,13 @@ import java.util.List;
 
 import javax.xml.namespace.QName;
 
+import org.apache.poi.POIXMLException;
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlString;
+import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
 import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty;
@@ -94,6 +97,16 @@ public class XWPFRun {
            XmlObject[] picts = o
                  .selectPath("declare namespace pic='http://schemas.openxmlformats.org/drawingml/2006/picture' .//pic:pic");
            for(XmlObject pict : picts) {
+              if(pict instanceof XmlAnyTypeImpl) {
+                 // Pesky XmlBeans bug - see Bugzilla #49934
+                 try {
+                    pict = org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture.Factory.parse(
+                          pict.toString()
+                    );
+                 } catch(XmlException e) {
+                    throw new POIXMLException(e);
+                 }
+              }
               if(pict instanceof org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture) {
                  XWPFPicture picture = new XWPFPicture(
                        (org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture)pict, p