poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1801901 - in /poi/trunk/src/ooxml: java/org/apache/poi/POIXMLTypeLoader.java java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
Date Fri, 14 Jul 2017 03:14:30 GMT
Author: onealj
Date: Fri Jul 14 03:14:30 2017
New Revision: 1801901

URL: http://svn.apache.org/viewvc?rev=1801901&view=rev
Log:
bug 61296: consolidate some of the ooxml namespace uri copy-paste in POI, prepare to make
these usable by downstream libraries like Tika

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java?rev=1801901&r1=1801900&r2=1801901&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java Fri Jul 14 03:14:30 2017
@@ -31,6 +31,7 @@ import java.util.Map;
 
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.poi.openxml4j.opc.PackageNamespaces;
 import org.apache.poi.util.DocumentHelper;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.SchemaTypeLoader;
@@ -49,6 +50,13 @@ import org.xml.sax.SAXException;
 public class POIXMLTypeLoader {
 
     private static ThreadLocal<ClassLoader> classLoader = new ThreadLocal<ClassLoader>();
+
+    // TODO: Do these have a good home like o.a.p.openxml4j.opc.PackageNamespaces and PackageRelationshipTypes?
+    // These constants should be common to all of POI and easy to use by other applications
such as Tika
+    private static final String MS_OFFICE_URN = "urn:schemas-microsoft-com:office:office";
+    private static final String MS_EXCEL_URN = "urn:schemas-microsoft-com:office:excel";
+    private static final String MS_WORD_URN = "urn:schemas-microsoft-com:office:word";
+    private static final String MS_VML_URN = "urn:schemas-microsoft-com:vml";
     
     public static final XmlOptions DEFAULT_XML_OPTIONS;
     static {
@@ -66,17 +74,17 @@ public class POIXMLTypeLoader {
         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/drawingml/2006/wordprocessingDrawing",
"wp");
-        map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
+        map.put(PackageNamespaces.MARKUP_COMPATIBILITY, "ve");
         map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
         map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
         map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
         map.put("http://schemas.openxmlformats.org/presentationml/2006/main", "p");
         map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
         map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
-        map.put("urn:schemas-microsoft-com:office:office", "o");
-        map.put("urn:schemas-microsoft-com:office:excel", "x");
-        map.put("urn:schemas-microsoft-com:office:word", "w10");
-        map.put("urn:schemas-microsoft-com:vml", "v");
+        map.put(MS_OFFICE_URN, "o");
+        map.put(MS_EXCEL_URN, "x");
+        map.put(MS_WORD_URN, "w10");
+        map.put(MS_VML_URN, "v");
         DEFAULT_XML_OPTIONS.setSaveSuggestedPrefixes(Collections.unmodifiableMap(map));
     }
     

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java?rev=1801901&r1=1801900&r2=1801901&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
Fri Jul 14 03:14:30 2017
@@ -30,6 +30,7 @@ import org.apache.poi.openxml4j.exceptio
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
 import org.apache.poi.openxml4j.opc.ContentTypes;
 import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageNamespaces;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagePartName;
 import org.apache.poi.openxml4j.opc.PackageProperties;
@@ -46,7 +47,7 @@ public final class PackagePropertiesPart
 
 	public final static String NAMESPACE_DC_URI = "http://purl.org/dc/elements/1.1/";
 
-	public final static String NAMESPACE_CP_URI = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
+	public final static String NAMESPACE_CP_URI = PackageNamespaces.CORE_PROPERTIES;
 
 	public final static String NAMESPACE_DCTERMS_URI = "http://purl.org/dc/terms/";
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java?rev=1801901&r1=1801900&r2=1801901&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java Fri
Jul 14 03:14:30 2017
@@ -260,7 +260,7 @@ public class TestRelationships extends T
     			partB.getRelationship("rId1").getTargetURI().toString());
     	// Check core too
     	assertEquals("/docProps/core.xml",
-    			pkg.getRelationshipsByType("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties").getRelationship(0).getTargetURI().toString());
+    			pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_PROPERTIES).getRelationship(0).getTargetURI().toString());
     	
     	
     	// Add some more



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


Mime
View raw message