* with the slide count of the current presentation document.
*/
public OdfSlide copyForeignSlide(int destIndex,
OdfPresentationDocument srcDoc, int srcIndex) {
checkAllSlideName();
OfficePresentationElement contentRoot = null;
OdfFileDom contentDom = null;
try {
contentRoot = getContentRoot();
contentDom = getContentDom();
} catch (Exception e) {
Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e);
return null;
}
NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
int slideCount = slideList.getLength();
if ((destIndex < 0) || (destIndex > slideCount)) {
throw new IndexOutOfBoundsException("the specified Index is out of slide count when call copyForeignSlide method.");
}
OdfSlide sourceSlide = srcDoc.getSlideByIndex(srcIndex);
DrawPageElement sourceSlideElement = sourceSlide.getOdfElement();
//clone the sourceSlideEle, and make a modification on this clone node.
DrawPageElement sourceCloneSlideElement = (DrawPageElement) sourceSlideElement.cloneNode(true);
//copy all the referred xlink:href here
copyForeignLinkRef(sourceCloneSlideElement);
//copy all the referred style definition here
copyForeignStyleRef(sourceCloneSlideElement, srcDoc);
//clone the sourceCloneSlideEle, and this cloned element should in the current dom tree
DrawPageElement cloneSlideElement = (DrawPageElement) cloneForeignElement(sourceCloneSlideElement, contentDom, true);
if (destIndex == slideCount) {
contentRoot.appendChild(cloneSlideElement);
} else {
DrawPageElement refSlide = (DrawPageElement) slideList.item(destIndex);
contentRoot.insertBefore(cloneSlideElement, refSlide);
}
adjustNotePageNumber(destIndex);
//in case that the appended new slide have the same name with the original slide
hasCheckSlideName = false;
checkAllSlideName();