return partList.getUnusedPartIndex(nameTemplate);
}
+ /**
+ * @return true if the package is in Strict OOXML format
+ * @since POI 5.0.1
+ */
+ public boolean isStrictOoxmlFormat() {
+ PackageRelationshipCollection coreDocRelationships = getRelationshipsByType(
+ PackageRelationshipTypes.STRICT_CORE_DOCUMENT);
+ return coreDocRelationships.size() > 0;
+ }
+
/**
* Has close been called already?
*/
private static final String CONTENT_EXT_PROPS = "application/vnd.openxmlformats-officedocument.extended-properties+xml";
private static final POIDataSamples xlsSamples = POIDataSamples.getSpreadSheetInstance();
+ @Test
+ void isStrictOoxmlFormat() throws IOException, InvalidFormatException {
+ try (OPCPackage p = OPCPackage.open(getSampleFileName("TestPackageCommon.docx"), PackageAccess.READ)) {
+ assertFalse(p.isStrictOoxmlFormat());
+ }
+ try (OPCPackage p = OPCPackage.open(xlsSamples.getFile("sample.xlsx"), PackageAccess.READ)) {
+ assertFalse(p.isStrictOoxmlFormat());
+ }
+ try (OPCPackage p = OPCPackage.open(xlsSamples.getFile("sample.strict.xlsx"), PackageAccess.READ)) {
+ assertTrue(p.isStrictOoxmlFormat());
+ }
+ }
+
+
/**
* Test that just opening and closing the file doesn't alter the document.
*/