You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/01/24 14:15:01 UTC
svn commit: r614872 -
/poi/branches/ooxml/src/scratchpad/ooxml-src/org/apache/poi/hxf/HXFDocument.java
Author: nick
Date: Thu Jan 24 05:14:58 2008
New Revision: 614872
URL: http://svn.apache.org/viewvc?rev=614872&view=rev
Log:
Tidy up some duplicated code, now that openxml4j has RelationshipSource
Modified:
poi/branches/ooxml/src/scratchpad/ooxml-src/org/apache/poi/hxf/HXFDocument.java
Modified: poi/branches/ooxml/src/scratchpad/ooxml-src/org/apache/poi/hxf/HXFDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/ooxml-src/org/apache/poi/hxf/HXFDocument.java?rev=614872&r1=614871&r2=614872&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/ooxml-src/org/apache/poi/hxf/HXFDocument.java (original)
+++ poi/branches/ooxml/src/scratchpad/ooxml-src/org/apache/poi/hxf/HXFDocument.java Thu Jan 24 05:14:58 2008
@@ -24,9 +24,7 @@
import org.apache.poi.POIXMLDocument;
import org.apache.poi.poifs.common.POIFSConstants;
-import org.apache.poi.poifs.storage.HeaderBlockConstants;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.LongField;
import org.apache.xmlbeans.XmlException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -40,6 +38,7 @@
import org.openxml4j.opc.PackageRelationship;
import org.openxml4j.opc.PackageRelationshipCollection;
import org.openxml4j.opc.PackagingURIHelper;
+import org.openxml4j.opc.RelationshipSource;
import org.openxml4j.opc.internal.PackagePropertiesPart;
import org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties;
import org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument;
@@ -147,9 +146,8 @@
* or null if none found.
* @param relationType The relation content type to search for
* @throws IllegalArgumentException If we find more than one part of that type
- * TODO: this sucks! Make Package and PackagePart implement common intf that defines getRelationshipsByType & friends
*/
- protected PackagePart getSinglePartByRelationType(String relationType, PackagePart part) throws IllegalArgumentException, OpenXML4JException {
+ protected PackagePart getSinglePartByRelationType(String relationType, RelationshipSource part) throws IllegalArgumentException, OpenXML4JException {
PackageRelationshipCollection rels =
part.getRelationshipsByType(relationType);
if(rels.size() == 0) {
@@ -170,16 +168,7 @@
* @throws IllegalArgumentException If we find more than one part of that type
*/
protected PackagePart getSinglePartByRelationType(String relationType) throws IllegalArgumentException, OpenXML4JException {
- PackageRelationshipCollection rels =
- container.getRelationshipsByType(relationType);
- if(rels.size() == 0) {
- return null;
- }
- if(rels.size() > 1) {
- throw new IllegalArgumentException("Found " + rels.size() + " relations for the type " + relationType + ", should only ever be one!");
- }
- PackageRelationship rel = rels.getRelationship(0);
- return getPackagePart(rel);
+ return getSinglePartByRelationType(relationType, container);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org