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/05/28 15:32:04 UTC

svn commit: r660945 - in /poi/branches/ooxml/src/ooxml: java/org/apache/poi/ java/org/apache/poi/xslf/ java/org/apache/poi/xssf/usermodel/ java/org/apache/poi/xwpf/ testcases/org/apache/poi/ testcases/org/apache/poi/ooxml/data/

Author: nick
Date: Wed May 28 06:32:03 2008
New Revision: 660945

URL: http://svn.apache.org/viewvc?rev=660945&view=rev
Log:
Update to ooxml embeding from bug #45018 from Yury

Modified:
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/POIXMLDocument.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/TestEmbeded.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/ExcelWithAttachments.xlsx
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/PPTWithAttachments.pptx
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/WordWithAttachments.docx

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/POIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/POIXMLDocument.java?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/POIXMLDocument.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/POIXMLDocument.java Wed May 28 06:32:03 2008
@@ -41,8 +41,12 @@
     
     public static final String EXTENDED_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
     
+    // OLE embeddings relation name
     public static final String OLE_OBJECT_REL_TYPE="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
     
+    // Embedded OPC documents relation name
+    public static final String PACK_OBJECT_REL_TYPE="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
+    
     /** The OPC Package */
     private Package pkg;
 
@@ -57,7 +61,7 @@
 	/**
 	 * The embedded OLE2 files in the OPC package
 	 */
-    private List<PackagePart> embedds;
+    protected List<PackagePart> embedds = new LinkedList<PackagePart>();
     
     protected POIXMLDocument() {}
     
@@ -70,16 +74,12 @@
 	    
 	        // Get core part
 	        this.corePart = this.pkg.getPart(coreDocRelationship);
-	        
-			// Get any embedded OLE2 documents
-	        this.embedds = new LinkedList<PackagePart>();
-	        for(PackageRelationship rel : corePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
-	            embedds.add(getTargetPart(rel));
-	        }
+
         } catch (OpenXML4JException e) {
             throw new IOException(e.toString());
     	}
     }
+    
     protected POIXMLDocument(String path) throws IOException {
    		this(openPackage(path));
     }

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java Wed May 28 06:32:03 2008
@@ -24,6 +24,7 @@
 import org.openxml4j.exceptions.OpenXML4JException;
 import org.openxml4j.opc.Package;
 import org.openxml4j.opc.PackagePart;
+import org.openxml4j.opc.PackageRelationship;
 import org.openxml4j.opc.PackageRelationshipCollection;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
@@ -63,6 +64,17 @@
 		
 		presentationDoc =
 			PresentationDocument.Factory.parse(getCorePart().getInputStream());
+		
+		for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
+	          PackagePart slidePart =
+	                getTargetPart(getCorePart().getRelationship(ctSlide.getId2()));
+	          
+	          for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE))
+	              embedds.add(getTargetPart(rel)); // TODO: Add this reference to each slide as well
+	          
+	          for(PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE))
+                  embedds.add(getTargetPart(rel));
+		}
 	}
 	public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException {
 		this(openPackage(file));

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Wed May 28 06:32:03 2008
@@ -121,7 +121,21 @@
 		    null,
 		    null
 	);
-    
+	public static final XSSFRelation OLEEMBEDDINGS = new XSSFRelation(
+	        null,
+	        OLE_OBJECT_REL_TYPE,
+	        null,
+	        null
+	);
+	
+	public static final XSSFRelation PACKEMBEDDINGS = new XSSFRelation(
+            null,
+            PACK_OBJECT_REL_TYPE,
+            null,
+            null
+    );
+	
+   
 	public static class XSSFRelation {
 		private String TYPE;
 		private String REL;
@@ -292,6 +306,13 @@
                 PackageRelationshipCollection hyperlinkRels =
                 	part.getRelationshipsByType(SHEET_HYPERLINKS.REL);
                 sheet.initHyperlinks(hyperlinkRels);
+                
+                // Get the embeddings for the workbook
+                for(PackageRelationship rel : part.getRelationshipsByType(OLEEMBEDDINGS.REL))
+                    embedds.add(getTargetPart(rel)); // TODO: Add this reference to each sheet as well
+                
+                for(PackageRelationship rel : part.getRelationshipsByType(PACKEMBEDDINGS.REL))
+                    embedds.add(getTargetPart(rel));
             }
         } catch (XmlException e) {
             throw new IOException(e.toString());

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java Wed May 28 06:32:03 2008
@@ -114,6 +114,15 @@
 				tables.add(new XWPFTable(table));
 			}
 		}
+		
+        this.embedds = new LinkedList<PackagePart>();
+        for(PackageRelationship rel : getCorePart().getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
+            embedds.add(getTargetPart(rel));
+        }
+        
+        for(PackageRelationship rel : getCorePart().getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
+            embedds.add(getTargetPart(rel));
+        }
 	}
 	
 	/**

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/TestEmbeded.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/TestEmbeded.java?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/TestEmbeded.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/TestEmbeded.java Wed May 28 06:32:03 2008
@@ -49,7 +49,7 @@
 		assertTrue(f.exists());
 		
 		POIXMLDocument doc = new XSSFWorkbook(Package.open(f.toString()));
-		test(doc, 0);
+		test(doc, 4);
 	}
 
 	public void testWord() throws Exception {
@@ -57,7 +57,7 @@
 		assertTrue(f.exists());
 		
 		POIXMLDocument doc = new XWPFDocument(Package.open(f.toString()));
-		test(doc, 4);
+		test(doc, 5);
 	}
 
 	public void testPowerPoint() throws Exception {
@@ -65,7 +65,7 @@
 		assertTrue(f.exists());
 		
 		POIXMLDocument doc = new XSLFSlideShow(Package.open(f.toString()));
-		test(doc, 0);
+		test(doc, 4);
 	}
 	
 	private void test(POIXMLDocument doc, int expectedCount) throws Exception {

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/ExcelWithAttachments.xlsx
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/ExcelWithAttachments.xlsx?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
Binary files - no diff available.

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/PPTWithAttachments.pptx
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/PPTWithAttachments.pptx?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
Binary files - no diff available.

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/WordWithAttachments.docx
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/ooxml/data/WordWithAttachments.docx?rev=660945&r1=660944&r2=660945&view=diff
==============================================================================
Binary files - no diff available.



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