poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1814122 - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/sl/usermodel/ trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ trunk/src/ooxml/testcases/org/apache/poi/sl/ trunk/src/scratchpad/src/org/apache/poi/h...
Date Thu, 02 Nov 2017 23:15:19 GMT
Author: kiwiwings
Date: Thu Nov  2 23:15:19 2017
New Revision: 1814122

URL: http://svn.apache.org/viewvc?rev=1814122&view=rev
Log:
#61671 - XSLFSlide does not contain isHidden and setHidden like HSLFSlide does

Added:
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java   (with props)
Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1814122&r1=1814121&r2=1814122&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Thu Nov  2 23:15:19 2017
@@ -66,6 +66,7 @@
         <summary-item>Removal of deprecated classes and methods that were marked for
removal in v3.18</summary-item>
       </summary>
       <actions>
+        <action dev="PD" type="add" fixes-bug="61671" module="XSLF">XSLFSlide does
not contain isHidden and setHidden like HSLFSlide does</action>
         <action dev="PD" type="update" fixes-bug="61630" module="XSSF">Performance
improvement to XSSFExportToXML</action>
         <action dev="PD" type="add" fixes-bug="58068" module="XSSF">Add a method to
pass the actual Color to StylesTable.findFont()</action>
         <action dev="PD" type="fix" fixes-bug="61096" module="POIFS">Add support for
modules in VBAMacroReader</action>

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java?rev=1814122&r1=1814121&r2=1814122&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java Thu Nov  2 23:15:19 2017
@@ -53,4 +53,20 @@ public interface Slide<
      * @since POI 3.16-beta2
      */
     boolean getDisplayPlaceholder(Placeholder placeholder);
+
+    /**
+     * Sets the slide visibility 
+     *
+     * @param hidden slide visibility, if {@code true} the slide is hidden, {@code false}
shows the slide
+     * 
+     * @since POI 4.0.0
+     */
+    void setHidden(boolean hidden);
+
+    /**
+     * @return the slide visibility, the slide is hidden when {@code true} - or shown when
{@code false}
+     * 
+     * @since POI 4.0.0
+     */
+    boolean isHidden();
 }

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=1814122&r1=1814121&r2=1814122&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 Thu Nov  2 23:15:19
2017
@@ -124,6 +124,7 @@ implements Slide<XSLFShape,XSLFTextParag
         return "sld";        
     }
 
+    @Override
     public XSLFSlideLayout getMasterSheet(){
         return getSlideLayout();
     }
@@ -162,6 +163,7 @@ implements Slide<XSLFShape,XSLFTextParag
        return _comments;
     }
 
+    @Override
     public XSLFNotes getNotes() {
        if(_notes == null) {
           for (POIXMLDocumentPart p : getRelations()) {
@@ -217,10 +219,12 @@ implements Slide<XSLFShape,XSLFTextParag
     }
 
 
+    @Override
     public boolean getFollowMasterObjects() {
         return getFollowMasterGraphics();
     }
     
+    @Override
     public void setFollowMasterObjects(boolean follow) {
         setFollowMasterGraphics(follow);
     }
@@ -260,20 +264,24 @@ implements Slide<XSLFShape,XSLFTextParag
         return this;
     }
 
+    @Override
     public boolean getFollowMasterBackground() {
         return false;
     }
     
+    @Override
     @NotImplemented
     public void setFollowMasterBackground(boolean follow) {
         // not implemented ... also not in the specs
         throw new UnsupportedOperationException();
     }
 
+    @Override
     public boolean getFollowMasterColourScheme() {
         return false;
     }
     
+    @Override
     @NotImplemented
     public void setFollowMasterColourScheme(boolean follow) {
         // not implemented ... only for OLE objects in the specs
@@ -309,4 +317,24 @@ implements Slide<XSLFShape,XSLFTextParag
     public boolean getDisplayPlaceholder(Placeholder placeholder) {
         return false;
     }
+
+    
+    @Override
+    public void setHidden(boolean hidden) {
+        CTSlide sld = getXmlObject();
+        if (hidden) {
+            sld.setShow(false);
+        } else {
+            // if the attribute does not exist, the slide is shown
+            if (sld.isSetShow()) {
+                sld.unsetShow();
+            }
+        }
+    }
+    
+    @Override
+    public boolean isHidden() {
+        CTSlide sld = getXmlObject();
+        return sld.isSetShow() && !sld.getShow();
+    }    
 }

Added: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java?rev=1814122&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java Thu Nov  2 23:15:19 2017
@@ -0,0 +1,73 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.sl;
+
+import static org.apache.poi.sl.SLCommonUtils.xslfOnly;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.sl.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.SlideShowFactory;
+import org.apache.poi.xslf.usermodel.XMLSlideShow;
+import org.junit.Test;
+
+public class TestSlide {
+
+    @Test
+    public void hideHSLF() throws IOException {
+        assumeFalse(xslfOnly());
+        SlideShow<?,?> ppt1 = new HSLFSlideShow();
+        hideSlide(ppt1);
+        ppt1.close();
+    }
+    
+    @Test
+    public void hideXSLF() throws IOException {
+        SlideShow<?,?> ppt1 = new XMLSlideShow();
+        hideSlide(ppt1);
+        ppt1.close();
+    }
+    
+    private void hideSlide(SlideShow<?,?> ppt1) throws IOException {
+        ppt1.createSlide().setHidden(true);
+        ppt1.createSlide();
+        
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        ppt1.write(bos);
+        ppt1.close();
+        
+        InputStream is = new ByteArrayInputStream(bos.toByteArray());
+        SlideShow<?,?> ppt2 = SlideShowFactory.create(is);
+
+        Boolean[] hiddenState = ppt2.getSlides().stream().map(e -> e.isHidden()).toArray(Boolean[]::new);
+        
+        assertTrue(hiddenState[0]);
+        assertFalse(hiddenState[1]);
+        
+        ppt2.close();
+    }
+}
\ No newline at end of file

Propchange: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1814122&r1=1814121&r2=1814122&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java Thu Nov  2 23:15:19
2017
@@ -460,6 +460,7 @@ public final class HSLFSlide extends HSL
 		return this.getPPDrawing().getTextboxWrappers();
 	}
 
+	@Override
 	public void setHidden(boolean hidden) {
 		org.apache.poi.hslf.record.Slide cont =	getSlideRecord();
 
@@ -473,7 +474,8 @@ public final class HSLFSlide extends HSL
 		slideInfo.setEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT, hidden);
 	}
 
-	public boolean getHidden() {
+    @Override
+	public boolean isHidden() {
 		SSSlideInfoAtom slideInfo =
 			(SSSlideInfoAtom)getSlideRecord().findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
 		return (slideInfo == null)

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java?rev=1814122&r1=1814121&r2=1814122&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java Thu Nov
 2 23:15:19 2017
@@ -89,8 +89,8 @@ public final class TestSlideAtom {
 		HSLFSlideShow ss2 = HSLFTestDataSamples.writeOutAndReadBack(ss1);
 		slide1 = ss2.getSlides().get(0);
 		slide2 = ss2.getSlides().get(1);
-		assertFalse(slide1.getHidden());
-		assertTrue(slide2.getHidden());
+		assertFalse(slide1.isHidden());
+		assertTrue(slide2.isHidden());
 		ss2.close();
 		ss1.close();
 	}



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


Mime
View raw message