diff options
author | Josh Micich <josh@apache.org> | 2008-09-17 21:54:32 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2008-09-17 21:54:32 +0000 |
commit | b3f56e20b2a20a6e7a423c80e6bf94c92e5eb665 (patch) | |
tree | b9fcde3848387f664510145804543bebc4d09ad7 /src/ooxml | |
parent | fe820eed5c4aba26347a7d117ffd9f4d052552de (diff) | |
download | poi-b3f56e20b2a20a6e7a423c80e6bf94c92e5eb665.tar.gz poi-b3f56e20b2a20a6e7a423c80e6bf94c92e5eb665.zip |
merged 696075,696084 from trunk - (Fix for bug 45805 - 16-bit signed/unsigned problems in HSSFSheet.getColWidth() etc)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@696475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r-- | src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java | 71 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 36 |
2 files changed, 78 insertions, 29 deletions
diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java index 18ec51b8a3..6c7343d00c 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java @@ -19,7 +19,9 @@ package org.apache.poi.ss.usermodel; 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 @@ public interface Sheet extends Iterable<Row> { 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 @@ public interface Sheet extends Iterable<Row> { * @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 @@ public interface Sheet extends Iterable<Row> { 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 @@ public interface Sheet extends Iterable<Row> { 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); /** diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index c2b2dccdb6..0e89964b3b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -35,6 +35,7 @@ import org.apache.poi.ss.usermodel.Patriarch; 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 @@ public class XSSFSheet implements Sheet { 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 @@ public class XSSFSheet implements Sheet { 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 @@ public class XSSFSheet implements Sheet { 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 class XSSFSheet implements Sheet { } + 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) { |