]> source.dussan.org Git - poi.git/commitdiff
Reverting method name change. Taking a risk on breaking binary compatibility for...
authorJosh Micich <josh@apache.org>
Tue, 16 Sep 2008 21:56:36 +0000 (21:56 +0000)
committerJosh Micich <josh@apache.org>
Tue, 16 Sep 2008 21:56:36 +0000 (21:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@696084 13f79535-47bb-0310-9956-ffa450edef68

src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java
src/java/org/apache/poi/hssf/dev/HSSF.java
src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java

index c11d781db483eab4cdd89ef10e186137fab2231b..f4695376d03ffc107500a87a10edf70b5d30124d 100644 (file)
@@ -103,7 +103,7 @@ public class SViewerPanel extends JPanel {
     TableColumnModel columns = sheetView.getColumnModel();
     for (int i=0; i< columns.getColumnCount(); i++) {
       TableColumn column = columns.getColumn(i);
-      int width = sheet.getColWidth(i);
+      int width = sheet.getColumnWidth(i);
       //256 is because the width is in 256ths of a character
       column.setPreferredWidth(width/256*magicCharFactor);
     }
index ecb07672abacc6b6ae4f3082e8ee1b744a5f5b3d..43afead985fb540c34bf4edb6fb8a1c8f8b62108 100644 (file)
@@ -134,7 +134,7 @@ public class HSSF
                 c = r.createCell(cellnum + 1,
                                  HSSFCell.CELL_TYPE_STRING);
                 c.setCellValue(new HSSFRichTextString("TEST"));
-                s.setColWidth(cellnum + 1, (int)(50 * 8 / 0.05));
+                s.setColumnWidth(cellnum + 1, (int)(50 * 8 / 0.05));
                 if ((rownum % 2) == 0)
                 {
                     c.setCellStyle(cs2);
index bc89d1fd842a942daa4d11de0632365728a0f0c3..1afb30f5a6e23c8eae3e56393f95d1223005cdfa 100644 (file)
@@ -160,9 +160,9 @@ public class HSSFPicture
         return anchor;
     }
 
-    private float getColumnWidthInPixels(short column){
+    private float getColumnWidthInPixels(int column){
 
-        int cw = patriarch.sheet.getColWidth(column);
+        int cw = patriarch.sheet.getColumnWidth(column);
         float px = getPixelWidth(column);
 
         return cw/px;
@@ -178,10 +178,10 @@ public class HSSFPicture
         return height/PX_ROW;
     }
 
-    private float getPixelWidth(short column){
+    private float getPixelWidth(int column){
 
-        int def = patriarch.sheet.getDefaultColWidth()*256;
-        int cw = patriarch.sheet.getColWidth(column);
+        int def = patriarch.sheet.getDefaultColumnWidth()*256;
+        int cw = patriarch.sheet.getColumnWidth(column);
 
         return cw == def ? PX_DEFAULT : PX_MODIFIED;
     }
index 0439853dfd1ed6709b3a99cd9360c15fd0daeba9..7febeb9c7cecc87dd81d70beb6a48b01a910320d 100644 (file)
@@ -404,30 +404,24 @@ public final class HSSFSheet {
     }
 
     /**
-     * @deprecated (Sep 2008) use {@link #setColWidth(int, int)}
+     * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)}
      */
     public void setColumnWidth(short columnIndex, short width) {
-        setColWidth(columnIndex & 0xFFFF, width & 0xFFFF);
+        setColumnWidth(columnIndex & 0xFFFF, width & 0xFFFF);
     }
 
     /**
-     * @deprecated (Sep 2008) use {@link #getColWidth(int)}
+     * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
      */
     public short getColumnWidth(short columnIndex) {
-        return (short)getColWidth(columnIndex & 0xFFFF);
+        return (short)getColumnWidth(columnIndex & 0xFFFF);
     }
 
     /**
-     * @deprecated (Sep 2008) use {@link #getDefaultColWidth()}
-     */
-    public short getDefaultColumnWidth() {
-        return (short) getDefaultColWidth();
-    }
-    /**
-     * @deprecated (Sep 2008) use {@link #setDefaultColWidth(int)}
+     * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)}
      */
     public void setDefaultColumnWidth(short width) {
-        setDefaultColWidth(width & 0xFFFF);
+        setDefaultColumnWidth(width & 0xFFFF);
     }
 
     /**
@@ -453,7 +447,7 @@ public final class HSSFSheet {
      * @param columnIndex - the column to set (0-based)
      * @param width - the width in units of 1/256th of a character width
      */
-    public void setColWidth(int columnIndex, int width) {
+    public void setColumnWidth(int columnIndex, int width) {
         sheet.setColumnWidth(columnIndex, width);
     }
 
@@ -462,7 +456,7 @@ public final class HSSFSheet {
      * @param columnIndex - the column to set (0-based)
      * @return width - the width in units of 1/256th of a character width
      */
-    public int getColWidth(int columnIndex) {
+    public int getColumnWidth(int columnIndex) {
         return sheet.getColumnWidth(columnIndex);
     }
 
@@ -471,7 +465,7 @@ public final class HSSFSheet {
      * characters
      * @return default column width
      */
-    public int getDefaultColWidth() {
+    public int getDefaultColumnWidth() {
         return sheet.getDefaultColumnWidth();
     }
     /**
@@ -479,7 +473,7 @@ public final class HSSFSheet {
      * characters
      * @param width default column width
      */
-    public void setDefaultColWidth(int width) {
+    public void setDefaultColumnWidth(int width) {
         sheet.setDefaultColumnWidth(width);
     }
 
index 6b2d90a9e27cc77fe1299eafa7124718de396cd0..a4f9bbf18dbda7065ef839ae6c099450bd189703 100644 (file)
@@ -218,7 +218,7 @@ public final class TestBugs extends TestCase {
             }
         }
 
-        sheet.setDefaultColWidth(18) ;
+        sheet.setDefaultColumnWidth(18) ;
 
         writeTestOutputFileForViewing(wb, "test22568");
     }
index 40f16c3e5aaef34ca2054943d312eacfaafbc0c2..68e13f489b8b65afc5abee341364ee69ae266186 100644 (file)
@@ -268,11 +268,11 @@ public final class TestDataValidation extends TestCase {
                        for (int i = 0; i < 6; i++) {
                                row.createCell(i).setCellStyle(_style_4);
                                if (i == 2 || i == 3 || i == 4) {
-                                       sheet.setColWidth(i, 3500);
+                                       sheet.setColumnWidth(i, 3500);
                                } else if (i == 5) {
-                                       sheet.setColWidth(i, 10000);
+                                       sheet.setColumnWidth(i, 10000);
                                } else {
-                                       sheet.setColWidth(i, 8000);
+                                       sheet.setColumnWidth(i, 8000);
                                }
                        }
                        HSSFCell cell = row.getCell(0);
index 880f2809dc9fd3a76f2fced1df57428b5e2b4346..5e9541d540e509a1e7c51f179e61ddf10e776f90 100644 (file)
@@ -681,8 +681,8 @@ public final class TestHSSFSheet extends TestCase {
         // autoSize the first column and check its size before the merged region (1,0,1,1) is set:
         // it has to be based on the 2nd row width
         sheet.autoSizeColumn((short)0);
-        assertTrue("Column autosized with only one row: wrong width", sheet.getColWidth(0) >= minWithRow1And2);
-        assertTrue("Column autosized with only one row: wrong width", sheet.getColWidth(0) <= maxWithRow1And2);
+        assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth(0) >= minWithRow1And2);
+        assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth(0) <= maxWithRow1And2);
 
         //create a region over the 2nd row and auto size the first column
         sheet.addMergedRegion(new CellRangeAddress(1,1,0,1));
@@ -692,16 +692,16 @@ public final class TestHSSFSheet extends TestCase {
         // check that the autoSized column width has ignored the 2nd row
         // because it is included in a merged region (Excel like behavior)
         HSSFSheet sheet2 = wb2.getSheet(sheetName);
-        assertTrue(sheet2.getColWidth(0) >= minWithRow1Only);
-        assertTrue(sheet2.getColWidth(0) <= maxWithRow1Only);
+        assertTrue(sheet2.getColumnWidth(0) >= minWithRow1Only);
+        assertTrue(sheet2.getColumnWidth(0) <= maxWithRow1Only);
 
         // remove the 2nd row merged region and check that the 2nd row value is used to the autoSizeColumn width
         sheet2.removeMergedRegion(1);
         sheet2.autoSizeColumn((short)0);
         HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
         HSSFSheet sheet3 = wb3.getSheet(sheetName);
-        assertTrue(sheet3.getColWidth(0) >= minWithRow1And2);
-        assertTrue(sheet3.getColWidth(0) <= maxWithRow1And2);
+        assertTrue(sheet3.getColumnWidth(0) >= minWithRow1And2);
+        assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2);
     }
 
     /**
@@ -785,16 +785,16 @@ public final class TestHSSFSheet extends TestCase {
         HSSFSheet sh = wb.getSheetAt(0);
         for (char i = 'A'; i <= 'S'; i++) {
             int idx = i - 'A';
-            int w = sh.getColWidth(idx);
+            int w = sh.getColumnWidth(idx);
             assertEquals(ref[idx], w);
         }
 
         //the second sheet doesn't have overridden column widths
         sh = wb.getSheetAt(1);
-        int def_width = sh.getDefaultColWidth();
+        int def_width = sh.getDefaultColumnWidth();
         for (char i = 'A'; i <= 'S'; i++) {
             int idx = i - 'A';
-            int w = sh.getColWidth(idx);
+            int w = sh.getColumnWidth(idx);
             //getDefaultColumnWidth returns width measured in characters
             //getColumnWidth returns width measured in 1/256th units
             assertEquals(def_width*256, w);
@@ -803,35 +803,35 @@ public final class TestHSSFSheet extends TestCase {
         //test new workbook
         wb = new HSSFWorkbook();
         sh = wb.createSheet();
-        sh.setDefaultColWidth(10);
-        assertEquals(10, sh.getDefaultColWidth());
-        assertEquals(256*10, sh.getColWidth(0));
-        assertEquals(256*10, sh.getColWidth(1));
-        assertEquals(256*10, sh.getColWidth(2));
+        sh.setDefaultColumnWidth(10);
+        assertEquals(10, sh.getDefaultColumnWidth());
+        assertEquals(256*10, sh.getColumnWidth(0));
+        assertEquals(256*10, sh.getColumnWidth(1));
+        assertEquals(256*10, sh.getColumnWidth(2));
         for (char i = 'D'; i <= 'F'; i++) {
             short w = (256*12);
-            sh.setColWidth(i, w);
-            assertEquals(w, sh.getColWidth(i));
+            sh.setColumnWidth(i, w);
+            assertEquals(w, sh.getColumnWidth(i));
         }
 
         //serialize and read again
         wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
 
         sh = wb.getSheetAt(0);
-        assertEquals(10, sh.getDefaultColWidth());
+        assertEquals(10, sh.getDefaultColumnWidth());
         //columns A-C have default width
-        assertEquals(256*10, sh.getColWidth(0));
-        assertEquals(256*10, sh.getColWidth(1));
-        assertEquals(256*10, sh.getColWidth(2));
+        assertEquals(256*10, sh.getColumnWidth(0));
+        assertEquals(256*10, sh.getColumnWidth(1));
+        assertEquals(256*10, sh.getColumnWidth(2));
         //columns D-F have custom width
         for (char i = 'D'; i <= 'F'; i++) {
             short w = (256*12);
-            assertEquals(w, sh.getColWidth(i));
+            assertEquals(w, sh.getColumnWidth(i));
         }
 
         // check for 16-bit signed/unsigned error:
-        sh.setColWidth(0, 40000);
-        assertEquals(40000, sh.getColWidth(0));
+        sh.setColumnWidth(0, 40000);
+        assertEquals(40000, sh.getColumnWidth(0));
     }
 
     /**