Import slide notes when importing slide content

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alain Béarez 2021-02-08 20:34:14 +00:00
parent db962309b9
commit 4cf6b5b071
3 changed files with 31 additions and 2 deletions

View File

@ -143,7 +143,10 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
if (this instanceof PlaceableShape) {
PlaceableShape<?,?> ps = (PlaceableShape<?,?>)this;
ps.setAnchor(sh.getAnchor());
Rectangle2D anchor = sh.getAnchor();
if (anchor != null) {
ps.setAnchor(anchor);
}
}
@ -485,4 +488,4 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
protected XmlObject getShapeProperties() {
return getChild(CTShapeProperties.class, PML_NS, "spPr");
}
}
}

View File

@ -295,6 +295,11 @@ implements Slide<XSLFShape,XSLFTextParagraph> {
return this;
}
XSLFNotes srcNotes = ((XSLFSlide)src).getNotes();
if (srcNotes != null) {
getSlideShow().getNotesSlide(this).importContent(srcNotes);
}
// only copy direct backgrounds - not backgrounds of master sheet
CTBackground bgOther = ((XSLFSlide)src)._slide.getCSld().getBg();
if (bgOther == null) {

View File

@ -103,4 +103,25 @@ class TestXSLFNotes {
ppt.close();
}
@Test
void importNotes() throws IOException {
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("sample.pptx");
XMLSlideShow newShow = new XMLSlideShow();
for (XSLFSlide slide : ppt.getSlides()) {
XSLFNotes slideNotes = slide.getNotes();
assertNotNull(slideNotes);
XSLFNotes notesSlide = ppt.getNotesSlide(slide);
assertNotNull(notesSlide);
assertEquals(notesSlide, slideNotes);
XSLFSlide newSlide = newShow.createSlide().importContent(slide);
XSLFNotes newNotes = newSlide.getNotes();
assertNotNull(newNotes);
}
ppt.close();
}
}