poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1686019 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java
Date Wed, 17 Jun 2015 14:26:32 GMT
Author: centic
Date: Wed Jun 17 14:26:31 2015
New Revision: 1686019

URL: http://svn.apache.org/r1686019
Log:
Make setLandscape(false) and setLeftToRight(false) do what one would expect

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java?rev=1686019&r1=1686018&r2=1686019&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java Wed Jun 17
14:26:31 2015
@@ -120,6 +120,8 @@ public class XSSFPrintSetup implements P
     public void setLeftToRight(boolean ltor) {
         if (ltor)
             setPageOrder(PageOrder.OVER_THEN_DOWN);
+        else 
+            setPageOrder(PageOrder.DOWN_THEN_OVER);
     }
 
     /**
@@ -130,6 +132,8 @@ public class XSSFPrintSetup implements P
     public void setLandscape(boolean ls) {
         if (ls)
             setOrientation(PrintOrientation.LANDSCAPE);
+        else 
+            setOrientation(PrintOrientation.PORTRAIT);
     }
 
     /**

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java?rev=1686019&r1=1686018&r2=1686019&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java Wed
Jun 17 14:26:31 2015
@@ -19,12 +19,18 @@ package org.apache.poi.xssf.usermodel;
 
 import junit.framework.TestCase;
 
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
-import org.apache.poi.ss.usermodel.PaperSize;
 import org.apache.poi.ss.usermodel.PageOrder;
-import org.apache.poi.ss.usermodel.PrintOrientation;
+import org.apache.poi.ss.usermodel.PaperSize;
 import org.apache.poi.ss.usermodel.PrintCellComments;
+import org.apache.poi.ss.usermodel.PrintOrientation;
 import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.junit.Test;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STOrientation;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPageOrder;
 
 /**
  * Tests for {@link XSSFPrintSetup}
@@ -226,10 +232,10 @@ public class TestXSSFPrintSetup extends
        assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
        
        // Round trip and check
-       wb = XSSFITestDataProvider.instance.writeOutAndReadBack(wb);
+       XSSFWorkbook wbBack = XSSFITestDataProvider.instance.writeOutAndReadBack(wb);
        
-       s1 = wb.getSheetAt(0);
-       s2 = wb.getSheetAt(1);
+       s1 = wbBack.getSheetAt(0);
+       s2 = wbBack.getSheetAt(1);
        
        assertEquals(true, s1.getCTWorksheet().isSetPageSetup());
        assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
@@ -239,6 +245,8 @@ public class TestXSSFPrintSetup extends
        print = s1.getPrintSetup();
        assertEquals(3, print.getCopies());
        assertEquals(true, print.getLandscape());
+       
+       wb.close();
     }
 
     /**
@@ -248,4 +256,30 @@ public class TestXSSFPrintSetup extends
     public void testRoundTrip() {
        // TODO
     }
+
+    @Test
+    public void testSetLandscapeFalse() throws Exception {
+        XSSFPrintSetup ps = new XSSFPrintSetup(CTWorksheet.Factory.newInstance());
+        
+        assertFalse(ps.getLandscape());
+        
+        ps.setLandscape(true);
+        assertTrue(ps.getLandscape());
+        
+        ps.setLandscape(false);
+        assertFalse(ps.getLandscape());
+    }
+
+    @Test
+    public void testSetLeftToRight() throws Exception {
+        XSSFPrintSetup ps = new XSSFPrintSetup(CTWorksheet.Factory.newInstance());
+        
+        assertFalse(ps.getLeftToRight());
+        
+        ps.setLeftToRight(true);
+        assertTrue(ps.getLeftToRight());
+        
+        ps.setLeftToRight(false);
+        assertFalse(ps.getLeftToRight());
+    }
 }



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


Mime
View raw message