You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/09/17 23:54:33 UTC
svn commit: r696475 - in /poi/branches/ooxml/src:
contrib/src/org/apache/poi/hssf/contrib/view/ documentation/content/xdocs/
java/org/apache/poi/hssf/dev/ java/org/apache/poi/hssf/model/
java/org/apache/poi/hssf/record/ java/org/apache/poi/hssf/record/...
Author: josh
Date: Wed Sep 17 14:54:32 2008
New Revision: 696475
URL: http://svn.apache.org/viewvc?rev=696475&view=rev
Log:
merged 696075,696084 from trunk - (Fix for bug 45805 - 16-bit signed/unsigned problems in HSSFSheet.getColWidth() etc)
Modified:
poi/branches/ooxml/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java
poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
poi/branches/ooxml/src/documentation/content/xdocs/status.xml
poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/HSSF.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Sheet.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java (props changed)
poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/LazyAreaEval.java (props changed)
poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/LazyRefEval.java (props changed)
poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
Modified: poi/branches/ooxml/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java (original)
+++ poi/branches/ooxml/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java Wed Sep 17 14:54:32 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hssf.contrib.view;
@@ -47,10 +44,10 @@
*
*/
private static final int magicCharFactor = 7;
- /** Reference to the woorkbook that is being displayed*/
- private HSSFWorkbook wb;
+ /** Reference to the wookbook that is being displayed*/
+ /* package */ HSSFWorkbook wb;
/** Reference to the tabs component*/
- private JTabbedPane sheetPane;
+ /* package */ JTabbedPane sheetPane;
/** Reference to the cell renderer that is used to render all cells*/
private SVTableCellRenderer cellRenderer;
/** Reference to the cell editor that is used to edit all cells.
@@ -106,7 +103,7 @@
TableColumnModel columns = sheetView.getColumnModel();
for (int i=0; i< columns.getColumnCount(); i++) {
TableColumn column = columns.getColumn(i);
- short width = sheet.getColumnWidth((short)i);
+ int width = sheet.getColumnWidth(i);
//256 is because the width is in 256ths of a character
column.setPreferredWidth(width/256*magicCharFactor);
}
@@ -208,7 +205,7 @@
public void actionPerformed(ActionEvent e) {
int tabIndex = sheetPane.getSelectedIndex();
if (tabIndex != -1) {
- String newSheetName = (String)JOptionPane.showInputDialog(sheetPane, "Enter a new Sheetname", "Rename Sheet", JOptionPane.QUESTION_MESSAGE);
+ String newSheetName = JOptionPane.showInputDialog(sheetPane, "Enter a new Sheetname", "Rename Sheet", JOptionPane.QUESTION_MESSAGE);
if (newSheetName != null) {
wb.setSheetName(tabIndex, newSheetName);
sheetPane.setTitleAt(tabIndex, newSheetName);
Modified: poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/changes.xml?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Wed Sep 17 14:54:32 2008
@@ -67,6 +67,7 @@
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
</release>
<release version="3.2-alpha1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">45805 - Fixed 16-bit signed/unsigned bug in HSSFSheet.getColWidth etc</action>
<action dev="POI-DEVELOPERS" type="fix">45780 - Fixed HSSFSheet.shiftRows to also update Area refs</action>
<action dev="POI-DEVELOPERS" type="fix">45804 - Update HSMF to handle Outlook 3.0 msg files, which have a different string chunk type</action>
<action dev="POI-DEVELOPERS" type="add">Expose the name of Named Cell Styles via HSSFCellStyle (normally held on the parent style though)</action>
Modified: poi/branches/ooxml/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/status.xml?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Wed Sep 17 14:54:32 2008
@@ -64,6 +64,7 @@
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
</release>
<release version="3.2-alpha1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">45805 - Fixed 16-bit signed/unsigned bug in HSSFSheet.getColWidth etc</action>
<action dev="POI-DEVELOPERS" type="fix">45780 - Fixed HSSFSheet.shiftRows to also update Area refs</action>
<action dev="POI-DEVELOPERS" type="fix">45804 - Update HSMF to handle Outlook 3.0 msg files, which have a different string chunk type</action>
<action dev="POI-DEVELOPERS" type="add">Expose the name of Named Cell Styles via HSSFCellStyle (normally held on the parent style though)</action>
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/HSSF.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/HSSF.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/HSSF.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/HSSF.java Wed Sep 17 14:54:32 2008
@@ -135,8 +135,7 @@
c = r.createCell(cellnum + 1,
HSSFCell.CELL_TYPE_STRING);
c.setCellValue(new HSSFRichTextString("TEST"));
- s.setColumnWidth(( short ) (cellnum + 1),
- ( short ) ((50 * 8) / (( double ) 1 / 20)));
+ s.setColumnWidth(cellnum + 1, (int)(50 * 8 / 0.05));
if ((rownum % 2) == 0)
{
c.setCellStyle(cs2);
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Sheet.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Sheet.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Sheet.java Wed Sep 17 14:54:32 2008
@@ -973,9 +973,7 @@
* get the default column width for the sheet (if the columns do not define their own width)
* @return default column width
*/
-
- public short getDefaultColumnWidth()
- {
+ public int getDefaultColumnWidth() {
return defaultcolwidth.getColWidth();
}
@@ -1009,9 +1007,7 @@
* set the default column width for the sheet (if the columns do not define their own width)
* @param dcw default column width
*/
-
- public void setDefaultColumnWidth(short dcw)
- {
+ public void setDefaultColumnWidth(int dcw) {
defaultcolwidth.setColWidth(dcw);
}
@@ -1043,15 +1039,15 @@
* @return column width in units of 1/256th of a character width
*/
- public short getColumnWidth(short columnIndex) {
+ public int getColumnWidth(int columnIndex) {
ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);
if (ci != null) {
- return (short)ci.getColumnWidth();
+ return ci.getColumnWidth();
}
//default column width is measured in characters
//multiply
- return (short)(256*defaultcolwidth.getColWidth());
+ return (256*defaultcolwidth.getColWidth());
}
/**
@@ -1084,8 +1080,8 @@
* @param width
* (in units of 1/256th of a character width)
*/
- public void setColumnWidth(short column, short width) {
- setColumn( column, new Short(width), null, null, null);
+ public void setColumnWidth(int column, int width) {
+ setColumn(column, null, new Integer(width), null, null, null);
}
/**
@@ -1096,7 +1092,7 @@
* @see #setColumnHidden(short,boolean)
* @return whether the column is hidden or not.
*/
- public boolean isColumnHidden(short columnIndex) {
+ public boolean isColumnHidden(int columnIndex) {
ColumnInfoRecord cir = _columnInfos.findColumnInfo(columnIndex);
if (cir == null) {
return false;
@@ -1109,16 +1105,14 @@
* @param column - the column number
* @param hidden - whether the column is hidden or not
*/
- public void setColumnHidden(short column, boolean hidden)
- {
- setColumn( column, null, null, new Boolean(hidden), null);
+ public void setColumnHidden(int column, boolean hidden) {
+ setColumn( column, null, null, null, Boolean.valueOf(hidden), null);
}
-
- public void setColumn(short column, Short width, Integer level, Boolean hidden, Boolean collapsed) {
- _columnInfos.setColumn( column, null, width, level, hidden, collapsed );
+ public void setDefaultColumnStyle(int column, int styleIndex) {
+ setColumn(column, new Short((short)styleIndex), null, null, null, null);
}
- public void setColumn(short column, Short xfStyle, Short width, Integer level, Boolean hidden, Boolean collapsed) {
+ private void setColumn(int column, Short xfStyle, Integer width, Integer level, Boolean hidden, Boolean collapsed) {
_columnInfos.setColumn( column, xfStyle, width, level, hidden, collapsed );
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java Wed Sep 17 14:54:32 2008
@@ -40,7 +40,7 @@
private static final BitField outlevel = BitFieldFactory.getInstance(0x0700);
private static final BitField collapsed = BitFieldFactory.getInstance(0x1000);
// Excel seems write values 2, 10, and 260, even though spec says "must be zero"
- private short field_6_reserved;
+ private int field_6_reserved;
/**
* Creates a column info record with default width and format
@@ -64,14 +64,14 @@
protected void fillFields(RecordInputStream in)
{
- field_1_first_col = in.readShort();
- field_2_last_col = in.readShort();
- field_3_col_width = in.readShort();
- field_4_xf_index = in.readShort();
- field_5_options = in.readShort();
+ field_1_first_col = in.readUShort();
+ field_2_last_col = in.readUShort();
+ field_3_col_width = in.readUShort();
+ field_4_xf_index = in.readUShort();
+ field_5_options = in.readUShort();
switch(in.remaining()) {
case 2: // usual case
- field_6_reserved = in.readShort();
+ field_6_reserved = in.readUShort();
break;
case 1:
// often COLINFO gets encoded 1 byte short
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java Wed Sep 17 14:54:32 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,14 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian;
/**
- * Title: Default Column Width Record<P>
+ * Title: Default Column Width Record (0x0055) <P>
* Description: Specifies the default width for columns that have no specific
* width set.<P>
* REFERENCE: PG 302 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
@@ -30,12 +28,9 @@
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public class DefaultColWidthRecord
- extends Record
-{
- public final static short sid = 0x55;
- private short field_1_col_width;
+public final class DefaultColWidthRecord extends Record {
+ public final static short sid = 0x0055;
+ private int field_1_col_width;
public DefaultColWidthRecord()
{
@@ -61,17 +56,17 @@
protected void fillFields(RecordInputStream in)
{
- field_1_col_width = in.readShort();
+ field_1_col_width = in.readUShort();
}
/**
* set the default column width
- * @param height defaultwidth for columns
+ * @param width defaultwidth for columns
*/
- public void setColWidth(short height)
+ public void setColWidth(int width)
{
- field_1_col_width = height;
+ field_1_col_width = width;
}
/**
@@ -79,7 +74,7 @@
* @return defaultwidth for columns
*/
- public short getColWidth()
+ public int getColWidth()
{
return field_1_col_width;
}
@@ -97,9 +92,9 @@
public int serialize(int offset, byte [] data)
{
- LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, ( short ) 0x2);
- LittleEndian.putShort(data, 4 + offset, getColWidth());
+ LittleEndian.putUShort(data, 0 + offset, sid);
+ LittleEndian.putUShort(data, 2 + offset, 0x2);
+ LittleEndian.putUShort(data, 4 + offset, getColWidth());
return getRecordSize();
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java Wed Sep 17 14:54:32 2008
@@ -299,7 +299,7 @@
}
- public void setColumn(int targetColumnIx, Short xfIndex, Short width,
+ public void setColumn(int targetColumnIx, Short xfIndex, Integer width,
Integer level, Boolean hidden, Boolean collapsed) {
ColumnInfoRecord ci = null;
int k = 0;
@@ -389,13 +389,13 @@
/**
* Sets all non null fields into the <code>ci</code> parameter.
*/
- private static void setColumnInfoFields( ColumnInfoRecord ci, Short xfStyle, Short width,
- Integer level, Boolean hidden, Boolean collapsed ) {
+ private static void setColumnInfoFields(ColumnInfoRecord ci, Short xfStyle, Integer width,
+ Integer level, Boolean hidden, Boolean collapsed) {
if (xfStyle != null) {
ci.setXFIndex(xfStyle.shortValue());
}
if (width != null) {
- ci.setColumnWidth(width.shortValue());
+ ci.setColumnWidth(width.intValue());
}
if (level != null) {
ci.setOutlineLevel( level.shortValue() );
Propchange: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 17 14:54:32 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java:695264-695420,695621,695649,696038
+/poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java:695264-695420,695621,695649,696038,696075-696084
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java Wed Sep 17 14:54:32 2008
@@ -160,9 +160,9 @@
return anchor;
}
- private float getColumnWidthInPixels(short column){
+ private float getColumnWidthInPixels(int column){
- short cw = patriarch.sheet.getColumnWidth(column);
+ int cw = patriarch.sheet.getColumnWidth(column);
float px = getPixelWidth(column);
return cw/px;
@@ -178,10 +178,10 @@
return height/PX_ROW;
}
- private float getPixelWidth(short column){
+ private float getPixelWidth(int column){
int def = patriarch.sheet.getDefaultColumnWidth()*256;
- short cw = patriarch.sheet.getColumnWidth(column);
+ int cw = patriarch.sheet.getColumnWidth(column);
return cw == def ? PX_DEFAULT : PX_MODIFIED;
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Wed Sep 17 14:54:32 2008
@@ -396,47 +396,74 @@
/**
+ * @deprecated (Sep 2008) use {@link #setColumnHidden(int, boolean)}
+ */
+ public void setColumnHidden(short columnIndex, boolean hidden) {
+ setColumnHidden(columnIndex & 0xFFFF, hidden);
+ }
+
+ /**
+ * @deprecated (Sep 2008) use {@link #isColumnHidden(int)}
+ */
+ public boolean isColumnHidden(short columnIndex) {
+ return isColumnHidden(columnIndex & 0xFFFF);
+ }
+
+ /**
+ * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)}
+ */
+ public void setColumnWidth(short columnIndex, short width) {
+ setColumnWidth(columnIndex & 0xFFFF, width & 0xFFFF);
+ }
+
+ /**
+ * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
+ */
+ public short getColumnWidth(short columnIndex) {
+ return (short)getColumnWidth(columnIndex & 0xFFFF);
+ }
+
+ /**
+ * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)}
+ */
+ public void setDefaultColumnWidth(short width) {
+ setDefaultColumnWidth(width & 0xFFFF);
+ }
+
+ /**
* Get the visibility state for a given column.
- * @param column - the column to get (0-based)
+ * @param columnIndex - the column to get (0-based)
* @param hidden - the visiblity state of the column
*/
-
- public void setColumnHidden(short column, boolean hidden)
- {
- sheet.setColumnHidden(column, hidden);
+ public void setColumnHidden(int columnIndex, boolean hidden) {
+ sheet.setColumnHidden(columnIndex, hidden);
}
/**
* Get the hidden state for a given column.
- * @param column - the column to set (0-based)
- * @return hidden - the visiblity state of the column
+ * @param columnIndex - the column to set (0-based)
+ * @return hidden - <code>false</code> if the column is visible
*/
-
- public boolean isColumnHidden(short column)
- {
- return sheet.isColumnHidden(column);
+ public boolean isColumnHidden(int columnIndex) {
+ return sheet.isColumnHidden(columnIndex);
}
/**
* set the width (in units of 1/256th of a character width)
- * @param column - the column to set (0-based)
+ * @param columnIndex - the column to set (0-based)
* @param width - the width in units of 1/256th of a character width
*/
-
- public void setColumnWidth(short column, short width)
- {
- sheet.setColumnWidth(column, width);
+ public void setColumnWidth(int columnIndex, int width) {
+ sheet.setColumnWidth(columnIndex, width);
}
/**
* get the width (in units of 1/256th of a character width )
- * @param column - the column to set (0-based)
+ * @param columnIndex - the column to set (0-based)
* @return width - the width in units of 1/256th of a character width
*/
-
- public short getColumnWidth(short column)
- {
- return sheet.getColumnWidth(column);
+ public int getColumnWidth(int columnIndex) {
+ return sheet.getColumnWidth(columnIndex);
}
/**
@@ -444,20 +471,25 @@
* characters
* @return default column width
*/
-
- public short getDefaultColumnWidth()
- {
+ public int getDefaultColumnWidth() {
return sheet.getDefaultColumnWidth();
}
+ /**
+ * set the default column width for the sheet (if the columns do not define their own width) in
+ * characters
+ * @param width default column width
+ */
+ public void setDefaultColumnWidth(int width) {
+ sheet.setDefaultColumnWidth(width);
+ }
+
/**
* get the default row height for the sheet (if the rows do not define their own height) in
* twips (1/20 of a point)
* @return default row height
*/
-
- public short getDefaultRowHeight()
- {
+ public short getDefaultRowHeight() {
return sheet.getDefaultRowHeight();
}
@@ -473,17 +505,6 @@
}
/**
- * set the default column width for the sheet (if the columns do not define their own width) in
- * characters
- * @param width default column width
- */
-
- public void setDefaultColumnWidth(short width)
- {
- sheet.setDefaultColumnWidth(width);
- }
-
- /**
* set the default row height for the sheet (if the rows do not define their own height) in
* twips (1/20 of a point)
* @param height default row height
@@ -1005,19 +1026,19 @@
/**
* Sets the protection on enabled or disabled
* @param protect true => protection enabled; false => protection disabled
- * @deprecated use protectSheet(String, boolean, boolean)
+ * @deprecated (Jul 2007) use {@link #protectSheet(String)}
*/
public void setProtect(boolean protect) {
getSheet().getProtect().setProtect(protect);
}
- /**
- * Sets the protection enabled as well as the password
- * @param password to set for protection
- */
- public void protectSheet(String password) {
- getSheet().protectSheet(password, true, true); //protect objs&scenarios(normal)
- }
+ /**
+ * Sets the protection enabled as well as the password
+ * @param password to set for protection
+ */
+ public void protectSheet(String password) {
+ getSheet().protectSheet(password, true, true); //protect objs&scenarios(normal)
+ }
/**
* Sets the zoom magnication for the sheet. The zoom is expressed as a
@@ -1630,7 +1651,7 @@
* @param style the style to set
*/
public void setDefaultColumnStyle(short column, CellStyle style) {
- sheet.setColumn(column, new Short(((HSSFCellStyle) style).getIndex()), null, null, null, null);
+ sheet.setDefaultColumnStyle(column, style.getIndex());
}
/**
Propchange: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/LazyAreaEval.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 17 14:54:32 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/hssf/usermodel/LazyAreaEval.java:695264-695420,695621,695649,696038
+/poi/trunk/src/java/org/apache/poi/hssf/usermodel/LazyAreaEval.java:695264-695420,695621,695649,696038,696075-696084
Propchange: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/LazyRefEval.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 17 14:54:32 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/hssf/usermodel/LazyRefEval.java:695264-695420,695621,695649,696038
+/poi/trunk/src/java/org/apache/poi/hssf/usermodel/LazyRefEval.java:695264-695420,695621,695649,696038,696075-696084
Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java Wed Sep 17 14:54:32 2008
@@ -19,7 +19,9 @@
import java.util.Iterator;
+import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.util.PaneInformation;
+import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.Region;
public interface Sheet extends Iterable<Row> {
@@ -96,37 +98,65 @@
int getLastRowNum();
+
+
+ /**
+ * @deprecated (Sep 2008) use {@link #setColumnHidden(int, boolean)}
+ */
+ void setColumnHidden(short columnIndex, boolean hidden);
+ /**
+ * @deprecated (Sep 2008) use {@link #isColumnHidden(int)}
+ */
+ boolean isColumnHidden(short columnIndex);
+
+ /**
+ * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)}
+ */
+ void setColumnWidth(short columnIndex, short width);
+
+ /**
+ * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
+ */
+ short getColumnWidth(short columnIndex);
+
+ /**
+ * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)}
+ */
+ void setDefaultColumnWidth(short width);
+
/**
* Get the visibility state for a given column.
- * @param column - the column to get (0-based)
+ * @param columnIndex - the column to get (0-based)
* @param hidden - the visiblity state of the column
*/
-
- void setColumnHidden(short column, boolean hidden);
+ void setColumnHidden(int columnIndex, boolean hidden);
/**
* Get the hidden state for a given column.
- * @param column - the column to set (0-based)
- * @return hidden - the visiblity state of the column
+ * @param columnIndex - the column to set (0-based)
+ * @return hidden - <code>false</code> if the column is visible
*/
-
- boolean isColumnHidden(short column);
+ boolean isColumnHidden(int columnIndex);
/**
* set the width (in units of 1/256th of a character width)
- * @param column - the column to set (0-based)
+ * @param columnIndex - the column to set (0-based)
* @param width - the width in units of 1/256th of a character width
*/
-
- void setColumnWidth(short column, short width);
+ void setColumnWidth(int columnIndex, int width);
/**
* get the width (in units of 1/256th of a character width )
- * @param column - the column to set (0-based)
+ * @param columnIndex - the column to set (0-based)
* @return width - the width in units of 1/256th of a character width
*/
-
- short getColumnWidth(short column);
+ int getColumnWidth(int columnIndex);
+ /**
+ * set the default column width for the sheet (if the columns do not define their own width) in
+ * characters
+ * @param width default column width
+ */
+ public void setDefaultColumnWidth(int width);
/**
* get the default column width for the sheet (if the columns do not define their own width) in
@@ -134,7 +164,7 @@
* @return default column width
*/
- short getDefaultColumnWidth();
+ int getDefaultColumnWidth();
/**
* get the default row height for the sheet (if the rows do not define their own height) in
@@ -153,14 +183,6 @@
float getDefaultRowHeightInPoints();
/**
- * set the default column width for the sheet (if the columns do not define their own width) in
- * characters
- * @param width default column width
- */
-
- void setDefaultColumnWidth(short width);
-
- /**
* set the default row height for the sheet (if the rows do not define their own height) in
* twips (1/20 of a point)
* @param height default row height
@@ -190,12 +212,17 @@
void setGridsPrinted(boolean value);
+
/**
* adds a merged region of cells (hence those cells form one)
* @param region (rowfrom/colfrom-rowto/colto) to merge
* @return index of this region
*/
+ int addMergedRegion(CellRangeAddress region);
+ /**
+ * @deprecated (Aug-2008) use {@link #addMergedRegion(CellRangeAddress)}
+ */
int addMergedRegion(Region region);
/**
Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Wed Sep 17 14:54:32 2008
@@ -35,6 +35,7 @@
import org.apache.poi.ss.usermodel.PrintSetup;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.Region;
import org.apache.poi.xssf.model.CommentsTable;
@@ -224,6 +225,12 @@
protected CTSheet getSheet() {
return this.sheet;
}
+ public int addMergedRegion(CellRangeAddress cra) {
+ Region r = new Region(cra.getFirstRow(), (short)cra.getFirstColumn(),
+ cra.getLastRow(), (short)cra.getLastColumn());
+ return addMergedRegion(r);
+ }
+
public int addMergedRegion(Region region) {
addNewMergeCell(region);
@@ -345,12 +352,15 @@
return worksheet.getColBreaks();
}
+ public int getColumnWidth(int columnIndex) {
+ return (int) columnHelper.getColumn(columnIndex, false).getWidth();
+ }
public short getColumnWidth(short column) {
- return (short) columnHelper.getColumn(column, false).getWidth();
+ return (short) getColumnWidth(column & 0xFFFF);
}
- public short getDefaultColumnWidth() {
- return (short) getSheetTypeSheetFormatPr().getDefaultColWidth();
+ public int getDefaultColumnWidth() {
+ return (int)getSheetTypeSheetFormatPr().getDefaultColWidth();
}
public short getDefaultRowHeight() {
@@ -714,8 +724,11 @@
return false;
}
+ public boolean isColumnHidden(int columnIndex) {
+ return columnHelper.getColumn(columnIndex, false).getHidden();
+ }
public boolean isColumnHidden(short column) {
- return columnHelper.getColumn(column, false).getHidden();
+ return isColumnHidden(column & 0xFFFF);
}
public boolean isDisplayFormulas() {
@@ -839,20 +852,29 @@
}
+ public void setColumnHidden(int columnIndex, boolean hidden) {
+ columnHelper.setColHidden(columnIndex, hidden);
+ }
public void setColumnHidden(short column, boolean hidden) {
- columnHelper.setColHidden(column, hidden);
+ setColumnHidden(column & 0xFFFF, hidden);
}
+ public void setColumnWidth(int columnIndex, int width) {
+ columnHelper.setColWidth(columnIndex, width);
+ }
public void setColumnWidth(short column, short width) {
- columnHelper.setColWidth(column, width);
+ setColumnWidth(column & 0xFFFF, width & 0xFFFF);
}
public void setDefaultColumnStyle(short column, CellStyle style) {
columnHelper.setColDefaultStyle(column, style);
}
+ public void setDefaultColumnWidth(int width) {
+ getSheetTypeSheetFormatPr().setDefaultColWidth(width);
+ }
public void setDefaultColumnWidth(short width) {
- getSheetTypeSheetFormatPr().setDefaultColWidth((double) width);
+ setDefaultColumnWidth(width & 0xFFFF);
}
public void setDefaultRowHeight(short height) {
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Wed Sep 17 14:54:32 2008
@@ -204,24 +204,23 @@
col_cnt = c;
rw_cnt = r;
- HSSFRow rw = null ;
- HSSFCell cell =null;
+ HSSFRow rw ;
rw = sheet.createRow(0) ;
//Header row
for(int j=0; j<col_cnt; j++){
- cell = rw.createCell(j) ;
+ HSSFCell cell = rw.createCell(j) ;
setCellText(cell, "Col " + (j+1)) ;
}
for(int i=1; i<rw_cnt; i++){
rw = sheet.createRow(i) ;
for(int j=0; j<col_cnt; j++){
- cell = rw.createCell(j) ;
+ HSSFCell cell = rw.createCell(j) ;
setCellText(cell, "Row:" + (i+1) + ",Column:" + (j+1)) ;
}
}
- sheet.setDefaultColumnWidth((short) 18) ;
+ sheet.setDefaultColumnWidth(18) ;
writeTestOutputFileForViewing(wb, "test22568");
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java Wed Sep 17 14:54:32 2008
@@ -269,11 +269,11 @@
for (int i = 0; i < 6; i++) {
row.createCell(i).setCellStyle(_style_4);
if (i == 2 || i == 3 || i == 4) {
- sheet.setColumnWidth((short) i, (short) 3500);
+ sheet.setColumnWidth(i, 3500);
} else if (i == 5) {
- sheet.setColumnWidth((short) i, (short) 10000);
+ sheet.setColumnWidth(i, 10000);
} else {
- sheet.setColumnWidth((short) i, (short) 8000);
+ sheet.setColumnWidth(i, 8000);
}
}
HSSFCell cell = row.getCell(0);
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java?rev=696475&r1=696474&r2=696475&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java Wed Sep 17 14:54:32 2008
@@ -435,7 +435,7 @@
// This will tell us that cloneSheet, and by extension,
// the list forms of createSheet leave us with an accessible
// ProtectRecord.
- hssfSheet.setProtect(true);
+ hssfSheet.protectSheet("secret");
Sheet cloned = sheet.cloneSheet();
assertNotNull(cloned.getProtect());
assertTrue(hssfSheet.getProtect());
@@ -682,8 +682,8 @@
// 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.getColumnWidth((short)0) >= minWithRow1And2);
- assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth((short)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));
@@ -693,16 +693,16 @@
// 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.getColumnWidth((short)0) >= minWithRow1Only);
- assertTrue(sheet2.getColumnWidth((short)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.getColumnWidth((short)0) >= minWithRow1And2);
- assertTrue(sheet3.getColumnWidth((short)0) <= maxWithRow1And2);
+ assertTrue(sheet3.getColumnWidth(0) >= minWithRow1And2);
+ assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2);
}
/**
@@ -786,7 +786,7 @@
HSSFSheet sh = wb.getSheetAt(0);
for (char i = 'A'; i <= 'S'; i++) {
int idx = i - 'A';
- int w = sh.getColumnWidth((short)idx);
+ int w = sh.getColumnWidth(idx);
assertEquals(ref[idx], w);
}
@@ -795,24 +795,24 @@
int def_width = sh.getDefaultColumnWidth();
for (char i = 'A'; i <= 'S'; i++) {
int idx = i - 'A';
- int w = sh.getColumnWidth((short)idx);
- //getDefaultColumnWidth returns width measued in characters
- //getColumnWidth returns width measued in 1/256th units
+ int w = sh.getColumnWidth(idx);
+ //getDefaultColumnWidth returns width measured in characters
+ //getColumnWidth returns width measured in 1/256th units
assertEquals(def_width*256, w);
}
//test new workbook
wb = new HSSFWorkbook();
sh = wb.createSheet();
- sh.setDefaultColumnWidth((short)10);
+ sh.setDefaultColumnWidth(10);
assertEquals(10, sh.getDefaultColumnWidth());
- assertEquals(256*10, sh.getColumnWidth((short)0));
- assertEquals(256*10, sh.getColumnWidth((short)1));
- assertEquals(256*10, sh.getColumnWidth((short)2));
+ 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 = (short)(256*12);
- sh.setColumnWidth((short)i, w);
- assertEquals(w, sh.getColumnWidth((short)i));
+ short w = (256*12);
+ sh.setColumnWidth(i, w);
+ assertEquals(w, sh.getColumnWidth(i));
}
//serialize and read again
@@ -821,14 +821,18 @@
sh = wb.getSheetAt(0);
assertEquals(10, sh.getDefaultColumnWidth());
//columns A-C have default width
- assertEquals(256*10, sh.getColumnWidth((short)0));
- assertEquals(256*10, sh.getColumnWidth((short)1));
- assertEquals(256*10, sh.getColumnWidth((short)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 = (short)(256*12);
- assertEquals(w, sh.getColumnWidth((short)i));
+ short w = (256*12);
+ assertEquals(w, sh.getColumnWidth(i));
}
+
+ // check for 16-bit signed/unsigned error:
+ sh.setColumnWidth(0, 40000);
+ assertEquals(40000, sh.getColumnWidth(0));
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org