Author: abearez
Date: Mon Feb  8 20:34:14 2021
New Revision: 1886338

URL: http://svn.apache.org/viewvc?rev=1886338&view=rev
Log:
Import slide notes when importing slide content

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java?rev=1886338&r1=1886337&r2=1886338&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java Mon 
Feb  8 20:34:14 2021
@@ -143,7 +143,10 @@ public abstract class XSLFShape implemen
 
         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 implemen
     protected XmlObject getShapeProperties() {
         return getChild(CTShapeProperties.class, PML_NS, "spPr");
     }
-}
\ No newline at end of file
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1886338&r1=1886337&r2=1886338&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Mon 
Feb  8 20:34:14 2021
@@ -295,6 +295,11 @@ implements Slide<XSLFShape,XSLFTextParag
             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) {

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java?rev=1886338&r1=1886337&r2=1886338&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java 
Mon Feb  8 20:34:14 2021
@@ -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();
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to