.loadDocument(ResourceUtilities.getTestResourceAsStream("NewSection.odt"));
theSec = newDoc.getSectionByName("ImageSection");
Section newSec = newDoc.getSectionByName(newName);
XPath xpath = newDoc.getContentDom().getXPath();
DrawImageElement oldImage = (DrawImageElement) xpath.evaluate(".//draw:image", theSec.getOdfElement(),
XPathConstants.NODE);
DrawImageElement newImage = (DrawImageElement) xpath.evaluate(".//draw:image", newSec.getOdfElement(),
XPathConstants.NODE);
Assert.assertEquals(oldImage.getXlinkHrefAttribute(), newImage.getXlinkHrefAttribute());
OdfPackage packageDocument = newDoc.getPackage();
String imagePathPrefix = "Pictures/";
int count = 0;
Iterator<String> filePaths = packageDocument.getFilePaths().iterator();
while (filePaths.hasNext()) {
String path = filePaths.next();
if (path.startsWith(imagePathPrefix) && path.length() > imagePathPrefix.length())
count++;
if (count > 2)
break;
}
Assert.assertEquals(1, count);
// ---------resource copied------
doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
theSec = doc.getSectionByName("ImageSection");
newName = doc.appendSection(theSec, true).getName();
doc.save(ResourceUtilities.newTestOutputFile("NewSection1.odt"));
newDoc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("NewSection1.odt"));
theSec = newDoc.getSectionByName("ImageSection");
newSec = newDoc.getSectionByName(newName);
xpath = newDoc.getContentDom().getXPath();
oldImage = (DrawImageElement) xpath.evaluate(".//draw:image", theSec.getOdfElement(), XPathConstants.NODE);
newImage = (DrawImageElement) xpath.evaluate(".//draw:image", newSec.getOdfElement(), XPathConstants.NODE);
if (oldImage.getXlinkHrefAttribute().equals(newImage.getXlinkHrefAttribute()))
Assert.fail();
packageDocument = newDoc.getPackage();
count = 0;
filePaths = packageDocument.getFilePaths().iterator();