]> source.dussan.org Git - poi.git/commitdiff
reuse code
authorPJ Fanning <fanningpj@apache.org>
Sun, 28 Aug 2022 13:49:05 +0000 (13:49 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sun, 28 Aug 2022 13:49:05 +0000 (13:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903737 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLTypeLoader.java
poi-ooxml/src/main/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java
poi-ooxml/src/main/java/org/apache/poi/xssf/model/ParagraphPropertyFetcher.java
poi-ooxml/src/test/java/org/apache/poi/xddf/usermodel/TestXDDFColor.java
poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java

index a73304da9971c1893b68d870474599bdcd097ebd..243f1d7f187e1f5e3962f6c75484cd7aa57bbf04 100644 (file)
@@ -54,7 +54,7 @@ public class POIXMLTypeLoader {
         // DEFAULT_XML_OPTIONS.setUnsynchronized();
 
         Map<String, String> map = new HashMap<>();
-        map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
+        map.put(XSSFRelation.NS_DRAWINGML, "a");
         map.put("http://schemas.openxmlformats.org/drawingml/2006/chart", "c");
         map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
         map.put(PackageNamespaces.MARKUP_COMPATIBILITY, "ve");
index e74615d4a79d836d1d6d5987dc6b80f51cbf90e9..c2731adc6c77731bb2fde025e93b8ea5ea7aa9c9 100644 (file)
@@ -20,6 +20,7 @@
 package org.apache.poi.xslf.model;
 
 import static org.apache.poi.ooxml.util.XPathHelper.selectProperty;
+import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_DRAWINGML;
 import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_PRESENTATIONML;
 
 import java.util.function.Consumer;
@@ -46,7 +47,7 @@ public final class ParagraphPropertyFetcher<T> extends PropertyFetcher<T> {
 
 
     static final String PML_NS = NS_PRESENTATIONML;
-    static final String DML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
+    static final String DML_NS = NS_DRAWINGML;
 
     private static final QName[] TX_BODY = { new QName(PML_NS, "txBody") };
     private static final QName[] LST_STYLE = { new QName(DML_NS, "lstStyle") };
index c60905b23579d33077cb052055e80fc2ee440ed8..cec0e475e142a456b3316cab58965d191f7f5b7c 100644 (file)
@@ -26,12 +26,13 @@ import org.apache.poi.ooxml.POIXMLDocument;
 import org.apache.poi.ooxml.POIXMLRelation;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.apache.poi.util.Beta;
+import org.apache.poi.xssf.usermodel.XSSFRelation;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 @SuppressWarnings({"unused", "WeakerAccess"})
 @Beta
 public final class XSLFRelation extends POIXMLRelation {
-    /* package */ static final String NS_DRAWINGML = "http://schemas.openxmlformats.org/drawingml/2006/main";
+    /* package */ static final String NS_DRAWINGML = XSSFRelation.NS_DRAWINGML;
 
     /**
      * A map to lookup POIXMLRelation by its relation type
index fe6572d658bf64a3eece9d4189740e24879c0017..1dbaee537f3bce90b2d9bbbd0bce4b127e611bf7 100644 (file)
@@ -60,6 +60,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_DRAWINGML;
 import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_PRESENTATIONML;
 
 /**
@@ -73,7 +74,7 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
         T parse(XMLStreamReader reader) throws XmlException;
     }
 
-    static final String DML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
+    static final String DML_NS = NS_DRAWINGML;
     static final String PML_NS = NS_PRESENTATIONML;
 
     private static final QName[] NV_CONTAINER = {
index 00f40f790c6bed8b99ca0eed5fc173ce07530b65..3e9b1bda636017ab7470ddff1fe1af409bd17aa5 100644 (file)
@@ -24,6 +24,8 @@ import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.poi.util.Internal;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_DRAWINGML;
+
 /**
  *  Used internally to navigate the paragraph text style hierarchy within a shape and fetch properties
 */
@@ -54,7 +56,7 @@ public abstract class ParagraphPropertyFetcher<T> {
 
         XmlObject[] o = shape.selectPath(
                 "declare namespace xdr='http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing' " +
-                "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' " +
+                "declare namespace a='" + NS_DRAWINGML + "' " +
                 ".//xdr:txBody/a:lstStyle/a:lvl" + (_level + 1) + "pPr"
         );
         if (o.length == 1) {
index 7eb01c29a77d31ad38ee561798391ff1b36d9bb6..e4b7fa0ecddad8c9dee02c7c2b020d6f9962d636 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xddf.usermodel;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_DRAWINGML;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -38,7 +39,7 @@ import org.xmlunit.builder.Input;
 import org.xmlunit.diff.Diff;
 
 class TestXDDFColor {
-    private static final String XMLNS = "xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/>";
+    private static final String XMLNS = "xmlns:a=\"" + NS_DRAWINGML + "\"/>";
 
     @Test
     void testSchemeColor() throws IOException {
index 807a6bc3dfae532371751515e4f7c5d9d64b27e7..d689226fc471c6a328a5d9b081ca00ff52189304 100644 (file)
@@ -16,6 +16,7 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_DRAWINGML;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -165,7 +166,7 @@ class TestXSSFDrawing {
         // Ensure it got the right namespaces
         String xml = ctDrawing.toString();
         assertTrue(xml.contains("xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\""));
-        assertTrue(xml.contains("xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\""));
+        assertTrue(xml.contains("xmlns:a=\"" + NS_DRAWINGML + '\"'));
 
         checkRewrite(wb2);
         wb2.close();