]> source.dussan.org Git - poi.git/commitdiff
#58617 - Add custom safe XmlBeans type loader / rename vendor specific schema packages
authorAndreas Beeker <kiwiwings@apache.org>
Sat, 21 Nov 2015 19:37:26 +0000 (19:37 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sat, 21 Nov 2015 19:37:26 +0000 (19:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1715555 13f79535-47bb-0310-9956-ffa450edef68

66 files changed:
.project
build.xml
sonar/ooxml-schema-encryption/pom.xml
sonar/ooxml-schema-security/pom.xml
sonar/ooxml-schema/pom.xml
sonar/pom.xml
src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java
src/ooxml/java/org/apache/poi/POIXMLProperties.java
src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/Office2010SignatureFacet.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java
src/ooxml/java/org/apache/poi/util/XmlSort.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java
src/ooxml/java/org/apache/poi/xssf/dev/XSSFDump.java
src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java
src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java
src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java
src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java
src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCache.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheRecords.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java
src/ooxml/resources/org/apache/poi/schemas/ooxmlSchemas.xsdconfig [new file with mode: 0644]
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFVMLDrawing.java

index 40d6466b2816a288c352e7e04eca31cb82c2a8d3..274051f30a2f52337a304b42d9ca2c21a980fe7b 100644 (file)
--- a/.project
+++ b/.project
@@ -12,6 +12,7 @@
                </buildCommand>
        </buildSpec>
        <natures>
+               <nature>org.sonar.ide.eclipse.core.sonarNature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
 </projectDescription>
index 5756ffb568292e3948f6c5a863cc411108f22711..9ba80ef04a267a840354dda8c9da6f7329200cd2 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -206,8 +206,8 @@ under the License.
     <property name="ooxml.xsds.url.1"
               value="http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%204%20(PDF).zip"/>
     <property name="ooxml.xsds.src.dir" location="build/ooxml-xsds-src"/>
-    <property name="ooxml.xsds.src.jar" location="${ooxml.lib}/ooxml-schemas-1.2-sources.jar"/>
-    <property name="ooxml.xsds.jar" location="${ooxml.lib}/ooxml-schemas-1.2.jar"/>
+    <property name="ooxml.xsds.src.jar" location="${ooxml.lib}/ooxml-schemas-1.3-sources.jar"/>
+    <property name="ooxml.xsds.jar" location="${ooxml.lib}/ooxml-schemas-1.3.jar"/>
 
     <!-- additional schemas are packed into the poi schemas jar, -->
     <!-- so we don't have to care about a seperate versioning of the original ooxml schemas -->
@@ -226,6 +226,8 @@ under the License.
     <property name="ooxml.security.jar" location="${ooxml.lib}/ooxml-security-1.0.jar"/>
     <property name="ooxml.security.xsd.dir" location="src/ooxml/resources/org/apache/poi/poifs/crypt"/>
     <property name="ooxml.visio.xsd.dir" location="src/ooxml/resources/org/apache/poi/xdgf"/>
+    <property name="ooxml.schema.xsdconfig.dir" location="src/ooxml/resources/org/apache/poi/schemas"/>
+
 
     <property name="maven.ooxml.xsds.version.id" value="1.0"/>
     <property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/>
@@ -657,77 +659,108 @@ under the License.
             </or>
         </condition>
     </target>
+
+    <macrodef name="compile-ooxml-xmlbean">
+        <attribute name="classes-jar"/>
+        <attribute name="sources-jar"/>
+        <attribute name="noupa" default="false"/>
+        <attribute name="nopvr" default="false"/>
+        <element name="xsds"/>
+        <sequential>
+            <!-- We need a fair amount of memory to compile the xml schema, -->
+            <!-- but limit it in case it goes wrong! -->
+            <!-- Pick the right amount based on 32 vs 64 bit jvm -->
+            <condition property="ooxml.memory" value="768m" else="512m">
+               <equals arg1="${sun.arch.data.model}" arg2="64" />
+            </condition>
+
+            <taskdef name="xmlbean"
+                     classname="org.apache.xmlbeans.impl.tool.XMLBean"
+                     classpath="${ooxml.xmlbeans23.jar}"/>
+
+            <property name="xmlbean.xsds.dir" location="build/xmlbean-xsds"/>
+            <property name="xmlbean.sources.dir" location="build/xmlbean-sources"/>
+            <property name="xmlbean.classes.dir" location="build/xmlbean-classes"/>
+            <delete dir="${xmlbean.xsds.dir}"/>
+            <mkdir dir="${xmlbean.xsds.dir}"/>
+            <delete dir="${xmlbean.sources.dir}"/>
+            <mkdir dir="${xmlbean.sources.dir}"/>
+            <delete dir="${xmlbean.classes.dir}"/>
+            <mkdir dir="${xmlbean.classes.dir}"/>
+
+            <copy todir="${xmlbean.xsds.dir}">
+                <xsds/>
+            </copy>
+
+            <!-- javasource > 1.5 will not generate all array accessor -->
+            <xmlbean
+                    schema="${xmlbean.xsds.dir}"
+                    srcgendir="${xmlbean.sources.dir}"
+                    classgendir="${xmlbean.classes.dir}"
+                    destfile="${xmlbean.xsds.dir}.jar"
+                    srconly="true"
+                    javasource="1.5"
+                    failonerror="true"
+                    fork="true"
+                    memoryMaximumSize="${ooxml.memory}"
+                    noupa="@{noupa}"
+                    nopvr="@{nopvr}"
+                    >
+                <classpath refid="ooxml.classpath"/>
+            </xmlbean>
+
+            <replace dir="${xmlbean.sources.dir}" includes="**/*.java" excludes="**/impl/**">
+                <replacetoken>org.apache.xmlbeans.XmlBeans.getContextTypeLoader()</replacetoken>
+                <replacevalue>org.apache.poi.POIXMLTypeLoader</replacevalue>
+            </replace>
+
+            <copy todir="${xmlbean.sources.dir}">
+                <fileset dir="src/ooxml/java" includes="org/apache/poi/POIXMLTypeLoader.java"/>
+            </copy>
+
+            <javac target="${jdk.version.class}"
+                   source="${jdk.version.source}"
+                   srcdir="${xmlbean.sources.dir}"
+                   destdir="${xmlbean.classes.dir}"
+                   encoding="${java.source.encoding}"
+                   fork="yes"
+                   optimize="true"
+                   memoryMaximumSize="${ooxml.memory}"
+                   includeantruntime="false">
+                   <!-- debug="${compile.debug}" -->
+                <classpath refid="ooxml.classpath"/>
+            </javac>
+
+            <jar basedir="${xmlbean.classes.dir}" destfile="@{classes-jar}" excludes="org/apache/**" level="9" />
+            <jar basedir="${xmlbean.sources.dir}" destfile="@{sources-jar}" excludes="org/apache/**" level="9" />
+
+            <delete file="${xmlbean.xsds.dir}.jar"/>
+            <delete dir="${xmlbean.xsds.dir}"/>
+            <delete dir="${xmlbean.sources.dir}"/>
+            <delete dir="${xmlbean.classes.dir}"/>
+        </sequential>
+    </macrodef>
+
     <target name="compile-ooxml-xsds" unless="ooxml-compiled-xsds.present"
         depends="init,check-compiled-ooxml-xsds"
         description="Unpacks the OOXML xsd files, and compiles them into XmlBeans">
-        <taskdef name="xmlbean"
-                 classname="org.apache.xmlbeans.impl.tool.XMLBean"
-                 classpath="${ooxml.xmlbeans23.jar}"/>
-
-        <!-- We need a fair amount of memory to compile the xml schema, -->
-        <!--  but limit it in case it goes wrong! -->
-        <!-- Pick the right amount based on 32 vs 64 bit jvm -->
-        <condition property="ooxml.memory" value="768m" else="512m">
-           <equals arg1="${sun.arch.data.model}" arg2="64" />
-        </condition>
-
-        <property name="ooxml.xsds.tmp.dir" location="build/ooxml-xsds"/>
-        <mkdir dir="${ooxml.xsds.tmp.dir}"/>
-        <unzip src="${ooxml.lib}/${ooxml.xsds.izip.1}" dest="${ooxml.xsds.tmp.dir}"/>
-        <copy todir="${ooxml.xsds.tmp.dir}">
-            <fileset dir="${ooxml.visio.xsd.dir}"/>
-        </copy>
-        <xmlbean
-                schema="${ooxml.xsds.tmp.dir}"
-                srcgendir="${ooxml.xsds.src.dir}"
-                optimize="yes"
-                destfile="${ooxml.xsds.jar}"
-                javasource="1.5"
-                failonerror="true"
-                fork="true"
-                memoryMaximumSize="${ooxml.memory}"
-                >
-            <classpath refid="ooxml.classpath"/>
-        </xmlbean>
-
-        <!-- Now make a jar of the schema sources -->
-        <jar
-                basedir="${ooxml.xsds.src.dir}"
-                destfile="${ooxml.xsds.src.jar}"
-                />
-
+        <compile-ooxml-xmlbean classes-jar="${ooxml.xsds.jar}" sources-jar="${ooxml.xsds.src.jar}">
+            <xsds>
+                <zipfileset src="${ooxml.lib}/${ooxml.xsds.izip.1}"/>
+                <fileset dir="${ooxml.visio.xsd.dir}"/>
+                <fileset dir="${ooxml.schema.xsdconfig.dir}"/>
+            </xsds>
+        </compile-ooxml-xmlbean>
         <!-- Now do the same for the security schemas -->
-        <property name="ooxml.enc.xsds.tmp.dir" location="build/ooxml-security-xsds"/>
-        <mkdir dir="${ooxml.enc.xsds.tmp.dir}"/>
-        <unzip src="${ooxml.lib}/${ooxml.xsds.izip.2}" dest="${ooxml.enc.xsds.tmp.dir}"/>
-
-        <copy todir="${ooxml.enc.xsds.tmp.dir}">
-            <fileset dir="${ooxml.lib}" includes="dc*.xsd,xmldsig*.xsd,XAdES*.xsd"/>
-            <fileset dir="${ooxml.security.xsd.dir}"/>
-        </copy>
-
         <!-- noupa/nopvr is set because of the dublincore schemas -->
         <!-- https://issues.apache.org/jira/browse/XMLBEANS-340 -->
-        <!-- javasource > 1.5 will not generate all array accessor -->
-        <xmlbean
-                schema="${ooxml.enc.xsds.tmp.dir}"
-                srcgendir="${ooxml.security.src.dir}"
-                optimize="yes"
-                destfile="${ooxml.security.jar}"
-                javasource="1.5"
-                failonerror="true"
-                fork="true"
-                memoryMaximumSize="${ooxml.memory}"
-                noupa="true"
-                nopvr="true"
-                >
-            <classpath refid="ooxml.classpath"/>
-        </xmlbean>
-
-        <jar
-                basedir="${ooxml.security.src.dir}"
-                destfile="${ooxml.security.src.jar}"
-                />
+        <compile-ooxml-xmlbean classes-jar="${ooxml.security.jar}" sources-jar="${ooxml.security.src.jar}" noupa="true" nopvr="true">
+            <xsds>
+                <zipfileset src="${ooxml.lib}/${ooxml.xsds.izip.2}"/>
+                <fileset dir="${ooxml.lib}" includes="dc*.xsd,xmldsig*.xsd,XAdES*.xsd"/>
+                <fileset dir="${ooxml.security.xsd.dir}"/>
+            </xsds>
+        </compile-ooxml-xmlbean>
     </target>
 
     <target name="compile" depends="init, compile-main,
index 3c2118f35d95efdbec00104aba06bac650770fcd..dec7da0a41c7e89a7e047778988ab4beebf9e883 100644 (file)
@@ -7,11 +7,12 @@
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
         <version>3.14-beta1-SNAPSHOT</version>
+        <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema-encryption</artifactId>
     <packaging>jar</packaging>
 
-    <name>Apach POI - Openxmlformats Encryption Schema package</name>
+    <name>Apache POI - Openxmlformats Encryption Schema package</name>
 
        <properties>
                <!-- see http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus for details of this property -->
        <build>
                <plugins>
                        <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>xmlbeans-maven-plugin</artifactId>
-                               <version>2.3.3</version>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-antrun-plugin</artifactId>
+                               <version>1.6</version>
                                <executions>
                                        <execution>
+                                               <id>unzip-schema</id>
                                                <phase>generate-sources</phase>
                                                <goals>
-                                                       <goal>xmlbeans</goal>
+                                                       <goal>run</goal>
                                                </goals>
+                                               <configuration>
+                                                       <target>
+                                                               <copy todir="target/schemas">
+                                                                       <fileset dir="../../src/ooxml/resources/org/apache/poi/poifs/crypt" includes="encryption*.*"/>
+                                                               </copy>
+                                                       </target>
+                                               </configuration>
                                        </execution>
                                </executions>
-                               <configuration>
-                                       <schemaDirectory>../../src/ooxml/resources/org/apache/poi/poifs/crypt</schemaDirectory>
-                                       <sourceSchemas>
-                                               <sourceSchema>encryptionInfo.xsd</sourceSchema>
-                                       </sourceSchemas>
-                                       <xmlConfigs>
-                                               <xmlConfig implementation="java.io.File">../../src/ooxml/resources/org/apache/poi/poifs/crypt/encryptionInfo.xsdconfig</xmlConfig>
-                                       </xmlConfigs>
-                                       <javaSource>1.5</javaSource>
-                                       <optimize>yes</optimize>
-                               </configuration>
                        </plugin>
                </plugins>
        </build>
index c947a1641195ab6c5d61f8d7c22941ed348a3f8b..4a9d0993bbd09029793b730317e63fac0b8d46b0 100644 (file)
@@ -7,18 +7,20 @@
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
         <version>3.14-beta1-SNAPSHOT</version>
+        <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema-security</artifactId>
     <packaging>jar</packaging>
 
-    <name>Apach POI - Openxmlformats Security-Schema package</name>
+    <name>Apache POI - Openxmlformats Security-Schema package</name>
 
        <properties>
                <!-- see http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus for details of this property -->
                <sonar.exclusions>target/generated-sources/*</sonar.exclusions>
                <maven.compiler.fork>true</maven.compiler.fork>
+               <xmlbeans.noUpa>true</xmlbeans.noUpa>
+               <xmlbeans.noPvr>true</xmlbeans.noPvr>
        </properties>
-  
     <build>
                <plugins>
                        <!-- Download and unpack the OfficeOpenXML Schema and use xmlbeans to create classes from the XSDs -->
                                        <execution>
                                                <id>unzip-schema</id>
                                                <phase>generate-sources</phase>
+                                               <goals>
+                                                       <goal>run</goal>
+                                               </goals>
                                                <configuration>
                                                        <target>
                                                                <echo message="unzip schemas" />
                                                                        todir="target/schemas"/>
                                                        </target>
                                                </configuration>
-                                               <goals>
-                                                       <goal>run</goal>
-                                               </goals>
                                        </execution>
                                </executions>
                        </plugin>
 
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>xmlbeans-maven-plugin</artifactId>
-                               <version>2.3.3</version>
-                               <executions>
-                                       <execution>
-                                               <phase>generate-sources</phase>
-                                               <goals>
-                                                       <goal>xmlbeans</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                               <configuration>
-                                       <schemaDirectory>target/schemas</schemaDirectory>
-                                       <noUpa>true</noUpa>
-                                       <noPvr>true</noPvr>
-                                       <noJavac>true</noJavac>
-                                       <javaSource>1.5</javaSource>
-                                       <optimize>yes</optimize>
-                               </configuration>
-                       </plugin>
                </plugins>
     </build>
 
index a40fb9a2acf23ed08d698505ecf1404d9af9f76c..3d234e02cc15a9ea4f1d3757aaad9d513cc4cba9 100644 (file)
@@ -7,50 +7,20 @@
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
         <version>3.14-beta1-SNAPSHOT</version>
+        <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema</artifactId>
     <packaging>jar</packaging>
 
-    <name>Apach POI - Openxmlformats Schema package</name>
+    <name>Apache POI - Openxmlformats Schema package</name>
 
        <properties>
                <!-- see http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus for details of this property -->
                <sonar.exclusions>target/generated-sources/*</sonar.exclusions>
                <maven.compiler.fork>true</maven.compiler.fork>
+               <xmlbeans.xsdconfig>${basedir}/../../src/ooxml/resources/org/apache/poi/schemas/ooxmlSchemas.xsdconfig</xmlbeans.xsdconfig>
        </properties>
 
-       <profiles>
-        <!-- We need a fair amount of memory to compile the xml schema, -->
-        <!-- but limit it in case it goes wrong!                        -->
-        <!-- Pick the right amount based on 32 vs 64 bit jvm            -->
-
-               <profile>
-                       <id>32bitstuff</id>
-                       <activation>
-                               <property>
-                                       <name>sun.arch.data.model</name>
-                                       <value>32</value>
-                               </property>
-                       </activation>
-                       <properties>
-                               <maven.compiler.maxmem>512m</maven.compiler.maxmem>
-                       </properties>
-               </profile>
-               
-               <profile>
-                       <id>64bitstuff</id>
-                       <activation>
-                               <property>
-                                       <name>sun.arch.data.model</name>
-                                       <value>64</value>
-                               </property>
-                       </activation>
-                       <properties>
-                               <maven.compiler.maxmem>768m</maven.compiler.maxmem>
-                       </properties>
-               </profile>
-       </profiles>
-  
     <build>
                <plugins>
                        <!-- Download and unpack the OfficeOpenXML Schema and use xmlbeans to create classes from the XSDs -->
@@ -60,7 +30,7 @@
                                <version>1.1.0</version>
                                <executions>
                                        <execution>
-                                               <id>install-xsds-part-4</id>
+                                               <id>download-xsds</id>
                                                <phase>generate-sources</phase>
                                                <goals>
                                                        <goal>wget</goal>
@@ -85,7 +55,9 @@
                                                <configuration>
                                                        <target>
                                                                <echo message="unzip schemas" />
-                                                               <unzip src="target/OfficeOpenXML-XMLSchema.zip" dest="target/schemas/" />
+                                                               <unzip src="target/OfficeOpenXML-XMLSchema.zip" dest="target/schemas" />
+                                                               <copy file="../../src/ooxml/resources/org/apache/poi/xdgf/visio.xsd"
+                                                                       todir="target/schemas"/>
                                                        </target>
                                                </configuration>
                                                <goals>
                                        </execution>
                                </executions>
                        </plugin>
-      
-      <!-- include the visio schema -->
-                       <plugin>
-                               <artifactId>maven-resources-plugin</artifactId>
-                               <version>2.6</version>
-                               <executions>
-                                       <execution>
-                                               <id>copy-sources</id>
-                                               <phase>generate-sources</phase>
-                                               <goals>
-                                                       <goal>copy-resources</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <outputDirectory>target/schemas/</outputDirectory>
-                                                       <resources>
-                                                               <resource>
-                                                                       <directory>../../src/ooxml/resources/org/apache/poi/xdgf/</directory>
-                                                               </resource>
-                                                       </resources>
-                                               </configuration>
-                                       </execution>
-                               </executions>
-                       </plugin>
-                       
-                       <plugin>
-                         <groupId>org.codehaus.mojo</groupId>
-                         <artifactId>xmlbeans-maven-plugin</artifactId>
-                         <version>2.3.3</version>
-                         <executions>
-                                <execution>
-                                       <phase>generate-sources</phase>
-                                       <goals>
-                                         <goal>xmlbeans</goal>
-                                       </goals>
-                                </execution>
-                         </executions>
-                               <configuration>
-                                       <schemaDirectory>target/schemas</schemaDirectory>
-                                       <javaSource>1.5</javaSource>
-                                       <optimize>yes</optimize>
-                                       <noJavac>true</noJavac>
-                               </configuration>
-                       </plugin>
                </plugins>
     </build>
 
             <artifactId>poi-scratchpad</artifactId>
             <version>${project.version}</version>
         </dependency>
-        
-               <dependency>
-                 <groupId>org.apache.xmlbeans</groupId>
-                 <artifactId>xmlbeans</artifactId>
-                 <version>2.6.0</version>
-               </dependency>
+        <dependency>
+          <groupId>org.apache.xmlbeans</groupId>
+          <artifactId>xmlbeans</artifactId>
+          <version>2.6.0</version>
+        </dependency>
     </dependencies>
 </project>
index f17c0655afa02f9b448420a4b2fa74919ffc1924..fe10ac3b0149f5743f061e2d17ff871e2cc1f153 100644 (file)
@@ -1,58 +1,52 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                             http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>org.apache.poi</groupId>
-    <artifactId>poi-parent</artifactId>
-    <packaging>pom</packaging>
-    <version>3.14-beta1-SNAPSHOT</version>
-
-    <name>Apache POI - the Java API for Microsoft Documents</name>
-
-    <description>Maven build of Apache POI for Sonar checks</description>
-    <url>http://poi.apache.org/</url>
-
-  <mailingLists>
-    <mailingList>
-      <name>POI Users List</name>
-      <subscribe>user-subscribe@poi.apache.org</subscribe>
-      <unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
-      <archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
-    </mailingList>
-    <mailingList>
-      <name>POI Developer List</name>
-      <subscribe>dev-subscribe@poi.apache.org</subscribe>
-      <unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
-      <archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
-    </mailingList>
-  </mailingLists>
-
-  <licenses>
-    <license>
-      <name>The Apache Software License, Version 2.0</name>
-      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-    </license>
-  </licenses>
-
-  <organization>
-    <name>Apache Software Foundation</name>
-    <url>http://www.apache.org/</url>
-  </organization>
-
-       <issueManagement>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>org.apache.poi</groupId>
+       <artifactId>poi-parent</artifactId>
+       <packaging>pom</packaging>
+       <version>3.14-beta1-SNAPSHOT</version>
+       <name>Apache POI - the Java API for Microsoft Documents</name>
+       <description>Maven build of Apache POI for Sonar checks</description>
+       <url>http://poi.apache.org/</url>
+       
+       <mailingLists>
+               <mailingList>
+                       <name>POI Users List</name>
+                       <subscribe>user-subscribe@poi.apache.org</subscribe>
+                       <unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
+                       <archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
+               </mailingList>
+               <mailingList>
+                       <name>POI Developer List</name>
+                       <subscribe>dev-subscribe@poi.apache.org</subscribe>
+                       <unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
+                       <archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
+               </mailingList>
+       </mailingLists>
+       
+       <licenses>
+               <license>
+                       <name>The Apache Software License, Version 2.0</name>
+                       <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+               </license>
+       </licenses>
+       
+       <organization>
+               <name>Apache Software Foundation</name>
+               <url>http://www.apache.org/</url>
+       </organization>
+       
+       <issueManagement>
                <system>bugzilla</system>
                <url>https://issues.apache.org/bugzilla/</url>
        </issueManagement>
-
-       <scm>
+       
+       <scm>
                <connection>scm:svn:http://svn.apache.org/repos/asf/poi/trunk</connection>
                <developerConnection>scm:svn:https://svn.apache.org/repos/asf/poi/trunk</developerConnection>
                <url>http://svn.apache.org/viewvc/poi</url>
-       </scm>
-
-    <modules>
+       </scm>
+       
+       <modules>
                <module>main</module>
                <module>ooxml-schema</module>
                <module>ooxml-schema-encryption</module>
                <module>ooxml</module>
                <module>scratchpad</module>
                <module>excelant</module>
-        <module>examples</module>
-    </modules>
-
+               <module>examples</module>
+       </modules>
+       
        <properties>
                <project.build.sourceEncoding>ASCII</project.build.sourceEncoding>
-               
                <!-- Try to disable running SVN blame as it causes errors here because the source is copied from the actual SVN location here! -->
                <sonar.scm.disabled>true</sonar.scm.disabled>
        </properties>
-  
-    <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-compiler-plugin</artifactId>
-                    <version>3.1</version>
-                    <configuration>
-                        <source>1.6</source>
-                        <target>1.6</target>
-                    </configuration>
-                </plugin>
-            </plugins>
-        </pluginManagement>
-
+       
+       <build>
+               <pluginManagement>
+                       <plugins>
+                               <plugin>
+                                       <groupId>org.apache.maven.plugins</groupId>
+                                       <artifactId>maven-compiler-plugin</artifactId>
+                                       <version>3.1</version>
+                                       <configuration>
+                                               <source>1.6</source>
+                                               <target>1.6</target>
+                                       </configuration>
+                               </plugin>
+                       </plugins>
+               </pluginManagement>
                <plugins>
-                 <plugin>
-                       <groupId>org.apache.maven.plugins</groupId>
-                       <artifactId>maven-surefire-plugin</artifactId>
-                       <version>2.16</version>
-                       <dependencies>
-                               <dependency>
-                                       <groupId>org.apache.maven.surefire</groupId>
-                                       <artifactId>surefire-junit47</artifactId>
-                                       <version>2.16</version>
-                               </dependency>
-                       </dependencies>
-                       
-                       <configuration>
-                               <systemPropertyVariables>
-                                       <POI.testdata.path>../../test-data</POI.testdata.path>
-                                       <java.awt.headless>true</java.awt.headless>
-                                       <org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
-                               </systemPropertyVariables>
-                               <!-- use to following to analyze OOM issues:  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -->
-                               <argLine>-Duser.language=en -Duser.country=US -Xmx1024m</argLine>
-                               <excludes>
-                                       <exclude>**/All*Tests.java</exclude>
-                                       <exclude>**/TestUnfixedBugs.java</exclude>
-                                       <exclude>**/TestcaseRecordInputStream.java</exclude>
-                                       <exclude>**/POITestCase.java</exclude>
-                                       
-                                       <!-- TODO: error about no public construct, seems to run with JUnit 3.8... -->
-                                       <exclude>**/TestWordToConverterSuite*.java</exclude>
-                                       <exclude>**/TestExcelConverterSuite*.java</exclude>
-                               </excludes>
-                               <!--test>TestPPTX2PNG</test-->
-                               <!--parallel>both</parallel>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <version>2.16</version>
+                               <dependencies>
+                                       <dependency>
+                                               <groupId>org.apache.maven.surefire</groupId>
+                                               <artifactId>surefire-junit47</artifactId>
+                                               <version>2.16</version>
+                                       </dependency>
+                               </dependencies>
+                               <configuration>
+                                       <systemPropertyVariables>
+                                               <POI.testdata.path>../../test-data</POI.testdata.path>
+                                               <java.awt.headless>true</java.awt.headless>
+                                               <org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
+                                       </systemPropertyVariables>
+                                       <!-- use to following to analyze OOM issues:    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -->
+                                       <argLine>-Duser.language=en -Duser.country=US -Xmx1024m</argLine>
+                                       <excludes>
+                                               <exclude>**/All*Tests.java</exclude>
+                                               <exclude>**/TestUnfixedBugs.java</exclude>
+                                               <exclude>**/TestcaseRecordInputStream.java</exclude>
+                                               <exclude>**/POITestCase.java</exclude>
+                                               <!-- TODO: error about no public construct, seems to run with JUnit 3.8... -->
+                                               <exclude>**/TestWordToConverterSuite*.java</exclude>
+                                               <exclude>**/TestExcelConverterSuite*.java</exclude>
+                                       </excludes>
+                                       <!--test>TestPPTX2PNG</test-->
+                                       <!--parallel>both</parallel>
                                <threadCount>10</threadCount-->
-                       </configuration>
-                 </plugin>                 
-                </plugins>
-    </build>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       
+       <dependencies>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+
+       <profiles>
+               <!-- We need a fair amount of memory to compile the xml schema, -->
+               <!-- but limit it in case it goes wrong!                        -->
+               <!-- Pick the right amount based on 32 vs 64 bit jvm            -->
+               <profile>
+                       <id>32bitstuff</id>
+                       <activation>
+                               <property>
+                                       <name>sun.arch.data.model</name>
+                                       <value>32</value>
+                               </property>
+                       </activation>
+                       <properties>
+                               <maven.compiler.maxmem>512m</maven.compiler.maxmem>
+                       </properties>
+               </profile>
+               
+               <profile>
+                       <id>64bitstuff</id>
+                       <activation>
+                               <property>
+                                       <name>sun.arch.data.model</name>
+                                       <value>64</value>
+                               </property>
+                       </activation>
+                       <properties>
+                               <maven.compiler.maxmem>768m</maven.compiler.maxmem>
+                       </properties>
+               </profile>
+
+               <profile>
+                       <id>xmlbean</id>
+      <activation>
+        <file><exists>xmlbeans.marker</exists></file>
+      </activation>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>xmlbeans-maven-plugin</artifactId>
+                                               <version>2.3.3</version>
+                                               <executions>
+                                                       <execution>
+                                                               <phase>process-sources</phase>
+                                                               <goals>
+                                                                       <goal>xmlbeans</goal>
+                                                               </goals>
+                <configuration>
+                  <schemaDirectory>${basedir}/target/schemas</schemaDirectory>
+                  <javaSource>1.5</javaSource>
+                  <noJavac>true</noJavac>
+                  <noUpa>${xmlbeans.noUpa}</noUpa>
+                  <noPvr>${xmlbeans.noPvr}</noPvr>
+                  <xmlConfigs>
+                    <xmlConfig implementation="java.io.File">${basedir}/../../src/ooxml/resources/org/apache/poi/poifs/crypt/encryptionCertificate.xsdconfig</xmlConfig>
+                    <xmlConfig implementation="java.io.File">${basedir}/../../src/ooxml/resources/org/apache/poi/poifs/crypt/encryptionInfo.xsdconfig</xmlConfig>
+                    <xmlConfig implementation="java.io.File">${basedir}/../../src/ooxml/resources/org/apache/poi/poifs/crypt/encryptionPassword.xsdconfig</xmlConfig>
+                    <xmlConfig implementation="java.io.File">${basedir}/../../src/ooxml/resources/org/apache/poi/schemas/ooxmlSchemas.xsdconfig</xmlConfig>
+                  </xmlConfigs>
+                </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
 
-    <dependencies>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <version>1.8</version>
+            <executions>
+              <execution>
+                <id>copy-xmltype-and-xsdconfig</id>
+                <phase>generate-sources</phase>
+                <goals><goal>run</goal></goals>                   
+                <configuration>
+                  <target>
+                    <copy todir="${basedir}/target/generated-sources/xmlbeans">
+                      <fileset dir="${basedir}/../../src/ooxml/java" includes="org/apache/poi/POIXMLTypeLoader.java"/>
+                    </copy>
+                    <copy todir="${basedir}/target/schemas">
+                      <fileset dir="${basedir}/../../src/ooxml/resources/org/apache/poi/schemas"/>
+                    </copy>
+                  </target>
+                </configuration>
+              </execution>
+              <execution>
+                <id>replace-xmltypeloader</id>
+                <phase>process-sources</phase>
+                <goals><goal>run</goal></goals>                   
+                <configuration>
+                  <target>
+                    <replace dir="${basedir}/target/generated-sources/xmlbeans" includes="**/*.java" excludes="**/impl/**">
+                        <replacetoken>org.apache.xmlbeans.XmlBeans.getContextTypeLoader()</replacetoken>
+                        <replacevalue>org.apache.poi.POIXMLTypeLoader</replacevalue>
+                    </replace>                    
+                  </target>
+                </configuration>
+              </execution>
+              <execution>
+                <id>remove-xmltypeloader-from-schema-jar</id>
+                <phase>prepare-package</phase>
+                <goals><goal>run</goal></goals>                   
+                <configuration>
+                  <target>
+                    <touch file="${basedir}/target/generated-sources/xmlbeans/.staleFlag"/>
+                    <delete dir="${basedir}/target/classes/org/apache"/>
+                  </target>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+                               </plugins>
+                       </build>
+      <dependencies>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.12</version>
-            <scope>test</scope>
+          <groupId>org.apache.xmlbeans</groupId>
+          <artifactId>xmlbeans</artifactId>
+          <version>2.6.0</version>
         </dependency>
-    </dependencies>
+      </dependencies>
+               </profile>
+       </profiles>
 </project>
index 842c37b6a5b48f2c159ce7ebe7bbdf0cbe57e45c..1abf91be0a7f04ac4333ccdfd092ee5ca98a5843 100644 (file)
@@ -41,7 +41,6 @@ import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
-import org.apache.xmlbeans.XmlOptions;
 
 /**
  * Represents an entry of a OOXML package.
@@ -55,16 +54,6 @@ import org.apache.xmlbeans.XmlOptions;
 public class POIXMLDocumentPart {
     private static final POILogger logger = POILogFactory.getLogger(POIXMLDocumentPart.class);
 
-    public static final XmlOptions DEFAULT_XML_OPTIONS;
-    static {
-        DEFAULT_XML_OPTIONS = new XmlOptions();
-        DEFAULT_XML_OPTIONS.setSaveOuter();
-        DEFAULT_XML_OPTIONS.setUseDefaultNamespace();
-        DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces();
-        DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8");
-        DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096);
-    }
-
     private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT;
     private PackagePart packagePart;
     private PackageRelationship packageRel;
index e6f68691e98f7cf48ea06165604f55552972a3d4..48ce99fce19a25523d4a0e7b8670b9242628e7b9 100644 (file)
 ==================================================================== */
 package org.apache.poi;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -33,9 +33,7 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
 import org.apache.poi.openxml4j.util.Nullable;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty;
 
 /**
@@ -74,7 +72,7 @@ public class POIXMLProperties {
                if(extRel.size() == 1) {
                        extPart = pkg.getPart( extRel.getRelationship(0));
                        org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.parse(
-                                extPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS
+                                extPart.getInputStream(), DEFAULT_XML_OPTIONS
                        );
                        ext = new ExtendedProperties(props);
                } else {
@@ -88,7 +86,7 @@ public class POIXMLProperties {
                if(custRel.size() == 1) {
                        custPart = pkg.getPart( custRel.getRelationship(0));
                        org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.parse(
-                                       custPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS
+                                       custPart.getInputStream(), DEFAULT_XML_OPTIONS
                        );
                        cust = new CustomProperties(props);
                } else {
@@ -142,28 +140,16 @@ public class POIXMLProperties {
                        }
                }
                if(extPart != null){
-                       XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
-
-                       Map<String, String> map = new HashMap<String, String>();
-                       map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
-                       xmlOptions.setSaveSuggestedPrefixes(map);
-
                        OutputStream out = extPart.getOutputStream();
                        if (extPart.getSize() > 0) {
                            extPart.clear();
                        }
-                       ext.props.save(out, xmlOptions);
+                       ext.props.save(out, DEFAULT_XML_OPTIONS);
                        out.close();
                }
                if(custPart != null){
-                       XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
-
-                       Map<String, String> map = new HashMap<String, String>();
-                       map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
-                       xmlOptions.setSaveSuggestedPrefixes(map);
-
                        OutputStream out = custPart.getOutputStream();
-                       cust.props.save(out, xmlOptions);
+                       cust.props.save(out, DEFAULT_XML_OPTIONS);
                        out.close();
                }
        }
diff --git a/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java b/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
new file mode 100644 (file)
index 0000000..3ff44c6
--- /dev/null
@@ -0,0 +1,119 @@
+/* ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.net.URL;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import javax.xml.stream.XMLStreamReader;\r
+\r
+import org.apache.xmlbeans.SchemaType;\r
+import org.apache.xmlbeans.XmlBeans;\r
+import org.apache.xmlbeans.XmlException;\r
+import org.apache.xmlbeans.XmlObject;\r
+import org.apache.xmlbeans.XmlOptions;\r
+import org.apache.xmlbeans.xml.stream.XMLInputStream;\r
+import org.apache.xmlbeans.xml.stream.XMLStreamException;\r
+import org.w3c.dom.Node;\r
+\r
+@SuppressWarnings("deprecation")\r
+public class POIXMLTypeLoader {\r
+\r
+    public static final XmlOptions DEFAULT_XML_OPTIONS;\r
+    static {\r
+        DEFAULT_XML_OPTIONS = new XmlOptions();\r
+        DEFAULT_XML_OPTIONS.setSaveOuter();\r
+        DEFAULT_XML_OPTIONS.setUseDefaultNamespace();\r
+        DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces();\r
+        DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8");\r
+        DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096);\r
+\r
+        Map<String, String> map = new HashMap<String, String>();\r
+        map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");\r
+        map.put("http://schemas.openxmlformats.org/drawingml/2006/chart", "c");\r
+        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");\r
+        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");\r
+        map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");\r
+        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");\r
+        map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");\r
+        map.put("http://schemas.openxmlformats.org/presentationml/2006/main", "p");\r
+        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");\r
+        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");\r
+        map.put("urn:schemas-microsoft-com:office:office", "o");\r
+        map.put("urn:schemas-microsoft-com:office:excel", "x");\r
+        map.put("urn:schemas-microsoft-com:office:word", "w10");\r
+        map.put("urn:schemas-microsoft-com:vml", "v");\r
+        DEFAULT_XML_OPTIONS.setSaveSuggestedPrefixes(Collections.unmodifiableMap(map));\r
+    }\r
+    \r
+    public static XmlObject newInstance(SchemaType type, XmlOptions options) {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().newInstance(type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(String xmlText, SchemaType type, XmlOptions options) throws XmlException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(xmlText, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(file, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(file, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(InputStream jiois, SchemaType type, XmlOptions options) throws XmlException, IOException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(jiois, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(XMLStreamReader xsr, SchemaType type, XmlOptions options) throws XmlException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(xsr, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(Reader jior, SchemaType type, XmlOptions options) throws XmlException, IOException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(jior, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(Node node, SchemaType type, XmlOptions options) throws XmlException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(node, type, opt);\r
+    }\r
+\r
+    public static XmlObject parse(XMLInputStream xis, SchemaType type, XmlOptions options) throws XmlException, XMLStreamException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().parse(xis, type, opt);\r
+    }\r
+    \r
+    public static XMLInputStream newValidatingXMLInputStream ( XMLInputStream xis, SchemaType type, XmlOptions options ) throws XmlException, XMLStreamException {\r
+        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;\r
+        return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream(xis, type, opt);\r
+    }\r
+}\r
index 37447cea51cd49943df9930aca6b0eb713f54147..39c6acf7422e2452a3a46646124e4352d873b464 100644 (file)
 ==================================================================== */\r
 package org.apache.poi.poifs.crypt.agile;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
+\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 \r
 import org.apache.poi.EncryptedDocumentException;\r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.poi.poifs.crypt.ChainingMode;\r
 import org.apache.poi.poifs.crypt.CipherAlgorithm;\r
 import org.apache.poi.poifs.crypt.EncryptionInfo;\r
@@ -112,7 +113,7 @@ public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder {
     \r
     protected static EncryptionDocument parseDescriptor(String descriptor) {\r
         try {\r
-            return EncryptionDocument.Factory.parse(descriptor, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            return EncryptionDocument.Factory.parse(descriptor, DEFAULT_XML_OPTIONS);\r
         } catch (XmlException e) {\r
             throw new EncryptedDocumentException("Unable to parse encryption descriptor", e);\r
         }\r
@@ -120,7 +121,7 @@ public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder {
 \r
     protected static EncryptionDocument parseDescriptor(InputStream descriptor) {\r
         try {\r
-            return EncryptionDocument.Factory.parse(descriptor, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            return EncryptionDocument.Factory.parse(descriptor, DEFAULT_XML_OPTIONS);\r
         } catch (Exception e) {\r
             throw new EncryptedDocumentException("Unable to parse encryption descriptor", e);\r
         }\r
index 49c6828e93f0f41cf64d925958d67cbf7dee6aba..9646ba07ad613b75b25df82740f64cfe6c3e4174 100644 (file)
@@ -24,6 +24,7 @@
 \r
 package org.apache.poi.poifs.crypt.dsig;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
 import static org.apache.poi.poifs.crypt.dsig.facets.SignatureFacet.XML_DIGSIG_NS;\r
 \r
 import java.io.ByteArrayOutputStream;\r
@@ -68,7 +69,6 @@ import javax.xml.xpath.XPathFactory;
 import org.apache.jcp.xml.dsig.internal.dom.DOMReference;\r
 import org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo;\r
 import org.apache.poi.EncryptedDocumentException;\r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;\r
 import org.apache.poi.openxml4j.opc.ContentTypes;\r
 import org.apache.poi.openxml4j.opc.OPCPackage;\r
@@ -213,7 +213,7 @@ public class SignatureInfo implements SignatureConfigurable {
          */\r
         public SignatureDocument getSignatureDocument() throws IOException, XmlException {\r
             // TODO: check for XXE\r
-            return SignatureDocument.Factory.parse(signaturePart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            return SignatureDocument.Factory.parse(signaturePart.getInputStream(), DEFAULT_XML_OPTIONS);\r
         }\r
         \r
         /**\r
@@ -631,7 +631,7 @@ public class SignatureInfo implements SignatureConfigurable {
         \r
         try {\r
             OutputStream os = sigPart.getOutputStream();\r
-            SignatureDocument sigDoc = SignatureDocument.Factory.parse(document, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            SignatureDocument sigDoc = SignatureDocument.Factory.parse(document, DEFAULT_XML_OPTIONS);\r
             sigDoc.save(os, xo);\r
             os.close();\r
         } catch (Exception e) {\r
index de12275c40372a16396620d5733ae9ab5212bffe..c6dc2491e6d229664c541cce17484a0b32e7d37c 100644 (file)
 \r
 package org.apache.poi.poifs.crypt.dsig.facets;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
+\r
 import javax.xml.crypto.MarshalException;\r
 \r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.xmlbeans.XmlException;\r
 import org.etsi.uri.x01903.v13.QualifyingPropertiesType;\r
 import org.etsi.uri.x01903.v13.UnsignedPropertiesType;\r
@@ -57,7 +58,7 @@ public class Office2010SignatureFacet extends SignatureFacet {
 \r
         QualifyingPropertiesType qualProps;\r
         try {\r
-            qualProps = QualifyingPropertiesType.Factory.parse(nl.item(0), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            qualProps = QualifyingPropertiesType.Factory.parse(nl.item(0), DEFAULT_XML_OPTIONS);\r
         } catch (XmlException e) {\r
             throw new MarshalException(e);\r
         }\r
index 61d61cf81065d8d6bba8392c753f1329aa43567e..d25bd7d1b81198350c05707fd967ae598616faae 100644 (file)
@@ -24,6 +24,7 @@
 \r
 package org.apache.poi.poifs.crypt.dsig.facets;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
 import static org.apache.poi.poifs.crypt.dsig.facets.XAdESSignatureFacet.insertXChild;\r
 \r
 import java.io.ByteArrayInputStream;\r
@@ -46,7 +47,6 @@ import java.util.UUID;
 \r
 import javax.xml.crypto.MarshalException;\r
 \r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.poi.poifs.crypt.dsig.services.RevocationData;\r
 import org.apache.poi.util.POILogFactory;\r
 import org.apache.poi.util.POILogger;\r
@@ -129,7 +129,7 @@ public class XAdESXLSignatureFacet extends SignatureFacet {
         NodeList qualNl = document.getElementsByTagNameNS(XADES_132_NS, "QualifyingProperties");\r
         if (qualNl.getLength() == 1) {\r
             try {\r
-                qualDoc = QualifyingPropertiesDocument.Factory.parse(qualNl.item(0), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+                qualDoc = QualifyingPropertiesDocument.Factory.parse(qualNl.item(0), DEFAULT_XML_OPTIONS);\r
             } catch (XmlException e) {\r
                 throw new MarshalException(e);\r
             }\r
index 656672d5090a908ab09e9b96d0512eb75451653f..495d843b4c9a161991eb09294018b40a398d04c6 100644 (file)
@@ -24,6 +24,8 @@
 \r
 package org.apache.poi.poifs.crypt.dsig.services;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
+\r
 import java.io.ByteArrayInputStream;\r
 import java.io.ByteArrayOutputStream;\r
 import java.io.IOException;\r
@@ -48,7 +50,6 @@ import javax.xml.crypto.dsig.TransformException;
 import javax.xml.crypto.dsig.TransformService;\r
 import javax.xml.crypto.dsig.spec.TransformParameterSpec;\r
 \r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.poi.util.POILogFactory;\r
 import org.apache.poi.util.POILogger;\r
 import org.apache.poi.util.XmlSort;\r
@@ -142,7 +143,7 @@ public class RelationshipTransformService extends TransformService {
         Node parentNode = domParent.getNode();\r
         \r
         try {\r
-            TransformDocument transDoc = TransformDocument.Factory.parse(parentNode, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            TransformDocument transDoc = TransformDocument.Factory.parse(parentNode, DEFAULT_XML_OPTIONS);\r
             XmlObject xoList[] = transDoc.getTransform().selectChildren(RelationshipReferenceDocument.type.getDocumentElementName());\r
             if (xoList.length == 0) {\r
                 LOG.log(POILogger.WARN, "no RelationshipReference/@SourceId parameters present");\r
@@ -188,7 +189,7 @@ public class RelationshipTransformService extends TransformService {
         \r
         RelationshipsDocument relDoc;\r
         try {\r
-            relDoc = RelationshipsDocument.Factory.parse(octetStream, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            relDoc = RelationshipsDocument.Factory.parse(octetStream, DEFAULT_XML_OPTIONS);\r
         } catch (Exception e) {\r
             throw new TransformException(e.getMessage(), e);\r
         }\r
index 93ff71d6924c30b40e6c5769e7f3b2175ab73e79..68d2c0874ff7e480dcd310a9b89a6beee4ae9268 100644 (file)
 \r
 package org.apache.poi.util;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
+\r
 import java.io.File;\r
 import java.io.IOException;\r
 import java.util.Comparator;\r
 \r
 import javax.xml.namespace.QName;\r
 \r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.xmlbeans.XmlCursor;\r
 import org.apache.xmlbeans.XmlException;\r
 import org.apache.xmlbeans.XmlObject;\r
@@ -50,7 +51,7 @@ public final class XmlSort
         File f = new File(args[0]);\r
         try\r
         {\r
-            XmlObject docInstance = XmlObject.Factory.parse(f, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            XmlObject docInstance = XmlObject.Factory.parse(f, DEFAULT_XML_OPTIONS);\r
             XmlObject element = null;\r
             if (args.length > 1)\r
             {\r
index bd150811a2922574748628bf9e9ca019d3cea128..1cc257c51de2659c0397a91d7cfc06df26be7b21 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.awt.Dimension;
 import java.io.IOException;
 import java.io.InputStream;
@@ -51,9 +53,7 @@ import org.apache.poi.util.PackageHelper;
 import org.apache.poi.util.Units;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdList;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
@@ -127,7 +127,7 @@ implements SlideShow<XSLFShape,XSLFTextParagraph> {
     protected void onDocumentRead() throws IOException {
         try {
             PresentationDocument doc =
-                    PresentationDocument.Factory.parse(getCorePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                    PresentationDocument.Factory.parse(getCorePart().getInputStream(), DEFAULT_XML_OPTIONS);
             _presentation = doc.getPresentation();
 
             Map<String, XSLFSlideMaster> masterMap = new HashMap<String, XSLFSlideMaster>();
@@ -170,14 +170,9 @@ implements SlideShow<XSLFShape,XSLFTextParagraph> {
 
     @Override
     protected void commit() throws IOException {
-        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
-        Map<String, String> map = new HashMap<String, String>();
-        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-        xmlOptions.setSaveSuggestedPrefixes(map);
-
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
-        _presentation.save(out, xmlOptions);
+        _presentation.save(out, DEFAULT_XML_OPTIONS);
         out.close();
     }
 
index 5ded5a7aedc576e506fc0460a17de6429cbfebd9..db8df4e9fa40fa53bc6fb400e022e186b4b60f19 100644 (file)
 
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.namespace.QName;
+
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
@@ -31,12 +37,6 @@ import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
 import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
 
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * Represents a Chart in a .pptx presentation
  *
@@ -66,7 +66,7 @@ public final class XSLFChart extends POIXMLDocumentPart {
        protected XSLFChart(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
                super(part, rel);
 
-               chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getChartSpace(); 
+               chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS).getChartSpace(); 
                chart = chartSpace.getChart();
        }
 
@@ -93,13 +93,7 @@ public final class XSLFChart extends POIXMLDocumentPart {
        @Override
        protected void commit() throws IOException {
                XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
-
                xmlOptions.setSaveSyntheticDocumentElement(new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c"));
-               Map<String, String> map = new HashMap<String, String>();
-               map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
-               map.put("http://schemas.openxmlformats.org/drawingml/2006/chart", "c");
-               map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
-               xmlOptions.setSaveSuggestedPrefixes(map);
 
                PackagePart part = getPackagePart();
                OutputStream out = part.getOutputStream();
index 4274ba7847cbb7303f754e3f4e1f218eb88b0959..1fe05a48cf6e338b6d01a26dac8b42b1ae60eb87 100644 (file)
 
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthor;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthorList;
@@ -54,7 +55,7 @@ public class XSLFCommentAuthors extends POIXMLDocumentPart {
         super(part, rel);
 
         CmAuthorLstDocument doc =
-           CmAuthorLstDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+           CmAuthorLstDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _authors = doc.getCmAuthorLst();
     }
     
index 16190c64c861595f58c2c36fdb3943d59f8699a2..8331289b4e48a1285bec40fe601e795fe278b0f4 100644 (file)
 
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
+import java.io.IOException;
+
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTComment;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList;
 import org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument;
 
-import java.io.IOException;
-
 @Beta
 public class XSLFComments extends POIXMLDocumentPart {
     private final CTCommentList _comments;
@@ -54,7 +55,7 @@ public class XSLFComments extends POIXMLDocumentPart {
         super(part, rel);
 
         CmLstDocument doc =
-           CmLstDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+           CmLstDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _comments = doc.getCmLst();
     }
     
index 7f87f6d695051611b415dfe4b8aa41890157507e..34d4e0031a78b196d371f25d36c28eeaa4ff5111 100644 (file)
 
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlCursor;
@@ -68,7 +69,7 @@ public class XSLFCommonSlideData {
                 if (o instanceof XmlAnyTypeImpl) {
                     // Pesky XmlBeans bug - see Bugzilla #49934
                     try {
-                        o = CTTable.Factory.parse(o.toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                        o = CTTable.Factory.parse(o.toString(), DEFAULT_XML_OPTIONS);
                     } catch (XmlException e) {
                         throw new POIXMLException(e);
                     }
index 283981d99ddc69b02778441b1765127b9404eb72..652cedcb50857340822fb0044b3d0c5d1fcfa502 100644 (file)
 \r
 package org.apache.poi.xslf.usermodel;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
+\r
 import java.io.ByteArrayInputStream;\r
 import java.io.IOException;\r
 \r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;\r
 import org.apache.poi.openxml4j.opc.OPCPackage;\r
 import org.apache.poi.openxml4j.opc.PackagePart;\r
@@ -49,7 +50,7 @@ public class XSLFMetroShape {
         try {\r
             pkg = OPCPackage.open(new ByteArrayInputStream(metroBytes));\r
             PackagePart shapePart = pkg.getPart(shapePN);\r
-            CTGroupShape gs = CTGroupShape.Factory.parse(shapePart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            CTGroupShape gs = CTGroupShape.Factory.parse(shapePart.getInputStream(), DEFAULT_XML_OPTIONS);\r
             XSLFGroupShape xgs = new XSLFGroupShape(gs, null);\r
             return xgs.getShapes().get(0);               \r
         } finally {\r
index 22b1607ddae11db28ef852b4fba42c6492b2d4a4..d69125e056e65a76c76f48d607d611313bac7cee 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -25,7 +27,6 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.sl.usermodel.Notes;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
@@ -57,7 +58,7 @@ implements Notes<XSLFShape,XSLFTextParagraph> {
         super(part, rel);
 
         NotesDocument doc =
-            NotesDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            NotesDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _notes = doc.getNotes();
         setCommonSlideData(_notes.getCSld());
     }
index b3d1777ac5996c487014bcf9846009f330119172..c93c9cc26e550a291a87b20d91b3dc421b91e74d 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -25,7 +27,6 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMaster;
@@ -61,7 +62,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
     protected XSLFNotesMaster(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
         super(part, rel);
         NotesMasterDocument doc =
-            NotesMasterDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            NotesMasterDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _slide = doc.getNotesMaster();
         setCommonSlideData(_slide.getCSld());
     }
@@ -74,7 +75,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
 
         try {
             try {
-                NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
                 CTNotesMaster slide =  doc.getNotesMaster();
                 return slide;
             } finally {
index 547e01fe8a51a28a7e30e8c216f9df341478383d..f999c6c4b60c97c8224a11c6154d3611b9bf67e0 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.awt.Graphics2D;
 import java.io.IOException;
 import java.io.InputStream;
@@ -25,6 +27,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+
 import javax.xml.namespace.QName;
 
 import org.apache.poi.POIXMLDocumentPart;
@@ -39,8 +42,8 @@ import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.DrawPictureShape;
 import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.sl.usermodel.PictureData;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
 import org.apache.poi.sl.usermodel.Sheet;
+import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -312,12 +315,6 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
 
     protected final void commit() throws IOException {
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
-
-        Map<String, String> map = new HashMap<String, String>();
-        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
-        map.put("http://schemas.openxmlformats.org/presentationml/2006/main", "p");
-        xmlOptions.setSaveSuggestedPrefixes(map);
         String docName = getRootElementName();
         if(docName != null) {
             xmlOptions.setSaveSyntheticDocumentElement(
index 1d0d854bda38faaf96f200af3312d43cd5d8ee51..4be19ea435a1504967711632d21dba5ab4565e4f 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.awt.Graphics2D;
 import java.io.IOException;
 
@@ -71,7 +73,7 @@ implements Slide<XSLFShape,XSLFTextParagraph> {
         super(part, rel);
 
         SldDocument doc =
-            SldDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            SldDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _slide = doc.getSld();
         setCommonSlideData(_slide.getCSld());
     }
index 329ebf8994be885dd2c5cb44ec09b0f29e863679..95835e49528da24a9781aab25032eaaf1478afa5 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 
 import org.apache.poi.POIXMLDocumentPart;
@@ -45,7 +47,7 @@ implements MasterSheet<XSLFShape,XSLFTextParagraph> {
     public XSLFSlideLayout(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
         super(part, rel);
         SldLayoutDocument doc =
-                SldLayoutDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                SldLayoutDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _layout = doc.getSldLayout();
         setCommonSlideData(_layout.getCSld());
     }
index 302e064b6a825da0c4d1353fe7538099766c774c..cf45bf74468d97878589725244b1d7543011e9e5 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Locale;
@@ -70,7 +72,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
     protected XSLFSlideMaster(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
         super(part, rel);
         SldMasterDocument doc =
-            SldMasterDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            SldMasterDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _slide = doc.getSldMaster();
         setCommonSlideData(_slide.getCSld());
     }
index 2646316415c23ba74048cff0a72ea1011a6b3900..8c69bbfa996e0a5bc921ac7b2092919da50b1e46 100644 (file)
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.poi.POIXMLDocument;
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
@@ -74,7 +75,7 @@ public class XSLFSlideShow extends POIXMLDocument {
                }
 
                presentationDoc =
-                       PresentationDocument.Factory.parse(getCorePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       PresentationDocument.Factory.parse(getCorePart().getInputStream(), DEFAULT_XML_OPTIONS);
 
                embedds = new LinkedList<PackagePart>();
                for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
@@ -146,7 +147,7 @@ public class XSLFSlideShow extends POIXMLDocument {
        public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
                PackagePart masterPart = getSlideMasterPart(master);
                SldMasterDocument masterDoc =
-                       SldMasterDocument.Factory.parse(masterPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       SldMasterDocument.Factory.parse(masterPart.getInputStream(), DEFAULT_XML_OPTIONS);
                return masterDoc.getSldMaster();
        }
 
@@ -166,7 +167,7 @@ public class XSLFSlideShow extends POIXMLDocument {
        public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
                PackagePart slidePart = getSlidePart(slide);
                SldDocument slideDoc =
-                       SldDocument.Factory.parse(slidePart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       SldDocument.Factory.parse(slidePart.getInputStream(), DEFAULT_XML_OPTIONS);
                return slideDoc.getSld();
        }
 
@@ -209,7 +210,7 @@ public class XSLFSlideShow extends POIXMLDocument {
                        return null;
 
                NotesDocument notesDoc =
-                       NotesDocument.Factory.parse(notesPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       NotesDocument.Factory.parse(notesPart.getInputStream(), DEFAULT_XML_OPTIONS);
 
                return notesDoc.getNotes();
        }
@@ -241,7 +242,7 @@ public class XSLFSlideShow extends POIXMLDocument {
                                        commentRels.getRelationship(0)
                        );
                        CmLstDocument commDoc =
-                               CmLstDocument.Factory.parse(cPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                               CmLstDocument.Factory.parse(cPart.getInputStream(), DEFAULT_XML_OPTIONS);
                        return commDoc.getCmLst();
                } catch(InvalidFormatException e) {
                        throw new IllegalStateException(e);
index 16a7c59c71e48b320516a880483a8bc53ae60dfd..d0d474944ae0f2734e1d66881f817b321e2cd1cd 100644 (file)
@@ -19,6 +19,8 @@
 \r
 package org.apache.poi.xslf.usermodel;\r
 \r
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;\r
+\r
 import java.util.ArrayList;\r
 import java.util.Collections;\r
 import java.util.Iterator;\r
@@ -26,7 +28,6 @@ import java.util.List;
 \r
 import javax.xml.namespace.QName;\r
 \r
-import org.apache.poi.POIXMLDocumentPart;\r
 import org.apache.poi.POIXMLException;\r
 import org.apache.poi.sl.usermodel.TableShape;\r
 import org.apache.poi.util.Internal;\r
@@ -68,7 +69,7 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
         // it never happens when using the full ooxml-schemas jar but may happen with the abridged poi-ooxml-schemas\r
         if(rs[0] instanceof XmlAnyTypeImpl){\r
             try {\r
-                rs[0] = CTTable.Factory.parse(rs[0].toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+                rs[0] = CTTable.Factory.parse(rs[0].toString(), DEFAULT_XML_OPTIONS);\r
             }catch (XmlException e){\r
                 throw new POIXMLException(e);\r
             }\r
index 86ae135344b3d8dc9b1c4b0d66f7c231cd496325..02532dbf1c03704f8fda8fe5b790d3392bc2fa11 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -26,7 +28,6 @@ import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyle;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleList;
@@ -44,7 +45,7 @@ public class XSLFTableStyles extends POIXMLDocumentPart implements Iterable<XSLF
     public XSLFTableStyles(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
         super(part, rel);
 
-        _tblStyleLst = CTTableStyleList.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+        _tblStyleLst = CTTableStyleList.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         CTTableStyle[] tblStyleArray = _tblStyleLst.getTblStyleArray();
         _styles = new ArrayList<XSLFTableStyle>(tblStyleArray.length);
         for(CTTableStyle c : tblStyleArray){
index 88b72602d9d97d34fd57c725149861d6cf738b9a..f51c2daace18f56244bcf525351979509aded717 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.HashMap;
@@ -27,7 +29,6 @@ import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -58,7 +59,7 @@ public class XSLFTheme extends POIXMLDocumentPart {
     public XSLFTheme(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
         super(part, rel);
         ThemeDocument doc =
-            ThemeDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            ThemeDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
         _theme = doc.getTheme();
         initialize();
     }
@@ -128,12 +129,8 @@ public class XSLFTheme extends POIXMLDocumentPart {
 
     protected final void commit() throws IOException {
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
-
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
-        xmlOptions.setSaveSuggestedPrefixes(map);
         xmlOptions.setSaveSyntheticDocumentElement(
-                new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "theme"));
+            new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "theme"));
 
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
index ecfcca717ba2b96c5de3de299c3576c9827970ee..2e660ac91f936320b2000b997414188faeff6c55 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.dev;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
@@ -24,7 +26,6 @@ import java.util.Enumeration;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.internal.ZipHelper;
 import org.apache.poi.util.IOUtils;
 import org.apache.xmlbeans.XmlObject;
@@ -71,7 +72,7 @@ public final class XSSFDump {
             try {
                 if(entry.getName().endsWith(".xml") || entry.getName().endsWith(".vml") || entry.getName().endsWith(".rels")){
                     try {
-                        XmlObject xml = XmlObject.Factory.parse(zip.getInputStream(entry), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                        XmlObject xml = XmlObject.Factory.parse(zip.getInputStream(entry), DEFAULT_XML_OPTIONS);
                         XmlOptions options = new XmlOptions();
                         options.setSavePrettyPrint();
                         xml.save(out, options);
index 172cf7a3b6913788ee1604432045ed67fb1f5376..cc5fbb2cd4bcba46e5bcb609e19afcb4ca76c6f8 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.eventusermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -25,7 +27,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -209,7 +210,7 @@ public class XSSFReader {
                 }
                 //step 2. Read array of CTSheet elements, wrap it in a ArayList and construct an iterator
                 //Note, using XMLBeans might be expensive, consider refactoring to use SAX or a plain regexp search
-                CTWorkbook wbBean = WorkbookDocument.Factory.parse(wb.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getWorkbook();
+                CTWorkbook wbBean = WorkbookDocument.Factory.parse(wb.getInputStream(), DEFAULT_XML_OPTIONS).getWorkbook();
                 sheetIterator = wbBean.getSheets().getSheetList().iterator(); 
             } catch (InvalidFormatException e){
                 throw new POIXMLException(e);
index 855353732836abbf1e70b7dab97041d06ce80e7d..13133f4fb1ab8ae1770703ec2a4e9755da0f6d86 100644 (file)
 ==================================================================== */
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.poi.POIXMLDocumentPart;
-import org.apache.xmlbeans.XmlException;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
+import org.apache.xmlbeans.XmlException;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcChain;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CalcChainDocument;
 
 /**
  * The cells in a workbook can be calculated in different orders depending on various optimizations and
@@ -48,7 +51,7 @@ public class CalculationChain extends POIXMLDocumentPart {
 
     public void readFrom(InputStream is) throws IOException {
         try {
-            CalcChainDocument doc = CalcChainDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            CalcChainDocument doc = CalcChainDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             chain = doc.getCalcChain();
         } catch (XmlException e) {
             throw new IOException(e.getLocalizedMessage());
index b9ef88a9fa77f93e546af93ea75f4b74c58727d5..3cbc49dd507b8a9b55efa2b752274ad9ed4989ec 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -25,7 +27,6 @@ import java.util.Map;
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
@@ -56,7 +57,7 @@ public class CommentsTable extends POIXMLDocumentPart {
 
     public void readFrom(InputStream is) throws IOException {
         try {
-            CommentsDocument doc = CommentsDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            CommentsDocument doc = CommentsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             comments = doc.getComments();
         } catch (XmlException e) {
             throw new IOException(e.getLocalizedMessage());
index a96081ef3056699695995f8bbeb3dd624215729d..42fce1159766cb8583b6fb6ed599b4876fc02b6e 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -28,7 +30,6 @@ import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
 import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.ss.usermodel.Name;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalDefinedName;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalLink;
@@ -55,7 +56,7 @@ public class ExternalLinksTable extends POIXMLDocumentPart {
 
     public void readFrom(InputStream is) throws IOException {
         try {
-            ExternalLinkDocument doc = ExternalLinkDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            ExternalLinkDocument doc = ExternalLinkDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             link = doc.getExternalLink();
         } catch (XmlException e) {
             throw new IOException(e.getLocalizedMessage());
index 959df17b46fb32f5bea7eb2674507a2a3f91509b..c8032e6021b4de3d1da49a969a7711fd1b53ba4c 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -27,7 +29,6 @@ import java.util.Map;
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.xssf.usermodel.XSSFMap;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.xmlbeans.XmlException;
@@ -69,7 +70,7 @@ public class MapInfo extends POIXMLDocumentPart {
     @SuppressWarnings("deprecation")
        public void readFrom(InputStream is) throws IOException {
                try {
-                       MapInfoDocument doc = MapInfoDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       MapInfoDocument doc = MapInfoDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
                        mapInfo = doc.getMapInfo();
 
             maps= new HashMap<Integer, XSSFMap>();
index 7f56448795bd9530fe6348a650a4833dc1675c2e..96a8ce89f243735c18615c546fa9c2038f52a16d 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -116,7 +118,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
     public void readFrom(InputStream is) throws IOException {
         try {
             int cnt = 0;
-            _sstDoc = SstDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            _sstDoc = SstDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             CTSst sst = _sstDoc.getSst();
             count = (int)sst.getCount();
             uniqueCount = (int)sst.getUniqueCount();
index effcde544f72e9320bdcff62f23715b21f9ac45c..953bad409cf56f268dfeaaef0e9dc50d42b8f7e2 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -26,7 +28,6 @@ import java.util.Vector;
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.helpers.XSSFSingleXmlCell;
 import org.apache.xmlbeans.XmlException;
@@ -62,7 +63,7 @@ public class SingleXmlCells extends POIXMLDocumentPart {
 
        public void readFrom(InputStream is) throws IOException {
                try {
-                       SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
                        singleXMLCells = doc.getSingleXmlCells();
                } catch (XmlException e) {
                        throw new IOException(e.getLocalizedMessage());
index be3855a06753eebc1c15e347c946c676fb5bc125..d413b64c519e94fc399d071530d9e2a8ff5c5ce4 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -42,7 +44,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
 import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorders;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyleXfs;
@@ -147,7 +148,7 @@ public class StylesTable extends POIXMLDocumentPart {
     @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
     protected void readFrom(InputStream is) throws IOException {
         try {
-            doc = StyleSheetDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            doc = StyleSheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
 
             CTStylesheet styleSheet = doc.getStyleSheet();
 
@@ -392,8 +393,6 @@ public class StylesTable extends POIXMLDocumentPart {
      * @throws IOException if an error occurs while writing.
      */
     public void writeTo(OutputStream out) throws IOException {
-        XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
-
         // Work on the current one
         // Need to do this, as we don't handle
         //  all the possible entries yet
@@ -486,7 +485,7 @@ public class StylesTable extends POIXMLDocumentPart {
         }
 
         // Save
-        doc.save(out, options);
+        doc.save(out, DEFAULT_XML_OPTIONS);
     }
 
     @Override
index 0873f07577fc5497d3d6af24aff966e1f20416ef..6d79ddeb71ae34a0eec16e90323f49fd61e0b659 100644 (file)
 ==================================================================== */
 package org.apache.poi.xssf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.OutputStream;
 
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.xssf.usermodel.XSSFColor;
 import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme;
 import org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument;
@@ -81,7 +81,7 @@ public class ThemesTable extends POIXMLDocumentPart {
         super(part, rel);
         
         try {
-           theme = ThemeDocument.Factory.parse(part.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+           theme = ThemeDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS);
         } catch(XmlException e) {
            throw new IOException(e.getLocalizedMessage(), e);
         }
@@ -166,9 +166,7 @@ public class ThemesTable extends POIXMLDocumentPart {
      * @throws IOException if an error occurs while writing.
      */
     public void writeTo(OutputStream out) throws IOException {
-        XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
-
-        theme.save(out, options);
+        theme.save(out, DEFAULT_XML_OPTIONS);
     }
 
     @Override
index 37be56189179ffb413f90fc9ac7dbab433749c7e..93798d1b53d8e9bc55b354e10b2409a4668785b4 100644 (file)
@@ -17,7 +17,8 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import org.apache.poi.POIXMLDocumentPart;
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import org.apache.poi.POIXMLException;
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.CellStyle;
@@ -154,12 +155,12 @@ public class XSSFCellStyle implements CellStyle {
 
                   // Create a new Xf with the same contents
                   _cellXf = CTXf.Factory.parse(
-                        src.getCoreXf().toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS
+                        src.getCoreXf().toString(), DEFAULT_XML_OPTIONS
                   );
 
                   // bug 56295: ensure that the fills is available and set correctly
                   CTFill fill = CTFill.Factory.parse(
-                                 src.getCTFill().toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS
+                                 src.getCTFill().toString(), DEFAULT_XML_OPTIONS
                                  );
                   addFill(fill);
 
@@ -178,7 +179,7 @@ public class XSSFCellStyle implements CellStyle {
                // Copy the font
                try {
                   CTFont ctFont = CTFont.Factory.parse(
-                        src.getFont().getCTFont().toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS
+                        src.getFont().getCTFont().toString(), DEFAULT_XML_OPTIONS
                   );
                   XSSFFont font = new XSSFFont(ctFont);
                   font.registerTo(_stylesSource);
index a31d2e8c1e3027209175f5b37062246d57ec376e..3dcb00d3ab1b556c97e07a8685604c1e995785bd 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -34,7 +34,6 @@ import org.apache.poi.ss.usermodel.charts.AxisPosition;
 import org.apache.poi.ss.usermodel.charts.ChartAxis;
 import org.apache.poi.ss.usermodel.charts.ChartAxisFactory;
 import org.apache.poi.ss.usermodel.charts.ChartData;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.util.Internal;
 import org.apache.poi.xssf.usermodel.charts.XSSFCategoryAxis;
 import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis;
@@ -54,7 +53,6 @@ import org.openxmlformats.schemas.drawingml.x2006.chart.CTPrintSettings;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
 import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 
@@ -101,7 +99,7 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA
        protected XSSFChart(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
                super(part, rel);
 
-               chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getChartSpace(); 
+               chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS).getChartSpace(); 
                chart = chartSpace.getChart();
        }
 
@@ -164,11 +162,6 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA
                      xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
                 */
                xmlOptions.setSaveSyntheticDocumentElement(new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c"));
-               Map<String, String> map = new HashMap<String, String>();
-               map.put(XSSFDrawing.NAMESPACE_A, "a");
-               map.put(XSSFDrawing.NAMESPACE_C, "c");
-               map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-               xmlOptions.setSaveSuggestedPrefixes(map);
 
                PackagePart part = getPackagePart();
                OutputStream out = part.getOutputStream();
@@ -199,8 +192,8 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA
                return this;
        }
 
-       public void plot(ChartData data, ChartAxis... axis) {
-               data.fillChart(this, axis);
+       public void plot(ChartData data, ChartAxis... chartAxis) {
+               data.fillChart(this, chartAxis);
        }
 
        public XSSFValueAxis createValueAxis(AxisPosition pos) {
index 5c8aae3c03da4a0134970e823be8cac5f28cf7d2..65a9adbe1806ec4c15342048d1494e6291651e4b 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTChartsheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDrawing;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTLegacyDrawing;
@@ -62,7 +60,7 @@ public class XSSFChartSheet extends XSSFSheet  {
         super.read(new ByteArrayInputStream(BLANK_WORKSHEET));
 
         try {
-            chartsheet = ChartsheetDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getChartsheet();
+            chartsheet = ChartsheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS).getChartsheet();
         } catch (XmlException e){
             throw new POIXMLException(e);
         }
@@ -92,10 +90,6 @@ public class XSSFChartSheet extends XSSFSheet  {
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(
                 new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-        xmlOptions.setSaveSuggestedPrefixes(map);
-
         chartsheet.save(out, xmlOptions);
 
     }
index 65eefec5592caf164c3460c2ad702f10db066151..642aa9e0fbe5803152cc46e2059e6608b032d8fe 100644 (file)
@@ -28,7 +28,7 @@ import org.apache.poi.xssf.model.CommentsTable;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
 
-import schemasMicrosoftComVml.CTShape;
+import com.microsoft.schemas.vml.CTShape;
 
 public class XSSFComment implements Comment {
        
index b2103e28936a4d7cca705d1274a549e7918ca999..2f3853973d6d18b2465f4f4d5c694c7fc926e454 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -41,8 +41,16 @@ import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.*;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTConnector;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrame;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTOneCellAnchor;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.STEditAs;
 
 /**
  * Represents a SpreadsheetML drawing
@@ -117,10 +125,6 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
         xmlOptions.setSaveSyntheticDocumentElement(
                 new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr")
         );
-        Map<String, String> map = new HashMap<String, String>();
-        map.put(NAMESPACE_A, "a");
-        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-        xmlOptions.setSaveSuggestedPrefixes(map);
 
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
@@ -297,7 +301,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
         //create comments and vmlDrawing parts if they don't exist
         CommentsTable comments = sheet.getCommentsTable(true);
         XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
-        schemasMicrosoftComVml.CTShape vmlShape = vml.newCommentShape();
+        com.microsoft.schemas.vml.CTShape vmlShape = vml.newCommentShape();
         if(ca.isSet()){
             // convert offsets from emus to pixels since we get a DrawingML-anchor
             // but create a VML Drawing
index e5896e73a18fc3322e0a3f1970751c76e8c77813..c6fb592056137a13d4518cbf44473eed0e86b308 100644 (file)
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.poi.POIXMLDocumentPart;
-import static org.apache.poi.POIXMLDocumentPart.DEFAULT_XML_OPTIONS;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
-
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache;
 
 public class XSSFPivotCache extends POIXMLDocumentPart {
@@ -65,7 +64,7 @@ public class XSSFPivotCache extends POIXMLDocumentPart {
         XmlOptions options  = new XmlOptions(DEFAULT_XML_OPTIONS);
         //Removing root element
         options.setLoadReplaceDocumentElement(null);
-            ctPivotCache = CTPivotCache.Factory.parse(is, options);
+        ctPivotCache = CTPivotCache.Factory.parse(is, options);
         } catch (XmlException e) {
             throw new IOException(e.getLocalizedMessage());
         }
index d63a18588d2c54dd2635fad0edbb8907c4d31d6e..f5c4fcad003fbd04c27dbb34206013cb5544b76c 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
index 93e04a022d18aef70dcac0e249240468a112023f..a8fca93c5ddbaf050a72a7974ed0e11a755ef6d4 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
index 07bfb77bcdf8a7912420be7009ea3089f0ba65c1..cd132c83109a4a8119020a31ec455dde3c4f88a1 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
index 610ec2ecd65fe07b13de253b95162cd9e593f2bf..6a35bf7d12c6dc861b6ad8a6fbac6daf2ab864d1 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
 import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.setPassword;
 import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.validatePassword;
 
@@ -76,7 +77,6 @@ import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
 import org.apache.poi.xssf.usermodel.helpers.XSSFRowShifter;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBreak;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
@@ -195,7 +195,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
 
     protected void read(InputStream is) throws IOException {
         try {
-            worksheet = WorksheetDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getWorksheet();
+            worksheet = WorksheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS).getWorksheet();
         } catch (XmlException e){
             throw new POIXMLException(e);
         }
@@ -3306,9 +3306,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
 
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorksheet.type.getName().getNamespaceURI(), "worksheet"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-        xmlOptions.setSaveSuggestedPrefixes(map);
 
         worksheet.save(out, xmlOptions);
 
index 8cd1e10cdb1162cf832801f672c604ff6b0ee48d..dcf5375023bd61cc5a87616ee9c20378c50ccb59 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -28,7 +30,6 @@ import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.xssf.usermodel.helpers.XSSFXmlColumnPr;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
@@ -70,7 +71,7 @@ public class XSSFTable extends POIXMLDocumentPart {
 
        public void readFrom(InputStream is) throws IOException {
                try {
-                       TableDocument doc = TableDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                       TableDocument doc = TableDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
                        ctTable = doc.getTable();
                } catch (XmlException e) {
                        throw new IOException(e.getLocalizedMessage());
index eb249f4148346877bc77bdc11ea2b0e7629d12eb..96dfede0d2c3a3bf4697a585b1e97fc6e5ee2a7c 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.QName;
+
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.xssf.util.EvilUnclosedBRFixingInputStream;
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlCursor;
 import org.w3c.dom.Node;
-import schemasMicrosoftComOfficeOffice.*;
 
-import javax.xml.namespace.QName;
-import java.io.*;
-import java.util.*;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.math.BigInteger;
-
-import schemasMicrosoftComVml.*;
-import schemasMicrosoftComVml.STTrueFalse;
-import schemasMicrosoftComOfficeExcel.CTClientData;
-import schemasMicrosoftComOfficeExcel.STObjectType;
+import com.microsoft.schemas.office.excel.CTClientData;
+import com.microsoft.schemas.office.excel.STObjectType;
+import com.microsoft.schemas.office.office.CTIdMap;
+import com.microsoft.schemas.office.office.CTShapeLayout;
+import com.microsoft.schemas.office.office.STConnectType;
+import com.microsoft.schemas.office.office.STInsetMode;
+import com.microsoft.schemas.vml.CTPath;
+import com.microsoft.schemas.vml.CTShadow;
+import com.microsoft.schemas.vml.CTShape;
+import com.microsoft.schemas.vml.CTShapetype;
+import com.microsoft.schemas.vml.STExt;
+import com.microsoft.schemas.vml.STStrokeJoinStyle;
+import com.microsoft.schemas.vml.STTrueFalse;
 
 /**
  * Represents a SpreadsheetML VML drawing.
@@ -107,7 +119,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart {
 
     protected void read(InputStream is) throws IOException, XmlException {
         XmlObject root = XmlObject.Factory.parse(
-              new EvilUnclosedBRFixingInputStream(is), POIXMLDocumentPart.DEFAULT_XML_OPTIONS
+              new EvilUnclosedBRFixingInputStream(is), DEFAULT_XML_OPTIONS
         );
 
         _qnames = new ArrayList<QName>();
@@ -116,13 +128,13 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart {
             Node nd = obj.getDomNode();
             QName qname = new QName(nd.getNamespaceURI(), nd.getLocalName());
             if (qname.equals(QNAME_SHAPE_LAYOUT)) {
-                _items.add(CTShapeLayout.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS));
+                _items.add(CTShapeLayout.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS));
             } else if (qname.equals(QNAME_SHAPE_TYPE)) {
-                CTShapetype st = CTShapetype.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                CTShapetype st = CTShapetype.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS);
                 _items.add(st);
                 _shapeTypeId = st.getId();
             } else if (qname.equals(QNAME_SHAPE)) {
-                CTShape shape = CTShape.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                CTShape shape = CTShape.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS);
                 String id = shape.getId();
                 if(id != null) {
                     Matcher m = ptrn_shapeId.matcher(id);
@@ -130,7 +142,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart {
                 }
                 _items.add(shape);
             } else {
-                _items.add(XmlObject.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS));
+                _items.add(XmlObject.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS));
             }
             _qnames.add(qname);
         }
@@ -160,15 +172,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart {
         }
         rootCursor.dispose();
 
-        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
-        xmlOptions.setSavePrettyPrint();
-        HashMap<String, String> map = new HashMap<String, String>();
-        map.put("urn:schemas-microsoft-com:vml", "v");
-        map.put("urn:schemas-microsoft-com:office:office", "o");
-        map.put("urn:schemas-microsoft-com:office:excel", "x");
-        xmlOptions.setSaveSuggestedPrefixes(map);
-
-        rootObject.save(out, xmlOptions);
+        rootObject.save(out, DEFAULT_XML_OPTIONS);
     }
 
     @Override
index dc2d8307ef812eb486b2b9ce1bd27e73b0a98494..d0d1fda63f6d2d3df6c18ac2ccfe969bf47ecad4 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
 import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.setPassword;
 import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.validatePassword;
 
@@ -80,7 +81,6 @@ import org.apache.poi.xssf.usermodel.helpers.XSSFFormulaUtils;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
@@ -333,7 +333,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
     @SuppressWarnings("deprecation") //  getXYZArray() array accessors are deprecated
     protected void onDocumentRead() throws IOException {
         try {
-            WorkbookDocument doc = WorkbookDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            WorkbookDocument doc = WorkbookDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
             this.workbook = doc.getWorkbook();
 
             ThemesTable theme = null;
@@ -1670,9 +1670,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
 
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorkbook.type.getName().getNamespaceURI(), "workbook"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
-        xmlOptions.setSaveSuggestedPrefixes(map);
 
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
index 4f210ae425ba65662a0da5f53bbcf4969e6d1d73..28ba945792a34172ed6822f2b863b815d7f2c7d5 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.model;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -31,7 +31,6 @@ import org.apache.poi.xwpf.usermodel.XWPFHeader;
 import org.apache.poi.xwpf.usermodel.XWPFHeaderFooter;
 import org.apache.poi.xwpf.usermodel.XWPFParagraph;
 import org.apache.poi.xwpf.usermodel.XWPFRelation;
-import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef;
@@ -46,18 +45,18 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.HdrDocument;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum;
 
-import schemasMicrosoftComOfficeOffice.CTLock;
-import schemasMicrosoftComOfficeOffice.STConnectType;
-import schemasMicrosoftComVml.CTFormulas;
-import schemasMicrosoftComVml.CTGroup;
-import schemasMicrosoftComVml.CTH;
-import schemasMicrosoftComVml.CTHandles;
-import schemasMicrosoftComVml.CTPath;
-import schemasMicrosoftComVml.CTShape;
-import schemasMicrosoftComVml.CTShapetype;
-import schemasMicrosoftComVml.CTTextPath;
-import schemasMicrosoftComVml.STExt;
-import schemasMicrosoftComVml.STTrueFalse;
+import com.microsoft.schemas.office.office.CTLock;
+import com.microsoft.schemas.office.office.STConnectType;
+import com.microsoft.schemas.vml.CTFormulas;
+import com.microsoft.schemas.vml.CTGroup;
+import com.microsoft.schemas.vml.CTH;
+import com.microsoft.schemas.vml.CTHandles;
+import com.microsoft.schemas.vml.CTPath;
+import com.microsoft.schemas.vml.CTShape;
+import com.microsoft.schemas.vml.CTShapetype;
+import com.microsoft.schemas.vml.CTTextPath;
+import com.microsoft.schemas.vml.STExt;
+import com.microsoft.schemas.vml.STTrueFalse;
 
 /**
  * A .docx file can have no headers/footers, the same header/footer
@@ -176,10 +175,8 @@ public class XWPFHeaderFooterPolicy {
         OutputStream outputStream = wrapper.getPackagePart().getOutputStream();
         hdrDoc.setHdr(hdr);
 
-        XmlOptions xmlOptions = commit(wrapper);
-
         assignHeader(wrapper, type);
-        hdrDoc.save(outputStream, xmlOptions);
+        hdrDoc.save(outputStream, DEFAULT_XML_OPTIONS);
         outputStream.close();
         
         return wrapper;
@@ -213,10 +210,8 @@ public class XWPFHeaderFooterPolicy {
         OutputStream outputStream = wrapper.getPackagePart().getOutputStream();
         ftrDoc.setFtr(ftr);
 
-        XmlOptions xmlOptions = commit(wrapper);
-
         assignFooter(wrapper, type);
-        ftrDoc.save(outputStream, xmlOptions);
+        ftrDoc.save(outputStream, DEFAULT_XML_OPTIONS);
         outputStream.close();
         return wrapper;
     }
@@ -299,22 +294,6 @@ public class XWPFHeaderFooterPolicy {
     }
 
 
-    private XmlOptions commit(XWPFHeaderFooter wrapper) {
-        XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
-        map.put("urn:schemas-microsoft-com:office:office", "o");
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
-        map.put("urn:schemas-microsoft-com:vml", "v");
-        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
-        map.put("urn:schemas-microsoft-com:office:word", "w10");
-        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
-        xmlOptions.setSaveSuggestedPrefixes(map);
-        return xmlOptions;
-    }
-
     public XWPFHeader getFirstPageHeader() {
         return firstPageHeader;
     }
index da99997215bdfe83f343971ed69ccf60473b1e9f..b22af706ca29b3354fa85e1887b846c7ccf38279 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -155,7 +157,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
     @Override
     protected void onDocumentRead() throws IOException {
         try {
-            DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
             ctDocument = doc.getDocument();
 
             initFootnotes();
@@ -205,7 +207,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
                     header.onDocumentRead();
                 } else if (relation.equals(XWPFRelation.COMMENT.getRelation())) {
                     // TODO Create according XWPFComment class, extending POIXMLDocumentPart
-                    CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                    CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
                     for (CTComment ctcomment : cmntdoc.getComments().getCommentArray()) {
                         comments.add(new XWPFComment(ctcomment, this));
                     }
@@ -258,7 +260,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
                 this.footnotes = (XWPFFootnotes) p;
                 this.footnotes.onDocumentRead();
             } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) {
-                EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+                EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
 
                 for (CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) {
                     endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
@@ -448,7 +450,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
             throw new IllegalStateException("Expecting one Styles document part, but found " + parts.length);
         }
 
-        StylesDocument sd = StylesDocument.Factory.parse(parts[0].getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+        StylesDocument sd = StylesDocument.Factory.parse(parts[0].getInputStream(), DEFAULT_XML_OPTIONS);
         return sd.getStyles();
     }
 
@@ -704,17 +706,6 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
     protected void commit() throws IOException {
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDocument1.type.getName().getNamespaceURI(), "document"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
-        map.put("urn:schemas-microsoft-com:office:office", "o");
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
-        map.put("urn:schemas-microsoft-com:vml", "v");
-        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
-        map.put("urn:schemas-microsoft-com:office:word", "w10");
-        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
-        xmlOptions.setSaveSuggestedPrefixes(map);
 
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
index eaf28e319e14b78b8a9dcb6cd6ac2127fd2c1374..8268ff6505ab37931e031ba4b6bdfde7d9f42173 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -28,7 +28,6 @@ import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
@@ -79,17 +78,6 @@ public class XWPFFooter extends XWPFHeaderFooter {
     protected void commit() throws IOException {
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "ftr"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
-        map.put("urn:schemas-microsoft-com:office:office", "o");
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
-        map.put("urn:schemas-microsoft-com:vml", "v");
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
-        map.put("urn:schemas-microsoft-com:office:word", "w10");
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
-        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
-        xmlOptions.setSaveSuggestedPrefixes(map);
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
         super._getHdrFtr().save(out, xmlOptions);
@@ -103,7 +91,7 @@ public class XWPFFooter extends XWPFHeaderFooter {
         InputStream is;
         try {
             is = getPackagePart().getInputStream();
-            ftrDocument = FtrDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            ftrDocument = FtrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             headerFooter = ftrDocument.getFtr();
             // parse the document with cursor and add
             // the XmlObject to its lists
index ecdf71d791c19ef5eaaf694999820dc6ac451c41..c97ccd4507415f64cd5471903ffaf9b50be31f07 100644 (file)
 
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -32,11 +32,10 @@ import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
-import org.apache.xmlbeans.XmlException;\r
-import org.apache.xmlbeans.XmlOptions;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;\r
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument;\r
 \r
 /**\r
@@ -72,7 +71,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
         FootnotesDocument notesDoc;\r
         try {\r
             InputStream is = getPackagePart().getInputStream();\r
-            notesDoc = FootnotesDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            notesDoc = FootnotesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             ctFootnotes = notesDoc.getFootnotes();
         } catch (XmlException e) {
             throw new POIXMLException();
@@ -88,10 +87,6 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
     protected void commit() throws IOException {\r
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);\r
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes"));\r
-        Map<String, String> map = new HashMap<String, String>();\r
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");\r
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");\r
-        xmlOptions.setSaveSuggestedPrefixes(map);\r
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
         ctFootnotes.save(out, xmlOptions);
index ccba7a00dab259d83379df7913ae15383f75dd8b..02157278979c311c08166c6a12f0953306a82063 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -28,7 +28,6 @@ import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -77,17 +76,6 @@ public class XWPFHeader extends XWPFHeaderFooter {
     protected void commit() throws IOException {
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "hdr"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
-        map.put("urn:schemas-microsoft-com:office:office", "o");
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
-        map.put("urn:schemas-microsoft-com:vml", "v");
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
-        map.put("urn:schemas-microsoft-com:office:word", "w10");
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
-        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
-        xmlOptions.setSaveSuggestedPrefixes(map);
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
         super._getHdrFtr().save(out, xmlOptions);
@@ -106,7 +94,7 @@ public class XWPFHeader extends XWPFHeaderFooter {
         InputStream is;
         try {
             is = getPackagePart().getInputStream();
-            hdrDocument = HdrDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            hdrDocument = HdrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             headerFooter = hdrDocument.getHdr();
             // parse the document with cursor and add
             // the XmlObject to its lists
index a2f03de09f4dd7dc287d55b856cf033d5609f24f..7059df9e2789a3c0669786e2991938f957fc2e69 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -32,7 +32,6 @@ import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;
@@ -76,7 +75,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
         InputStream is;\r
         is = getPackagePart().getInputStream();\r
         try {\r
-            numberingDoc = NumberingDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+            numberingDoc = NumberingDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);\r
             ctNumbering = numberingDoc.getNumbering();\r
             //get any Nums\r
             for (CTNum ctNum : ctNumbering.getNumArray()) {\r
@@ -98,17 +97,6 @@ public class XWPFNumbering extends POIXMLDocumentPart {
     protected void commit() throws IOException {\r
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);\r
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "numbering"));\r
-        Map<String, String> map = new HashMap<String, String>();\r
-        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");\r
-        map.put("urn:schemas-microsoft-com:office:office", "o");\r
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");\r
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
-        map.put("urn:schemas-microsoft-com:vml", "v");
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
-        map.put("urn:schemas-microsoft-com:office:word", "w10");
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
-        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
-        xmlOptions.setSaveSuggestedPrefixes(map);
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
         ctNumbering.save(out, xmlOptions);
index 860aff25e013ed9bf23c2f94328f1b536f7c97a0..99f63609e93acf9620a53d1cb8102e9a18a00a9a 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
@@ -25,7 +27,6 @@ import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.util.Internal;
@@ -177,7 +178,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
             if (pict instanceof XmlAnyTypeImpl) {\r
                 // Pesky XmlBeans bug - see Bugzilla #49934\r
                 try {\r
-                    pict = CTPicture.Factory.parse(pict.toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS);\r
+                    pict = CTPicture.Factory.parse(pict.toString(), DEFAULT_XML_OPTIONS);\r
                 } catch (XmlException e) {\r
                     throw new POIXMLException(e);\r
                 }\r
@@ -958,7 +959,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
                             "<pic:pic xmlns:pic=\"" + CTPicture.type.getName().getNamespaceURI() + "\" />" +\r
                             "</a:graphicData>" +\r
                             "</a:graphic>";\r
-            inline.set(XmlToken.Factory.parse(xml, POIXMLDocumentPart.DEFAULT_XML_OPTIONS));\r
+            inline.set(XmlToken.Factory.parse(xml, DEFAULT_XML_OPTIONS));\r
 \r
             // Setup the inline\r
             inline.setDistT(0);
index 1dbc295875422183b1c7d7e0bc0131b82817797d..66408c448fb6ebc8643006cc94e23730fa102f72 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigInteger;
 import java.security.SecureRandom;
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -33,7 +33,6 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.poifs.crypt.CryptoFunctions;
 import org.apache.poi.poifs.crypt.HashAlgorithm;
-import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocProtect;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
@@ -383,9 +382,6 @@ public class XWPFSettings extends POIXMLDocumentPart {
 
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTSettings.type.getName().getNamespaceURI(), "settings"));
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
-        xmlOptions.setSaveSuggestedPrefixes(map);
 
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
@@ -404,7 +400,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
 
     private void readFrom(InputStream inputStream) {
         try {
-            ctSettings = SettingsDocument.Factory.parse(inputStream, POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getSettings();
+            ctSettings = SettingsDocument.Factory.parse(inputStream, DEFAULT_XML_OPTIONS).getSettings();
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
index 3be62b6717604c72da88bbcc40f47df94e287545..d9632926b22a7d34fe0ad890b3238bd1ab79d628 100644 (file)
 
 package org.apache.poi.xwpf.usermodel;
 
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -32,17 +32,16 @@ import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.DocumentHelper;
-import org.apache.xmlbeans.XmlException;\r
-import org.apache.xmlbeans.XmlOptions;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocDefaults;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrDefault;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPrDefault;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;\r
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles;\r
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocDefaults;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrDefault;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPrDefault;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;\r
 \r
 /**\r
@@ -83,7 +82,7 @@ public class XWPFStyles extends POIXMLDocumentPart {
         StylesDocument stylesDoc;\r
         try {\r
             InputStream is = getPackagePart().getInputStream();\r
-            stylesDoc = StylesDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+            stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             setStyles(stylesDoc.getStyles());
             latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
         } catch (XmlException e) {
@@ -99,10 +98,6 @@ public class XWPFStyles extends POIXMLDocumentPart {
 \r
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);\r
         xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles"));\r
-        Map<String, String> map = new HashMap<String, String>();\r
-        map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");\r
-        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");\r
-        xmlOptions.setSaveSuggestedPrefixes(map);\r
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
         ctStyles.save(out, xmlOptions);
diff --git a/src/ooxml/resources/org/apache/poi/schemas/ooxmlSchemas.xsdconfig b/src/ooxml/resources/org/apache/poi/schemas/ooxmlSchemas.xsdconfig
new file mode 100644 (file)
index 0000000..3121e45
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+   ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+   ====================================================================\r
+-->\r
+<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">\r
+\r
+  <xb:namespace uri="urn:schemas-microsoft-com:office:office">\r
+    <xb:package>com.microsoft.schemas.office.office</xb:package>\r
+  </xb:namespace>\r
+\r
+  <xb:namespace uri="urn:schemas-microsoft-com:office:excel">\r
+    <xb:package>com.microsoft.schemas.office.excel</xb:package>\r
+  </xb:namespace>\r
+\r
+  <xb:namespace uri="urn:schemas-microsoft-com:office:word">\r
+    <xb:package>com.microsoft.schemas.office.word</xb:package>\r
+  </xb:namespace>\r
+\r
+  <xb:namespace uri="urn:schemas-microsoft-com:office:powerpoint">\r
+    <xb:package>com.microsoft.schemas.office.powerpoint</xb:package>\r
+  </xb:namespace>\r
+\r
+  <xb:namespace uri="urn:schemas-microsoft-com:vml">\r
+    <xb:package>com.microsoft.schemas.vml</xb:package>\r
+  </xb:namespace>\r
+\r
+</xb:config>
\ No newline at end of file
index f3328d9e6cd60ee8550339b4f0bf8d5ec18c2e59..0687c4b323b552477026550bbcf10d6067c7e462 100644 (file)
@@ -49,7 +49,7 @@ import org.junit.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt;
 
-import schemasMicrosoftComVml.CTShape;
+import com.microsoft.schemas.vml.CTShape;
 
 /**
  * @author Yegor Kozlov
@@ -221,7 +221,7 @@ public final class TestXSSFComment extends BaseTestCellComment  {
                     .getSheetAt(0).getCommentsTable(true);
             XSSFVMLDrawing vml = ((SXSSFWorkbook) wb).getXSSFWorkbook()
                     .getSheetAt(0).getVMLDrawing(true);
-            schemasMicrosoftComVml.CTShape vmlShape1 = vml.newCommentShape();
+            CTShape vmlShape1 = vml.newCommentShape();
             if (ca.isSet()) {
                 String position = ca.getCol1() + ", 0, " + ca.getRow1()
                         + ", 0, " + ca.getCol2() + ", 0, " + ca.getRow2()
@@ -235,7 +235,7 @@ public final class TestXSSFComment extends BaseTestCellComment  {
             shape1.setColumn(ca.getCol1());
             shape1.setRow(ca.getRow1());
 
-            schemasMicrosoftComVml.CTShape vmlShape2 = vml.newCommentShape();
+            CTShape vmlShape2 = vml.newCommentShape();
             if (ca.isSet()) {
                 String position = ca.getCol1() + ", 0, " + ca.getRow1()
                         + ", 0, " + ca.getCol2() + ", 0, " + ca.getRow2()
index 5bb3acd0fb2bbc275ec483e321214b766833d7a2..3b3d88b66f2994097d9357c257e3d21eeeb37baa 100644 (file)
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.math.BigInteger;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.POIDataSamples;
 import org.apache.xmlbeans.XmlObject;
 
-import schemasMicrosoftComVml.*;
-import schemasMicrosoftComOfficeOffice.CTShapeLayout;
-import schemasMicrosoftComOfficeOffice.STConnectType;
-import schemasMicrosoftComOfficeOffice.STInsetMode;
-import schemasMicrosoftComOfficeExcel.CTClientData;
-import schemasMicrosoftComOfficeExcel.STObjectType;
+import com.microsoft.schemas.office.excel.CTClientData;
+import com.microsoft.schemas.office.excel.STObjectType;
+import com.microsoft.schemas.office.office.CTShapeLayout;
+import com.microsoft.schemas.office.office.STConnectType;
+import com.microsoft.schemas.office.office.STInsetMode;
+import com.microsoft.schemas.vml.CTShadow;
+import com.microsoft.schemas.vml.CTShape;
+import com.microsoft.schemas.vml.CTShapetype;
+import com.microsoft.schemas.vml.STExt;
+import com.microsoft.schemas.vml.STTrueFalse;
+
+import junit.framework.TestCase;
 
 /**
  * @author Yegor Kozlov