poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1723966 [2/3] - in /poi: site/src/documentation/content/xdocs/ trunk/src/integrationtest/org/apache/poi/ trunk/src/integrationtest/org/apache/poi/stress/ trunk/src/ooxml/java/org/apache/poi/ trunk/src/ooxml/java/org/apache/poi/openxml4j/op...
Date Sun, 10 Jan 2016 20:44:19 GMT
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java Sun Jan 10 20:44:17 2016
@@ -113,17 +113,23 @@ public class ReadOnlySharedStringsTable
 
     /**
      * Like POIXMLDocumentPart constructor
-     *
-     * @param part
-     * @param rel_ignored
-     * @throws IOException
+     * 
+     * @since POI 3.14-Beta1
      */
-    public ReadOnlySharedStringsTable(PackagePart part, PackageRelationship rel_ignored)
-            throws IOException, SAXException {
+    public ReadOnlySharedStringsTable(PackagePart part) throws IOException, SAXException {
         readFrom(part.getInputStream());
     }
 
     /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public ReadOnlySharedStringsTable(PackagePart part, PackageRelationship rel_ignored)
+    throws IOException, SAXException {
+        this(part);
+    }
+    
+    /**
      * Read this shared strings table from an XML file.
      *
      * @param is The input stream containing the XML document.

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java Sun Jan 10 20:44:17 2016
@@ -44,11 +44,22 @@ public class CalculationChain extends PO
         chain = CTCalcChain.Factory.newInstance();
     }
 
-    public CalculationChain(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public CalculationChain(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public CalculationChain(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     public void readFrom(InputStream is) throws IOException {
         try {
             CalcChainDocument doc = CalcChainDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java Sun Jan 10 20:44:17 2016
@@ -60,11 +60,22 @@ public class CommentsTable extends POIXM
         comments.addNewAuthors().addAuthor(DEFAULT_AUTHOR);
     }
 
-    public CommentsTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public CommentsTable(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public CommentsTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     public void readFrom(InputStream is) throws IOException {
         try {
             CommentsDocument doc = CommentsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java Sun Jan 10 20:44:17 2016
@@ -49,11 +49,22 @@ public class ExternalLinksTable extends
         link.addNewExternalBook();
     }
 
-    public ExternalLinksTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public ExternalLinksTable(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public ExternalLinksTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     public void readFrom(InputStream is) throws IOException {
         try {
             ExternalLinkDocument doc = ExternalLinkDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java Sun Jan 10 20:44:17 2016
@@ -61,10 +61,19 @@ public class MapInfo extends POIXMLDocum
 
 	}
 
-	public MapInfo(PackagePart part, PackageRelationship rel)
-			throws IOException {
-		super(part, rel);
-		readFrom(part.getInputStream());
+	/**
+     * @since POI 3.14-Beta1
+     */
+	public MapInfo(PackagePart part) throws IOException {
+	    super(part);
+	    readFrom(part.getInputStream());
+    }	
+	
+   /**
+    * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+    */
+	public MapInfo(PackagePart part, PackageRelationship rel) throws IOException {
+		this(part);
 	}
 
 	public void readFrom(InputStream is) throws IOException {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java Sun Jan 10 20:44:17 2016
@@ -103,9 +103,19 @@ public class SharedStringsTable extends
         _sstDoc.addNewSst();
     }
 
-    public SharedStringsTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public SharedStringsTable(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
+    }    
+    
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    public SharedStringsTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java Sun Jan 10 20:44:17 2016
@@ -55,12 +55,22 @@ public class SingleXmlCells extends POIX
 
 	}
 
-	public SingleXmlCells(PackagePart part, PackageRelationship rel)
-			throws IOException {
-		super(part, rel);
+	/**
+	 * @since POI 3.14-Beta1
+	 */
+	public SingleXmlCells(PackagePart part) throws IOException {
+		super(part);
 		readFrom(part.getInputStream());
 	}
 
+	/**
+	 * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+	 */
+	@Deprecated
+	public SingleXmlCells(PackagePart part, PackageRelationship rel) throws IOException {
+	    this(part);
+	}
+
 	public void readFrom(InputStream is) throws IOException {
 		try {
 			SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java Sun Jan 10 20:44:17 2016
@@ -138,10 +138,21 @@ public class StylesTable extends POIXMLD
         initialize();
     }
 
-    public StylesTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public StylesTable(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
+
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public StylesTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
     
     public void setWorkbook(XSSFWorkbook wb) {
         this.workbook = wb;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java Sun Jan 10 20:44:17 2016
@@ -76,9 +76,11 @@ public class ThemesTable extends POIXMLD
      * Construct a ThemesTable.
      * @param part A PackagePart.
      * @param rel A PackageRelationship.
+     * 
+     * @since POI 3.14-Beta1
      */
-    public ThemesTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    public ThemesTable(PackagePart part) throws IOException {
+        super(part);
         
         try {
            theme = ThemeDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS);
@@ -88,6 +90,14 @@ public class ThemesTable extends POIXMLD
     }
 
     /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public ThemesTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
+    /**
      * Construct a ThemesTable from an existing ThemeDocument.
      * @param theme A ThemeDocument.
      */

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java Sun Jan 10 20:44:17 2016
@@ -95,15 +95,26 @@ public final class XSSFChart extends POI
 	 * the content type must be <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
 	 * @param rel  the package relationship holding this chart,
 	 * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart
+	 * 
+	 * @since POI 3.14-Beta1
 	 */
-	protected XSSFChart(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
-		super(part, rel);
+	protected XSSFChart(PackagePart part) throws IOException, XmlException {
+		super(part);
 
 		chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS).getChartSpace(); 
 		chart = chartSpace.getChart();
 	}
 
 	/**
+	 * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+	 */
+	@Deprecated
+	protected XSSFChart(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
+	    this(part);
+	}
+
+	
+	/**
 	 * Construct a new CTChartSpace bean.
 	 * By default, it's just an empty placeholder for chart objects.
 	 *

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java Sun Jan 10 20:44:17 2016
@@ -51,10 +51,21 @@ public class XSSFChartSheet extends XSSF
 
     protected CTChartsheet chartsheet;
 
-    protected XSSFChartSheet(PackagePart part, PackageRelationship rel) {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    protected XSSFChartSheet(PackagePart part) {
+        super(part);
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFChartSheet(PackagePart part, PackageRelationship rel) {
+        this(part);
+    }
+    
     protected void read(InputStream is) throws IOException {
         //initialize the supeclass with a blank worksheet
         super.read(new ByteArrayInputStream(BLANK_WORKSHEET));

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java Sun Jan 10 20:44:17 2016
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDialogsheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
@@ -33,8 +34,8 @@ import org.openxmlformats.schemas.spread
 public class XSSFDialogsheet extends XSSFSheet implements Sheet{
     protected CTDialogsheet dialogsheet;
 
-    protected XSSFDialogsheet(XSSFSheet sheet) {
-        super(sheet.getPackagePart(), sheet.getPackageRelationship());
+    protected XSSFDialogsheet(XSSFSheet sheet, PackageRelationship rel) {
+        super(sheet.getPackagePart(), rel);
         this.dialogsheet = CTDialogsheet.Factory.newInstance();
         this.worksheet = CTWorksheet.Factory.newInstance();
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java Sun Jan 10 20:44:17 2016
@@ -28,9 +28,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackagePartName;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.Drawing;
 import org.apache.poi.ss.util.CellAddress;
@@ -84,9 +82,11 @@ public final class XSSFDrawing extends P
      * the content type must be <code>application/vnd.openxmlformats-officedocument.drawing+xml</code>
      * @param rel  the package relationship holding this drawing,
      * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
+     * 
+     * @since POI 3.14-Beta1
      */
-    public XSSFDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
-        super(part, rel);
+    public XSSFDrawing(PackagePart part) throws IOException, XmlException {
+        super(part);
         XmlOptions options  = new XmlOptions(DEFAULT_XML_OPTIONS);
         //Removing root element
         options.setLoadReplaceDocumentElement(null);
@@ -94,6 +94,14 @@ public final class XSSFDrawing extends P
     }
 
     /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XSSFDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
+        this(part);
+    }
+    
+    /**
      * Construct a new CTDrawing bean. By default, it's just an empty placeholder for drawing objects
      *
      * @return a new CTDrawing bean
@@ -199,9 +207,10 @@ public final class XSSFDrawing extends P
         int chartNumber = getPackagePart().getPackage().
             getPartsByContentType(XSSFRelation.CHART.getContentType()).size() + 1;
 
-        XSSFChart chart = (XSSFChart) createRelationship(
-                XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber);
-        String chartRelId = chart.getPackageRelationship().getId();
+        RelationPart rp = createRelationship(
+            XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber, false);
+        XSSFChart chart = rp.getDocumentPart();
+        String chartRelId = rp.getRelationship().getId();
 
         XSSFGraphicFrame frame = createGraphicFrame(anchor);
         frame.setChart(chart, chartRelId);
@@ -220,13 +229,13 @@ public final class XSSFDrawing extends P
      * @param pictureIndex the index of the picture in the workbook collection of pictures,
      *   {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
      */
+    @SuppressWarnings("resource")
     protected PackageRelationship addPictureReference(int pictureIndex){
         XSSFWorkbook wb = (XSSFWorkbook)getParent().getParent();
         XSSFPictureData data = wb.getAllPictures().get(pictureIndex);
-        PackagePartName ppName = data.getPackagePart().getPartName();
-        PackageRelationship rel = getPackagePart().addRelationship(ppName, TargetMode.INTERNAL, XSSFRelation.IMAGES.getRelation());
-        addRelation(rel.getId(),new XSSFPictureData(data.getPackagePart(), rel));
-        return rel;
+        XSSFPictureData pic = new XSSFPictureData(data.getPackagePart(), null);
+        RelationPart rp = addRelation(null, XSSFRelation.IMAGES, pic);
+        return rp.getRelationship();
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java Sun Jan 10 20:44:17 2016
@@ -18,26 +18,17 @@
 package org.apache.poi.xssf.usermodel;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.poi.POIXMLDocumentPart;
-import org.apache.poi.POIXMLException;
 import org.apache.poi.POIXMLFactory;
 import org.apache.poi.POIXMLRelation;
-import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
 
 /**
  * Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
- *
- * @author Yegor Kozlov
  */
 public final class XSSFFactory extends POIXMLFactory  {
-    private static final POILogger logger = POILogFactory.getLogger(XSSFFactory.class);
-
-    private XSSFFactory(){
-
+    private XSSFFactory() {
     }
 
     private static final XSSFFactory inst = new XSSFFactory();
@@ -46,32 +37,22 @@ public final class XSSFFactory extends P
         return inst;
     }
 
+    /**
+     * @since POI 3.14-Beta1
+     */
     @Override
-    public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part){
-        POIXMLRelation descriptor = XSSFRelation.getInstance(rel.getRelationshipType());
-        if(descriptor == null || descriptor.getRelationClass() == null){
-            logger.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType());
-            return new POIXMLDocumentPart(part, rel);
-        }
-
-        try {
-            Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass();
-            Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(PackagePart.class, PackageRelationship.class);
-            return constructor.newInstance(part, rel);
-        } catch (Exception e){
-            throw new POIXMLException(e);
-        }
+    protected POIXMLRelation getDescriptor(String relationshipType) {
+        return XSSFRelation.getInstance(relationshipType);
     }
 
+    /**
+     * @since POI 3.14-Beta1
+     */
     @Override
-    public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor){
-        try {
-            Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass();
-            Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor();
-            return constructor.newInstance();
-        } catch (Exception e){
-            throw new POIXMLException(e);
-        }
+    protected POIXMLDocumentPart createDocumentPart
+        (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
+    throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
+        Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(classes);
+        return constructor.newInstance(values);
     }
-
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFMap.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFMap.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFMap.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFMap.java Sun Jan 10 20:44:17 2016
@@ -21,6 +21,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.POIXMLDocumentPart.RelationPart;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.util.Internal;
 import org.apache.poi.xssf.model.MapInfo;
 import org.apache.poi.xssf.model.SingleXmlCells;
@@ -97,15 +99,11 @@ public class XSSFMap {
      * @return the list of all Tables that provide a map rule to this mapping
      */
     public List<XSSFTable> getRelatedTables() {
-
         List<XSSFTable> tables = new ArrayList<XSSFTable>();
-        int sheetNumber = mapInfo.getWorkbook().getNumberOfSheets();
-
-        for (int i = 0; i < sheetNumber; i++) {
-            XSSFSheet sheet = mapInfo.getWorkbook().getSheetAt(i);
-            for (POIXMLDocumentPart p : sheet.getRelations()) {
-                if (p.getPackageRelationship().getRelationshipType().equals(XSSFRelation.TABLE.getRelation())) {
-                    XSSFTable table = (XSSFTable) p;
+        for (Sheet sheet : mapInfo.getWorkbook()) {
+            for (RelationPart rp : ((XSSFSheet)sheet).getRelationParts()) {
+                if (rp.getRelationship().getRelationshipType().equals(XSSFRelation.TABLE.getRelation())) {
+                    XSSFTable table = rp.getDocumentPart();
                     if (table.mapsTo(ctMap.getID())) {
                         tables.add(table);
                     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java Sun Jan 10 20:44:17 2016
@@ -68,12 +68,22 @@ public class XSSFPictureData extends POI
      * @param part the package part holding the drawing data,
      * @param rel  the package relationship holding this drawing,
      * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
+     * 
+     * @since POI 3.14-Beta1
      */
-    protected XSSFPictureData(PackagePart part, PackageRelationship rel) {
-        super(part, rel);
+    protected XSSFPictureData(PackagePart part) {
+        super(part);
     }
 
     /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFPictureData(PackagePart part, PackageRelationship rel) {
+        this(part);
+    }
+    
+    /**
      * Gets the picture data as a byte array.
      * <p>
      * Note, that this call might be expensive since all the picture data is copied into a temporary byte array.

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCache.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCache.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCache.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCache.java Sun Jan 10 20:44:17 2016
@@ -51,13 +51,23 @@ public class XSSFPivotCache extends POIX
      *
      * @param part - The package part that holds xml data representing this pivot cache definition.
      * @param rel - the relationship of the given package part in the underlying OPC package
+     * 
+     * @since POI 3.14-Beta1
      */
     @Beta
-    protected XSSFPivotCache(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    protected XSSFPivotCache(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFPivotCache(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     @Beta
     protected void readFrom(InputStream is) throws IOException {
 	try {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java Sun Jan 10 20:44:17 2016
@@ -58,13 +58,23 @@ public class XSSFPivotCacheDefinition ex
      *
      * @param part - The package part that holds xml data representing this pivot cache definition.
      * @param rel - the relationship of the given package part in the underlying OPC package
+     * 
+     * @since POI 3.14-Beta1
      */
     @Beta
-    protected XSSFPivotCacheDefinition(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    protected XSSFPivotCacheDefinition(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFPivotCacheDefinition(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     @Beta
     public void readFrom(InputStream is) throws IOException {
 	try {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheRecords.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheRecords.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheRecords.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheRecords.java Sun Jan 10 20:44:17 2016
@@ -48,13 +48,23 @@ public class XSSFPivotCacheRecords exten
      *
      * @param part - The package part that holds xml data representing this pivot cache records.
      * @param rel - the relationship of the given package part in the underlying OPC package
+     * 
+     * @since POI 3.14-Beta1
      */
     @Beta
-    protected XSSFPivotCacheRecords(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    protected XSSFPivotCacheRecords(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFPivotCacheRecords(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     @Beta
     protected void readFrom(InputStream is) throws IOException {
 	try {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java Sun Jan 10 20:44:17 2016
@@ -88,13 +88,23 @@ public class XSSFPivotTable extends POIX
      *
      * @param part - The package part that holds xml data representing this pivot table.
      * @param rel - the relationship of the given package part in the underlying OPC package
+     * 
+     * @since POI 3.14-Beta1
      */
     @Beta
-    protected XSSFPivotTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    protected XSSFPivotTable(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFPivotTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     @Beta
     public void readFrom(InputStream is) throws IOException {
 	try {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java Sun Jan 10 20:44:17 2016
@@ -347,8 +347,7 @@ public final class XSSFRelation extends
 
     private XSSFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
         super(type, rel, defaultName, cls);
-
-        if(cls != null && !_table.containsKey(rel)) _table.put(rel, this);
+        _table.put(rel, this);
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Jan 10 20:44:17 2016
@@ -162,17 +162,27 @@ public class XSSFSheet extends POIXMLDoc
 
     /**
      * Creates an XSSFSheet representing the given package part and relationship.
-     * Should only be called by XSSFWorkbook when reading in an exisiting file.
+     * Should only be called by XSSFWorkbook when reading in an existing file.
      *
-     * @param part - The package part that holds xml data represenring this sheet.
+     * @param part - The package part that holds xml data representing this sheet.
      * @param rel - the relationship of the given package part in the underlying OPC package
+     * 
+     * @since POI 3.14-Beta1
      */
-    protected XSSFSheet(PackagePart part, PackageRelationship rel) {
-        super(part, rel);
+    protected XSSFSheet(PackagePart part) {
+        super(part);
         dataValidationHelper = new XSSFDataValidationHelper(this);
     }
 
     /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFSheet(PackagePart part, PackageRelationship rel) {
+        this(part);
+    }
+    
+    /**
      * Returns the parent XSSFWorkbook
      *
      * @return the parent XSSFWorkbook
@@ -204,12 +214,13 @@ public class XSSFSheet extends POIXMLDoc
         initRows(worksheet);
         columnHelper = new ColumnHelper(worksheet);
         // Look for bits we're interested in
-        for(POIXMLDocumentPart p : getRelations()){
+        for(RelationPart rp : getRelationParts()){
+            POIXMLDocumentPart p = rp.getDocumentPart();
             if(p instanceof CommentsTable) {
                sheetComments = (CommentsTable)p;
             }
             if(p instanceof XSSFTable) {
-               tables.put( p.getPackageRelationship().getId(), (XSSFTable)p );
+               tables.put( rp.getRelationship().getId(), (XSSFTable)p );
             }
             if(p instanceof XSSFPivotTable) {
                 getWorkbook().getPivotTables().add((XSSFPivotTable) p);
@@ -449,10 +460,11 @@ public class XSSFSheet extends POIXMLDoc
         CTDrawing ctDrawing = getCTDrawing();
         if (ctDrawing != null) {
             // Search the referenced drawing in the list of the sheet's relations
-            for (POIXMLDocumentPart p : getRelations()){
+            for (RelationPart rp : getRelationParts()){
+                POIXMLDocumentPart p = rp.getDocumentPart();
                 if (p instanceof XSSFDrawing) {
                     XSSFDrawing dr = (XSSFDrawing)p;
-                    String drId = dr.getPackageRelationship().getId();
+                    String drId = rp.getRelationship().getId();
                     if (drId.equals(ctDrawing.getId())){
                         return dr;
                     }
@@ -478,8 +490,9 @@ public class XSSFSheet extends POIXMLDoc
         
         //drawingNumber = #drawings.size() + 1
         int drawingNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.DRAWINGS.getContentType()).size() + 1;
-        XSSFDrawing drawing = (XSSFDrawing)createRelationship(XSSFRelation.DRAWINGS, XSSFFactory.getInstance(), drawingNumber);
-        String relId = drawing.getPackageRelationship().getId();
+        RelationPart rp = createRelationship(XSSFRelation.DRAWINGS, XSSFFactory.getInstance(), drawingNumber, false);
+        XSSFDrawing drawing = rp.getDocumentPart();
+        String relId = rp.getRelationship().getId();
 
         //add CT_Drawing element which indicates that this sheet contains drawing components built on the drawingML platform.
         //The relationship Id references the part containing the drawingML definitions.
@@ -504,8 +517,9 @@ public class XSSFSheet extends POIXMLDoc
             if(autoCreate) {
                 //drawingNumber = #drawings.size() + 1
                 int drawingNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.VML_DRAWINGS.getContentType()).size() + 1;
-                drawing = (XSSFVMLDrawing)createRelationship(XSSFRelation.VML_DRAWINGS, XSSFFactory.getInstance(), drawingNumber);
-                String relId = drawing.getPackageRelationship().getId();
+                RelationPart rp = createRelationship(XSSFRelation.VML_DRAWINGS, XSSFFactory.getInstance(), drawingNumber, false);
+                drawing = rp.getDocumentPart();
+                String relId = rp.getRelationship().getId();
 
                 //add CTLegacyDrawing element which indicates that this sheet contains drawing components built on the drawingML platform.
                 //The relationship Id references the part containing the drawing definitions.
@@ -514,10 +528,11 @@ public class XSSFSheet extends POIXMLDoc
             }
         } else {
             //search the referenced drawing in the list of the sheet's relations
-            for(POIXMLDocumentPart p : getRelations()){
+            for (RelationPart rp : getRelationParts()){
+                POIXMLDocumentPart p = rp.getDocumentPart();
                 if(p instanceof XSSFVMLDrawing) {
                     XSSFVMLDrawing dr = (XSSFVMLDrawing)p;
-                    String drId = dr.getPackageRelationship().getId();
+                    String drId = rp.getRelationship().getId();
                     if(drId.equals(ctDrawing.getId())){
                         drawing = dr;
                         break;
@@ -3695,6 +3710,7 @@ public class XSSFSheet extends POIXMLDoc
 
     }
 
+    @SuppressWarnings("resource")
     @Override
     public XSSFAutoFilter setAutoFilter(CellRangeAddress range) {
         CTAutoFilter af = worksheet.getAutoFilter();
@@ -3735,8 +3751,9 @@ public class XSSFSheet extends POIXMLDoc
        // Table numbers need to be unique in the file, not just
        //  unique within the sheet. Find the next one
        int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1;
-       XSSFTable table = (XSSFTable)createRelationship(XSSFRelation.TABLE, XSSFFactory.getInstance(), tableNumber);
-       tbl.setId(table.getPackageRelationship().getId());
+       RelationPart rp = createRelationship(XSSFRelation.TABLE, XSSFFactory.getInstance(), tableNumber, false);
+       XSSFTable table = rp.getDocumentPart();
+       tbl.setId(rp.getRelationship().getId());
 
        tables.put(tbl.getId(), table);
 
@@ -3933,6 +3950,7 @@ public class XSSFSheet extends POIXMLDoc
      * including: pivotCacheDefinition, pivotCacheRecords
      * @return returns a pivotTable
      */
+    @SuppressWarnings("resource")
     @Beta
     private XSSFPivotTable createPivotTable() {
         XSSFWorkbook wb = getWorkbook();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java Sun Jan 10 20:44:17 2016
@@ -62,12 +62,22 @@ public class XSSFTable extends POIXMLDoc
         ctTable = CTTable.Factory.newInstance();
     }
 
-    public XSSFTable(PackagePart part, PackageRelationship rel)
-            throws IOException {
-        super(part, rel);
+    /** 
+     * @since POI 3.14-Beta1
+     */
+    public XSSFTable(PackagePart part) throws IOException {
+        super(part);
         readFrom(part.getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XSSFTable(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     public void readFrom(InputStream is) throws IOException {
         try {
             TableDocument doc = TableDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java Sun Jan 10 20:44:17 2016
@@ -35,12 +35,22 @@ public class XSSFVBAPart extends POIXMLD
      *
      * @param part the package part holding the VBA data,
      * @param rel  the package relationship holding this part
+     * 
+     * @since POI 3.14-Beta1
      */
-    protected XSSFVBAPart(PackagePart part, PackageRelationship rel) {
-        super(part, rel);
+    protected XSSFVBAPart(PackagePart part) {
+        super(part);
     }
 
     /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFVBAPart(PackagePart part, PackageRelationship rel) {
+        this(part);
+    }
+    
+    /**
      * Like *PictureData, VBA objects store the actual content in the part
      * directly without keeping a copy like all others therefore we need to
      * handle them differently.

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java Sun Jan 10 20:44:17 2016
@@ -110,12 +110,21 @@ public final class XSSFVMLDrawing extend
      * the content type must be <code>application/vnd.openxmlformats-officedocument.drawing+xml</code>
      * @param rel  the package relationship holding this drawing,
      * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
+     * 
+     * @since POI 3.14-Beta1
      */
-    protected XSSFVMLDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
-        super(part, rel);
+    protected XSSFVMLDrawing(PackagePart part) throws IOException, XmlException {
+        super(part);
         read(getPackagePart().getInputStream());
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    protected XSSFVMLDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
+        this(part);
+    }
 
     protected void read(InputStream is) throws IOException, XmlException {
         XmlObject root = XmlObject.Factory.parse(

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Sun Jan 10 20:44:17 2016
@@ -338,17 +338,18 @@ public class XSSFWorkbook extends POIXML
             ThemesTable theme = null;
             Map<String, XSSFSheet> shIdMap = new HashMap<String, XSSFSheet>();
             Map<String, ExternalLinksTable> elIdMap = new HashMap<String, ExternalLinksTable>();
-            for(POIXMLDocumentPart p : getRelations()){
+            for(RelationPart rp : getRelationParts()){
+                POIXMLDocumentPart p = rp.getDocumentPart();
                 if(p instanceof SharedStringsTable) sharedStringSource = (SharedStringsTable)p;
                 else if(p instanceof StylesTable) stylesSource = (StylesTable)p;
                 else if(p instanceof ThemesTable) theme = (ThemesTable)p;
                 else if(p instanceof CalculationChain) calcChain = (CalculationChain)p;
                 else if(p instanceof MapInfo) mapInfo = (MapInfo)p;
                 else if (p instanceof XSSFSheet) {
-                    shIdMap.put(p.getPackageRelationship().getId(), (XSSFSheet)p);
+                    shIdMap.put(rp.getRelationship().getId(), (XSSFSheet)p);
                 }
                 else if (p instanceof ExternalLinksTable) {
-                    elIdMap.put(p.getPackageRelationship().getId(), (ExternalLinksTable)p);
+                    elIdMap.put(rp.getRelationship().getId(), (ExternalLinksTable)p);
                 }
             }
             boolean packageReadOnly = (getPackage().getPackageAccess() == PackageAccess.READ);
@@ -492,7 +493,7 @@ public class XSSFWorkbook extends POIXML
     @Override
     public int addPicture(byte[] pictureData, int format) {
         int imageNumber = getAllPictures().size() + 1;
-        XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true);
+        XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
         try {
             OutputStream out = img.getPackagePart().getOutputStream();
             out.write(pictureData);
@@ -521,7 +522,7 @@ public class XSSFWorkbook extends POIXML
      */
     public int addPicture(InputStream is, int format) throws IOException {
         int imageNumber = getAllPictures().size() + 1;
-        XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true);
+        XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
         OutputStream out = img.getPackagePart().getOutputStream();
         IOUtils.copy(is, out);
         out.close();
@@ -546,6 +547,34 @@ public class XSSFWorkbook extends POIXML
         String clonedName = getUniqueSheetName(srcName);
 
         XSSFSheet clonedSheet = createSheet(clonedName);
+
+        // copy sheet's relations
+        List<RelationPart> rels = srcSheet.getRelationParts();
+        // if the sheet being cloned has a drawing then rememebr it and re-create it too
+        XSSFDrawing dg = null;
+        for(RelationPart rp : rels) {
+            POIXMLDocumentPart r = rp.getDocumentPart();
+            // do not copy the drawing relationship, it will be re-created
+            if(r instanceof XSSFDrawing) {
+                dg = (XSSFDrawing)r;
+                continue;
+            }
+
+            addRelation(rp, clonedSheet);
+        }
+
+        try {
+            for(PackageRelationship pr : srcSheet.getPackagePart().getRelationships()) {
+                if (pr.getTargetMode() == TargetMode.EXTERNAL) {
+                    clonedSheet.getPackagePart().addExternalRelationship
+                        (pr.getTargetURI().toASCIIString(), pr.getRelationshipType(), pr.getId());
+                }
+            }
+        } catch (InvalidFormatException e) {
+            throw new POIXMLException("Failed to clone sheet", e);
+        }
+        
+        
         try {
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             srcSheet.write(out);
@@ -565,23 +594,6 @@ public class XSSFWorkbook extends POIXML
 
         clonedSheet.setSelected(false);
 
-        // copy sheet's relations
-        List<POIXMLDocumentPart> rels = srcSheet.getRelations();
-        // if the sheet being cloned has a drawing then rememebr it and re-create tpoo
-        XSSFDrawing dg = null;
-        for(POIXMLDocumentPart r : rels) {
-            // do not copy the drawing relationship, it will be re-created
-            if(r instanceof XSSFDrawing) {
-                dg = (XSSFDrawing)r;
-                continue;
-            }
-
-            PackageRelationship rel = r.getPackageRelationship();
-            clonedSheet.getPackagePart().addRelationship(
-                    rel.getTargetURI(), rel.getTargetMode(),rel.getRelationshipType());
-            clonedSheet.addRelation(rel.getId(), r);
-        }
-
         // clone the sheet drawing alongs with its relationships
         if (dg != null) {
             if(ct.isSetDrawing()) {
@@ -596,20 +608,31 @@ public class XSSFWorkbook extends POIXML
             clonedDg = clonedSheet.createDrawingPatriarch();
             
             // Clone drawing relations
-            List<POIXMLDocumentPart> srcRels = srcSheet.createDrawingPatriarch().getRelations();
-            for (POIXMLDocumentPart rel : srcRels) {
-                PackageRelationship relation = rel.getPackageRelationship();
-
-                clonedDg.addRelation(relation.getId(), rel);
-                
-                clonedDg
-						.getPackagePart()
-                        .addRelationship(relation.getTargetURI(), relation.getTargetMode(),
-                                relation.getRelationshipType(), relation.getId());
+            List<RelationPart> srcRels = srcSheet.createDrawingPatriarch().getRelationParts();
+            for (RelationPart rp : srcRels) {
+                addRelation(rp, clonedDg);
             }
         }
         return clonedSheet;
     }
+    
+    /**
+     * @since 3.14-Beta1
+     */
+    private static void addRelation(RelationPart rp, POIXMLDocumentPart target) {
+        PackageRelationship rel = rp.getRelationship();
+        if (rel.getTargetMode() == TargetMode.EXTERNAL) {
+            target.getPackagePart().addRelationship(
+                rel.getTargetURI(), rel.getTargetMode(), rel.getRelationshipType(), rel.getId());
+        } else {        
+            XSSFRelation xssfRel = XSSFRelation.getInstance(rel.getRelationshipType());
+            if (xssfRel == null) {
+                // Don't copy all relations blindly, but only the ones we know about
+                throw new POIXMLException("Can't clone sheet - unknown relation type found: "+rel.getRelationshipType());
+            }
+            target.addRelation(rel.getId(), xssfRel, rp.getDocumentPart());
+        }
+    }
 
     /**
      * Generate a valid sheet name based on the existing one. Used when cloning sheets.
@@ -794,18 +817,21 @@ public class XSSFWorkbook extends POIXML
             break;
         }
 
-        XSSFSheet wrapper = (XSSFSheet)createRelationship(XSSFRelation.WORKSHEET, XSSFFactory.getInstance(), sheetNumber);
+        RelationPart rp = createRelationship(XSSFRelation.WORKSHEET, XSSFFactory.getInstance(), sheetNumber, false);
+        XSSFSheet wrapper = rp.getDocumentPart();
         wrapper.sheet = sheet;
-        sheet.setId(wrapper.getPackageRelationship().getId());
+        sheet.setId(rp.getRelationship().getId());
         sheet.setSheetId(sheetNumber);
-        if(sheets.size() == 0) wrapper.setSelected(true);
+        if (sheets.isEmpty()) wrapper.setSelected(true);
         sheets.add(wrapper);
         return wrapper;
     }
 
     protected XSSFDialogsheet createDialogsheet(String sheetname, CTDialogsheet dialogsheet) {
         XSSFSheet sheet = createSheet(sheetname);
-        return new XSSFDialogsheet(sheet);
+        String sheetRelId = getRelationId(sheet);
+        PackageRelationship pr = getPackagePart().getRelationship(sheetRelId);
+        return new XSSFDialogsheet(sheet, pr);
     }
 
     private CTSheet addSheet(String sheetname) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java Sun Jan 10 20:44:17 2016
@@ -20,10 +20,9 @@ import static org.apache.poi.POIXMLTypeL
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.List;
 
 import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.POIXMLDocumentPart.RelationPart;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -221,11 +220,9 @@ public class XWPFHeaderFooterPolicy {
     }
 
     private int getRelationIndex(XWPFRelation relation) {
-        List<POIXMLDocumentPart> relations = doc.getRelations();
         int i = 1;
-        for (Iterator<POIXMLDocumentPart> it = relations.iterator(); it.hasNext(); ) {
-            POIXMLDocumentPart item = it.next();
-            if (item.getPackageRelationship().getRelationshipType().equals(relation.getRelation())) {
+        for (RelationPart rp : doc.getRelationParts()) {
+            if (rp.getRelationship().getRelationshipType().equals(relation.getRelation())) {
                 i++;
             }
         }
@@ -287,17 +284,16 @@ public class XWPFHeaderFooterPolicy {
     private void setFooterReference(Enum type, XWPFHeaderFooter wrapper) {
         CTHdrFtrRef ref = doc.getDocument().getBody().getSectPr().addNewFooterReference();
         ref.setType(type);
-        ref.setId(wrapper.getPackageRelationship().getId());
+        ref.setId(doc.getRelationId(wrapper));
     }
 
 
     private void setHeaderReference(Enum type, XWPFHeaderFooter wrapper) {
         CTHdrFtrRef ref = doc.getDocument().getBody().getSectPr().addNewHeaderReference();
         ref.setType(type);
-        ref.setId(wrapper.getPackageRelationship().getId());
+        ref.setId(doc.getRelationId(wrapper));
     }
-
-
+    
     public XWPFHeader getFirstPageHeader() {
         return firstPageHeader;
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Sun Jan 10 20:44:17 2016
@@ -193,8 +193,9 @@ public class XWPFDocument extends POIXML
                 headerFooterPolicy = new XWPFHeaderFooterPolicy(this);
 
             // Create for each XML-part in the Package a PartClass
-            for (POIXMLDocumentPart p : getRelations()) {
-                String relation = p.getPackageRelationship().getRelationshipType();
+            for (RelationPart rp : getRelationParts()) {
+                POIXMLDocumentPart p = rp.getDocumentPart();
+                String relation = rp.getRelationship().getRelationshipType();
                 if (relation.equals(XWPFRelation.STYLES.getRelation())) {
                     this.styles = (XWPFStyles) p;
                     this.styles.onDocumentRead();
@@ -257,8 +258,9 @@ public class XWPFDocument extends POIXML
     }
 
     private void initFootnotes() throws XmlException, IOException {
-        for (POIXMLDocumentPart p : getRelations()) {
-            String relation = p.getPackageRelationship().getRelationshipType();
+        for (RelationPart rp : getRelationParts()) {
+            POIXMLDocumentPart p = rp.getDocumentPart();
+            String relation = rp.getRelationship().getRelationshipType();
             if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) {
                 this.footnotes = (XWPFFootnotes) p;
                 this.footnotes.onDocumentRead();
@@ -723,11 +725,9 @@ public class XWPFDocument extends POIXML
      * @return i
      */
     private int getRelationIndex(XWPFRelation relation) {
-        List<POIXMLDocumentPart> relations = getRelations();
         int i = 1;
-        for (Iterator<POIXMLDocumentPart> it = relations.iterator(); it.hasNext(); ) {
-            POIXMLDocumentPart item = it.next();
-            if (item.getPackageRelationship().getRelationshipType().equals(relation.getRelation())) {
+        for (RelationPart rp : getRelationParts()) {
+            if (rp.getRelationship().getRelationshipType().equals(relation.getRelation())) {
                 i++;
             }
         }
@@ -1313,16 +1313,9 @@ public class XWPFDocument extends POIXML
              * relationship to the already existing part and update
              * POIXMLDocumentPart data.
              */
-            PackagePart picDataPart = xwpfPicData.getPackagePart();
             // TODO add support for TargetMode.EXTERNAL relations.
-            TargetMode targetMode = TargetMode.INTERNAL;
-            PackagePartName partName = picDataPart.getPartName();
-            String relation = relDesc.getRelation();
-            PackageRelationship relShip = getPackagePart().addRelationship(partName, targetMode, relation);
-            String id = relShip.getId();
-            addRelation(id, xwpfPicData);
-            pictures.add(xwpfPicData);
-            return id;
+            RelationPart rp = addRelation(null, XWPFRelation.IMAGES, xwpfPicData);
+            return rp.getRelationship().getId();
         } else {
             /* Part already existed, get relation id and return it */
             return getRelationId(xwpfPicData);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java Sun Jan 10 20:44:17 2016
@@ -18,63 +18,42 @@
 package org.apache.poi.xwpf.usermodel;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.poi.POIXMLDocumentPart;
-import org.apache.poi.POIXMLException;
 import org.apache.poi.POIXMLFactory;
 import org.apache.poi.POIXMLRelation;
-import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
-
-/**
- * @author Yegor Kozlov
- */
-public final class XWPFFactory extends POIXMLFactory {
-
-    private static final POILogger logger = POILogFactory.getLogger(XWPFFactory.class);
-    private static final XWPFFactory inst = new XWPFFactory();
-
-    private XWPFFactory() {
-
-    }
-
-    public static XWPFFactory getInstance() {
-        return inst;
-    }
-
-    @Override
-    public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part) {
-        POIXMLRelation descriptor = XWPFRelation.getInstance(rel.getRelationshipType());
-        if (descriptor == null || descriptor.getRelationClass() == null) {
-            logger.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType());
-            return new POIXMLDocumentPart(part, rel);
-        }
-
-        try {
-            Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass();
-            try {
-                Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(POIXMLDocumentPart.class, PackagePart.class, PackageRelationship.class);
-                return constructor.newInstance(parent, part, rel);
-            } catch (NoSuchMethodException e) {
-                Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(PackagePart.class, PackageRelationship.class);
-                return constructor.newInstance(part, rel);
-            }
-        } catch (Exception e) {
-            throw new POIXMLException(e);
-        }
-    }
-
-    @Override
-    public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor) {
-        try {
-            Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass();
-            Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor();
-            return constructor.newInstance();
-        } catch (Exception e) {
-            throw new POIXMLException(e);
-        }
-    }
 
-}
+/**
+ * Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
+ */
+public final class XWPFFactory extends POIXMLFactory {
+    private XWPFFactory() {
+
+    }
+
+    private static final XWPFFactory inst = new XWPFFactory();
+
+    public static XWPFFactory getInstance() {
+        return inst;
+    }
+
+    /**
+     * @since POI 3.14-Beta1
+     */
+    @Override
+    protected POIXMLRelation getDescriptor(String relationshipType) {
+        return XWPFRelation.getInstance(relationshipType);
+    }
+
+    /**
+     * @since POI 3.14-Beta1
+     */
+    @Override
+    protected POIXMLDocumentPart createDocumentPart
+        (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
+    throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
+        Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(classes);
+        return constructor.newInstance(values);
+    }
+}
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java Sun Jan 10 20:44:17 2016
@@ -67,8 +67,19 @@ public class XWPFFooter extends XWPFHead
         cursor.dispose();
     }
 
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public XWPFFooter(POIXMLDocumentPart parent, PackagePart part) throws IOException {
+        super(parent, part);
+    }
+    
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
     public XWPFFooter(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) throws IOException {
-        super(parent, part, rel);
+        this(parent, part);
     }
 
     /**
@@ -88,7 +99,7 @@ public class XWPFFooter extends XWPFHead
     protected void onDocumentRead() throws IOException {
         super.onDocumentRead();
         FtrDocument ftrDocument = null;
-        InputStream is;
+        InputStream is = null;
         try {
             is = getPackagePart().getInputStream();
             ftrDocument = FtrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
@@ -117,6 +128,10 @@ public class XWPFFooter extends XWPFHead
             cursor.dispose();
         } catch (Exception e) {
             throw new POIXMLException(e);
+        } finally {
+            if (is != null) {
+                is.close();
+            }
         }
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java Sun Jan 10 20:44:17 2016
@@ -48,14 +48,24 @@ public class XWPFFootnotes extends POIXM
 
     /**
      * Construct XWPFFootnotes from a package part
-     *
-     * @param part the package part holding the data of the footnotes,
-     * @param rel  the package relationship of type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
-     */
-    public XWPFFootnotes(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException {
-        super(part, rel);
-    }
-
+     *
+     * @param part the package part holding the data of the footnotes,
+     * @param rel  the package relationship of type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
+     * 
+     * @since POI 3.14-Beta1
+     */
+    public XWPFFootnotes(PackagePart part) throws IOException, OpenXML4JException {
+        super(part);
+    }
+
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XWPFFootnotes(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException {
+        this(part);
+    }
+    
     /**
      * Construct XWPFFootnotes from scratch for a new document.
      */
@@ -67,13 +77,18 @@ public class XWPFFootnotes extends POIXM
      */
     @Override
     protected void onDocumentRead() throws IOException {
-        FootnotesDocument notesDoc;
+        FootnotesDocument notesDoc;
+        InputStream is = null;
         try {
-            InputStream is = getPackagePart().getInputStream();
+            is = getPackagePart().getInputStream();
             notesDoc = FootnotesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             ctFootnotes = notesDoc.getFootnotes();
         } catch (XmlException e) {
             throw new POIXMLException();
+        } finally {
+            if (is != null) {
+                is.close();
+            }
         }
 
         // Find our footnotes

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java Sun Jan 10 20:44:17 2016
@@ -47,8 +47,19 @@ public class XWPFHeader extends XWPFHead
         super();
     }
 
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public XWPFHeader(POIXMLDocumentPart parent, PackagePart part) throws IOException {
+        super(parent, part);
+    }
+    
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
     public XWPFHeader(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) throws IOException {
-        super(parent, part, rel);
+        this(parent, part);
     }
 
     public XWPFHeader(XWPFDocument doc, CTHdrFtr hdrFtr) {
@@ -91,7 +102,7 @@ public class XWPFHeader extends XWPFHead
     protected void onDocumentRead() throws IOException {
         super.onDocumentRead();
         HdrDocument hdrDocument = null;
-        InputStream is;
+        InputStream is = null;
         try {
             is = getPackagePart().getInputStream();
             hdrDocument = HdrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
@@ -120,6 +131,10 @@ public class XWPFHeader extends XWPFHead
             cursor.dispose();
         } catch (XmlException e) {
             throw new POIXMLException(e);
+        } finally {
+            if (is != null) {
+                is.close();
+            }
         }
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java Sun Jan 10 20:44:17 2016
@@ -28,9 +28,7 @@ import org.apache.poi.POIXMLException;
 import org.apache.poi.POIXMLRelation;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackagePartName;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlCursor;
@@ -68,14 +66,25 @@ public abstract class XWPFHeaderFooter e
         readHdrFtr();
     }
 
-    public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) throws IOException {
-        super(parent, part, rel);
+    /**
+     * @since by POI 3.14-Beta1
+     */
+    public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part) throws IOException {
+        super(parent, part);
         this.document = (XWPFDocument) getParent();
 
         if (this.document == null) {
             throw new NullPointerException();
         }
     }
+    
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) throws IOException {
+        this(parent, part);
+    }
 
     @Override
     protected void onDocumentRead() throws IOException {
@@ -271,16 +280,10 @@ public abstract class XWPFHeaderFooter e
              * relationship to the already existing part and update
              * POIXMLDocumentPart data.
              */
-            PackagePart picDataPart = xwpfPicData.getPackagePart();
             // TODO add support for TargetMode.EXTERNAL relations.
-            TargetMode targetMode = TargetMode.INTERNAL;
-            PackagePartName partName = picDataPart.getPartName();
-            String relation = relDesc.getRelation();
-            PackageRelationship relShip = getPackagePart().addRelationship(partName, targetMode, relation);
-            String id = relShip.getId();
-            addRelation(id, xwpfPicData);
+            RelationPart rp = addRelation(null, XWPFRelation.IMAGES, xwpfPicData);
             pictures.add(xwpfPicData);
-            return id;
+            return rp.getRelationship().getId();
         } else {
             /* Part already existed, get relation id and return it */
             return getRelationId(xwpfPicData);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java Sun Jan 10 20:44:17 2016
@@ -47,19 +47,29 @@ public class XWPFNumbering extends POIXM
     protected List<XWPFNum> nums = new ArrayList<XWPFNum>();
     boolean isNew;
     private CTNumbering ctNumbering;
-
-    /**
-     * create a new styles object with an existing document
-     */
-    public XWPFNumbering(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException {
-        super(part, rel);
-        isNew = true;
-    }
-
-    /**
-     * create a new XWPFNumbering object for use in a new document
-     */
-    public XWPFNumbering() {
+
+    /**
+     * create a new styles object with an existing document
+     * 
+     * @since POI 3.14-Beta1
+     */
+    public XWPFNumbering(PackagePart part) throws IOException, OpenXML4JException {
+        super(part);
+        isNew = true;
+    }
+
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XWPFNumbering(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException {
+        this(part);
+    }
+    
+    /**
+     * create a new XWPFNumbering object for use in a new document
+     */
+    public XWPFNumbering() {
         abstractNums = new ArrayList<XWPFAbstractNum>();
         nums = new ArrayList<XWPFNum>();
         isNew = true;
@@ -83,12 +93,14 @@ public class XWPFNumbering extends POIXM
             for (CTAbstractNum ctAbstractNum : ctNumbering.getAbstractNumArray()) {
                 abstractNums.add(new XWPFAbstractNum(ctAbstractNum, this));
             }
-            isNew = false;
-        } catch (XmlException e) {
-            throw new POIXMLException();
-        }
-    }
-
+            isNew = false;
+        } catch (XmlException e) {
+            throw new POIXMLException();
+        } finally {
+            is.close();
+        }
+    }
+
     /**
      * save and commit numbering
      */

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java Sun Jan 10 20:44:17 2016
@@ -70,15 +70,23 @@ public class XWPFPictureData extends POI
 
     /**
      * Construct XWPFPictureData from a package part
-     *
-     * @param part the package part holding the drawing data,
-     * @param rel  the package relationship holding this drawing,
-     *             the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
-     */
-    public XWPFPictureData(PackagePart part, PackageRelationship rel) {
-        super(part, rel);
+     *
+     * @param part the package part holding the drawing data,
+     * 
+     * @since POI 3.14-Beta1
+     */
+    public XWPFPictureData(PackagePart part) {
+        super(part);
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XWPFPictureData(PackagePart part, PackageRelationship rel) {
+        this(part);
+    }
+    
     @Override
     protected void onDocumentRead() throws IOException {
         super.onDocumentRead();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java Sun Jan 10 20:44:17 2016
@@ -208,13 +208,12 @@ public final class XWPFRelation extends
             null,
             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
             null,
-            null
+            XWPFPictureData.class
     );
 
     private XWPFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
         super(type, rel, defaultName, cls);
-
-        if (cls != null && !_table.containsKey(rel)) _table.put(rel, this);
+        _table.put(rel, this);
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java Sun Jan 10 20:44:17 2016
@@ -994,13 +994,13 @@ public class XWPFRun implements ISDTCont
 
             CTNonVisualPictureProperties cNvPicPr = nvPicPr.addNewCNvPicPr();
             cNvPicPr.addNewPicLocks().setNoChangeAspect(true);
-
-            CTBlipFillProperties blipFill = pic.addNewBlipFill();
-            CTBlip blip = blipFill.addNewBlip();
-            blip.setEmbed(picData.getPackageRelationship().getId());
-            blipFill.addNewStretch().addNewFillRect();
-
-            CTShapeProperties spPr = pic.addNewSpPr();
+
+            CTBlipFillProperties blipFill = pic.addNewBlipFill();
+            CTBlip blip = blipFill.addNewBlip();
+            blip.setEmbed(parent.getDocument().getRelationId(picData));
+            blipFill.addNewStretch().addNewFillRect();
+
+            CTShapeProperties spPr = pic.addNewSpPr();
             CTTransform2D xfrm = spPr.addNewXfrm();
 
             CTPoint2D off = xfrm.addNewOff();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java Sun Jan 10 20:44:17 2016
@@ -49,10 +49,21 @@ public class XWPFSettings extends POIXML
 
     private CTSettings ctSettings;
 
-    public XWPFSettings(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
+    /**
+     * @since POI 3.14-Beta1
+     */
+    public XWPFSettings(PackagePart part) throws IOException {
+        super(part);
     }
 
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XWPFSettings(PackagePart part, PackageRelationship rel) throws IOException {
+        this(part);
+    }
+    
     public XWPFSettings() {
         super();
         ctSettings = CTSettings.Factory.newInstance();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java Sun Jan 10 20:44:17 2016
@@ -61,13 +61,22 @@ public class XWPFStyles extends POIXMLDo
     /**
      * Construct XWPFStyles from a package part
      *
-     * @param part the package part holding the data of the styles,
-     * @param rel  the package relationship of type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
-     */
-    public XWPFStyles(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException {
-        super(part, rel);
-    }
-
+     * @param part the package part holding the data of the styles,
+     * 
+     * @since POI 3.14-Beta1
+     */
+    public XWPFStyles(PackagePart part) throws IOException, OpenXML4JException {
+        super(part);
+    }
+
+    /**
+     * @deprecated in POI 3.14, scheduled for removal in POI 3.16
+     */
+    @Deprecated
+    public XWPFStyles(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException {
+        this(part);
+    }
+    
     /**
      * Construct XWPFStyles from scratch for a new document.
      */
@@ -77,16 +86,18 @@ public class XWPFStyles extends POIXMLDo
     /**
      * Read document
      */
-    @Override
-    protected void onDocumentRead() throws IOException {
-        StylesDocument stylesDoc;
-        try {
-            InputStream is = getPackagePart().getInputStream();
+    @Override
+    protected void onDocumentRead() throws IOException {
+        StylesDocument stylesDoc;
+        InputStream is = getPackagePart().getInputStream();
+        try {
             stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
             setStyles(stylesDoc.getStyles());
             latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
         } catch (XmlException e) {
             throw new POIXMLException("Unable to read styles", e);
+        } finally {
+            is.close();
         }
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java Sun Jan 10 20:44:17 2016
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertSam
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -34,7 +35,6 @@ import java.util.List;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
 import org.apache.poi.util.PackageHelper;
 import org.apache.poi.util.TempFile;
@@ -71,14 +71,18 @@ public final class TestPOIXMLDocument {
             //
         }
 
-        @Override
-        public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part){
-            return new POIXMLDocumentPart(part, rel);
+        protected POIXMLRelation getDescriptor(String relationshipType) {
+            return null;
         }
 
+        /**
+         * @since POI 3.14-Beta1
+         */
         @Override
-        public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor){
-            throw new RuntimeException("not supported");
+        protected POIXMLDocumentPart createDocumentPart
+            (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
+        throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
+            return null;
         }
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java?rev=1723966&r1=1723965&r2=1723966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java Sun Jan 10 20:44:17 2016
@@ -25,25 +25,20 @@ import static org.junit.Assert.fail;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics2D;
-import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URI;
 import java.util.Collection;
-import java.util.List;
 
 import javax.imageio.ImageIO;
 
-import org.apache.poi.POIDataSamples;
 import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.POIXMLDocumentPart.RelationPart;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
-import org.apache.poi.util.IOUtils;
 import org.apache.poi.xslf.usermodel.DrawingParagraph;
 import org.apache.poi.xslf.usermodel.DrawingTextBody;
 import org.apache.poi.xslf.usermodel.XMLSlideShow;
@@ -109,7 +104,7 @@ public class TestXSLFBugs {
        XSLFSlide slide = ss.getSlides().get(0);
        
        // Check the relations from this
-       List<POIXMLDocumentPart> rels = slide.getRelations();
+       Collection<RelationPart> rels = slide.getRelationParts();
        
        // Should have 6 relations:
        //   1 external hyperlink (skipped from list)
@@ -118,10 +113,10 @@ public class TestXSLFBugs {
        assertEquals(5, rels.size());
        int layouts = 0;
        int hyperlinks = 0;
-       for(POIXMLDocumentPart p : rels) {
-          if(p.getPackageRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation())) {
+       for(RelationPart p : rels) {
+          if(p.getRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation())) {
              hyperlinks++;
-          } else if(p instanceof XSLFSlideLayout) {
+          } else if(p.getDocumentPart() instanceof XSLFSlideLayout) {
              layouts++;
           }
        }
@@ -129,9 +124,9 @@ public class TestXSLFBugs {
        assertEquals(4, hyperlinks);
        
        // Hyperlinks should all be to #_ftn1 or #ftnref1
-       for(POIXMLDocumentPart p : rels) {
-          if(p.getPackageRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation())) {
-             URI target = p.getPackageRelationship().getTargetURI();
+       for(RelationPart p : rels) {
+          if(p.getRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation())) {
+             URI target = p.getRelationship().getTargetURI();
              
              if(target.getFragment().equals("_ftn1") ||
                 target.getFragment().equals("_ftnref1")) {
@@ -150,7 +145,6 @@ public class TestXSLFBugs {
      *  rID2 -> slide3.xml
      */
     @Test
-    @Ignore
     public void bug54916() throws Exception {
         XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("OverlappingRelations.pptx");
         XSLFSlide slide; 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message