View | Details | Raw Unified | Return to bug 45018
Collapse All | Expand All

(-)C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (-1 / +22 lines)
Lines 121-127 Link Here
121
		    null,
121
		    null,
122
		    null
122
		    null
123
	);
123
	);
124
    
124
	public static final XSSFRelation OLEEMBEDDINGS = new XSSFRelation(
125
	        null,
126
	        OLE_OBJECT_REL_TYPE,
127
	        null,
128
	        null
129
	);
130
	
131
	public static final XSSFRelation PACKEMBEDDINGS = new XSSFRelation(
132
            null,
133
            PACK_OBJECT_REL_TYPE,
134
            null,
135
            null
136
    );
137
	
138
   
125
	public static class XSSFRelation {
139
	public static class XSSFRelation {
126
		private String TYPE;
140
		private String TYPE;
127
		private String REL;
141
		private String REL;
Lines 292-297 Link Here
292
                PackageRelationshipCollection hyperlinkRels =
306
                PackageRelationshipCollection hyperlinkRels =
293
                	part.getRelationshipsByType(SHEET_HYPERLINKS.REL);
307
                	part.getRelationshipsByType(SHEET_HYPERLINKS.REL);
294
                sheet.initHyperlinks(hyperlinkRels);
308
                sheet.initHyperlinks(hyperlinkRels);
309
                
310
                // Get the embeddings for the workbook
311
                for(PackageRelationship rel : part.getRelationshipsByType(OLEEMBEDDINGS.REL))
312
                    embedds.add(getTargetPart(rel)); // TODO: Add this reference to each sheet as well
313
                
314
                for(PackageRelationship rel : part.getRelationshipsByType(PACKEMBEDDINGS.REL))
315
                    embedds.add(getTargetPart(rel));
295
            }
316
            }
296
        } catch (XmlException e) {
317
        } catch (XmlException e) {
297
            throw new IOException(e.toString());
318
            throw new IOException(e.toString());
(-)C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java (+9 lines)
Lines 114-119 Link Here
114
				tables.add(new XWPFTable(table));
114
				tables.add(new XWPFTable(table));
115
			}
115
			}
116
		}
116
		}
117
		
118
        this.embedds = new LinkedList<PackagePart>();
119
        for(PackageRelationship rel : getCorePart().getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
120
            embedds.add(getTargetPart(rel));
121
        }
122
        
123
        for(PackageRelationship rel : getCorePart().getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
124
            embedds.add(getTargetPart(rel));
125
        }
117
	}
126
	}
118
	
127
	
119
	/**
128
	/**
(-)C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/POIXMLDocument.java (-7 / +7 lines)
Lines 41-48 Link Here
41
    
41
    
42
    public static final String EXTENDED_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
42
    public static final String EXTENDED_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
43
    
43
    
44
    // OLE embeddings relation name
44
    public static final String OLE_OBJECT_REL_TYPE="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
45
    public static final String OLE_OBJECT_REL_TYPE="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
45
    
46
    
47
    // Embedded OPC documents relation name
48
    public static final String PACK_OBJECT_REL_TYPE="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
49
    
46
    /** The OPC Package */
50
    /** The OPC Package */
47
    private Package pkg;
51
    private Package pkg;
48
52
Lines 57-63 Link Here
57
	/**
61
	/**
58
	 * The embedded OLE2 files in the OPC package
62
	 * The embedded OLE2 files in the OPC package
59
	 */
63
	 */
60
    private List<PackagePart> embedds;
64
    protected List<PackagePart> embedds = new LinkedList<PackagePart>();
61
    
65
    
62
    protected POIXMLDocument() {}
66
    protected POIXMLDocument() {}
63
    
67
    
Lines 70-85 Link Here
70
	    
74
	    
71
	        // Get core part
75
	        // Get core part
72
	        this.corePart = this.pkg.getPart(coreDocRelationship);
76
	        this.corePart = this.pkg.getPart(coreDocRelationship);
73
	        
77
74
			// Get any embedded OLE2 documents
75
	        this.embedds = new LinkedList<PackagePart>();
76
	        for(PackageRelationship rel : corePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
77
	            embedds.add(getTargetPart(rel));
78
	        }
79
        } catch (OpenXML4JException e) {
78
        } catch (OpenXML4JException e) {
80
            throw new IOException(e.toString());
79
            throw new IOException(e.toString());
81
    	}
80
    	}
82
    }
81
    }
82
    
83
    protected POIXMLDocument(String path) throws IOException {
83
    protected POIXMLDocument(String path) throws IOException {
84
   		this(openPackage(path));
84
   		this(openPackage(path));
85
    }
85
    }
(-)C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java (+12 lines)
Lines 24-29 Link Here
24
import org.openxml4j.exceptions.OpenXML4JException;
24
import org.openxml4j.exceptions.OpenXML4JException;
25
import org.openxml4j.opc.Package;
25
import org.openxml4j.opc.Package;
26
import org.openxml4j.opc.PackagePart;
26
import org.openxml4j.opc.PackagePart;
27
import org.openxml4j.opc.PackageRelationship;
27
import org.openxml4j.opc.PackageRelationshipCollection;
28
import org.openxml4j.opc.PackageRelationshipCollection;
28
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
29
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
29
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
30
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
Lines 63-68 Link Here
63
		
64
		
64
		presentationDoc =
65
		presentationDoc =
65
			PresentationDocument.Factory.parse(getCorePart().getInputStream());
66
			PresentationDocument.Factory.parse(getCorePart().getInputStream());
67
		
68
		for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
69
	          PackagePart slidePart =
70
	                getTargetPart(getCorePart().getRelationship(ctSlide.getId2()));
71
	          
72
	          for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE))
73
	              embedds.add(getTargetPart(rel)); // TODO: Add this reference to each slide as well
74
	          
75
	          for(PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE))
76
                  embedds.add(getTargetPart(rel));
77
		}
66
	}
78
	}
67
	public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException {
79
	public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException {
68
		this(openPackage(file));
80
		this(openPackage(file));
(-)C:/Documents and Settings/ybatrakov/workspace/OOXML SVN/src/ooxml/testcases/org/apache/poi/TestEmbeded.java (-5 / +5 lines)
Lines 45-55 Link Here
45
	}
45
	}
46
46
47
	public void testExcel() throws Exception {
47
	public void testExcel() throws Exception {
48
		File f = new File(dirname, "ExcelWithAttachments.xlsx");
48
		File f = new File(dirname, "ExcelWithAttachments.xlsm");
49
		assertTrue(f.exists());
49
		assertTrue(f.exists());
50
		
50
		
51
		POIXMLDocument doc = new XSSFWorkbook(Package.open(f.toString()));
51
		POIXMLDocument doc = new XSSFWorkbook(Package.open(f.toString()));
52
		test(doc, 0);
52
		test(doc, 4);
53
	}
53
	}
54
54
55
	public void testWord() throws Exception {
55
	public void testWord() throws Exception {
Lines 57-71 Link Here
57
		assertTrue(f.exists());
57
		assertTrue(f.exists());
58
		
58
		
59
		POIXMLDocument doc = new XWPFDocument(Package.open(f.toString()));
59
		POIXMLDocument doc = new XWPFDocument(Package.open(f.toString()));
60
		test(doc, 4);
60
		test(doc, 5);
61
	}
61
	}
62
62
63
	public void testPowerPoint() throws Exception {
63
	public void testPowerPoint() throws Exception {
64
		File f = new File(dirname, "PPTWithAttachments.pptx");
64
		File f = new File(dirname, "PPTWithAttachments.pptm");
65
		assertTrue(f.exists());
65
		assertTrue(f.exists());
66
		
66
		
67
		POIXMLDocument doc = new XSLFSlideShow(Package.open(f.toString()));
67
		POIXMLDocument doc = new XSLFSlideShow(Package.open(f.toString()));
68
		test(doc, 0);
68
		test(doc, 4);
69
	}
69
	}
70
	
70
	
71
	private void test(POIXMLDocument doc, int expectedCount) throws Exception {
71
	private void test(POIXMLDocument doc, int expectedCount) throws Exception {

Return to bug 45018