diff --git a/src/documentation/content/xdocs/spreadsheet/quick-guide.xml b/src/documentation/content/xdocs/spreadsheet/quick-guide.xml index d577d0974..eeca60ebe 100644 --- a/src/documentation/content/xdocs/spreadsheet/quick-guide.xml +++ b/src/documentation/content/xdocs/spreadsheet/quick-guide.xml @@ -22,10 +22,6 @@
Busy Developers' Guide to HSSF and XSSF Features - - - -
Busy Developers' Guide to Features diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index d9045f2be..26cc4a93b 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,8 @@ + 46419 - Fixed compatibility issue with OpenOffice 3.0 + 47559 - Fixed compatibility issue with Excel 2008 Max sp2 47540 - Fix for saving custom and extended OOXML properties 47535 - Fixed WordExtractor to tolerate files with empty footnote block 47517 - Fixed ExtractorFactory to support .xltx and .dotx files diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java index 0deb73731..ab15fdf68 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java @@ -136,7 +136,7 @@ public final class PackageRelationship { /* Getters */ - public URI getContainerPartRelationship() { + public static URI getContainerPartRelationship() { return containerRelationshipPart; } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java index b53903df9..2b6dcc63f 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java @@ -259,11 +259,14 @@ public final class PackagingURIHelper { * The source part URI. * @param targetURI * The target part URI. + * @param msCompatible if true then remove leading slash from the relativized URI. + * This flag violates [M1.4]: A part name shall start with a forward slash ('/') character, but + * allows generating URIs compatible with MS Office and OpenOffice. * @return A fully relativize part name URI ('word/media/image1.gif', * '/word/document.xml' => 'media/image1.gif') else * null. */ - public static URI relativizeURI(URI sourceURI, URI targetURI) { + public static URI relativizeURI(URI sourceURI, URI targetURI, boolean msCompatible) { StringBuilder retVal = new StringBuilder(); String[] segmentsSource = sourceURI.getPath().split("/", -1); String[] segmentsTarget = targetURI.getPath().split("/", -1); @@ -283,6 +286,15 @@ public final class PackagingURIHelper { // If the source is the root, then the relativized // form must actually be an absolute URI if(sourceURI.toString().equals("/")) { + String path = targetURI.getPath(); + if(msCompatible && path.charAt(0) == '/') { + try { + targetURI = new URI(path.substring(1)); + } catch (Exception e) { + System.err.println(e); + return null; + } + } return targetURI; } @@ -358,7 +370,22 @@ public final class PackagingURIHelper { } } - /** + /** + * Fully relativize the source part URI against the target part URI. + * + * @param sourceURI + * The source part URI. + * @param targetURI + * The target part URI. + * @return A fully relativize part name URI ('word/media/image1.gif', + * '/word/document.xml' => 'media/image1.gif') else + * null. + */ + public static URI relativizeURI(URI sourceURI, URI targetURI) { + return relativizeURI(sourceURI, targetURI, false); + } + + /** * Resolve a source uri against a target. * * @param sourcePartUri diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java index cfe0fb0a5..c8bbb96af 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java @@ -163,7 +163,7 @@ public final class ZipPartMarshaller implements PartMarshaller { } else { URI targetURI = rel.getTargetURI(); targetValue = PackagingURIHelper.relativizeURI( - sourcePartURI, targetURI).getPath(); + sourcePartURI, targetURI, true).getPath(); if (targetURI.getRawFragment() != null) { targetValue += "#" + targetURI.getRawFragment(); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 5453b33b1..3ff17e456 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -30,6 +30,7 @@ import javax.xml.namespace.QName; import org.apache.poi.POIXMLDocument; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; +import org.apache.poi.POIXMLProperties; import org.apache.poi.hssf.record.formula.SheetNameFormatter; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.OPCPackage; @@ -228,6 +229,10 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable