diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-04-19 09:56:05 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-04-19 09:56:05 +0000 |
commit | 1899bee1b9b69ae184386fff72cb11aa123b78d8 (patch) | |
tree | ba4ac061b6a1267a3c10b393882907fb92b46431 /poi-ooxml | |
parent | 5955dd75de90b176b2871f6fb4a792b523949961 (diff) | |
download | poi-1899bee1b9b69ae184386fff72cb11aa123b78d8.tar.gz poi-1899bee1b9b69ae184386fff72cb11aa123b78d8.zip |
refactor some code
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917136 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
4 files changed, 14 insertions, 10 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java index cec0e475e1..61e79686e0 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.poi.ooxml.POIXMLDocument; import org.apache.poi.ooxml.POIXMLRelation; +import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; import org.apache.poi.sl.usermodel.PictureData.PictureType; import org.apache.poi.util.Beta; import org.apache.poi.xssf.usermodel.XSSFRelation; @@ -118,7 +119,7 @@ public final class XSLFRelation extends POIXMLRelation { public static final XSLFRelation HYPERLINK = new XSLFRelation( null, - "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", + PackageRelationshipTypes.HYPERLINK_PART, null ); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java index 4566e6113a..f8d1f3e236 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java @@ -138,7 +138,7 @@ public final class XWPFRelation extends POIXMLRelation { ); public static final XWPFRelation HYPERLINK = new XWPFRelation( null, - "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", + PackageRelationshipTypes.HYPERLINK_PART, null ); public static final XWPFRelation COMMENT = new XWPFRelation( diff --git a/poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java b/poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java index fe370a6fe5..7bbbea564b 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java +++ b/poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java @@ -33,14 +33,15 @@ import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.poi.openxml4j.OpenXML4JTestDataSamples; +import org.apache.poi.xssf.usermodel.XSSFRelation; import org.junit.jupiter.api.Test; class TestRelationships { private static final String HYPERLINK_REL_TYPE = - "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; + PackageRelationshipTypes.HYPERLINK_PART; private static final String COMMENTS_REL_TYPE = - "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"; + XSSFRelation.SHEET_COMMENTS.getRelation(); private static final String SHEET_WITH_COMMENTS = "/xl/worksheets/sheet1.xml"; @@ -48,7 +49,7 @@ class TestRelationships { /** * Test relationships are correctly loaded. This at the moment fails (as of r499) - * whenever a document is loaded before its correspondig .rels file has been found. + * whenever a document is loaded before its corresponding .rels file has been found. * The code in this case assumes there are no relationships defined, but it should * really look also for not yet loaded parts. */ @@ -319,9 +320,10 @@ class TestRelationships { // expected one image assertEquals(1, drawingPart.getRelationshipsByType(IMAGE_PART).size()); // and three hyperlinks - assertEquals(5, drawingPart.getRelationshipsByType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink").size()); + assertEquals(5, drawingPart.getRelationshipsByType(HYPERLINK_REL_TYPE).size()); PackageRelationship rId1 = drawingPart.getRelationship("rId1"); + assertNotNull(rId1); URI parent = drawingPart.getPartName().getURI(); // Hyperlink is not a target of relativize() because it is not resolved based on sourceURI in getTargetURI() // URI rel1 = parent.relativize(rId1.getTargetURI()); diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFCloneSheet.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFCloneSheet.java index e966520bed..bf6499d6ce 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFCloneSheet.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFCloneSheet.java @@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.ooxml.ReferenceRelationship; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; import org.apache.poi.ss.usermodel.BaseTestCloneSheet; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -143,10 +144,10 @@ class TestXSSFCloneSheet extends BaseTestCloneSheet { void testBug63189() throws IOException { try (XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("bug63189.xlsx")) { // given - String linkRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; - String linkTargetUrl = "#Sheet3!A1"; - String imageRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"; - String imageTargetUrl = "/xl/media/image1.png"; + final String linkRelationType = PackageRelationshipTypes.HYPERLINK_PART; + final String linkTargetUrl = "#Sheet3!A1"; + final String imageRelationType = PackageRelationshipTypes.IMAGE_PART; + final String imageTargetUrl = "/xl/media/image1.png"; XSSFSheet srcSheet = workbook.getSheetAt(0); assertEquals("CloneMe", srcSheet.getSheetName()); |