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;
public static final XSLFRelation HYPERLINK = new XSLFRelation(
null,
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
+ PackageRelationshipTypes.HYPERLINK_PART,
null
);
);
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(
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";
/**
* 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.
*/
// 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());
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;
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());