ASF Bugzilla – Attachment 22013 Details for
Bug 45018
[PATCH] Patch to fetch embedded documents from OOXML files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
updated patch file
ooxml_.patch (text/plain), 7.36 KB, created by
Yury Batrakov
on 2008-05-27 09:32:57 UTC
(
hide
)
Description:
updated patch file
Filename:
MIME Type:
Creator:
Yury Batrakov
Created:
2008-05-27 09:32:57 UTC
Size:
7.36 KB
patch
obsolete
>Index: C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java >=================================================================== >--- C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (revision 660492) >+++ C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (working copy) >@@ -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()); >Index: C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java >=================================================================== >--- C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java (revision 660492) >+++ C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java (working copy) >@@ -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)); >+ } > } > > /** >Index: C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/POIXMLDocument.java >=================================================================== >--- C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/POIXMLDocument.java (revision 660492) >+++ C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/POIXMLDocument.java (working copy) >@@ -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)); > } >Index: C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java >=================================================================== >--- C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java (revision 660492) >+++ C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java (working copy) >@@ -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)); >Index: C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/testcases/org/apache/poi/TestEmbeded.java >=================================================================== >--- C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/testcases/org/apache/poi/TestEmbeded.java (revision 660492) >+++ C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/testcases/org/apache/poi/TestEmbeded.java (working copy) >@@ -45,11 +45,11 @@ > } > > public void testExcel() throws Exception { >- File f = new File(dirname, "ExcelWithAttachments.xlsx"); >+ File f = new File(dirname, "ExcelWithAttachments.xlsm"); > assertTrue(f.exists()); > > POIXMLDocument doc = new XSSFWorkbook(Package.open(f.toString())); >- test(doc, 0); >+ test(doc, 4); > } > > public void testWord() throws Exception { >@@ -57,15 +57,15 @@ > assertTrue(f.exists()); > > POIXMLDocument doc = new XWPFDocument(Package.open(f.toString())); >- test(doc, 4); >+ test(doc, 5); > } > > public void testPowerPoint() throws Exception { >- File f = new File(dirname, "PPTWithAttachments.pptx"); >+ File f = new File(dirname, "PPTWithAttachments.pptm"); > 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 { >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 45018
:
21975
|
22003
|
22004
|
22005
|
22012
| 22013 |
22014
|
22015