From b8ac27ed99e00ed02766618fecf56cc9c26c20f8 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 21 Sep 2010 11:43:36 +0000 Subject: [PATCH] Add a temporary workaround for bug #49934, while we wait for a proper xmlbeans fix git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@999339 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/xwpf/usermodel/XWPFRun.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 4f9a68b2b..c26cbf322 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -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