]> source.dussan.org Git - poi.git/commitdiff
XSLFCommonSlideData: Workaround for XmlBeans bug#49934
authorMaxim Valyanskiy <maxcom@apache.org>
Fri, 1 Jul 2011 12:21:05 +0000 (12:21 +0000)
committerMaxim Valyanskiy <maxcom@apache.org>
Fri, 1 Jul 2011 12:21:05 +0000 (12:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1141915 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java

index 3716f7e93dc27b7ef75fb401ed50b8bfea90a031..22cde4f9b06fdec7e582dcdc0b2666ad8ac98962 100644 (file)
 
 package org.apache.poi.xslf.usermodel;
 
+import org.apache.poi.POIXMLException;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
@@ -52,11 +55,20 @@ public class XSLFCommonSlideData {
         for (CTGraphicalObjectFrame frame: gs.getGraphicFrameList()) {
             CTGraphicalObjectData data = frame.getGraphic().getGraphicData();
             XmlCursor c = data.newCursor();
-            c.selectPath("./*");
+            c.selectPath("declare namespace pic='"+CTTable.type.getName().getNamespaceURI()+"' .//pic:tbl");
 
             while (c.toNextSelection()) {
                 XmlObject o = c.getObject();
 
+                if (o instanceof XmlAnyTypeImpl) {
+                    // Pesky XmlBeans bug - see Bugzilla #49934
+                    try {
+                        o = CTTable.Factory.parse(o.toString());
+                    } catch (XmlException e) {
+                        throw new POIXMLException(e);
+                    }
+                }
+
                 if (o instanceof CTTable) {
                     DrawingTable table = new DrawingTable((CTTable) o);