poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r965267 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/49524.xls
Date Sun, 18 Jul 2010 18:00:36 GMT
Author: nick
Date: Sun Jul 18 18:00:36 2010
New Revision: 965267

URL: http://svn.apache.org/viewvc?rev=965267&view=rev
Log:
Fix bug #49524 - Support for setting cell text to be vertically rotated, via style.setRotation(0xff)

Added:
    poi/trunk/test-data/spreadsheet/49524.xls   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=965267&r1=965266&r2=965267&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Jul 18 18:00:36 2010
@@ -34,6 +34,8 @@
 
     <changes>
         <release version="3.7-beta2" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="add">49524 - Support for setting cell
text to be vertically rotated, via style.setRotation(0xff)</action>
+           <action dev="POI-DEVELOPERS" type="fix">49609 - Case insensitive matching
of OOXML part names</action>
            <action dev="POI-DEVELOPERS" type="add">49581 - Ability to add, modify and
remove series from HSSF Charts</action>
            <action dev="POI-DEVELOPERS" type="add">49185 - Support for HSSFNames where
the comment is stored in a NameCommentRecord</action>
            <action dev="POI-DEVELOPERS" type="fix">49599 - Correct writing of NoteRecord
author text when switching between ASCII and Unicode</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=965267&r1=965266&r2=965267&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Sun Jul 18 18:00:36
2010
@@ -283,31 +283,40 @@ public final class HSSFCellStyle impleme
 
     /**
      * set the degree of rotation for the text in the cell
-     * @param rotation degrees (between -90 and 90 degrees)
+     * @param rotation degrees (between -90 and 90 degrees, of 0xff for vertical)
      */
     public void setRotation(short rotation)
     {
-      if ((rotation < 0)&&(rotation >= -90)) {
+      if (rotation == 0xff) {
+          // Special cases for vertically aligned text
+      } 
+      else if ((rotation < 0)&&(rotation >= -90)) {
         //Take care of the funny 4th quadrant issue
         //The 4th quadrant (-1 to -90) is stored as (91 to 180)
         rotation = (short)(90 - rotation);
       }
-      else if ((rotation < -90)  ||(rotation > 90))
+      else if ((rotation < -90)  ||(rotation > 90)) {
         //Do not allow an incorrect rotation to be set
-        throw new IllegalArgumentException("The rotation must be between -90 and 90 degrees");
-        _format.setRotation(rotation);
+        throw new IllegalArgumentException("The rotation must be between -90 and 90 degrees,
or 0xff");
+      }
+      _format.setRotation(rotation);
     }
 
     /**
      * get the degree of rotation for the text in the cell
-     * @return rotation degrees (between -90 and 90 degrees)
+     * @return rotation degrees (between -90 and 90 degrees, or 0xff for vertical)
      */
     public short getRotation()
     {
       short rotation = _format.getRotation();
-      if (rotation > 90)
+      if (rotation == 0xff) {
+         // Vertical aligned special case
+         return rotation;
+      }
+      if (rotation > 90) {
         //This is actually the 4th quadrant
         rotation = (short)(90-rotation);
+      }
       return rotation;
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=965267&r1=965266&r2=965267&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sun Jul 18 18:00:36
2010
@@ -42,7 +42,12 @@ import org.apache.poi.hssf.record.common
 import org.apache.poi.hssf.record.formula.Area3DPtg;
 import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
 import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.util.TempFile;
 
 /**
@@ -1761,4 +1766,41 @@ if(1==2) {
       name = wb.getName("ChangedName");
       assertEquals("Changed Comment", name.getComment());
     }
+    
+    /**
+     * Vertically aligned text
+     */
+    public void test49524() throws Exception {
+       HSSFWorkbook wb = openSample("49524.xls");
+       Sheet s = wb.getSheetAt(0);
+       Row r = s.getRow(0);
+       Cell rotated = r.getCell(0);
+       Cell normal = r.getCell(1);
+       
+       // Check the current ones
+       assertEquals(0, normal.getCellStyle().getRotation());
+       assertEquals(0xff, rotated.getCellStyle().getRotation());
+       
+       // Add a new style, also rotated
+       CellStyle cs = wb.createCellStyle();
+       cs.setRotation((short)0xff);
+       Cell nc = r.createCell(2);
+       nc.setCellValue("New Rotated Text");
+       nc.setCellStyle(cs);
+       assertEquals(0xff, nc.getCellStyle().getRotation());
+       
+       // Write out and read back
+       wb = writeOutAndReadBack(wb);
+       
+       // Re-check
+       s = wb.getSheetAt(0);
+       r = s.getRow(0);
+       rotated = r.getCell(0);
+       normal = r.getCell(1);
+       nc = r.getCell(2);
+       
+       assertEquals(0, normal.getCellStyle().getRotation());
+       assertEquals(0xff, rotated.getCellStyle().getRotation());
+       assertEquals(0xff, nc.getCellStyle().getRotation());
+    }
 }

Added: poi/trunk/test-data/spreadsheet/49524.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/49524.xls?rev=965267&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/49524.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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


Mime
View raw message