- Code: Select all
for(FooterPart footerPart : footerParts){
footerPart.setPackage(baseDocPackage);
Relationship rel = baseDocPackage.getMainDocumentPart().addTargetPart(footerPart);
baseDocPackage.getParts().put(footerPart);
createFooterReference(baseDocPackage, rel);
}
I then get basically the same error Giuseppe originally posted, as the save function cannot find "/word/footer3.xml". Originally I didn't have the lines "footerPart.setPackage(...)" and "baseDocPackage.getParts().put(...)" but adding those doesn't seem to have made a difference.
When I debug through the code in Eclipse, it appears that the size of the baseDocPackage parts table is 16 to begin with. The first FooterPart (/word/footer1.xml) already exists in the destination file, so it is overwritten. When the second FooterPart is added (/word/footer3.xml), the parts table expands to 32 and a new FooterPart is added to "values" but not "table". The third FooterPart (/word/footer2.xml) is correctly added to both the "values" and "table". So, when it attempts to save, it appears there are three FooterPart objects in "values", but only two in "table". Could this be the source of my problem? Or is this totally irrelevant?
Thanks!
-Sean