Lines 19-25
Link Here
|
19 |
import java.io.IOException; |
19 |
import java.io.IOException; |
20 |
import java.util.LinkedList; |
20 |
import java.util.LinkedList; |
21 |
import java.util.List; |
21 |
import java.util.List; |
22 |
import java.net.URI; |
22 |
import java.util.Map; |
|
|
23 |
import java.util.Set; |
23 |
|
24 |
|
24 |
import org.apache.xmlbeans.XmlOptions; |
25 |
import org.apache.xmlbeans.XmlOptions; |
25 |
import org.apache.poi.util.POILogger; |
26 |
import org.apache.poi.util.POILogger; |
Lines 180-185
Link Here
|
180 |
} |
181 |
} |
181 |
|
182 |
|
182 |
/** |
183 |
/** |
|
|
184 |
* Save changes in the underlying OOXML package. |
185 |
* Recursively fires {@link #commit()} for each package part |
186 |
*/ |
187 |
protected final void onSave(Set<PackagePart> alreadySaved) throws IOException{ |
188 |
commit(); |
189 |
alreadySaved.add(this.getPackagePart()); |
190 |
for(POIXMLDocumentPart p : relations){ |
191 |
if (!alreadySaved.contains(p.getPackagePart())) { |
192 |
p.onSave(alreadySaved); |
193 |
} |
194 |
} |
195 |
} |
196 |
|
197 |
/** |
183 |
* Create a new child POIXMLDocumentPart |
198 |
* Create a new child POIXMLDocumentPart |
184 |
* |
199 |
* |
185 |
* @param descriptor the part descriptor |
200 |
* @param descriptor the part descriptor |
Lines 258-263
Link Here
|
258 |
} |
273 |
} |
259 |
} |
274 |
} |
260 |
|
275 |
|
|
|
276 |
protected final void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart> context) throws OpenXML4JException { |
277 |
PackageRelationshipCollection rels = packagePart.getRelationships(); |
278 |
for (PackageRelationship rel : rels) { |
279 |
if(rel.getTargetMode() == TargetMode.INTERNAL){ |
280 |
PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI()); |
281 |
PackagePart p = packagePart.getPackage().getPart(relName); |
282 |
if(p == null) { |
283 |
logger.log(POILogger.ERROR, "Skipped invalid entry " + rel.getTargetURI()); |
284 |
continue; |
285 |
} |
286 |
if (!context.containsKey(p)) { |
287 |
POIXMLDocumentPart childPart = factory.createDocumentPart(rel, p); |
288 |
context.put(p, childPart); |
289 |
childPart.parent = this; |
290 |
addRelation(childPart); |
291 |
if(p.hasRelationships()) childPart.read(factory, context); |
292 |
} |
293 |
else { |
294 |
addRelation(context.get(p)); |
295 |
} |
296 |
} |
297 |
} |
298 |
} |
261 |
|
299 |
|
262 |
/** |
300 |
/** |
263 |
* Fired when a new package part is created |
301 |
* Fired when a new package part is created |