]> source.dussan.org Git - poi.git/commitdiff
Make setLandscape(false) and setLeftToRight(false) do what one would expect
authorDominik Stadler <centic@apache.org>
Wed, 17 Jun 2015 14:26:31 +0000 (14:26 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 17 Jun 2015 14:26:31 +0000 (14:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1686019 13f79535-47bb-0310-9956-ffa450edef68

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

index ecbbe8ecd6d5e31371359a23a94291afbb0750f8..43b8c5a212518e23342f2c6f5259e4af539e72af 100644 (file)
@@ -120,6 +120,8 @@ public class XSSFPrintSetup implements PrintSetup {
     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 PrintSetup {
     public void setLandscape(boolean ls) {
         if (ls)
             setOrientation(PrintOrientation.LANDSCAPE);
+        else 
+            setOrientation(PrintOrientation.PORTRAIT);
     }
 
     /**
index 3001197cd436ccf7edb7fcfd6f82648739f4c8df..6cda3aff290204847ced5c237545fbaaf3b0e72d 100644 (file)
@@ -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 TestCase {
        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 TestCase {
        print = s1.getPrintSetup();
        assertEquals(3, print.getCopies());
        assertEquals(true, print.getLandscape());
+       
+       wb.close();
     }
 
     /**
@@ -248,4 +256,30 @@ public class TestXSSFPrintSetup extends TestCase {
     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());
+    }
 }