From b5153f13955b3a077200efac1390fdf6b4e3b93e Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 22 May 2023 16:00:10 +0000 Subject: [PATCH] [bug-66612] get macrosheet xml (test) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1909994 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/xssf/usermodel/XSSFRelation.java | 16 ++++++++++++++-- .../apache/poi/xssf/usermodel/TestXSSFBugs.java | 13 +++++++++++++ test-data/spreadsheet/xlmmacro.xlsm | Bin 0 -> 8768 bytes 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/xlmmacro.xlsm diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java index 04ec265eaf..712e874267 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java @@ -286,17 +286,29 @@ public final class XSSFRelation extends POIXMLRelation { ); public static final XSSFRelation MACRO_SHEET_BIN = new XSSFRelation( - "application/vnd.ms-excel.macrosheet+xml", + "application/vnd.ms-excel.macrosheet", "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet", "/xl/macroSheets/sheet#.bin" ); + public static final XSSFRelation MACRO_SHEET_XML = new XSSFRelation( + "application/vnd.ms-excel.macrosheet+xml", + "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet", + "/xl/macroSheets/sheet#.xml" + ); + public static final XSSFRelation INTL_MACRO_SHEET_BIN = new XSSFRelation( - "application/vnd.ms-excel.intlmacrosheet+xml", + "application/vnd.ms-excel.intlmacrosheet", "http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet", "/xl/macroSheets/sheet#.bin" ); + public static final XSSFRelation INTL_MACRO_SHEET_XML = new XSSFRelation( + "application/vnd.ms-excel.intlmacrosheet+xml", + "http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet", + "/xl/macroSheets/sheet#.xml" + ); + public static final XSSFRelation DIALOG_SHEET_BIN = new XSSFRelation( null,//TODO: figure out what this should be? "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet", diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 4522797792..a9240a6f0a 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -68,6 +68,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.util.ZipSecureFile; import org.apache.poi.poifs.crypt.Decryptor; @@ -3841,6 +3842,18 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { readByCommonsCompress(temp_excel_poi_decrypt); } + @Test + void getMacrosheet() throws IOException, InvalidFormatException { + try (XSSFWorkbook wb = openSampleWorkbook("xlmmacro.xlsm")) { + PackageRelationshipCollection prc = wb.getPackagePart().getRelationships(); + assertNotNull(prc); + assertEquals(6, prc.size()); + PackageRelationshipCollection prc2 = prc.getRelationships(XSSFRelation.MACRO_SHEET_XML.getRelation()); + assertNotNull(prc2); + assertEquals(1, prc2.size()); + } + } + private static void readByCommonsCompress(File temp_excel_poi) throws IOException { /* read by commons-compress*/ try (ZipFile zipFile = new ZipFile(temp_excel_poi)) { diff --git a/test-data/spreadsheet/xlmmacro.xlsm b/test-data/spreadsheet/xlmmacro.xlsm new file mode 100644 index 0000000000000000000000000000000000000000..5cae057879748f522fe6889fc75d61f2b296ed79 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