diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index b3b4fc929..e076047c5 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -50,6 +50,10 @@ import org.apache.poi.hssf.record.TextObjectRecord; import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; import org.apache.poi.hssf.record.formula.Ptg; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Comment; +import org.apache.poi.ss.usermodel.RichTextString; /** * High level representation of a cell in a row of a spreadsheet. @@ -70,7 +74,7 @@ import org.apache.poi.hssf.record.formula.Ptg; * @version 1.0-pre */ -public class HSSFCell +public class HSSFCell implements Cell { /** @@ -590,12 +594,13 @@ public class HSSFCell * If value is null then we will change the cell to a Blank cell. */ - public void setCellValue(HSSFRichTextString value) + public void setCellValue(RichTextString value) { + HSSFRichTextString hvalue = (HSSFRichTextString) value; int row=record.getRow(); short col=record.getColumn(); short styleIndex=record.getXFIndex(); - if (value == null) + if (hvalue == null) { setCellType(CELL_TYPE_BLANK, false, row, col, styleIndex); } @@ -607,7 +612,7 @@ public class HSSFCell } int index = 0; - UnicodeString str = value.getUnicodeString(); + UnicodeString str = hvalue.getUnicodeString(); // jmh if (encoding == ENCODING_COMPRESSED_UNICODE) // jmh { // jmh str.setCompressedUnicode(); @@ -617,7 +622,7 @@ public class HSSFCell // jmh } index = book.addSSTString(str); (( LabelSSTRecord ) record).setSSTIndex(index); - stringValue = value; + stringValue = hvalue; stringValue.setWorkbookReferences(book, (( LabelSSTRecord ) record)); stringValue.setUnicodeString(book.getSSTString(index)); } @@ -873,7 +878,7 @@ public class HSSFCell * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short) */ - public void setCellStyle(HSSFCellStyle style) + public void setCellStyle(CellStyle style) { record.setXFIndex(style.getIndex()); } @@ -1000,10 +1005,10 @@ public class HSSFCell * * @param comment comment associated with this cell */ - public void setCellComment(HSSFComment comment){ + public void setCellComment(Comment comment){ comment.setRow((short)record.getRow()); comment.setColumn(record.getColumn()); - this.comment = comment; + this.comment = (HSSFComment) comment; } /** diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java index cdea9ee5b..fa8489cba 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java @@ -20,8 +20,9 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.record.ExtendedFormatRecord; -import org.apache.poi.hssf.record.FormatRecord; -import org.apache.poi.hssf.util.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; /** * High level representation of the style of a cell in a sheet of a workbook. @@ -35,7 +36,7 @@ import org.apache.poi.hssf.util.*; * @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle) */ -public class HSSFCellStyle +public class HSSFCellStyle implements CellStyle { private ExtendedFormatRecord format = null; private short index = 0; @@ -287,7 +288,7 @@ public class HSSFCellStyle * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) */ - public void setFont(HSSFFont font) + public void setFont(Font font) { format.setIndentNotParentFont(true); short fontindex = font.getIndex(); @@ -309,7 +310,7 @@ public class HSSFCellStyle * @see org.apache.poi.hssf.usermodel.HSSFCellStyle#getFontIndex() * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) */ - public HSSFFont getFont(HSSFWorkbook parentWorkbook) { + public Font getFont(org.apache.poi.ss.usermodel.Workbook parentWorkbook) { return parentWorkbook.getFontAt(getFontIndex()); } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java index 258f26e22..08d209a27 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java @@ -16,21 +16,17 @@ ==================================================================== */ package org.apache.poi.hssf.usermodel; -import org.apache.poi.hssf.record.EscherAggregate; import org.apache.poi.hssf.record.NoteRecord; import org.apache.poi.hssf.record.TextObjectRecord; -import org.apache.poi.ddf.*; - -import java.util.Map; -import java.util.List; -import java.util.Iterator; +import org.apache.poi.ss.usermodel.Comment; +import org.apache.poi.ss.usermodel.RichTextString; /** * Represents a cell comment - a sticky note associated with a cell. * * @author Yegor Kozlov */ -public class HSSFComment extends HSSFTextbox { +public class HSSFComment extends HSSFTextbox implements Comment { private boolean visible; private short col, row; @@ -147,7 +143,7 @@ public class HSSFComment extends HSSFTextbox { * * @param string Sets the rich text string used by this object. */ - public void setString( HSSFRichTextString string ) { + public void setString( RichTextString string ) { //if font is not set we must set the default one if (string.numFormattingRuns() == 0) string.applyFont((short)0); @@ -155,7 +151,7 @@ public class HSSFComment extends HSSFTextbox { int frLength = ( string.numFormattingRuns() + 1 ) * 8; txo.setFormattingRunLength( (short) frLength ); txo.setTextLength( (short) string.length() ); - txo.setStr( string ); + txo.setStr( (HSSFRichTextString) string ); } super.setString(string); } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java index 64fbccb8b..547ec8303 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java @@ -23,14 +23,15 @@ */ package org.apache.poi.hssf.usermodel; -import org.apache.poi.hssf.model.Workbook; -import org.apache.poi.hssf.record.FormatRecord; - import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Vector; +import org.apache.poi.hssf.model.Workbook; +import org.apache.poi.hssf.record.FormatRecord; +import org.apache.poi.ss.usermodel.DataFormat; + /** * Utility to identify builtin formats. Now can handle user defined data formats also. The following is a list of the formats as * returned by this class.
@@ -79,7 +80,7 @@ import java.util.Vector; * @author Shawn M. Laubach (slaubach at apache dot org) */ -public class HSSFDataFormat +public class HSSFDataFormat implements DataFormat { private static List builtinFormats = createBuiltinFormats(); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java index cfaa5e4f4..282704357 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java @@ -24,6 +24,7 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.record.FontRecord; +import org.apache.poi.ss.usermodel.Font; /** * Represents a Font used in a workbook. @@ -35,7 +36,7 @@ import org.apache.poi.hssf.record.FontRecord; * @see org.apache.poi.hssf.usermodel.HSSFCellStyle#setFont(HSSFFont) */ -public class HSSFFont +public class HSSFFont implements Font { /** diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java index a72010378..4e62e8b47 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.record.FooterRecord; +import org.apache.poi.ss.usermodel.Footer; /** * Class to read and manipulate the footer. @@ -32,7 +33,7 @@ import org.apache.poi.hssf.record.FooterRecord; *
* @author Shawn Laubach (slaubach at apache dot org) */ -public class HSSFFooter extends Object { +public class HSSFFooter implements Footer { FooterRecord footerRecord; String left; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java index 614caf9b4..e1cd0b009 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.record.HeaderRecord; +import org.apache.poi.ss.usermodel.Header; /** * Class to read and manipulate the header. @@ -32,7 +33,7 @@ import org.apache.poi.hssf.record.HeaderRecord; * * @author Shawn Laubach (slaubach at apache dot org) */ -public class HSSFHeader +public class HSSFHeader implements Header { HeaderRecord headerRecord; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java index 73da4fe9c..501373e35 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java @@ -18,9 +18,9 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.model.Workbook; -import org.apache.poi.hssf.record.BoundSheetRecord; import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.util.RangeAddress; +import org.apache.poi.ss.usermodel.Name; /** * Title: High Level Represantion of Named Range
@@ -28,7 +28,7 @@ import org.apache.poi.hssf.util.RangeAddress;
* @author Libin Roman (Vista Portal LDT. Developer)
*/
-public class HSSFName {
+public class HSSFName implements Name {
private Workbook book;
private NameRecord name;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
index 7fc552595..42773d4a3 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.PaletteRecord;
import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.Palette;
/**
* Represents a workbook color palette.
@@ -28,7 +29,7 @@ import org.apache.poi.hssf.util.HSSFColor;
*
* @author Brian Sanders (bsanders at risklabs dot com)
*/
-public class HSSFPalette
+public class HSSFPalette implements Palette
{
private PaletteRecord palette;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
index 583e1b479..9e69fa255 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
@@ -25,7 +25,7 @@ import org.apache.poi.ddf.EscherComplexProperty;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperty;
import org.apache.poi.hssf.record.EscherAggregate;
-import org.apache.poi.util.LittleEndian;
+import org.apache.poi.ss.usermodel.Patriarch;
import org.apache.poi.util.StringUtil;
/**
@@ -35,7 +35,7 @@ import org.apache.poi.util.StringUtil;
* @author Glen Stampoultzis (glens at apache.org)
*/
public class HSSFPatriarch
- implements HSSFShapeContainer
+ implements HSSFShapeContainer, Patriarch
{
List shapes = new ArrayList();
HSSFSheet sheet;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java
index 713f44b3d..369561654 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java
@@ -19,6 +19,7 @@
package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.PrintSetupRecord;
+import org.apache.poi.ss.usermodel.PrintSetup;
/**
* Used to modify the print setup.
@@ -36,16 +37,7 @@ import org.apache.poi.hssf.record.PrintSetupRecord;
* public static final short ENVELOPE_MONARCH_PAPERSIZE = 37;
*
* @author Shawn Laubach (slaubach at apache dot org) */
-public class HSSFPrintSetup extends Object {
- public static final short LETTER_PAPERSIZE = 1;
- public static final short LEGAL_PAPERSIZE = 5;
- public static final short EXECUTIVE_PAPERSIZE = 7;
- public static final short A4_PAPERSIZE = 9;
- public static final short A5_PAPERSIZE = 11;
- public static final short ENVELOPE_10_PAPERSIZE = 20;
- public static final short ENVELOPE_DL_PAPERSIZE = 27;
- public static final short ENVELOPE_CS_PAPERSIZE = 28;
- public static final short ENVELOPE_MONARCH_PAPERSIZE = 37;
+public class HSSFPrintSetup implements PrintSetup {
PrintSetupRecord printSetupRecord;
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
index 93db9214a..bd9a4cd79 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
@@ -17,11 +17,13 @@
package org.apache.poi.hssf.usermodel;
+import java.util.Iterator;
+
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.UnicodeString;
-
-import java.util.Iterator;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.RichTextString;
/**
* Rich text unicode string. These strings can have fonts applied to
* arbitary parts of the string.
@@ -30,7 +32,7 @@ import java.util.Iterator;
* @author Jason Height (jheight at apache.org)
*/
public class HSSFRichTextString
- implements Comparable
+ implements Comparable, RichTextString
{
/** Place holder for indicating that NO_FONT has been applied here */
public static final short NO_FONT = 0;
@@ -136,7 +138,7 @@ public class HSSFRichTextString
* @param endIndex The end index to apply to font to (exclusive)
* @param font The index of the font to use.
*/
- public void applyFont(int startIndex, int endIndex, HSSFFont font)
+ public void applyFont(int startIndex, int endIndex, Font font)
{
applyFont(startIndex, endIndex, font.getIndex());
}
@@ -145,7 +147,7 @@ public class HSSFRichTextString
* Sets the font of the entire string.
* @param font The font to use.
*/
- public void applyFont(HSSFFont font)
+ public void applyFont(Font font)
{
applyFont(0, string.getCharCount(), font);
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
index ae5727bc6..ce2bc605f 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
@@ -29,6 +29,8 @@ import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
/**
* High level representation of a row of a spreadsheet.
@@ -40,7 +42,7 @@ import org.apache.poi.hssf.record.RowRecord;
*/
public class HSSFRow
- implements Comparable
+ implements Comparable, Row
{
// used for collections
@@ -156,26 +158,29 @@ public class HSSFRow
* remove the HSSFCell from this row.
* @param cell to remove
*/
- public void removeCell(HSSFCell cell) {
+ public void removeCell(Cell cell) {
removeCell(cell, true);
}
- private void removeCell(HSSFCell cell, boolean alsoRemoveRecords) {
+
+ private void removeCell(Cell cell, boolean alsoRemoveRecords) {
+
+ HSSFCell hcell = (HSSFCell) cell;
if(alsoRemoveRecords) {
- CellValueRecordInterface cval = cell.getCellValueRecord();
+ CellValueRecordInterface cval = hcell.getCellValueRecord();
sheet.removeValueRecord(getRowNum(), cval);
}
- short column=cell.getCellNum();
- if(cell!=null && column