aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorGlen Stampoultzis <glens@apache.org>2004-08-23 08:52:54 +0000
committerGlen Stampoultzis <glens@apache.org>2004-08-23 08:52:54 +0000
commited3268bd931a6005d8a6019d0eba9760a84afddc (patch)
tree98df9545c1c9e1fd9a29b049cade3ec995988b46 /src/java
parent68b95f3a3fda2a484ea0ded1d083676704703c68 (diff)
downloadpoi-ed3268bd931a6005d8a6019d0eba9760a84afddc.tar.gz
poi-ed3268bd931a6005d8a6019d0eba9760a84afddc.zip
Merged REL_2_BRANCH to head.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353586 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/hssf/dev/BiffViewer.java27
-rwxr-xr-xsrc/java/org/apache/poi/hssf/dev/BiffViewer.java.rep174
-rw-r--r--src/java/org/apache/poi/hssf/dev/EFBiffViewer.java2
-rw-r--r--src/java/org/apache/poi/hssf/dev/EFHSSF.java3
-rwxr-xr-xsrc/java/org/apache/poi/hssf/dev/EFHSSF.java.rep116
-rw-r--r--src/java/org/apache/poi/hssf/dev/FormulaViewer.java5
-rw-r--r--src/java/org/apache/poi/hssf/dev/HSSF.java64
-rwxr-xr-xsrc/java/org/apache/poi/hssf/dev/package.html1
-rw-r--r--src/java/org/apache/poi/hssf/eventmodel/ERFListener.java3
-rw-r--r--src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java3
-rw-r--r--src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java3
-rw-r--r--src/java/org/apache/poi/hssf/eventmodel/ModelFactoryListener.java3
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/AbortableHSSFListener.java11
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java4
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/HSSFListener.java5
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/HSSFRequest.java8
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/HSSFUserException.java3
-rw-r--r--src/java/org/apache/poi/hssf/model/AbstractShape.java5
-rw-r--r--src/java/org/apache/poi/hssf/model/ConvertAnchor.java16
-rw-r--r--src/java/org/apache/poi/hssf/model/DrawingManager.java5
-rw-r--r--src/java/org/apache/poi/hssf/model/LineShape.java6
-rw-r--r--src/java/org/apache/poi/hssf/model/Model.java6
-rw-r--r--src/java/org/apache/poi/hssf/model/PolygonShape.java6
-rw-r--r--src/java/org/apache/poi/hssf/model/Sheet.java1266
-rw-r--r--src/java/org/apache/poi/hssf/model/SimpleFilledShape.java5
-rw-r--r--src/java/org/apache/poi/hssf/model/TextboxShape.java4
-rw-r--r--src/java/org/apache/poi/hssf/model/Workbook.java52
-rw-r--r--src/java/org/apache/poi/hssf/model/WorkbookRecordList.java3
-rw-r--r--src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java84
-rw-r--r--src/java/org/apache/poi/hssf/record/BOFRecord.java12
-rw-r--r--src/java/org/apache/poi/hssf/record/BookBoolRecord.java2
-rw-r--r--src/java/org/apache/poi/hssf/record/BoolErrRecord.java1
-rw-r--r--src/java/org/apache/poi/hssf/record/BottomMarginRecord.java235
-rw-r--r--src/java/org/apache/poi/hssf/record/BoundSheetRecord.java2
-rw-r--r--src/java/org/apache/poi/hssf/record/CodepageRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/CustomField.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DBCellRecord.java13
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/EscherAggregate.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java1
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtSSTRecord.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java8
-rw-r--r--src/java/org/apache/poi/hssf/record/ExternSheetRecord.java186
-rw-r--r--src/java/org/apache/poi/hssf/record/FormulaRecord.java8
-rw-r--r--src/java/org/apache/poi/hssf/record/IndexRecord.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/LabelRecord.java17
-rw-r--r--src/java/org/apache/poi/hssf/record/LeftMarginRecord.java84
-rw-r--r--src/java/org/apache/poi/hssf/record/Margin.java23
-rw-r--r--src/java/org/apache/poi/hssf/record/MergeCellsRecord.java33
-rw-r--r--src/java/org/apache/poi/hssf/record/NameRecord.java3
-rw-r--r--src/java/org/apache/poi/hssf/record/PaletteRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/RecordFactory.java13
-rw-r--r--src/java/org/apache/poi/hssf/record/RightMarginRecord.java109
-rw-r--r--src/java/org/apache/poi/hssf/record/SSTDeserializer.java3
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/SharedFormulaRecord.java2
-rw-r--r--src/java/org/apache/poi/hssf/record/StringRecord.java18
-rw-r--r--src/java/org/apache/poi/hssf/record/TextObjectRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/TopMarginRecord.java92
-rw-r--r--src/java/org/apache/poi/hssf/record/UnicodeString.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/UnknownRecord.java22
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java509
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java3
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java341
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java738
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/AddPtg.java3
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/AreaPtg.java14
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/AttrPtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/BoolPtg.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/ControlPtg.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/DividePtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/EqualPtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/ExpPtg.java8
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/FuncPtg.java8
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java6
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java65
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/IntPtg.java4
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java21
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java8
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/NamePtg.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/NameXPtg.java9
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java118
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/NumberPtg.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/OperationPtg.java11
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/PowerPtg.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/Ptg.java19
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/StringPtg.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/UnionPtg.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java10
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java6
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java7
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/FontDetails.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFAnchor.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFCell.java138
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java8
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java29
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFErrorConstants.java3
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFFont.java14
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java12
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java13
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFName.java9
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java35
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java666
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFRow.java160
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFShape.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java347
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java208
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java5
-rwxr-xr-xsrc/java/org/apache/poi/hssf/usermodel/package.html1
-rw-r--r--src/java/org/apache/poi/hssf/util/AreaReference.java5
-rw-r--r--src/java/org/apache/poi/hssf/util/CellReference.java3
-rw-r--r--src/java/org/apache/poi/hssf/util/HSSFColor.java3
-rw-r--r--src/java/org/apache/poi/hssf/util/RKUtil.java2
-rw-r--r--src/java/org/apache/poi/hssf/util/RangeAddress.java3
-rw-r--r--src/java/org/apache/poi/hssf/util/Region.java7
-rw-r--r--src/java/org/apache/poi/hssf/util/SheetReferences.java2
-rwxr-xr-xsrc/java/org/apache/poi/hssf/util/package.html2
-rwxr-xr-xsrc/java/org/apache/poi/poifs/common/package.html1
-rwxr-xr-xsrc/java/org/apache/poi/poifs/dev/package.html1
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java9
-rwxr-xr-xsrc/java/org/apache/poi/poifs/storage/package.html1
-rw-r--r--src/java/org/apache/poi/util/POILogger.java1
-rw-r--r--src/java/org/apache/poi/util/StringUtil.java19
-rwxr-xr-xsrc/java/org/apache/poi/util/package.html1
151 files changed, 3258 insertions, 3449 deletions
diff --git a/src/java/org/apache/poi/hssf/dev/BiffViewer.java b/src/java/org/apache/poi/hssf/dev/BiffViewer.java
index 9cab6c5c68..f37bec7647 100644
--- a/src/java/org/apache/poi/hssf/dev/BiffViewer.java
+++ b/src/java/org/apache/poi/hssf/dev/BiffViewer.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* BiffViewer.java
*
@@ -91,7 +90,7 @@ public class BiffViewer {
public static Record[] createRecords(InputStream in, boolean dump)
throws RecordFormatException {
ArrayList records = new ArrayList();
- //Record last_record = null;
+// Record last_record = null;
int loc = 0;
RecordDetails activeRecord = null;
@@ -103,8 +102,6 @@ public class BiffViewer {
do {
rectype = LittleEndian.readShort(in);
int startloc = loc;
-// System.out.println("============================================");
-// System.out.println("Offset 0x" + Integer.toHexString(loc) + " (" + loc + ")");
loc += 2;
if (rectype != 0) {
short recsize = LittleEndian.readShort(in);
@@ -148,8 +145,8 @@ public class BiffViewer {
System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
System.out.println( record.toString() );
- }
+ }
private static void dumpContinueRecord(Record last_record, boolean dump, byte[] data) throws IOException {
if (last_record == null) {
@@ -227,14 +224,11 @@ public class BiffViewer {
* up non-debug operations.
*
*/
-
private static Record createRecord( short rectype, short size,
byte[] data )
{
Record retval = null;
- Record[] realretval = null;
- // int irectype = rectype;
switch ( rectype )
{
@@ -587,14 +581,14 @@ public class BiffViewer {
retval = new PaneRecord( rectype, size, data );
break;
case SharedFormulaRecord.sid:
- retval = new SharedFormulaRecord( rectype, size, data);
- break;
+ retval = new SharedFormulaRecord( rectype, size, data);
+ break;
case ObjRecord.sid:
- retval = new ObjRecord( rectype, size, data);
- break;
+ retval = new ObjRecord( rectype, size, data);
+ break;
case TextObjectRecord.sid:
- retval = new TextObjectRecord( rectype, size, data);
- break;
+ retval = new TextObjectRecord( rectype, size, data);
+ break;
case HorizontalPageBreakRecord.sid:
retval = new HorizontalPageBreakRecord( rectype, size, data);
break;
@@ -674,7 +668,7 @@ public class BiffViewer {
this.data = data;
this.record = record;
}
-
+
public short getRectype()
{
return rectype;
@@ -705,3 +699,4 @@ public class BiffViewer {
}
}
+
diff --git a/src/java/org/apache/poi/hssf/dev/BiffViewer.java.rep b/src/java/org/apache/poi/hssf/dev/BiffViewer.java.rep
deleted file mode 100755
index d5b5fd32e3..0000000000
--- a/src/java/org/apache/poi/hssf/dev/BiffViewer.java.rep
+++ /dev/null
@@ -1,174 +0,0 @@
-println
-filename
-short
-stream
-Record
-equals
-length
-RKRecord
-FileInputStream
-InterfaceEndRecord
-FooterRecord
-toString
-BackupRecord
-static
-RecordFormatException
-toArray
-ArrayList
-SeriesRecord
-records
-processContinueRecord
-read
-VCenterRecord
-readShort
-run
-ColumnInfoRecord
-Exception
-io
-SSTRecord
-in
-printStackTrace
-GridsetRecord
-if
-PrintSetupRecord
-null
-BlankRecord
-add
-UnknownRecord
-DeltaRecord
-CalcCountRecord
-HideObjRecord
-RefreshAllRecord
-void
-BookBoolRecord
-FileOutputStream
-POIFSFileSystem
-size
-else
-int
-args
-record
-true
-public
-this
-try
-ExtSSTRecord
-hssf
-DefaultColWidthRecord
-default
-filesystem
-EndRecord
-fs
-main
-poifs
-print
-MMSRecord
-InputStream
-createRecord
-ContinueRecord
-throw
-class
-switch
-case
-PasswordRev4Record
-new
-util
-LabelRecord
-while
-net
-ByteArrayInputStream
-break
-UseSelFSRecord
-RowRecord
-import
-CalcModeRecord
-BiffViewer
-HeaderRecord
-WindowProtectRecord
-PasswordRecord
-last_record
-HexDump
-CodepageRecord
-dev
-BoundSheetRecord
-RefModeRecord
-GutsRecord
-do
-WindowOneRecord
-DSFRecord
-viewer
-data
-PrintHeadersRecord
-available
-System
-IOException
-LittleEndian
-IterationRecord
-NumberRecord
-StyleRecord
-sid
-FontRecord
-WSBoolRecord
-out
-long
-poi
-k
-SelectionRecord
-PrecisionRecord
-usermodel
-String
-e
-EOFRecord
-rectype
-SaveRecalcRecord
-WindowTwoRecord
-catch
-DimensionsRecord
-WriteAccessRecord
-loc
-package
-MulBlankRecord
-InterfaceHdrRecord
-java
-DBCellRecord
-realretval
-for
-private
-MergeCellsRecord
-sourceforge
-BOFRecord
-serialize
-setDump
-retval
-TabIdRecord
-throws
-MulRKRecord
-ProtectionRev4Record
-createRecords
-recsize
-DefaultRowHeightRecord
-DateWindow1904Record
-LabelSSTRecord
-ChartFormatRecord
-CountryRecord
-ChartRecord
-ProtectRecord
-boolean
-ExtendedFormatRecord
-PrintGridlinesRecord
-FormatRecord
-createDocumentInputStream
-HCenterRecord
-FnGroupCountRecord
-BeginRecord
-toHexString
-offset
-IndexRecord
-model
-return
-lr
-recs
-Integer
-byte
-dump
-instanceof
diff --git a/src/java/org/apache/poi/hssf/dev/EFBiffViewer.java b/src/java/org/apache/poi/hssf/dev/EFBiffViewer.java
index d79e9db572..bc0b21575b 100644
--- a/src/java/org/apache/poi/hssf/dev/EFBiffViewer.java
+++ b/src/java/org/apache/poi/hssf/dev/EFBiffViewer.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.dev;
diff --git a/src/java/org/apache/poi/hssf/dev/EFHSSF.java b/src/java/org/apache/poi/hssf/dev/EFHSSF.java
index 4ed3b74d9e..6acdec333d 100644
--- a/src/java/org/apache/poi/hssf/dev/EFHSSF.java
+++ b/src/java/org/apache/poi/hssf/dev/EFHSSF.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.dev;
diff --git a/src/java/org/apache/poi/hssf/dev/EFHSSF.java.rep b/src/java/org/apache/poi/hssf/dev/EFHSSF.java.rep
deleted file mode 100755
index a1bde00fa8..0000000000
--- a/src/java/org/apache/poi/hssf/dev/EFHSSF.java.rep
+++ /dev/null
@@ -1,116 +0,0 @@
-cell
-println
-addSSTString
-CELL_TYPE_NUMERIC
-write
-getString
-getSSTString
-Record
-equals
-length
-FileInputStream
-static
-getRow
-getSid
-sheetnum
-run
-eventmodel
-io
-SSTRecord
-CELL_TYPE_STRING
-printStackTrace
-if
-null
-recordHandler
-fin
-void
-din
-FileOutputStream
-getType
-POIFSFileSystem
-getNumUniqueStrings
-else
-int
-args
-processEvents
-record
-HSSFWorkbook
-public
-createRow
-this
-rowrec
-try
-close
-getSSTIndex
-hssf
-filesystem
-main
-poifs
-setInputFile
-InputStream
-req
-switch
-class
-case
-bsr
-numrec
-new
-break
-net
-setOutputFile
-RowRecord
-HSSFRow
-HSSFRequest
-HSSFEventFactory
-EFHSSF
-import
-HSSFCell
-TYPE_WORKSHEET
-outfile
-dev
-BoundSheetRecord
-setCellValue
-viewer
-System
-createCell
-row
-efhssf
-IOException
-infile
-NumberRecord
-implements
-getValue
-sid
-TYPE_WORKBOOK
-cursheet
-out
-poi
-k
-createSheet
-usermodel
-String
-getSheetAt
-e
-processRecord
-catch
-package
-java
-for
-HSSFSheet
-sourceforge
-BOFRecord
-fout
-EFHSSFListener
-HSSFListener
-throws
-bof
-factory
-LabelSSTRecord
-sstrec
-addListenerForAllRecords
-createDocumentInputStream
-workbook
-lrec
-getSheetname
-getRowNumber
-getColumn
diff --git a/src/java/org/apache/poi/hssf/dev/FormulaViewer.java b/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
index 99f24dd9c2..aad277106c 100644
--- a/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
+++ b/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* FormulaViewer.java - finds formulas in a BIFF8 file and attempts to parse them and
diff --git a/src/java/org/apache/poi/hssf/dev/HSSF.java b/src/java/org/apache/poi/hssf/dev/HSSF.java
index 731dafd38a..2b683f8386 100644
--- a/src/java/org/apache/poi/hssf/dev/HSSF.java
+++ b/src/java/org/apache/poi/hssf/dev/HSSF.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,17 +13,19 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-package org.apache.poi.hssf.dev;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.hssf.util.Region;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+package org.apache.poi.hssf.dev;
+import java.io.InputStream;
+import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.IOException;
+
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.*;
/**
* File for HSSF testing/examples
@@ -38,9 +39,11 @@ import java.io.IOException;
public class HSSF
{
+ private String filename = null;
+
// private POIFSFileSystem fs = null;
-// private InputStream stream = null;
-// private Record[] records = null;
+ private InputStream stream = null;
+ private Record[] records = null;
protected HSSFWorkbook hssfworkbook = null;
/**
@@ -57,6 +60,7 @@ public class HSSF
public HSSF(String filename)
throws IOException
{
+ this.filename = filename;
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream(filename));
@@ -94,13 +98,13 @@ public class HSSF
f.setFontHeightInPoints(( short ) 12);
f.setColor(( short ) 0xA);
- f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ f.setBoldweight(f.BOLDWEIGHT_BOLD);
f2.setFontHeightInPoints(( short ) 10);
f2.setColor(( short ) 0xf);
- f2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ f2.setBoldweight(f2.BOLDWEIGHT_BOLD);
cs.setFont(f);
cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
- cs2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+ cs2.setBorderBottom(cs2.BORDER_THIN);
cs2.setFillPattern(( short ) 1); // fill w fg
cs2.setFillForegroundColor(( short ) 0xA);
cs2.setFont(f2);
@@ -116,7 +120,7 @@ public class HSSF
// r.setRowNum(( short ) rownum);
for (short cellnum = ( short ) 0; cellnum < 50; cellnum += 2)
{
- c = r.createCell(cellnum);
+ c = r.createCell(cellnum, HSSFCell.CELL_TYPE_NUMERIC);
c.setCellValue(rownum * 10000 + cellnum
+ ((( double ) rownum / 1000)
+ (( double ) cellnum / 10000)));
@@ -124,7 +128,8 @@ public class HSSF
{
c.setCellStyle(cs);
}
- c = r.createCell(( short ) (cellnum + 1));
+ c = r.createCell(( short ) (cellnum + 1),
+ HSSFCell.CELL_TYPE_STRING);
c.setCellValue("TEST");
s.setColumnWidth(( short ) (cellnum + 1),
( short ) ((50 * 8) / (( double ) 1 / 20)));
@@ -139,11 +144,10 @@ public class HSSF
rownum++;
rownum++;
r = s.createRow(rownum);
- cs3.setBorderBottom(HSSFCellStyle.BORDER_THICK);
+ cs3.setBorderBottom(cs3.BORDER_THICK);
for (short cellnum = ( short ) 0; cellnum < 50; cellnum++)
{
- c = r.createCell(cellnum);
-// c = r.createCell(cellnum, HSSFCell.CELL_TYPE_BLANK);
+ c = r.createCell(cellnum, HSSFCell.CELL_TYPE_BLANK);
// c.setCellValue(0);
c.setCellStyle(cs3);
@@ -165,6 +169,30 @@ public class HSSF
}
/**
+ * Constructor HSSF - takes in file - attempts to read it then reconstruct it
+ *
+ *
+ * @param infile
+ * @param outfile
+ * @param write
+ *
+ * @exception IOException
+ *
+ */
+
+ public HSSF(String infile, String outfile, boolean write)
+ throws IOException
+ {
+ this.filename = filename;
+ POIFSFileSystem fs =
+ new POIFSFileSystem(new FileInputStream(filename));
+
+ hssfworkbook = new HSSFWorkbook(fs);
+
+ // HSSFWorkbook book = hssfstream.getWorkbook();
+ }
+
+ /**
* Method main
*
* Given 1 argument takes that as the filename, inputs it and dumps the
@@ -256,7 +284,7 @@ public class HSSF
try
{
long time = System.currentTimeMillis();
- new HSSF(args[ 0 ], true);
+ HSSF hssf = new HSSF(args[ 0 ], true);
System.out
.println("" + (System.currentTimeMillis() - time)
diff --git a/src/java/org/apache/poi/hssf/dev/package.html b/src/java/org/apache/poi/hssf/dev/package.html
index 02da5df4cd..2468134d7f 100755
--- a/src/java/org/apache/poi/hssf/dev/package.html
+++ b/src/java/org/apache/poi/hssf/dev/package.html
@@ -16,5 +16,6 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
+@see org.apache.poi.hssf
</body>
</html>
diff --git a/src/java/org/apache/poi/hssf/eventmodel/ERFListener.java b/src/java/org/apache/poi/hssf/eventmodel/ERFListener.java
index cd2d7193f5..b3c01ec30b 100644
--- a/src/java/org/apache/poi/hssf/eventmodel/ERFListener.java
+++ b/src/java/org/apache/poi/hssf/eventmodel/ERFListener.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventmodel;
import org.apache.poi.hssf.record.Record;
diff --git a/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java b/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java
index fc9b2e99a8..50bafcf98c 100644
--- a/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java
+++ b/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventmodel;
import java.io.IOException;
diff --git a/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java b/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
index 9cd13749ae..277f04c22e 100644
--- a/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
+++ b/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventmodel;
import java.io.InputStream;
diff --git a/src/java/org/apache/poi/hssf/eventmodel/ModelFactoryListener.java b/src/java/org/apache/poi/hssf/eventmodel/ModelFactoryListener.java
index 9802a9918c..2c7ce9b0f0 100644
--- a/src/java/org/apache/poi/hssf/eventmodel/ModelFactoryListener.java
+++ b/src/java/org/apache/poi/hssf/eventmodel/ModelFactoryListener.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventmodel;
import org.apache.poi.hssf.model.Model;
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/AbortableHSSFListener.java b/src/java/org/apache/poi/hssf/eventusermodel/AbortableHSSFListener.java
index 35661d5ff0..333ade0bda 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/AbortableHSSFListener.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/AbortableHSSFListener.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventusermodel;
@@ -26,9 +25,9 @@ import org.apache.poi.hssf.eventusermodel.HSSFUserException;
* a listener supporting this interface and register it with the HSSFRequest (associating
* it with Record SID's).
*
- * @see HSSFEventFactory
- * @see HSSFRequest
- * @see AbortableHSSFListener
+ * @see org.apache.poi.hssf.eventmodel.HSSFEventFactory
+ * @see org.apache.poi.hssf.eventmodel.HSSFRequest
+ * @see org.apache.poi.hssf.HSSFUserException
*
* @author Carey Sublette (careysub@earthling.net)
*
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
index c382690b57..39dde4b7f4 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
@@ -1,6 +1,6 @@
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.eventusermodel;
@@ -127,6 +126,7 @@ public class HSSFEventFactory
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem#createDocumentInputStream(String)
* @param req an Instance of HSSFRequest which has your registered listeners
* @param in a DocumentInputStream obtained from POIFS's POIFSFileSystem object
+ * @param in a DocumentInputStream obtained from POIFS's POIFSFileSystem object
* @return numeric user-specified result code.
*/
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFListener.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFListener.java
index d45e41c079..2123a11163 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFListener.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFListener.java
@@ -14,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.eventusermodel;
@@ -25,8 +24,8 @@ import org.apache.poi.hssf.record.Record;
* a listener supporting this interface and register it with the HSSFRequest (associating
* it with Record SID's).
*
- * @see org.apache.poi.hssf.eventusermodel.HSSFEventFactory
- * @see org.apache.poi.hssf.eventusermodel.HSSFRequest
+ * @see org.apache.poi.hssf.eventmodel.HSSFEventFactory
+ * @see org.apache.poi.hssf.eventmodel.HSSFRequest
* @author acoliver@apache.org
*/
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFRequest.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFRequest.java
index ac90891df2..63b2c28189 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFRequest.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFRequest.java
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventusermodel;
@@ -29,10 +29,10 @@ import org.apache.poi.hssf.record.RecordFactory;
* An HSSFRequest object should be constructed registering an instance or multiple
* instances of HSSFListener with each Record.sid you wish to listen for.
*
- * @see org.apache.poi.hssf.eventusermodel.HSSFEventFactory
- * @see org.apache.poi.hssf.eventusermodel.HSSFRequest
+ * @see org.apache.poi.hssf.eventmodel.HSSFEventFactory
+ * @see org.apache.poi.hssf.eventmodel.HSSFListener
* @see org.apache.poi.hssf.dev.EFHSSF
- * @see org.apache.poi.hssf.eventusermodel.HSSFUserException
+ * @see org.apache.poi.hssf.HSSFUserException
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Carey Sublette (careysub@earthling.net)
*/
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFUserException.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFUserException.java
index d89db176a7..05ce724bfc 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFUserException.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFUserException.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.eventusermodel;
diff --git a/src/java/org/apache/poi/hssf/model/AbstractShape.java b/src/java/org/apache/poi/hssf/model/AbstractShape.java
index 79e1f36a86..41f4ee73bb 100644
--- a/src/java/org/apache/poi/hssf/model/AbstractShape.java
+++ b/src/java/org/apache/poi/hssf/model/AbstractShape.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*;
diff --git a/src/java/org/apache/poi/hssf/model/ConvertAnchor.java b/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
index bb07a121a8..8f1943a81f 100644
--- a/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
+++ b/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
@@ -1,3 +1,19 @@
+/* ====================================================================
+ Copyright 2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.EscherRecord;
diff --git a/src/java/org/apache/poi/hssf/model/DrawingManager.java b/src/java/org/apache/poi/hssf/model/DrawingManager.java
index e2aec95339..fbf1f444cb 100644
--- a/src/java/org/apache/poi/hssf/model/DrawingManager.java
+++ b/src/java/org/apache/poi/hssf/model/DrawingManager.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.EscherDggRecord;
diff --git a/src/java/org/apache/poi/hssf/model/LineShape.java b/src/java/org/apache/poi/hssf/model/LineShape.java
index e58aa2ef2a..a12323979f 100644
--- a/src/java/org/apache/poi/hssf/model/LineShape.java
+++ b/src/java/org/apache/poi/hssf/model/LineShape.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*;
diff --git a/src/java/org/apache/poi/hssf/model/Model.java b/src/java/org/apache/poi/hssf/model/Model.java
index 0545e3f96e..a707251043 100644
--- a/src/java/org/apache/poi/hssf/model/Model.java
+++ b/src/java/org/apache/poi/hssf/model/Model.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.model;
/**
diff --git a/src/java/org/apache/poi/hssf/model/PolygonShape.java b/src/java/org/apache/poi/hssf/model/PolygonShape.java
index f3bf2cbccd..5c6f44bbf3 100644
--- a/src/java/org/apache/poi/hssf/model/PolygonShape.java
+++ b/src/java/org/apache/poi/hssf/model/PolygonShape.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*;
diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java
index d57d1300c4..705e367b6d 100644
--- a/src/java/org/apache/poi/hssf/model/Sheet.java
+++ b/src/java/org/apache/poi/hssf/model/Sheet.java
@@ -14,20 +14,23 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.model;
-import java.util.List;
+import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
+import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
+import org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate;
+import org.apache.poi.hssf.record.aggregates.ColumnInfoRecordsAggregate;
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.util.IntList;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
import java.util.ArrayList;
import java.util.Iterator;
-
-import org.apache.poi.hssf
- .record.*; // normally I don't do this, buy we literally mean ALL
-import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.util.*;
-import org.apache.poi.hssf.record
- .aggregates.*; // normally I don't do this, buy we literally mean ALL
+import java.util.List;
/**
* Low level model implementation of a Sheet (one workbook contains many sheets)
@@ -58,36 +61,38 @@ public class Sheet implements Model
public static final short TopMargin = 2;
public static final short BottomMargin = 3;
- protected ArrayList records = null;
- int preoffset = 0; // offset of the sheet in a new file
- int loc = 0;
- protected boolean containsLabels = false;
- protected int dimsloc = 0;
- protected DimensionsRecord dims;
- protected DefaultColWidthRecord defaultcolwidth = null;
- protected DefaultRowHeightRecord defaultrowheight = null;
- protected GridsetRecord gridset = null;
- protected PrintSetupRecord printSetup = null;
- protected HeaderRecord header = null;
- protected FooterRecord footer = null;
- protected PrintGridlinesRecord printGridlines = null;
- protected WindowTwoRecord windowTwo = null;
- protected MergeCellsRecord merged = null;
- protected Margin margins[] = null;
- protected ArrayList mergedRecords = new ArrayList();
- protected int numMergedRegions = 0;
- protected SelectionRecord selection = null;
private static POILogger log = POILogFactory.getLogger(Sheet.class);
- private ArrayList columnSizes = null; // holds column info
- protected ValueRecordsAggregate cells = null;
- protected RowRecordsAggregate rows = null;
- private Iterator valueRecIterator = null;
- private Iterator rowRecIterator = null;
- protected int eofLoc = 0;
- protected ProtectRecord protect = null;
- protected PageBreakRecord rowBreaks = null;
- protected PageBreakRecord colBreaks = null;
+ protected ArrayList records = null;
+ int preoffset = 0; // offset of the sheet in a new file
+ int loc = 0;
+ protected boolean containsLabels = false;
+ protected int dimsloc = 0;
+ protected DimensionsRecord dims;
+ protected DefaultColWidthRecord defaultcolwidth = null;
+ protected DefaultRowHeightRecord defaultrowheight = null;
+ protected GridsetRecord gridset = null;
+ protected PrintSetupRecord printSetup = null;
+ protected HeaderRecord header = null;
+ protected FooterRecord footer = null;
+ protected PrintGridlinesRecord printGridlines = null;
+ protected WindowTwoRecord windowTwo = null;
+ protected MergeCellsRecord merged = null;
+ protected Margin[] margins = null;
+ protected List mergedRecords = new ArrayList();
+ protected int numMergedRegions = 0;
+ protected SelectionRecord selection = null;
+ protected ColumnInfoRecordsAggregate columns = null;
+ protected ValueRecordsAggregate cells = null;
+ protected RowRecordsAggregate rows = null;
+ private Iterator valueRecIterator = null;
+ private Iterator rowRecIterator = null;
+ protected int eofLoc = 0;
+ protected ProtectRecord protect = null;
+ protected PageBreakRecord rowBreaks = null;
+ protected PageBreakRecord colBreaks = null;
+
+
public static final byte PANE_LOWER_RIGHT = (byte)0;
public static final byte PANE_UPPER_RIGHT = (byte)1;
public static final byte PANE_LOWER_LEFT = (byte)2;
@@ -120,9 +125,10 @@ public class Sheet implements Model
*/
public static Sheet createSheet(List recs, int sheetnum, int offset)
{
- log.logFormatted(POILogger.DEBUG,
- "Sheet createSheet (existing file) with %",
- new Integer(recs.size()));
+ if (log.check( POILogger.DEBUG ))
+ log.logFormatted(POILogger.DEBUG,
+ "Sheet createSheet (existing file) with %",
+ new Integer(recs.size()));
Sheet retval = new Sheet();
ArrayList records = new ArrayList(recs.size() / 5);
boolean isfirstcell = true;
@@ -158,6 +164,13 @@ public class Sheet implements Model
}
else if (rec.getSid() == DimensionsRecord.sid)
{
+ // Make a columns aggregate if one hasn't ready been created.
+ if (retval.columns == null)
+ {
+ retval.columns = new ColumnInfoRecordsAggregate();
+ records.add(retval.columns);
+ }
+
retval.dims = ( DimensionsRecord ) rec;
retval.dimsloc = records.size();
}
@@ -169,11 +182,16 @@ public class Sheet implements Model
}
else if (rec.getSid() == ColumnInfoRecord.sid)
{
- if (retval.columnSizes == null)
+ ColumnInfoRecord col = (ColumnInfoRecord)rec;
+ if (retval.columns != null)
{
- retval.columnSizes = new ArrayList();
+ rec = null; //only add the aggregate once
}
- retval.columnSizes.add(rec);
+ else
+ {
+ rec = retval.columns = new ColumnInfoRecordsAggregate();
+ }
+ retval.columns.insertColumn(col);
}
else if (rec.getSid() == DefaultColWidthRecord.sid)
{
@@ -203,18 +221,16 @@ public class Sheet implements Model
}
else if ( rec.getSid() == RowRecord.sid )
{
+ RowRecord row = (RowRecord)rec;
+ if (!isfirstrow) rec = null; //only add the aggregate once
+
if ( isfirstrow )
{
retval.rows = new RowRecordsAggregate();
- rec = retval.rows;
- retval.rows.construct( k, recs );
+ rec = retval.rows;
isfirstrow = false;
}
- else
- {
- rec = null;
- }
-
+ retval.rows.insertRow(row);
}
else if ( rec.getSid() == PrintGridlinesRecord.sid )
{
@@ -232,62 +248,59 @@ public class Sheet implements Model
{
retval.printSetup = (PrintSetupRecord) rec;
}
- else if ( rec.getSid() == ProtectRecord.sid )
+ else if ( rec.getSid() == LeftMarginRecord.sid)
{
- retval.protect = (ProtectRecord) rec;
+ retval.getMargins()[LeftMargin] = (LeftMarginRecord) rec;
}
- else if ( rec.getSid() == LeftMarginRecord.sid)
- {
- retval.getMargins()[LeftMargin] = (LeftMarginRecord) rec;
- }
- else if ( rec.getSid() == RightMarginRecord.sid)
- {
- retval.getMargins()[RightMargin] = (RightMarginRecord) rec;
- }
- else if ( rec.getSid() == TopMarginRecord.sid)
+ else if ( rec.getSid() == RightMarginRecord.sid)
{
- retval.getMargins()[TopMargin] = (TopMarginRecord) rec;
- }
- else if ( rec.getSid() == BottomMarginRecord.sid)
+ retval.getMargins()[RightMargin] = (RightMarginRecord) rec;
+ }
+ else if ( rec.getSid() == TopMarginRecord.sid)
{
- retval.getMargins()[BottomMargin] = (BottomMarginRecord) rec;
- }
- else if ( rec.getSid() == WindowTwoRecord.sid )
- {
- retval.windowTwo = (WindowTwoRecord) rec;
- }
- else if ( rec.getSid() == DBCellRecord.sid )
+ retval.getMargins()[TopMargin] = (TopMarginRecord) rec;
+ }
+ else if ( rec.getSid() == BottomMarginRecord.sid)
{
- rec = null;
+ retval.getMargins()[BottomMargin] = (BottomMarginRecord) rec;
}
- else if ( rec.getSid() == IndexRecord.sid )
+ else if ( rec.getSid() == SelectionRecord.sid )
{
- rec = null;
+ retval.selection = (SelectionRecord) rec;
}
- else if (rec.getSid() == PageBreakRecord.HORIZONTAL_SID)
- {
- retval.rowBreaks = (PageBreakRecord)rec;
+ else if ( rec.getSid() == WindowTwoRecord.sid )
+ {
+ retval.windowTwo = (WindowTwoRecord) rec;
}
- else if (rec.getSid() == PageBreakRecord.VERTICAL_SID)
+ else if ( rec.getSid() == ProtectRecord.sid )
{
- retval.colBreaks = (PageBreakRecord)rec;
+ retval.protect = (ProtectRecord) rec;
+ }
+ else if (rec.getSid() == PageBreakRecord.HORIZONTAL_SID)
+ {
+ retval.rowBreaks = (PageBreakRecord)rec;
}
-
-
+ else if (rec.getSid() == PageBreakRecord.VERTICAL_SID)
+ {
+ retval.colBreaks = (PageBreakRecord)rec;
+ }
+
if (rec != null)
{
records.add(rec);
}
}
retval.records = records;
- if (retval.rows == null)
- {
- retval.rows = new RowRecordsAggregate();
- }
- if (retval.cells == null)
- {
- retval.cells = new ValueRecordsAggregate();
- }
+// if (retval.rows == null)
+// {
+// retval.rows = new RowRecordsAggregate();
+// }
+ retval.checkCells();
+ retval.checkRows();
+// if (retval.cells == null)
+// {
+// retval.cells = new ValueRecordsAggregate();
+// }
if (log.check( POILogger.DEBUG ))
log.log(POILogger.DEBUG, "sheet createSheet (existing file) exited");
return retval;
@@ -350,7 +363,7 @@ public class Sheet implements Model
{
if (log.check( POILogger.DEBUG ))
log.log(POILogger.DEBUG,
- "Sheet createSheet (exisiting file) assumed offset 0");
+ "Sheet createSheet (exisiting file) assumed offset 0");
return createSheet(records, sheetnum, 0);
}
@@ -388,12 +401,14 @@ public class Sheet implements Model
(DefaultRowHeightRecord) retval.createDefaultRowHeight();
records.add( retval.defaultrowheight );
records.add( retval.createWSBool() );
+
retval.rowBreaks = new PageBreakRecord(PageBreakRecord.HORIZONTAL_SID);
records.add(retval.rowBreaks);
retval.colBreaks = new PageBreakRecord(PageBreakRecord.VERTICAL_SID);
records.add(retval.colBreaks);
+
retval.header = (HeaderRecord) retval.createHeader();
- records.add( retval.header );
+ records.add( retval.header );
retval.footer = (FooterRecord) retval.createFooter();
records.add( retval.footer );
records.add( retval.createHCenter() );
@@ -403,6 +418,9 @@ public class Sheet implements Model
retval.defaultcolwidth =
(DefaultColWidthRecord) retval.createDefaultColWidth();
records.add( retval.defaultcolwidth);
+ ColumnInfoRecordsAggregate columns = new ColumnInfoRecordsAggregate();
+ records.add( columns );
+ retval.columns = columns;
retval.dims = ( DimensionsRecord ) retval.createDimensions();
records.add(retval.dims);
retval.dimsloc = records.size()-1;
@@ -414,6 +432,8 @@ public class Sheet implements Model
retval.protect = (ProtectRecord) retval.createProtect();
records.add(retval.protect);
records.add(retval.createEOF());
+
+
retval.records = records;
if (log.check( POILogger.DEBUG ))
log.log(POILogger.DEBUG, "Sheet createsheet from scratch exit");
@@ -445,61 +465,61 @@ public class Sheet implements Model
if (merged == null || merged.getNumAreas() == 1027)
{
merged = ( MergeCellsRecord ) createMergedCells();
- mergedRecords.add(merged);
+ mergedRecords.add(merged);
records.add(records.size() - 1, merged);
}
merged.addArea(rowFrom, colFrom, rowTo, colTo);
return numMergedRegions++;
}
- public void removeMergedRegion(int index)
- {
- //safety checks
- if (index >= numMergedRegions || mergedRecords.size() == 0)
- return;
+ public void removeMergedRegion(int index)
+ {
+ //safety checks
+ if (index >= numMergedRegions || mergedRecords.size() == 0)
+ return;
- int pos = 0;
- int startNumRegions = 0;
+ int pos = 0;
+ int startNumRegions = 0;
- //optimisation for current record
- if (numMergedRegions - index < merged.getNumAreas())
- {
- pos = mergedRecords.size() - 1;
- startNumRegions = numMergedRegions - merged.getNumAreas();
- }
- else
- {
- for (int n = 0; n < mergedRecords.size(); n++)
- {
- MergeCellsRecord record = (MergeCellsRecord) mergedRecords.get(n);
- if (startNumRegions + record.getNumAreas() > index)
- {
- pos = n;
- break;
- }
- startNumRegions += record.getNumAreas();
- }
- }
+ //optimisation for current record
+ if (numMergedRegions - index < merged.getNumAreas())
+ {
+ pos = mergedRecords.size() - 1;
+ startNumRegions = numMergedRegions - merged.getNumAreas();
+ }
+ else
+ {
+ for (int n = 0; n < mergedRecords.size(); n++)
+ {
+ MergeCellsRecord record = (MergeCellsRecord) mergedRecords.get(n);
+ if (startNumRegions + record.getNumAreas() > index)
+ {
+ pos = n;
+ break;
+ }
+ startNumRegions += record.getNumAreas();
+ }
+ }
- MergeCellsRecord rec = (MergeCellsRecord) mergedRecords.get(pos);
- rec.removeAreaAt(index - startNumRegions);
- numMergedRegions--;
- if (rec.getNumAreas() == 0)
- {
+ MergeCellsRecord rec = (MergeCellsRecord) mergedRecords.get(pos);
+ rec.removeAreaAt(index - startNumRegions);
+ numMergedRegions--;
+ if (rec.getNumAreas() == 0)
+ {
mergedRecords.remove(pos);
//get rid of the record from the sheet
records.remove(merged);
- if (merged == rec) {
- //pull up the LAST record for operations when we finally
- //support continue records for mergedRegions
- if (mergedRecords.size() > 0) {
- merged = (MergeCellsRecord) mergedRecords.get(mergedRecords.size() - 1);
- } else {
- merged = null;
- }
- }
- }
- }
+ if (merged == rec) {
+ //pull up the LAST record for operations when we finally
+ //support continue records for mergedRegions
+ if (mergedRecords.size() > 0) {
+ merged = (MergeCellsRecord) mergedRecords.get(mergedRecords.size() - 1);
+ } else {
+ merged = null;
+ }
+ }
+ }
+ }
public MergeCellsRecord.MergedRegion getMergedRegionAt(int index)
{
@@ -537,11 +557,6 @@ public class Sheet implements Model
return numMergedRegions;
}
- public CellValueRecordInterface getValueRecord (int row, short col) {
- return cells.getCell(row, col);
- }
-
-
/**
* This is basically a kludge to deal with the now obsolete Label records. If
* you have to read in a sheet that contains Label records, be aware that the rest
@@ -641,9 +656,7 @@ public class Sheet implements Model
dims.setLastCol(lastcol);
dims.setLastRow(lastrow);
if (log.check( POILogger.DEBUG ))
- {
log.log(POILogger.DEBUG, "Sheet.setDimensions exiting");
- }
}
/**
@@ -710,6 +723,51 @@ public class Sheet implements Model
* Serializes all records in the sheet into one big byte array. Use this to write
* the sheet out.
*
+ * @return byte[] array containing the binary representation of the records in this sheet
+ *
+ */
+
+ public byte [] serialize()
+ {
+ if (log.check( POILogger.DEBUG ))
+ log.log(POILogger.DEBUG, "Sheet.serialize");
+
+ // addDBCellRecords();
+ byte[] retval = null;
+
+ // ArrayList bytes = new ArrayList(4096);
+ int arraysize = getSize();
+ int pos = 0;
+
+ // for (int k = 0; k < records.size(); k++)
+ // {
+ // bytes.add((( Record ) records.get(k)).serialize());
+ //
+ // }
+ // for (int k = 0; k < bytes.size(); k++)
+ // {
+ // arraysize += (( byte [] ) bytes.get(k)).length;
+ // POILogger.DEBUG((new StringBuffer("arraysize=")).append(arraysize)
+ // .toString());
+ // }
+ retval = new byte[ arraysize ];
+ for (int k = 0; k < records.size(); k++)
+ {
+
+ // byte[] rec = (( byte [] ) bytes.get(k));
+ // System.arraycopy(rec, 0, retval, pos, rec.length);
+ pos += (( Record ) records.get(k)).serialize(pos,
+ retval); // rec.length;
+ }
+ if (log.check( POILogger.DEBUG ))
+ log.log(POILogger.DEBUG, "Sheet.serialize returning " + retval);
+ return retval;
+ }
+
+ /**
+ * Serializes all records in the sheet into one big byte array. Use this to write
+ * the sheet out.
+ *
* @param offset to begin write at
* @param data array containing the binary representation of the records in this sheet
*
@@ -718,72 +776,48 @@ public class Sheet implements Model
public int serialize(int offset, byte [] data)
{
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "Sheet.serialize using offsets");
-
- int pos = offset;
- boolean haveSerializedIndex = false;
+ log.log(POILogger.DEBUG, "Sheet.serialize using offsets");
+
+ // addDBCellRecords();
+ // ArrayList bytes = new ArrayList(4096);
+ // int arraysize = getSize(); // 0;
+ int pos = 0;
+
+ // for (int k = 0; k < records.size(); k++)
+ // {
+ // bytes.add((( Record ) records.get(k)).serialize());
+ //
+ // }
+ // for (int k = 0; k < bytes.size(); k++)
+ // {
+ // arraysize += (( byte [] ) bytes.get(k)).length;
+ // POILogger.DEBUG((new StringBuffer("arraysize=")).append(arraysize)
+ // .toString());
+ // }
for (int k = 0; k < records.size(); k++)
{
+// byte[] rec = (( byte [] ) bytes.get(k));
+ // System.arraycopy(rec, 0, data, offset + pos, rec.length);
Record record = (( Record ) records.get(k));
- int startPos = pos;
- //Once the rows have been found in the list of records, start
- //writing out the blocked row information. This includes the DBCell references
- if (record instanceof RowRecordsAggregate) {
- pos += ((RowRecordsAggregate)record).serialize(pos, data, cells); // rec.length;
- } else if (record instanceof ValueRecordsAggregate) {
- //Do nothing here. The records were serialized during the RowRecordAggregate block serialization
- } else {
- pos += record.serialize(pos, data ); // rec.length;
- }
- //If the BOF record was just serialized then add the IndexRecord
- if (record.getSid() == BOFRecord.sid) {
- //Can there be more than one BOF for a sheet? If not then we can
- //remove this guard. So be safe it is left here.
- if (!haveSerializedIndex) {
- haveSerializedIndex = true;
- pos += serializeIndexRecord(k, pos, data);
- }
- }
+ //// uncomment to test record sizes ////
+// System.out.println( record.getClass().getName() );
+// byte[] data2 = new byte[record.getRecordSize()];
+// record.serialize(0, data2 ); // rec.length;
+// if (LittleEndian.getUShort(data2, 2) != record.getRecordSize() - 4
+// && record instanceof RowRecordsAggregate == false
+// && record instanceof ValueRecordsAggregate == false
+// && record instanceof EscherAggregate == false)
+// {
+// throw new RuntimeException("Blah!!! Size off by " + ( LittleEndian.getUShort(data2, 2) - record.getRecordSize() - 4) + " records.");
+// }
+
+ pos += record.serialize(pos + offset, data ); // rec.length;
+
}
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "Sheet.serialize returning ");
- return pos-offset;
- }
-
- private int serializeIndexRecord(final int BOFRecordIndex, final int offset, byte[] data) {
- IndexRecord index = new IndexRecord();
- index.setFirstRow(rows.getFirstRowNum());
- index.setLastRowAdd1(rows.getLastRowNum()+1);
- //Calculate the size of the records from the end of the BOF
- //and up to the RowRecordsAggregate...
- int sheetRecSize = 0;
- for (int j = BOFRecordIndex+1; j < records.size(); j++)
- {
- Record tmpRec = (( Record ) records.get(j));
- if (tmpRec instanceof RowRecordsAggregate)
- break;
- sheetRecSize+= tmpRec.getRecordSize();
- }
- //Add the references to the DBCells in the IndexRecord (one for each block)
- int blockCount = rows.getRowBlockCount();
- //Calculate the size of this IndexRecord
- int indexRecSize = index.getRecordSizeForBlockCount(blockCount);
-
- int rowBlockOffset = 0;
- int cellBlockOffset = 0;
- int dbCellOffset = 0;
- for (int block=0;block<blockCount;block++) {
- rowBlockOffset += rows.getRowBlockSize(block);
- cellBlockOffset += cells.getRowCellBlockSize(rows.getStartRowNumberForBlock(block),
- rows.getEndRowNumberForBlock(block));
- //Note: The offsets are relative to the Workbook BOF. Assume that this is
- //0 for now.....
- index.addDbcell(offset + indexRecSize + sheetRecSize + dbCellOffset + rowBlockOffset + cellBlockOffset);
- //Add space required to write the dbcell record(s) (whose references were just added).
- dbCellOffset += (8 + (rows.getRowCountForBlock(block) * 2));
- }
- return index.serialize(offset, data);
+ log.log(POILogger.DEBUG, "Sheet.serialize returning ");
+ return pos;
}
/**
@@ -796,17 +830,7 @@ public class Sheet implements Model
public RowRecord createRow(int row)
{
- if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "create row number " + row);
- RowRecord rowrec = new RowRecord();
-
- //rowrec.setRowNumber(( short ) row);
- rowrec.setRowNumber(row);
- rowrec.setHeight(( short ) 0xff);
- rowrec.setOptimize(( short ) 0x0);
- rowrec.setOptionFlags(( short ) 0x0);
- rowrec.setXFIndex(( short ) 0x0);
- return rowrec;
+ return RowRecordsAggregate.createRow( row );
}
/**
@@ -822,7 +846,7 @@ public class Sheet implements Model
//public LabelSSTRecord createLabelSST(short row, short col, int index)
public LabelSSTRecord createLabelSST(int row, short col, int index)
{
- log.logFormatted(log.DEBUG, "create labelsst row,col,index %,%,%",
+ log.logFormatted(POILogger.DEBUG, "create labelsst row,col,index %,%,%",
new int[]
{
row, col, index
@@ -849,7 +873,7 @@ public class Sheet implements Model
//public NumberRecord createNumber(short row, short col, double value)
public NumberRecord createNumber(int row, short col, double value)
{
- log.logFormatted(log.DEBUG, "create number row,col,value %,%,%",
+ log.logFormatted(POILogger.DEBUG, "create number row,col,value %,%,%",
new double[]
{
row, col, value
@@ -874,8 +898,8 @@ public class Sheet implements Model
//public BlankRecord createBlank(short row, short col)
public BlankRecord createBlank(int row, short col)
{
- //log.logFormatted(log.DEBUG, "create blank row,col %,%", new short[]
- log.logFormatted(log.DEBUG, "create blank row,col %,%", new int[]
+ //log.logFormatted(POILogger.DEBUG, "create blank row,col %,%", new short[]
+ log.logFormatted(POILogger.DEBUG, "create blank row,col %,%", new int[]
{
row, col
});
@@ -901,7 +925,7 @@ public class Sheet implements Model
//public FormulaRecord createFormula(short row, short col, String formula)
public FormulaRecord createFormula(int row, short col, String formula)
{
- log.logFormatted(log.DEBUG, "create formula row,col,formula %,%,%",
+ log.logFormatted(POILogger.DEBUG, "create formula row,col,formula %,%,%",
//new short[]
new int[]
{
@@ -945,7 +969,7 @@ public class Sheet implements Model
public void addValueRecord(int row, CellValueRecordInterface col)
{
checkCells();
- log.logFormatted(log.DEBUG, "add value record row,loc %,%", new int[]
+ log.logFormatted(POILogger.DEBUG, "add value record row,loc %,%", new int[]
{
row, loc
});
@@ -999,11 +1023,8 @@ public class Sheet implements Model
public void removeValueRecord(int row, CellValueRecordInterface col)
{
checkCells();
- log.logFormatted(log.DEBUG, "remove value record row,dimsloc %,%",
- new int[]
- {
- row, dimsloc
- });
+ log.logFormatted(POILogger.DEBUG, "remove value record row,dimsloc %,%",
+ new int[]{row, dimsloc} );
loc = dimsloc;
cells.removeCell(col);
@@ -1044,7 +1065,7 @@ public class Sheet implements Model
checkCells();
setLoc(dimsloc);
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "replaceValueRecord ");
+ log.log(POILogger.DEBUG, "replaceValueRecord ");
cells.insertCell(newval);
/*
@@ -1081,10 +1102,10 @@ public class Sheet implements Model
{
checkRows();
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "addRow ");
+ log.log(POILogger.DEBUG, "addRow ");
DimensionsRecord d = ( DimensionsRecord ) records.get(getDimsLoc());
- if (row.getRowNumber() > d.getLastRow())
+ if (row.getRowNumber() >= d.getLastRow())
{
d.setLastRow(row.getRowNumber() + 1);
}
@@ -1136,7 +1157,7 @@ public class Sheet implements Model
* }
*/
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "exit addRow");
+ log.log(POILogger.DEBUG, "exit addRow");
}
/**
@@ -1154,7 +1175,6 @@ public class Sheet implements Model
setLoc(getDimsLoc());
rows.removeRow(row);
- cells.removeRow(row.getRowNumber());
/*
* for (int k = loc; k < records.size(); k++)
@@ -1198,7 +1218,7 @@ public class Sheet implements Model
public CellValueRecordInterface getNextValueRecord()
{
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "getNextValue loc= " + loc);
+ log.log(POILogger.DEBUG, "getNextValue loc= " + loc);
if (valueRecIterator == null)
{
valueRecIterator = cells.getIterator();
@@ -1245,7 +1265,7 @@ public class Sheet implements Model
/* public Record getNextRowOrValue()
{
- log.debug((new StringBuffer("getNextRow loc= ")).append(loc)
+ POILogger.DEBUG((new StringBuffer("getNextRow loc= ")).append(loc)
.toString());
if (this.getLoc() < records.size())
{
@@ -1286,7 +1306,7 @@ public class Sheet implements Model
public RowRecord getNextRow()
{
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "getNextRow loc= " + loc);
+ log.log(POILogger.DEBUG, "getNextRow loc= " + loc);
if (rowRecIterator == null)
{
rowRecIterator = rows.getIterator();
@@ -1333,10 +1353,7 @@ public class Sheet implements Model
public RowRecord getRow(int rownum)
{
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "getNextRow loc= " + loc);
- if (rows == null) {
- return null;
- }
+ log.log(POILogger.DEBUG, "getNextRow loc= " + loc);
return rows.getRow(rownum);
/*
@@ -1361,21 +1378,116 @@ public class Sheet implements Model
// return null;
}
+ /**
+ * Not currently used method to calculate and add dbcell records
+ *
+ */
- public Iterator rowRecordIterator() {
- return rows.getIterator();
- }
+ public void addDBCellRecords()
+ {
+ int offset = 0;
+ int recnum = 0;
+ int rownum = 0;
+ //int lastrow = 0;
+ //long lastrowoffset = 0;
+ IndexRecord index = null;
+
+ // ArrayList rowOffsets = new ArrayList();
+ IntList rowOffsets = new IntList();
+
+ for (recnum = 0; recnum < records.size(); recnum++)
+ {
+ Record rec = ( Record ) records.get(recnum);
+
+ if (rec.getSid() == IndexRecord.sid)
+ {
+ index = ( IndexRecord ) rec;
+ }
+ if (rec.getSid() != RowRecord.sid)
+ {
+ offset += rec.serialize().length;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ // First Row Record
+ for (; recnum < records.size(); recnum++)
+ {
+ Record rec = ( Record ) records.get(recnum);
+
+ if (rec.getSid() == RowRecord.sid)
+ {
+ rownum++;
+ rowOffsets.add(offset);
+ if ((rownum % 32) == 0)
+ {
- public Iterator rowCellIterator(int row) {
- return this.cells.getRowCellIterator(row);
+ // if this is the last rec in a dbcell block
+ // find the next row or last value record
+ for (int rn = recnum; rn < records.size(); rn++)
+ {
+ rec = ( Record ) records.get(rn);
+ if ((!rec.isInValueSection())
+ || (rec.getSid() == RowRecord.sid))
+ {
+
+ // here is the next row or last value record
+ records.add(rn,
+ createDBCell(offset, rowOffsets,
+ index));
+ recnum = rn;
+ break;
+ }
+ }
+ }
+ else
+ {
+ }
+ }
+ if (!rec.isInValueSection())
+ {
+ records.add(recnum, createDBCell(offset, rowOffsets, index));
+ break;
+ }
+ offset += rec.serialize().length;
+ }
}
- public int getFirstRow() {
- return rows.getFirstRowNum();
+ /** not currently used */
+
+ private DBCellRecord createDBCell(int offset, IntList rowoffsets,
+ IndexRecord index)
+ {
+ DBCellRecord rec = new DBCellRecord();
+
+ rec.setRowOffset(offset - rowoffsets.get(0));
+
+ // test hack
+ rec.addCellOffset(( short ) 0x0);
+
+ // end test hack
+ addDbCellToIndex(offset, index);
+ return rec;
}
- public int getLastRow() {
- return rows.getLastRowNum();
+ /** not currently used */
+
+ private void addDbCellToIndex(int offset, IndexRecord index)
+ {
+ int numdbcells = index.getNumDbcells() + 1;
+
+ index.addDbcell(offset + preoffset);
+
+ // stupid but whenever we add an offset that causes everything to be shifted down 4
+ for (int k = 0; k < numdbcells; k++)
+ {
+ int dbval = index.getDbcellAt(k);
+
+ index.setDbcell(k, dbval + 4);
+ }
}
/**
@@ -1457,7 +1569,7 @@ public class Sheet implements Model
{
RefModeRecord retval = new RefModeRecord();
- retval.setMode(retval.USE_A1_MODE);
+ retval.setMode(RefModeRecord.USE_A1_MODE);
return retval;
}
@@ -1713,12 +1825,7 @@ public class Sheet implements Model
protected Record createColInfo()
{
- ColumnInfoRecord retval = new ColumnInfoRecord();
-
- retval.setColumnWidth(( short ) 0x8);
- retval.setOptions(( short ) 6);
- retval.setXFIndex(( short ) 0x0f);
- return retval;
+ return ColumnInfoRecordsAggregate.createColInfo();
}
/**
@@ -1793,14 +1900,13 @@ public class Sheet implements Model
{
short retval = 0;
ColumnInfoRecord ci = null;
- int k = 0;
- if (columnSizes != null)
+ if (columns != null)
{
- for (k = 0; k < columnSizes.size(); k++)
+ for ( Iterator iterator = columns.getIterator(); iterator.hasNext(); )
{
- ci = ( ColumnInfoRecord ) columnSizes.get(k);
- if ((column >= ci.getFirstColumn())
+ ci = ( ColumnInfoRecord ) iterator.next();
+ if ((ci.getFirstColumn() <= column)
&& (column <= ci.getLastColumn()))
{
break;
@@ -1824,104 +1930,46 @@ public class Sheet implements Model
* @param column - the column number
* @param width (in units of 1/20th of a character width)
*/
-
public void setColumnWidth(short column, short width)
{
- ColumnInfoRecord ci = null;
- int k = 0;
-
- if (columnSizes == null)
- {
- columnSizes = new ArrayList();
- }
- //int cioffset = getDimsLoc() - columnSizes.size();
+ setColumn( column, new Short(width), null, null, null);
+ }
- for (k = 0; k < columnSizes.size(); k++)
- {
- ci = ( ColumnInfoRecord ) columnSizes.get(k);
- if ((ci.getFirstColumn() >= column)
- && (column <= ci.getLastColumn()))
- {
- break;
- }
- ci = null;
- }
- if (ci != null)
- {
- if (ci.getColumnWidth() == width)
- {
+ public void setColumn(short column, Short width, Integer level, Boolean hidden, Boolean collapsed)
+ {
+ if (columns == null)
+ columns = new ColumnInfoRecordsAggregate();
- // do nothing...the cell's width is equal to what we're setting it to.
- }
- else if ((ci.getFirstColumn() == column)
- && (ci.getLastColumn() == column))
- { // if its only for this cell then
- ci.setColumnWidth(width); // who cares, just change the width
- }
- else if ((ci.getFirstColumn() == column)
- || (ci.getLastColumn() == column))
- {
+ columns.setColumn( column, width, level, hidden, collapsed );
+ }
- // okay so the width is different but the first or last column == the column we'return setting
- // we'll just divide the info and create a new one
- if (ci.getFirstColumn() == column)
- {
- ci.setFirstColumn(( short ) (column + 1));
- }
- else
- {
- ci.setLastColumn(( short ) (column - 1));
- }
- ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
-
- nci.setFirstColumn(column);
- nci.setLastColumn(column);
- nci.setOptions(ci.getOptions());
- nci.setXFIndex(ci.getXFIndex());
- nci.setColumnWidth(width);
- columnSizes.add(k, nci);
- records.add((1 + getDimsLoc() - columnSizes.size()) + k, nci);
- dimsloc++;
- }
- else{
- //split to 3 records
- short lastcolumn = ci.getLastColumn();
- ci.setLastColumn(( short ) (column - 1));
-
- ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
- nci.setFirstColumn(column);
- nci.setLastColumn(column);
- nci.setOptions(ci.getOptions());
- nci.setXFIndex(ci.getXFIndex());
- nci.setColumnWidth(width);
- columnSizes.add(k, nci);
- records.add((1 + getDimsLoc() - columnSizes.size()) + k, nci);
- dimsloc++;
-
- nci = ( ColumnInfoRecord ) createColInfo();
- nci.setFirstColumn((short)(column+1));
- nci.setLastColumn(lastcolumn);
- nci.setOptions(ci.getOptions());
- nci.setXFIndex(ci.getXFIndex());
- nci.setColumnWidth(ci.getColumnWidth());
- columnSizes.add(k, nci);
- records.add((1 + getDimsLoc() - columnSizes.size()) + k, nci);
- dimsloc++;
- }
- }
- else
- {
+ /**
+ * Creates an outline group for the specified columns.
+ * @param fromColumn group from this column (inclusive)
+ * @param toColumn group to this column (inclusive)
+ * @param indent if true the group will be indented by one level,
+ * if false indenting will be removed by one level.
+ */
+ public void groupColumnRange(short fromColumn, short toColumn, boolean indent)
+ {
- // okay so there ISN'T a column info record that cover's this column so lets create one!
- ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
+ // Set the level for each column
+ columns.groupColumnRange( fromColumn, toColumn, indent);
- nci.setFirstColumn(column);
- nci.setLastColumn(column);
- nci.setColumnWidth(width);
- columnSizes.add(k, nci);
- records.add((1 + getDimsLoc() - columnSizes.size()) + k, nci);
- dimsloc++;
+ // Determine the maximum overall level
+ int maxLevel = 0;
+ for ( Iterator iterator = columns.getIterator(); iterator.hasNext(); )
+ {
+ ColumnInfoRecord columnInfoRecord = (ColumnInfoRecord) iterator.next();
+ maxLevel = Math.max(columnInfoRecord.getOutlineLevel(), maxLevel);
}
+
+ GutsRecord guts = (GutsRecord) findFirstRecordBySid( GutsRecord.sid );
+ guts.setColLevelMax( (short) ( maxLevel+1 ) );
+ if (maxLevel == 0)
+ guts.setTopColGutter( (short)0 );
+ else
+ guts.setTopColGutter( (short) ( 29 + (12 * (maxLevel-1)) ) );
}
/**
@@ -2051,7 +2099,6 @@ public class Sheet implements Model
protected Record createMergedCells()
{
MergeCellsRecord retval = new MergeCellsRecord();
-
retval.setNumAreas(( short ) 0);
return retval;
}
@@ -2068,32 +2115,6 @@ public class Sheet implements Model
return new EOFRecord();
}
- public void setLastColForRow(int row, short col) {
- this.getRow(row).setLastCol(col);
- }
-
- public void setFirstColForRow(int row, short col) {
- this.getRow(row).setFirstCol(col);
- }
-
- public short getLastColForRow(int row) {
- return this.getRow(row).getLastCol();
- }
-
-
- public short getFirstColForRow(int row) {
- return this.getRow(row).getFirstCol();
- }
-
- public void setCellValue(int row, short col, double val) {
- this.cells.setValue(row, col, val);
- }
-
- public void setCellStyle(int row, short col, short xf) {
- this.cells.setStyle(row, col, xf);
- }
-
-
/**
* get the location of the DimensionsRecord (which is the last record before the value section)
* @return location in the array of records of the DimensionsRecord
@@ -2102,7 +2123,7 @@ public class Sheet implements Model
public int getDimsLoc()
{
if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "getDimsLoc dimsloc= " + dimsloc);
+ log.log(POILogger.DEBUG, "getDimsLoc dimsloc= " + dimsloc);
return dimsloc;
}
@@ -2127,22 +2148,6 @@ public class Sheet implements Model
{
retval += (( Record ) records.get(k)).getRecordSize();
}
- //Add space for the IndexRecord
- final int blocks = rows.getRowBlockCount();
- retval += IndexRecord.getRecordSizeForBlockCount(blocks);
-
- //Add space for the DBCell records
- //Once DBCell per block.
- //8 bytes per DBCell (non variable section)
- //2 bytes per row reference
- int startRetVal = retval;
- retval += (8 * blocks);
- for (Iterator itr = rows.getIterator(); itr.hasNext();) {
- RowRecord row = (RowRecord)itr.next();
- if (cells.rowHasCells(row.getRowNumber()))
- retval += 2;
- }
-
return retval;
}
@@ -2178,11 +2183,6 @@ public class Sheet implements Model
return null;
}
- public int getPhysicalNumberOfRows() {
- return rows.getPhysicalNumberOfRows();
- }
-
-
/**
* Sets the SCL record or creates it in the correct place if it does not
* already exist.
@@ -2407,25 +2407,8 @@ public class Sheet implements Model
windowTwo.setFreezePanesNoSplit(true);
SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
-// SelectionRecord sel2 = (SelectionRecord) sel.clone();
-// SelectionRecord sel3 = (SelectionRecord) sel.clone();
-// SelectionRecord sel4 = (SelectionRecord) sel.clone();
-// sel.setPane(PANE_LOWER_RIGHT); // 0
-// sel3.setPane(PANE_UPPER_RIGHT); // 1
- sel.setPane((byte)pane.getActivePane()); // 2
-// sel2.setPane(PANE_UPPER_LEFT); // 3
-// sel4.setActiveCellCol((short)Math.max(sel3.getActiveCellCol(), colSplit));
-// sel3.setActiveCellRow((short)Math.max(sel4.getActiveCellRow(), rowSplit));
-
- int selLoc = findFirstRecordLocBySid(SelectionRecord.sid);
-// sel.setActiveCellCol((short)15);
-// sel.setActiveCellRow((short)15);
-// sel2.setActiveCellCol((short)0);
-// sel2.setActiveCellRow((short)0);
+ sel.setPane((byte)pane.getActivePane());
-// records.add(selLoc+1,sel2);
-// records.add(selLoc+2,sel3);
-// records.add(selLoc+3,sel4);
}
/**
@@ -2456,25 +2439,8 @@ public class Sheet implements Model
windowTwo.setFreezePanesNoSplit(false);
SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
-// SelectionRecord sel2 = (SelectionRecord) sel.clone();
-// SelectionRecord sel3 = (SelectionRecord) sel.clone();
-// SelectionRecord sel4 = (SelectionRecord) sel.clone();
- sel.setPane(PANE_LOWER_RIGHT); // 0
-// sel3.setPane(PANE_UPPER_RIGHT); // 1
-// sel4.setPane(PANE_LOWER_LEFT); // 2
-// sel2.setPane(PANE_UPPER_LEFT); // 3
-// sel4.setActiveCellCol((short)Math.max(sel3.getActiveCellCol(), colSplit));
-// sel3.setActiveCellRow((short)Math.max(sel4.getActiveCellRow(), rowSplit));
-
- int selLoc = findFirstRecordLocBySid(SelectionRecord.sid);
-// sel.setActiveCellCol((short)15);
-// sel.setActiveCellRow((short)15);
-// sel2.setActiveCellCol((short)0);
-// sel2.setActiveCellRow((short)0);
-
-// records.add(selLoc+1,sel2);
-// records.add(selLoc+2,sel3);
-// records.add(selLoc+3,sel4);
+ sel.setPane(PANE_LOWER_RIGHT);
+
}
public SelectionRecord getSelection()
@@ -2488,6 +2454,28 @@ public class Sheet implements Model
}
/**
+ * creates a Protect record with protect set to false.
+ * @see org.apache.poi.hssf.record.ProtectRecord
+ * @see org.apache.poi.hssf.record.Record
+ * @return a ProtectRecord
+ */
+ protected Record createProtect()
+ {
+ if (log.check( POILogger.DEBUG ))
+ log.log(POILogger.DEBUG, "create protect record with protection disabled");
+ ProtectRecord retval = new ProtectRecord();
+
+ retval.setProtect(false);
+ // by default even when we support encryption we won't
+ return retval;
+ }
+
+ public ProtectRecord getProtect()
+ {
+ return protect;
+ }
+
+ /**
* Sets whether the gridlines are shown in a viewer.
* @param show whether to show gridlines or not
*/
@@ -2532,7 +2520,7 @@ public class Sheet implements Model
* @return whether RowColHeadings are displayed
*/
public boolean isDisplayRowColHeadings() {
- return windowTwo.getDisplayRowColHeadings();
+ return windowTwo.getDisplayRowColHeadings();
}
/**
@@ -2543,30 +2531,7 @@ public class Sheet implements Model
protected Margin[] getMargins() {
if (margins == null)
margins = new Margin[4];
- return margins;
- }
-
- /**
- * creates a Protect record with protect set to false.
- * @see org.apache.poi.hssf.record.ProtectRecord
- * @see org.apache.poi.hssf.record.Record
- * @return a ProtectRecord
- */
-
- protected Record createProtect()
- {
- if (log.check( POILogger.DEBUG ))
- log.log(log.DEBUG, "create protect record with protection disabled");
- ProtectRecord retval = new ProtectRecord();
-
- retval.setProtect(false);
- // by default even when we support encryption we won't
- return retval; // want to default to be protected
- }
-
- public ProtectRecord getProtect()
- {
- return protect;
+ return margins;
}
public int aggregateDrawingRecords(DrawingManager drawingManager)
@@ -2628,15 +2593,15 @@ public class Sheet implements Model
* @param breaks The page record to be shifted
* @param start Starting "main" value to shift breaks
* @param stop Ending "main" value to shift breaks
- * @param count number of units (rows/columns) to shift by
+ * @param count number of units (rows/columns) to shift by
*/
public void shiftBreaks(PageBreakRecord breaks, short start, short stop, int count) {
-
+
if(rowBreaks == null)
return;
Iterator iterator = breaks.getBreaksIterator();
List shiftedBreak = new ArrayList();
- while(iterator.hasNext())
+ while(iterator.hasNext())
{
PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next();
short breakLocation = breakItem.main;
@@ -2645,20 +2610,20 @@ public class Sheet implements Model
if(inStart && inEnd)
shiftedBreak.add(breakItem);
}
-
+
iterator = shiftedBreak.iterator();
- while (iterator.hasNext()) {
+ while (iterator.hasNext()) {
PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next();
breaks.removeBreak(breakItem.main);
breaks.addBreak((short)(breakItem.main+count), breakItem.subFrom, breakItem.subTo);
}
}
-
+
/**
* Sets a page break at the indicated row
* @param row
*/
- public void setRowBreak(int row, short fromCol, short toCol) {
+ public void setRowBreak(int row, short fromCol, short toCol) {
rowBreaks.addBreak((short)row, fromCol, toCol);
}
@@ -2681,15 +2646,15 @@ public class Sheet implements Model
/**
* Sets a page break at the indicated column
- * @param row
+ *
*/
- public void setColumnBreak(short column, short fromRow, short toRow) {
+ public void setColumnBreak(short column, short fromRow, short toRow) {
colBreaks.addBreak(column, fromRow, toRow);
}
/**
* Removes a page break at the indicated column
- * @param row
+ *
*/
public void removeColumnBreak(short column) {
colBreaks.removeBreak(column);
@@ -2697,13 +2662,13 @@ public class Sheet implements Model
/**
* Queries if the specified column has a page break
- * @param row
+ *
* @return true if the specified column has a page break
*/
public boolean isColumnBroken(short column) {
return colBreaks.getBreak(column) != null;
}
-
+
/**
* Shifts the horizontal page breaks for the indicated count
* @param startingRow
@@ -2723,7 +2688,7 @@ public class Sheet implements Model
public void shiftColumnBreaks(short startingCol, short endingCol, short count) {
shiftBreaks(colBreaks, startingCol, endingCol, count);
}
-
+
/**
* Returns all the row page breaks
* @return
@@ -2731,7 +2696,7 @@ public class Sheet implements Model
public Iterator getRowBreaks() {
return rowBreaks.getBreaksIterator();
}
-
+
/**
* Returns the number of row page breaks
* @return
@@ -2739,7 +2704,7 @@ public class Sheet implements Model
public int getNumRowBreaks(){
return (int)rowBreaks.getNumBreaks();
}
-
+
/**
* Returns all the column page breaks
* @return
@@ -2747,7 +2712,7 @@ public class Sheet implements Model
public Iterator getColumnBreaks(){
return colBreaks.getBreaksIterator();
}
-
+
/**
* Returns the number of column page breaks
* @return
@@ -2756,4 +2721,359 @@ public class Sheet implements Model
return (int)colBreaks.getNumBreaks();
}
+ public void setColumnGroupCollapsed( short columnNumber, boolean collapsed )
+ {
+ if (collapsed)
+ {
+ columns.collapseColumn( columnNumber );
+ }
+ else
+ {
+ columns.expandColumn( columnNumber );
+ }
+ }
+
+// private void collapseColumn( short columnNumber )
+// {
+// int idx = findColumnIdx( columnNumber, 0 );
+// if (idx == -1)
+// return;
+//
+// // Find the start of the group.
+// ColumnInfoRecord columnInfo = (ColumnInfoRecord) columnSizes.get( findStartOfColumnOutlineGroup( idx ) );
+//
+// // Hide all the columns until the end of the group
+// columnInfo = writeHidden( columnInfo, idx, true );
+//
+// // Write collapse field
+// setColumn( (short) ( columnInfo.getLastColumn() + 1 ), null, null, null, Boolean.TRUE);
+// }
+
+// private void expandColumn( short columnNumber )
+// {
+// int idx = findColumnIdx( columnNumber, 0 );
+// if (idx == -1)
+// return;
+//
+// // If it is already exapanded do nothing.
+// if (!isColumnGroupCollapsed(idx))
+// return;
+//
+// // Find the start of the group.
+// int startIdx = findStartOfColumnOutlineGroup( idx );
+// ColumnInfoRecord columnInfo = getColInfo( startIdx );
+//
+// // Find the end of the group.
+// int endIdx = findEndOfColumnOutlineGroup( idx );
+// ColumnInfoRecord endColumnInfo = getColInfo( endIdx );
+//
+// // expand:
+// // colapsed bit must be unset
+// // hidden bit gets unset _if_ surrounding groups are expanded you can determine
+// // this by looking at the hidden bit of the enclosing group. You will have
+// // to look at the start and the end of the current group to determine which
+// // is the enclosing group
+// // hidden bit only is altered for this outline level. ie. don't uncollapse contained groups
+// if (!isColumnGroupHiddenByParent( idx ))
+// {
+// for (int i = startIdx; i <= endIdx; i++)
+// {
+// if (columnInfo.getOutlineLevel() == getColInfo(i).getOutlineLevel())
+// getColInfo(i).setHidden( false );
+// }
+// }
+//
+// // Write collapse field
+// setColumn( (short) ( columnInfo.getLastColumn() + 1 ), null, null, null, Boolean.FALSE);
+// }
+
+// private boolean isColumnGroupCollapsed( int idx )
+// {
+// int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup( idx );
+// if (endOfOutlineGroupIdx >= columnSizes.size())
+// return false;
+// if (getColInfo(endOfOutlineGroupIdx).getLastColumn() + 1 != getColInfo(endOfOutlineGroupIdx + 1).getFirstColumn())
+// return false;
+// else
+// return getColInfo(endOfOutlineGroupIdx+1).getCollapsed();
+// }
+
+// private boolean isColumnGroupHiddenByParent( int idx )
+// {
+// // Look out outline details of end
+// int endLevel;
+// boolean endHidden;
+// int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup( idx );
+// if (endOfOutlineGroupIdx >= columnSizes.size())
+// {
+// endLevel = 0;
+// endHidden = false;
+// }
+// else if (getColInfo(endOfOutlineGroupIdx).getLastColumn() + 1 != getColInfo(endOfOutlineGroupIdx + 1).getFirstColumn())
+// {
+// endLevel = 0;
+// endHidden = false;
+// }
+// else
+// {
+// endLevel = getColInfo( endOfOutlineGroupIdx + 1).getOutlineLevel();
+// endHidden = getColInfo( endOfOutlineGroupIdx + 1).getHidden();
+// }
+//
+// // Look out outline details of start
+// int startLevel;
+// boolean startHidden;
+// int startOfOutlineGroupIdx = findStartOfColumnOutlineGroup( idx );
+// if (startOfOutlineGroupIdx <= 0)
+// {
+// startLevel = 0;
+// startHidden = false;
+// }
+// else if (getColInfo(startOfOutlineGroupIdx).getFirstColumn() - 1 != getColInfo(startOfOutlineGroupIdx - 1).getLastColumn())
+// {
+// startLevel = 0;
+// startHidden = false;
+// }
+// else
+// {
+// startLevel = getColInfo( startOfOutlineGroupIdx - 1).getOutlineLevel();
+// startHidden = getColInfo( startOfOutlineGroupIdx - 1 ).getHidden();
+// }
+//
+// if (endLevel > startLevel)
+// {
+// return endHidden;
+// }
+// else
+// {
+// return startHidden;
+// }
+// }
+
+// private ColumnInfoRecord getColInfo(int idx)
+// {
+// return columns.getColInfo( idx );
+// }
+
+// private int findStartOfColumnOutlineGroup(int idx)
+// {
+// // Find the start of the group.
+// ColumnInfoRecord columnInfo = (ColumnInfoRecord) columnSizes.get( idx );
+// int level = columnInfo.getOutlineLevel();
+// while (idx != 0)
+// {
+// ColumnInfoRecord prevColumnInfo = (ColumnInfoRecord) columnSizes.get( idx - 1 );
+// if (columnInfo.getFirstColumn() - 1 == prevColumnInfo.getLastColumn())
+// {
+// if (prevColumnInfo.getOutlineLevel() < level)
+// {
+// break;
+// }
+// idx--;
+// columnInfo = prevColumnInfo;
+// }
+// else
+// {
+// break;
+// }
+// }
+//
+// return idx;
+// }
+
+// private int findEndOfColumnOutlineGroup(int idx)
+// {
+// // Find the end of the group.
+// ColumnInfoRecord columnInfo = (ColumnInfoRecord) columnSizes.get( idx );
+// int level = columnInfo.getOutlineLevel();
+// while (idx < columnSizes.size() - 1)
+// {
+// ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) columnSizes.get( idx + 1 );
+// if (columnInfo.getLastColumn() + 1 == nextColumnInfo.getFirstColumn())
+// {
+// if (nextColumnInfo.getOutlineLevel() < level)
+// {
+// break;
+// }
+// idx++;
+// columnInfo = nextColumnInfo;
+// }
+// else
+// {
+// break;
+// }
+// }
+//
+// return idx;
+// }
+
+ public void groupRowRange(int fromRow, int toRow, boolean indent)
+ {
+ checkRows();
+ for (int rowNum = fromRow; rowNum <= toRow; rowNum++)
+ {
+ RowRecord row = getRow( rowNum );
+ if (row == null)
+ {
+ row = createRow( rowNum );
+ addRow( row );
+ }
+ int level = row.getOutlineLevel();
+ if (indent) level++; else level--;
+ level = Math.max(0, level);
+ level = Math.min(7, level);
+ row.setOutlineLevel((short) ( level ));
+ }
+
+ recalcRowGutter();
+ }
+
+ private void recalcRowGutter()
+ {
+ int maxLevel = 0;
+ Iterator iterator = rows.getIterator();
+ while ( iterator.hasNext() )
+ {
+ RowRecord rowRecord = (RowRecord) iterator.next();
+ maxLevel = Math.max(rowRecord.getOutlineLevel(), maxLevel);
+ }
+
+ GutsRecord guts = (GutsRecord) findFirstRecordBySid( GutsRecord.sid );
+ guts.setRowLevelMax( (short) ( maxLevel + 1 ) );
+ guts.setLeftRowGutter( (short) ( 29 + (12 * (maxLevel)) ) );
+ }
+
+ public void setRowGroupCollapsed( int row, boolean collapse )
+ {
+ if (collapse)
+ {
+ rows.collapseRow( row );
+ }
+ else
+ {
+ rows.expandRow( row );
+ }
+ }
+
+
+// private void collapseRow( int rowNumber )
+// {
+//
+// // Find the start of the group.
+// int startRow = rows.findStartOfRowOutlineGroup( rowNumber );
+// RowRecord rowRecord = (RowRecord) rows.getRow( startRow );
+//
+// // Hide all the columns until the end of the group
+// int lastRow = rows.writeHidden( rowRecord, startRow, true );
+//
+// // Write collapse field
+// if (getRow(lastRow + 1) != null)
+// {
+// getRow(lastRow + 1).setColapsed( true );
+// }
+// else
+// {
+// RowRecord row = createRow( lastRow + 1);
+// row.setColapsed( true );
+// rows.insertRow( row );
+// }
+// }
+
+// private int findStartOfRowOutlineGroup(int row)
+// {
+// // Find the start of the group.
+// RowRecord rowRecord = rows.getRow( row );
+// int level = rowRecord.getOutlineLevel();
+// int currentRow = row;
+// while (rows.getRow( currentRow ) != null)
+// {
+// rowRecord = rows.getRow( currentRow );
+// if (rowRecord.getOutlineLevel() < level)
+// return currentRow + 1;
+// currentRow--;
+// }
+//
+// return currentRow + 1;
+// }
+
+// private int writeHidden( RowRecord rowRecord, int row, boolean hidden )
+// {
+// int level = rowRecord.getOutlineLevel();
+// while (rowRecord != null && rows.getRow(row).getOutlineLevel() >= level)
+// {
+// rowRecord.setZeroHeight( hidden );
+// row++;
+// rowRecord = rows.getRow( row );
+// }
+// return row - 1;
+// }
+
+// private int findEndOfRowOutlineGroup( int row )
+// {
+// int level = getRow( row ).getOutlineLevel();
+// int currentRow;
+// for (currentRow = row; currentRow < rows.getLastRowNum(); currentRow++)
+// {
+// if (getRow(currentRow) == null || getRow(currentRow).getOutlineLevel() < level)
+// {
+// break;
+// }
+// }
+//
+// return currentRow-1;
+// }
+
+// private boolean isRowGroupCollapsed( int row )
+// {
+// int collapseRow = rows.findEndOfRowOutlineGroup( row ) + 1;
+//
+// if (getRow(collapseRow) == null)
+// return false;
+// else
+// return getRow( collapseRow ).getColapsed();
+// }
+
+
+// private boolean isRowGroupHiddenByParent( int row )
+// {
+// // Look out outline details of end
+// int endLevel;
+// boolean endHidden;
+// int endOfOutlineGroupIdx = rows.findEndOfRowOutlineGroup( row );
+// if (getRow( endOfOutlineGroupIdx + 1 ) == null)
+// {
+// endLevel = 0;
+// endHidden = false;
+// }
+// else
+// {
+// endLevel = getRow( endOfOutlineGroupIdx + 1).getOutlineLevel();
+// endHidden = getRow( endOfOutlineGroupIdx + 1).getZeroHeight();
+// }
+//
+// // Look out outline details of start
+// int startLevel;
+// boolean startHidden;
+// int startOfOutlineGroupIdx = rows.findStartOfRowOutlineGroup( row );
+// if (startOfOutlineGroupIdx - 1 < 0 || getRow(startOfOutlineGroupIdx - 1) == null)
+// {
+// startLevel = 0;
+// startHidden = false;
+// }
+// else
+// {
+// startLevel = getRow( startOfOutlineGroupIdx - 1).getOutlineLevel();
+// startHidden = getRow( startOfOutlineGroupIdx - 1 ).getZeroHeight();
+// }
+//
+// if (endLevel > startLevel)
+// {
+// return endHidden;
+// }
+// else
+// {
+// return startHidden;
+// }
+// }
+
}
diff --git a/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java b/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java
index ae04d2f859..0f56afe255 100644
--- a/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java
+++ b/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*;
diff --git a/src/java/org/apache/poi/hssf/model/TextboxShape.java b/src/java/org/apache/poi/hssf/model/TextboxShape.java
index 18d42164e4..35e89c24df 100644
--- a/src/java/org/apache/poi/hssf/model/TextboxShape.java
+++ b/src/java/org/apache/poi/hssf/model/TextboxShape.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*;
diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java
index c3a9437fc7..9b0a18f362 100644
--- a/src/java/org/apache/poi/hssf/model/Workbook.java
+++ b/src/java/org/apache/poi/hssf/model/Workbook.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,13 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.model;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.SheetReferences;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.ddf.*;
@@ -55,7 +55,8 @@ import java.util.Locale;
* @version 1.0-pre
*/
-public class Workbook implements Model {
+public class Workbook implements Model
+{
private static final int DEBUG = POILogger.DEBUG;
// public static Workbook currentBook = null;
@@ -97,7 +98,7 @@ public class Workbook implements Model {
protected int numfonts = 0; // hold the number of font records
private short maxformatid = -1; // holds the max format id
private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used
- private DrawingManager drawingManager;
+ private DrawingManager drawingManager;
private static POILogger log = POILogFactory.getLogger(Workbook.class);
@@ -649,7 +650,7 @@ public class Workbook implements Model {
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "Returning SST for index=", new Integer(str),
- " String= ", retval);
+ " String= ", retval);
return retval;
}
@@ -674,30 +675,20 @@ public class Workbook implements Model {
*
* @return byte array containing the HSSF-only portions of the POIFS file.
*/
- // GJS: Not used by system
+ // GJS: Not used so why keep it.
// public byte [] serialize() {
// log.log(DEBUG, "Serializing Workbook!");
// byte[] retval = null;
//
-// // ArrayList bytes = new ArrayList(records.size());
+//// ArrayList bytes = new ArrayList(records.size());
// int arraysize = getSize();
// int pos = 0;
//
-// // for (int k = 0; k < records.size(); k++)
-// // {
-// // bytes.add((( Record ) records.get(k)).serialize());
-// // }
-// // for (int k = 0; k < bytes.size(); k++)
-// // {
-// // arraysize += (( byte [] ) bytes.get(k)).length;
-// // }
// retval = new byte[ arraysize ];
// for (int k = 0; k < records.size(); k++) {
//
-// // byte[] rec = (( byte [] ) bytes.get(k));
-// // System.arraycopy(rec, 0, retval, pos, rec.length);
// Record record = records.get(k);
-// // Let's skip RECALCID records, as they are only use for optimization
+//// Let's skip RECALCID records, as they are only use for optimization
// if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
// pos += record.serialize(pos, retval); // rec.length;
// }
@@ -724,7 +715,7 @@ public class Workbook implements Model {
int sstPos = 0;
for ( int k = 0; k < records.size(); k++ )
{
-
+
Record record = records.get( k );
// Let's skip RECALCID records, as they are only use for optimization
if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
@@ -766,7 +757,8 @@ public class Workbook implements Model {
}
}
return retval;
- }
+ }
+
/**
* creates the BOF record
* @see org.apache.poi.hssf.record.BOFRecord
@@ -2063,24 +2055,24 @@ public class Workbook implements Model {
*/
public PaletteRecord getCustomPalette()
{
- PaletteRecord palette;
+ PaletteRecord palette;
int palettePos = records.getPalettepos();
if (palettePos != -1) {
Record rec = records.get(palettePos);
if (rec instanceof PaletteRecord) {
- palette = (PaletteRecord) rec;
+ palette = (PaletteRecord) rec;
} else throw new RuntimeException("InternalError: Expected PaletteRecord but got a '"+rec+"'");
- }
- else
- {
- palette = createPalette();
+ }
+ else
+ {
+ palette = createPalette();
//Add the palette record after the bof which is always the first record
records.add(1, palette);
records.setPalettepos(1);
- }
- return palette;
+ }
+ return palette;
}
-
+
/**
* Creates a drawing group record. If it already exists then it's left
* alone.
@@ -2131,6 +2123,6 @@ public class Workbook implements Model {
{
return drawingManager;
}
-
+
}
diff --git a/src/java/org/apache/poi/hssf/model/WorkbookRecordList.java b/src/java/org/apache/poi/hssf/model/WorkbookRecordList.java
index a23be2821c..cf6d05cfea 100644
--- a/src/java/org/apache/poi/hssf/model/WorkbookRecordList.java
+++ b/src/java/org/apache/poi/hssf/model/WorkbookRecordList.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.model;
import java.util.ArrayList;
diff --git a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
index ab86b45915..b2701e3fc4 100644
--- a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
+++ b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
-
-
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordFactory;
@@ -36,6 +32,7 @@ import java.util.List;
* must be subclassed for maximum benefit.
*
* @author Glen Stampoultzis (glens at apache.org)
+ * @author Michael Zalewski (zalewski at optonline.net)
*/
public abstract class AbstractEscherHolderRecord
extends Record
@@ -122,13 +119,13 @@ public abstract class AbstractEscherHolderRecord
StringBuffer buffer = new StringBuffer();
final String nl = System.getProperty("line.separator");
- buffer.append("[" + getRecordName() + "]" + nl);
+ buffer.append('[' + getRecordName() + ']' + nl);
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{
EscherRecord r = (EscherRecord) iterator.next();
buffer.append(r.toString());
}
- buffer.append("[/" + getRecordName() + "]" + nl);
+ buffer.append("[/" + getRecordName() + ']' + nl);
return buffer.toString();
}
@@ -137,29 +134,49 @@ public abstract class AbstractEscherHolderRecord
public int serialize(int offset, byte[] data)
{
- if (escherRecords.size() == 0 && rawData != null)
+ LittleEndian.putShort( data, 0 + offset, getSid() );
+ LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
+ if ( escherRecords.size() == 0 && rawData != null )
{
- System.arraycopy( rawData, 0, data, offset, rawData.length);
- return rawData.length;
+ System.arraycopy( rawData, 0, data, offset + 4, rawData.length );
}
else
{
- collapseShapeInformation();
-
- LittleEndian.putShort(data, 0 + offset, getSid());
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
-
int pos = offset + 4;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{
EscherRecord r = (EscherRecord) iterator.next();
- pos += r.serialize(pos, data, new NullEscherSerializationListener() );
+ pos += r.serialize( pos, data, new NullEscherSerializationListener() );
}
-
- return getRecordSize();
}
+ return getRecordSize();
}
+// public int serialize(int offset, byte[] data)
+// {
+// if (escherRecords.size() == 0 && rawData != null)
+// {
+// System.arraycopy( rawData, 0, data, offset, rawData.length);
+// return rawData.length;
+// }
+// else
+// {
+// collapseShapeInformation();
+//
+// LittleEndian.putShort(data, 0 + offset, getSid());
+// LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+//
+// int pos = offset + 4;
+// for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
+// {
+// EscherRecord r = (EscherRecord) iterator.next();
+// pos += r.serialize(pos, data, new NullEscherSerializationListener() );
+// }
+//
+// return getRecordSize();
+// }
+// }
+
/**
* Size of record (including 4 byte header)
*/
@@ -167,12 +184,10 @@ public abstract class AbstractEscherHolderRecord
{
if (escherRecords.size() == 0 && rawData != null)
{
- return rawData.length;
+ return rawData.length + 4;
}
else
{
- collapseShapeInformation();
-
int size = 4;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{
@@ -183,10 +198,29 @@ public abstract class AbstractEscherHolderRecord
}
}
- private void collapseShapeInformation()
- {
-
- }
+//
+// /**
+// * Size of record (including 4 byte header)
+// */
+// public int getRecordSize()
+// {
+// if (escherRecords.size() == 0 && rawData != null)
+// {
+// return rawData.length;
+// }
+// else
+// {
+// collapseShapeInformation();
+//
+// int size = 4;
+// for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
+// {
+// EscherRecord r = (EscherRecord) iterator.next();
+// size += r.getRecordSize();
+// }
+// return size;
+// }
+// }
public abstract short getSid();
diff --git a/src/java/org/apache/poi/hssf/record/BOFRecord.java b/src/java/org/apache/poi/hssf/record/BOFRecord.java
index 6747b77ae0..ca925bf255 100644
--- a/src/java/org/apache/poi/hssf/record/BOFRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BOFRecord.java
@@ -137,7 +137,7 @@ public class BOFRecord
/**
* Version number - for BIFF8 should be 0x06
* @see #VERSION
- * @param version to be set
+ * @param short version to be set
*/
public void setVersion(short version)
@@ -153,7 +153,7 @@ public class BOFRecord
* @see #TYPE_CHART
* @see #TYPE_EXCEL_4_MACRO
* @see #TYPE_WORKSPACE_FILE
- * @param type to be set
+ * @param short type to be set
*/
public void setType(short type)
@@ -164,7 +164,7 @@ public class BOFRecord
/**
* build that wrote this file
* @see #BUILD
- * @param build number to set
+ * @param short build number to set
*/
public void setBuild(short build)
@@ -175,7 +175,7 @@ public class BOFRecord
/**
* Year of the build that wrote this file
* @see #BUILD_YEAR
- * @param year year to set
+ * @param short build year to set
*/
public void setBuildYear(short year)
@@ -186,7 +186,7 @@ public class BOFRecord
/**
* set the history bit mask (not very useful)
* @see #HISTORY_MASK
- * @param bitmask to set for the history
+ * @param int bitmask to set for the history
*/
public void setHistoryBitMask(int bitmask)
@@ -198,7 +198,7 @@ public class BOFRecord
* set the minimum version required to read this file
*
* @see #VERSION
- * @param version to set
+ * @param int version to set
*/
public void setRequiredVersion(int version)
diff --git a/src/java/org/apache/poi/hssf/record/BookBoolRecord.java b/src/java/org/apache/poi/hssf/record/BookBoolRecord.java
index 7ba166c1b7..5489beaa69 100644
--- a/src/java/org/apache/poi/hssf/record/BookBoolRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BookBoolRecord.java
@@ -82,7 +82,7 @@ public class BookBoolRecord
/**
* set the save ext links flag
*
- * @param flag (0/1 -off/on)
+ * @param short flag (0/1 -off/on)
*/
public void setSaveLinkValues(short flag)
diff --git a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
index 89a3e8dabb..ccc246da81 100644
--- a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
@@ -148,6 +148,7 @@ public class BoolErrRecord
throw new RuntimeException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value);
}
}
+
//public short getRow()
public int getRow()
{
diff --git a/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java b/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java
index 881ab375c2..d268cef370 100644
--- a/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
@@ -22,130 +20,121 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.*;
+
/**
* Record for the bottom margin.
* NOTE: This source was automatically generated.
+ *
* @author Shawn Laubach (slaubach at apache dot org)
*/
-
public class BottomMarginRecord
- extends Record implements Margin
+ extends Record implements Margin
{
- public final static short sid = 0x29;
- private double field_1_margin;
-
-
- public BottomMarginRecord()
- {
-
- }
-
- /**
- * Constructs a BottomMargin record and sets its fields appropriately.
- *
- * @param id id must be 0x29 or an exception
- * will be throw upon validation
- * @param size size the size of the data area of the record
- * @param data data of the record (should not contain sid/len)
- */
-
- public BottomMarginRecord(short id, short size, byte [] data)
- {
- super(id, size, data);
- }
-
- /**
- * Constructs a BottomMargin record and sets its fields appropriately.
- *
- * @param id id must be 0x29 or an exception
- * will be throw upon validation
- * @param size size the size of the data area of the record
- * @param data data of the record (should not contain sid/len)
- * @param offset of the record's data
- */
-
- public BottomMarginRecord(short id, short size, byte [] data, int offset)
- {
- super(id, size, data, offset);
- }
-
- /**
- * Checks the sid matches the expected side for this record
- *
- * @param id the expected sid.
- */
- protected void validateSid(short id)
- {
- if (id != sid)
- {
- throw new RecordFormatException("Not a BottomMargin record");
- }
- }
-
- protected void fillFields(byte [] data, short size, int offset)
- {
- field_1_margin = LittleEndian.getDouble(data, 0x0 + offset);
-
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[BottomMargin]\n");
-
- buffer.append(" .margin = ")
- .append(" (").append(getMargin()).append(" )\n");
-
- buffer.append("[/BottomMargin]\n");
- return buffer.toString();
- }
-
- public int serialize(int offset, byte[] data)
- {
- LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
-
- LittleEndian.putDouble(data, 4 + offset, field_1_margin);
-
- return getRecordSize();
- }
-
- /**
- * Size of record (exluding 4 byte header)
- */
- public int getRecordSize()
- {
- return 4 + 8;
- }
-
- public short getSid()
- {
- return this.sid;
- }
-
-
- /**
- * Get the margin field for the BottomMargin record.
- */
- public double getMargin()
- {
- return field_1_margin;
- }
-
- /**
- * Set the margin field for the BottomMargin record.
- */
- public void setMargin(double field_1_margin)
- {
- this.field_1_margin = field_1_margin;
- }
-
- public Object clone() {
- BottomMarginRecord rec = new BottomMarginRecord();
- rec.field_1_margin = this.field_1_margin;
- return rec;
- }
-
-
-}
+ public final static short sid = 0x29;
+ private double field_1_margin;
+
+ public BottomMarginRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a BottomMargin record and sets its fields appropriately.
+ *
+ * @param id id must be 0x29 or an exception
+ * will be throw upon validation
+ * @param size size the size of the data area of the record
+ * @param data data of the record (should not contain sid/len)
+ */
+ public BottomMarginRecord( short id, short size, byte[] data )
+ {
+ super( id, size, data );
+ }
+
+ /**
+ * Constructs a BottomMargin record and sets its fields appropriately.
+ *
+ * @param id id must be 0x29 or an exception
+ * will be throw upon validation
+ * @param size size the size of the data area of the record
+ * @param data data of the record (should not contain sid/len)
+ * @param offset of the record's data
+ */
+ public BottomMarginRecord( short id, short size, byte[] data, int offset )
+ {
+ super( id, size, data, offset );
+ }
+
+ /**
+ * Checks the sid matches the expected side for this record
+ *
+ * @param id the expected sid.
+ */
+ protected void validateSid( short id )
+ {
+ if ( id != sid )
+ {
+ throw new RecordFormatException( "Not a BottomMargin record" );
+ }
+ }
+
+ protected void fillFields( byte[] data, short size, int offset )
+ {
+ field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "[BottomMargin]\n" );
+ buffer.append( " .margin = " )
+ .append( " (" ).append( getMargin() ).append( " )\n" );
+ buffer.append( "[/BottomMargin]\n" );
+ return buffer.toString();
+ }
+
+ public int serialize( int offset, byte[] data )
+ {
+ LittleEndian.putShort( data, 0 + offset, sid );
+ LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
+ LittleEndian.putDouble( data, 4 + offset, field_1_margin );
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 8;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+ /**
+ * Get the margin field for the BottomMargin record.
+ */
+ public double getMargin()
+ {
+ return field_1_margin;
+ }
+
+ /**
+ * Set the margin field for the BottomMargin record.
+ */
+ public void setMargin( double field_1_margin )
+ {
+ this.field_1_margin = field_1_margin;
+ }
+
+ public Object clone()
+ {
+ BottomMarginRecord rec = new BottomMarginRecord();
+ rec.field_1_margin = this.field_1_margin;
+ return rec;
+ }
+
+} // END OF CLASS
diff --git a/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java b/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
index 72aa8dd04e..50d770323f 100644
--- a/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
@@ -158,7 +158,7 @@ public class BoundSheetRecord
/**
* Set the sheetname for this sheet. (this appears in the tabs at the bottom)
* @param sheetname the name of the sheet
- * @throws IllegalArgumentException if sheet name will cause excel to crash.
+ * @thows IllegalArgumentException if sheet name will cause excel to crash.
*/
public void setSheetname( String sheetname )
diff --git a/src/java/org/apache/poi/hssf/record/CodepageRecord.java b/src/java/org/apache/poi/hssf/record/CodepageRecord.java
index 4193c76717..34d362f5b7 100644
--- a/src/java/org/apache/poi/hssf/record/CodepageRecord.java
+++ b/src/java/org/apache/poi/hssf/record/CodepageRecord.java
@@ -65,7 +65,7 @@ public class CodepageRecord
* @param id id must be 0x42 or an exception will be throw upon validation
* @param size the size of the data area of the record
* @param data data of the record (should not contain sid/len)
- * @param offset of the record
+ * @param int offset of the record
*/
public CodepageRecord(short id, short size, byte [] data, int offset)
@@ -90,7 +90,7 @@ public class CodepageRecord
* set the codepage for this workbook
*
* @see #CODEPAGE
- * @param cp the codepage to set
+ * @param codepage - the codepage to set
*/
public void setCodepage(short cp)
diff --git a/src/java/org/apache/poi/hssf/record/CustomField.java b/src/java/org/apache/poi/hssf/record/CustomField.java
index 1630cbb8b1..8671628e6d 100644
--- a/src/java/org/apache/poi/hssf/record/CustomField.java
+++ b/src/java/org/apache/poi/hssf/record/CustomField.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
public interface CustomField
diff --git a/src/java/org/apache/poi/hssf/record/DBCellRecord.java b/src/java/org/apache/poi/hssf/record/DBCellRecord.java
index c464374121..af4fd1880d 100644
--- a/src/java/org/apache/poi/hssf/record/DBCellRecord.java
+++ b/src/java/org/apache/poi/hssf/record/DBCellRecord.java
@@ -21,18 +21,16 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian;
/**
- * Title: DBCell Record
- * Description: Used by Excel and other MS apps to quickly find rows in the sheets.<P>
+ * Title: DBCell Record (Currently read only. Not required.)
+ * Description: Used to find rows in blocks...TODO<P>
* REFERENCE: PG 299/440 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
- * @author Jason Height
* @version 2.0-pre
*/
public class DBCellRecord
extends Record
{
- public final static int BLOCK_SIZE = 32;
public final static short sid = 0xd7;
private int field_1_row_offset;
private short[] field_2_cell_offsets;
@@ -182,7 +180,7 @@ public class DBCellRecord
LittleEndian.putInt(data, 4 + offset, getRowOffset());
for (int k = 0; k < getNumCellOffsets(); k++)
{
- LittleEndian.putShort(data, 8 + 2*k + offset, getCellOffsetAt(k));
+ LittleEndian.putShort(data, 8 + k + offset, getCellOffsetAt(k));
}
return getRecordSize();
}
@@ -192,11 +190,6 @@ public class DBCellRecord
return 8 + (getNumCellOffsets() * 2);
}
- /** Returns the size of a DBCellRecord when it needs to reference a certain number of rows*/
- public static int getRecordSizeForRows(int rows) {
- return 8 + (rows * 2);
- }
-
public short getSid()
{
return this.sid;
diff --git a/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java b/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
index 7c99cc9410..d114666d49 100644
--- a/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
+++ b/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
public class DrawingGroupRecord extends AbstractEscherHolderRecord
diff --git a/src/java/org/apache/poi/hssf/record/DrawingRecord.java b/src/java/org/apache/poi/hssf/record/DrawingRecord.java
index 692f199923..c17588c833 100644
--- a/src/java/org/apache/poi/hssf/record/DrawingRecord.java
+++ b/src/java/org/apache/poi/hssf/record/DrawingRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
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;
diff --git a/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java b/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java
index 18d1ef5efd..e88910c5b1 100644
--- a/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java
+++ b/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
/**
diff --git a/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java b/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java
index c5c906f473..070be73579 100644
--- a/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java
+++ b/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
public class DrawingSelectionRecord extends AbstractEscherHolderRecord
diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java
index c7827aa598..e3f65d0bd8 100644
--- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
import org.apache.poi.ddf.*;
diff --git a/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java b/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java
index 9410e1c91f..16c43e4c6f 100644
--- a/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java
@@ -29,7 +29,6 @@ import org.apache.poi.util.LittleEndian;
* Extended SST table info subrecord<P>
* contains the elements of "info" in the SST's array field<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
- * @author Jason Height
* @version 2.0-pre
* @see org.apache.poi.hssf.record.ExtSSTRecord
*/
diff --git a/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java b/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
index 2859e40338..8bd9b23770 100644
--- a/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
@@ -30,7 +30,7 @@ import java.util.ArrayList;
* position relative to the start of the SST record.
* REFERENCE: PG 313 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
- * @author Jason Height
+ * @author Jason Height (jheight at apache dot org)
* @version 2.0-pre
* @see org.apache.poi.hssf.record.ExtSSTInfoSubRecord
*/
@@ -162,18 +162,16 @@ public class ExtSSTRecord
for (int k = 0; k < getNumInfoRecords(); k++)
{
- ExtSSTInfoSubRecord rec = getInfoRecordAt(k);
- int length = rec.serialize(pos + offset, data);
- pos += length;
+ ExtSSTInfoSubRecord rec = getInfoRecordAt(k);
+ pos += rec.serialize(pos + offset, data);
}
-
return pos;
}
/** Returns the size of this record */
public int getRecordSize()
{
- return 6+8*getNumInfoRecords();
+ return 6 + 8*getNumInfoRecords();
}
public static final int getNumberOfInfoRecsForStrings(int numStrings) {
diff --git a/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java b/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java
index cfee1a5e77..d1cc908543 100644
--- a/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java
@@ -604,8 +604,8 @@ public class ExtendedFormatRecord
* set whether or not to use the pattern in this XF instead of the parent XF.
* (foregrount/background)
*
- * @param pattern true if this XF has a different pattern value than its parent,
- * false otherwise.
+ * @param pattern- true if this XF has a different pattern value than its parent,
+ * false otherwise.
* @see #setIndentionOptions(short)
*/
@@ -620,8 +620,8 @@ public class ExtendedFormatRecord
* set whether or not to use the locking/hidden in this XF instead of the parent XF.
*
*
- * @param options true if this XF has a different locking or hidden value than its parent,
- * false otherwise.
+ * @param options- true if this XF has a different locking or hidden value than its parent,
+ * false otherwise.
* @see #setIndentionOptions(short)
*/
diff --git a/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java b/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java
index 214796f1b4..c79094d8e1 100644
--- a/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java
@@ -29,128 +29,132 @@ import java.util.ArrayList;
* @author Libin Roman (Vista Portal LDT. Developer)
* @version 1.0-pre
*/
-public class ExternSheetRecord extends Record
-{
- public final static short sid = 0x17;
- private short field_1_number_of_REF_sturcutres;
- private ArrayList field_2_REF_structures;
- public ExternSheetRecord()
- {
+public class ExternSheetRecord extends Record {
+ public final static short sid = 0x17;
+ private short field_1_number_of_REF_sturcutres;
+ private ArrayList field_2_REF_structures;
+
+ public ExternSheetRecord() {
field_2_REF_structures = new ArrayList();
}
-
+
/**
* Constructs a Extern Sheet record and sets its fields appropriately.
*
* @param id id must be 0x16 or an exception will be throw upon validation
* @param size the size of the data area of the record
- * @param data data of the record (should not contain sid/len) */
- public ExternSheetRecord( short id, short size, byte[] data )
- {
- super( id, size, data );
+ * @param data data of the record (should not contain sid/len)
+ */
+
+ public ExternSheetRecord(short id, short size, byte[] data) {
+ super(id, size, data);
}
-
+
/**
* Constructs a Extern Sheet record and sets its fields appropriately.
*
* @param id id must be 0x16 or an exception will be throw upon validation
* @param size the size of the data area of the record
* @param data data of the record (should not contain sid/len)
- * @param offset of the record's data */
- public ExternSheetRecord( short id, short size, byte[] data, int offset )
- {
- super( id, size, data, offset );
+ * @param offset of the record's data
+ */
+ public ExternSheetRecord(short id, short size, byte[] data, int offset) {
+ super(id, size, data, offset);
}
-
+
/**
* called by constructor, should throw runtime exception in the event of a
* record passed with a differing ID.
*
- * @param id alleged id for this record */
- protected void validateSid( short id )
- {
- if ( id != sid )
- {
- throw new RecordFormatException( "NOT An ExternSheet RECORD" );
+ * @param id alleged id for this record
+ */
+ protected void validateSid(short id) {
+ if (id != sid) {
+ throw new RecordFormatException("NOT An ExternSheet RECORD");
}
}
-
+
/**
* called by the constructor, should set class level fields. Should throw
* runtime exception for bad/icomplete data.
*
* @param data raw data
* @param size size of data
- * @param offset of the record's data (provided a big array of the file) */
- protected void fillFields( byte[] data, short size, int offset )
- {
- field_2_REF_structures = new ArrayList();
- field_1_number_of_REF_sturcutres = LittleEndian.getShort( data, 0 + offset );
+ * @param offset of the record's data (provided a big array of the file)
+ */
+ protected void fillFields(byte [] data, short size, int offset) {
+ field_2_REF_structures = new ArrayList();
+
+ field_1_number_of_REF_sturcutres = LittleEndian.getShort(data, 0 + offset);
+
int pos = 2 + offset;
- for ( int i = 0; i < field_1_number_of_REF_sturcutres; ++i )
- {
- ExternSheetSubRecord rec = new ExternSheetSubRecord( (short) 0, (short) 6, data, pos );
+ for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) {
+ ExternSheetSubRecord rec = new ExternSheetSubRecord((short)0, (short)6 , data , pos);
+
pos += 6;
- field_2_REF_structures.add( rec );
+
+ field_2_REF_structures.add( rec);
}
}
-
- /**
+
+ /**
* sets the number of the REF structors , that is in Excel file
- * @param numStruct number of REF structs */
- public void setNumOfREFStructures( short numStruct )
- {
+ * @param numStruct number of REF structs
+ */
+ public void setNumOfREFStructures(short numStruct) {
field_1_number_of_REF_sturcutres = numStruct;
}
-
- /**
+
+ /**
* return the number of the REF structors , that is in Excel file
- * @return number of REF structs */
- public short getNumOfREFStructures()
- {
+ * @return number of REF structs
+ */
+ public short getNumOfREFStructures() {
return field_1_number_of_REF_sturcutres;
}
-
- /**
+
+ /**
* adds REF struct (ExternSheetSubRecord)
- * @param rec REF struct */
- public void addREFRecord( ExternSheetSubRecord rec )
- {
- field_2_REF_structures.add( rec );
+ * @param rec REF struct
+ */
+ public void addREFRecord(ExternSheetSubRecord rec) {
+ field_2_REF_structures.add(rec);
}
-
+
/** returns the number of REF Records, which is in model
- * @return number of REF records */
- public int getNumOfREFRecords()
- {
+ * @return number of REF records
+ */
+ public int getNumOfREFRecords() {
return field_2_REF_structures.size();
}
-
+
/** returns the REF record (ExternSheetSubRecord)
* @param elem index to place
- * @return REF record */
- public ExternSheetSubRecord getREFRecordAt( int elem )
- {
- ExternSheetSubRecord result = (ExternSheetSubRecord) field_2_REF_structures.get( elem );
+ * @return REF record
+ */
+ public ExternSheetSubRecord getREFRecordAt(int elem) {
+ ExternSheetSubRecord result = ( ExternSheetSubRecord ) field_2_REF_structures.get(elem);
+
return result;
}
-
- public String toString()
- {
+
+ public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append( "[EXTERNSHEET]\n" );
- buffer.append( " numOfRefs = " ).append( getNumOfREFStructures() ).append( "\n" );
- for ( int k = 0; k < this.getNumOfREFRecords(); k++ )
- {
- buffer.append( "refrec #" ).append( k ).append( '\n' );
- buffer.append( getREFRecordAt( k ).toString() );
- buffer.append( "----refrec #" ).append( k ).append( '\n' );
+
+ buffer.append("[EXTERNSHEET]\n");
+ buffer.append(" numOfRefs = ").append(getNumOfREFStructures()).append("\n");
+ for (int k=0; k < this.getNumOfREFRecords(); k++) {
+ buffer.append("refrec #").append(k).append('\n');
+ buffer.append(getREFRecordAt(k).toString());
+ buffer.append("----refrec #").append(k).append('\n');
}
- buffer.append( "[/EXTERNSHEET]\n" );
+ buffer.append("[/EXTERNSHEET]\n");
+
+
return buffer.toString();
}
-
+
/**
* called by the class that is responsible for writing this sucker.
* Subclasses should implement this so that their data is passed back in a
@@ -158,31 +162,33 @@ public class ExternSheetRecord extends Record
*
* @param offset to begin writing at
* @param data byte array containing instance data
- * @return number of bytes written */
- public int serialize( int offset, byte[] data )
- {
- LittleEndian.putShort( data, 0 + offset, sid );
- LittleEndian.putShort( data, 2 + offset, (short) ( 2 + ( getNumOfREFRecords() * 6 ) ) );
- LittleEndian.putShort( data, 4 + offset, getNumOfREFStructures() );
- int pos = 6;
- for ( int k = 0; k < getNumOfREFRecords(); k++ )
- {
- ExternSheetSubRecord record = getREFRecordAt( k );
- System.arraycopy( record.serialize(), 0, data, pos + offset, 6 );
- pos += 6;
+ * @return number of bytes written
+ */
+ public int serialize(int offset, byte [] data) {
+ LittleEndian.putShort(data, 0 + offset, sid);
+ LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecords() *6)));
+
+ LittleEndian.putShort(data, 4 + offset, getNumOfREFStructures());
+
+ int pos = 6 ;
+
+ for (int k = 0; k < getNumOfREFRecords(); k++) {
+ ExternSheetSubRecord record = getREFRecordAt(k);
+ System.arraycopy(record.serialize(), 0, data, pos + offset, 6);
+
+ pos +=6;
}
return getRecordSize();
}
-
- public int getRecordSize()
- {
+
+ public int getRecordSize() {
return 4 + 2 + getNumOfREFRecords() * 6;
}
-
+
/**
- * return the non static version of the id for this record. */
- public short getSid()
- {
+ * return the non static version of the id for this record.
+ */
+ public short getSid() {
return this.sid;
}
}
diff --git a/src/java/org/apache/poi/hssf/record/FormulaRecord.java b/src/java/org/apache/poi/hssf/record/FormulaRecord.java
index 1ffa74f264..b47002c1af 100644
--- a/src/java/org/apache/poi/hssf/record/FormulaRecord.java
+++ b/src/java/org/apache/poi/hssf/record/FormulaRecord.java
@@ -306,14 +306,6 @@ public class FormulaRecord
}
/**
- * sets the stack with a list
- */
- public void setParsedExpression(List ptgs) {
- field_8_parsed_expr = new Stack();
- field_8_parsed_expr.addAll(ptgs);
- }
-
- /**
* called by constructor, should throw runtime exception in the event of a
* record passed with a differing ID.
*
diff --git a/src/java/org/apache/poi/hssf/record/IndexRecord.java b/src/java/org/apache/poi/hssf/record/IndexRecord.java
index c638642065..883c929e8d 100644
--- a/src/java/org/apache/poi/hssf/record/IndexRecord.java
+++ b/src/java/org/apache/poi/hssf/record/IndexRecord.java
@@ -185,13 +185,6 @@ public class IndexRecord
return 20 + (getNumDbcells() * 4);
}
- /** Returns the size of an INdexRecord when it needs to index the specified number of blocks
- *
- */
- public static int getRecordSizeForBlockCount(int blockCount) {
- return 20 + (4 * blockCount);
- }
-
public short getSid()
{
return this.sid;
diff --git a/src/java/org/apache/poi/hssf/record/LabelRecord.java b/src/java/org/apache/poi/hssf/record/LabelRecord.java
index 1e89928c89..a0d697aaf9 100644
--- a/src/java/org/apache/poi/hssf/record/LabelRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LabelRecord.java
@@ -114,15 +114,14 @@ public class LabelRecord
field_4_string_len = LittleEndian.getShort(data, 6 + offset);
field_5_unicode_flag = data[ 8 + offset ];
if (field_4_string_len > 0) {
- if (isUnCompressedUnicode())
- {
- field_6_value = StringUtil.getFromUnicodeLE(data, 9 + offset,
- field_4_string_len);
- }
- else
- {
- field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
- }
+ if (isUnCompressedUnicode()) {
+ field_6_value = StringUtil.getFromUnicodeLE(data, 9 + offset,
+ field_4_string_len);
+ }
+ else {
+ field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset,
+ getStringLength());
+ }
} else field_6_value = null;
}
diff --git a/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java b/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java
index 9d7d8375b2..68589ed833 100644
--- a/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,12 +13,9 @@
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.*;
/**
@@ -27,16 +23,12 @@ import org.apache.poi.util.*;
* NOTE: This source was automatically generated.
* @author Shawn Laubach (slaubach at apache dot org)
*/
+public class LeftMarginRecord extends Record implements Margin
+{
+ public final static short sid = 0x26;
+ private double field_1_margin;
-public class LeftMarginRecord
- extends Record implements Margin{
- public final static short sid = 0x26;
- private double field_1_margin;
-
- public LeftMarginRecord()
- {
-
- }
+ public LeftMarginRecord() { }
/**
* Constructs a LeftMargin record and sets its fields appropriately.
@@ -46,99 +38,85 @@ public class LeftMarginRecord
* @param size size the size of the data area of the record
* @param data data of the record (should not contain sid/len)
*/
-
- public LeftMarginRecord(short id, short size, byte [] data)
- {
- super(id, size, data);
- }
+ public LeftMarginRecord( short id, short size, byte[] data )
+ { super( id, size, data ); }
/**
* Constructs a LeftMargin record and sets its fields appropriately.
- *
* @param id id must be 0x26 or an exception
* will be throw upon validation
* @param size size the size of the data area of the record
* @param data data of the record (should not contain sid/len)
* @param offset of the record's data
*/
-
- public LeftMarginRecord(short id, short size, byte [] data, int offset)
- {
- super(id, size, data, offset);
- }
+ public LeftMarginRecord( short id, short size, byte[] data, int offset )
+ { super( id, size, data, offset ); }
/**
- * Checks the sid matches the expected side for this record
+ * Checks the sid matches the expected side for this record
*
* @param id the expected sid.
*/
-
- protected void validateSid(short id)
+ protected void validateSid( short id )
{
- if (id != sid)
+ if ( id != sid )
{
- throw new RecordFormatException("Not a LeftMargin record");
+ throw new RecordFormatException( "Not a LeftMargin record" );
}
}
- protected void fillFields(byte [] data, short size, int offset)
+ protected void fillFields( byte[] data, short size, int offset )
{
- field_1_margin = LittleEndian.getDouble(data, 0x0 + offset);
+ field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("[LeftMargin]\n");
- buffer.append(" .margin = ") .append(" (").append(getMargin()).append(" )\n");
- buffer.append("[/LeftMargin]\n");
+ buffer.append( "[LeftMargin]\n" );
+ buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
+ buffer.append( "[/LeftMargin]\n" );
return buffer.toString();
}
- public int serialize(int offset, byte[] data)
+ public int serialize( int offset, byte[] data )
{
- LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
- LittleEndian.putDouble(data, 4 + offset, field_1_margin);
+ LittleEndian.putShort( data, 0 + offset, sid );
+ LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
+ LittleEndian.putDouble( data, 4 + offset, field_1_margin );
return getRecordSize();
}
/**
* Size of record (exluding 4 byte header)
*/
-
- public int getRecordSize()
- {
- return 4 + 8;
+ public int getRecordSize() {
+ return 4 + 8;
}
- public short getSid()
- {
+ public short getSid() {
return this.sid;
}
/**
* Get the margin field for the LeftMargin record.
*/
-
- public double getMargin()
- {
+ public double getMargin() {
return field_1_margin;
}
/**
* Set the margin field for the LeftMargin record.
*/
-
- public void setMargin(double field_1_margin)
+ public void setMargin( double field_1_margin )
{
this.field_1_margin = field_1_margin;
}
- public Object clone() {
+ public Object clone()
+ {
LeftMarginRecord rec = new LeftMarginRecord();
rec.field_1_margin = this.field_1_margin;
return rec;
}
-
-}
+} // END OF CLASS \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/Margin.java b/src/java/org/apache/poi/hssf/record/Margin.java
index 887e220c62..304e4bffee 100644
--- a/src/java/org/apache/poi/hssf/record/Margin.java
+++ b/src/java/org/apache/poi/hssf/record/Margin.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,31 +13,25 @@
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.*;
-
/**
- * The margin interface is a parent used to define left, right, top and bottom margins. This allows much of the code to be generic when it comes to handling margins.
+ * The margin interface is a parent used to define left, right, top and bottom margins.
+ * This allows much of the code to be generic when it comes to handling margins.
* NOTE: This source wass automatically generated.
+ *
* @author Shawn Laubach (slaubach at apache dot org)
*/
-
-public interface Margin{
-
+public interface Margin
+{
/**
* Get the margin field for the Margin.
*/
-
public double getMargin();
/**
* Set the margin field for the Margin.
*/
-
- public void setMargin(double field_1_margin);
-
-}
+ public void setMargin( double field_1_margin );
+} // END OF CLASS \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java b/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
index dfed5c61b1..dc75dd88d9 100644
--- a/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
+++ b/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
@@ -24,19 +24,18 @@ import java.util.Iterator;
import org.apache.poi.util.LittleEndian;
/**
- * Title: Merged Cells Record<P>
+ * Title: Merged Cells Record
+ * <br>
* Description: Optional record defining a square area of cells to "merged" into
- * one cell. <P>
- * REFERENCE: NONE (UNDOCUMENTED PRESENTLY) <P>
+ * one cell. <br>
+ * REFERENCE: NONE (UNDOCUMENTED PRESENTLY) <br>
* @author Andrew C. Oliver (acoliver at apache dot org)
* @version 2.0-pre
*/
-
public class MergeCellsRecord
extends Record
{
public final static short sid = 0xe5;
- private short field_1_num_areas;
private ArrayList field_2_regions;
public MergeCellsRecord()
@@ -72,11 +71,11 @@ public class MergeCellsRecord
protected void fillFields(byte [] data, short size, int offset)
{
- field_1_num_areas = LittleEndian.getShort(data, 0 + offset);
- field_2_regions = new ArrayList(field_1_num_areas + 10);
+ short numAreas = LittleEndian.getShort(data, 0 + offset);
+ field_2_regions = new ArrayList(numAreas + 10);
int pos = 2;
- for (int k = 0; k < field_1_num_areas; k++)
+ for (int k = 0; k < numAreas; k++)
{
MergedRegion region =
new MergedRegion(LittleEndian
@@ -98,7 +97,9 @@ public class MergeCellsRecord
public short getNumAreas()
{
- return field_1_num_areas;
+ //if the array size is larger than a short (65536), the record can't hold that many merges anyway
+ if (field_2_regions == null) return 0;
+ return (short)field_2_regions.size();
}
/**
@@ -106,13 +107,14 @@ public class MergeCellsRecord
* it will be incremented automatically or decremented when an area is removed. If
* you are setting this to 0 then you are a terrible person. Just remove the record.
* (just kidding about you being a terrible person..hehe)
- *
+ * @deprecated We now link the size to the actual array of merged regions
+ * @see #getNumAreas()
* @param numareas number of areas
*/
public void setNumAreas(short numareas)
{
- field_1_num_areas = numareas;
+
}
/**
@@ -138,7 +140,6 @@ public class MergeCellsRecord
colto);
field_2_regions.add(region);
- field_1_num_areas++;
return field_2_regions.size() - 1;
}
@@ -150,7 +151,6 @@ public class MergeCellsRecord
public void removeAreaAt(int area)
{
field_2_regions.remove(area);
- field_1_num_areas--;
}
/**
@@ -209,9 +209,9 @@ public class MergeCellsRecord
retval.append("[MERGEDCELLS]").append("\n");
retval.append(" .sid =").append(sid).append("\n");
- retval.append(" .numregions =").append(field_1_num_areas)
+ retval.append(" .numregions =").append(getNumAreas())
.append("\n");
- for (int k = 0; k < field_1_num_areas; k++)
+ for (int k = 0; k < getNumAreas(); k++)
{
MergedRegion region = ( MergedRegion ) field_2_regions.get(k);
@@ -288,8 +288,7 @@ public class MergeCellsRecord
}
public Object clone() {
- MergeCellsRecord rec = new MergeCellsRecord();
- rec.field_1_num_areas = field_1_num_areas;
+ MergeCellsRecord rec = new MergeCellsRecord();
rec.field_2_regions = new ArrayList();
Iterator iterator = field_2_regions.iterator();
while (iterator.hasNext()) {
diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java
index 5494362aec..a1b9adf437 100644
--- a/src/java/org/apache/poi/hssf/record/NameRecord.java
+++ b/src/java/org/apache/poi/hssf/record/NameRecord.java
@@ -924,7 +924,8 @@ public class NameRecord extends Record {
.append("\n");
buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text )
.append("\n");
- buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0));
+ if (field_13_raw_name_definition != null)
+ buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0));
buffer.append("[/NAME]\n");
return buffer.toString();
diff --git a/src/java/org/apache/poi/hssf/record/PaletteRecord.java b/src/java/org/apache/poi/hssf/record/PaletteRecord.java
index 61f1a0a743..6d646359f3 100644
--- a/src/java/org/apache/poi/hssf/record/PaletteRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PaletteRecord.java
@@ -168,8 +168,8 @@ public class PaletteRecord
* If the given index is greater than the current last color index,
* then black is inserted at every index required to make the palette continuous.
*
- * @param byteIndex the index to set; if this index is less than 0x8 or
- * greater than 0x40, then no modification is made
+ * @param i the index to set; if this index is less than 0x8 or greater than
+ * 0x40, then no modification is made
*/
public void setColor(short byteIndex, byte red, byte green, byte blue)
{
diff --git a/src/java/org/apache/poi/hssf/record/RecordFactory.java b/src/java/org/apache/poi/hssf/record/RecordFactory.java
index 888d5b5932..e02e24468c 100644
--- a/src/java/org/apache/poi/hssf/record/RecordFactory.java
+++ b/src/java/org/apache/poi/hssf/record/RecordFactory.java
@@ -18,14 +18,12 @@
package org.apache.poi.hssf.record;
-import java.io.InputStream;
-import java.io.IOException;
-
-import java.util.*;
+import org.apache.poi.util.LittleEndian;
+import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Constructor;
-
-import org.apache.poi.util.LittleEndian;
+import java.util.*;
/**
* Title: Record Factory<P>
@@ -75,9 +73,9 @@ public class RecordFactory
FormulaRecord.class, BoolErrRecord.class, ExternSheetRecord.class,
NameRecord.class, LeftMarginRecord.class, RightMarginRecord.class,
TopMarginRecord.class, BottomMarginRecord.class,
- PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
DrawingRecord.class, DrawingGroupRecord.class, DrawingSelectionRecord.class,
ObjRecord.class, TextObjectRecord.class,
+ PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class
};
} else {
@@ -329,6 +327,7 @@ public class RecordFactory
}
catch (Exception illegalArgumentException)
{
+ illegalArgumentException.printStackTrace();
throw new RecordFormatException(
"Unable to determine record types");
}
diff --git a/src/java/org/apache/poi/hssf/record/RightMarginRecord.java b/src/java/org/apache/poi/hssf/record/RightMarginRecord.java
index d47ac523ca..a44f7d4db7 100644
--- a/src/java/org/apache/poi/hssf/record/RightMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RightMarginRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
@@ -22,123 +20,82 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.*;
/**
- * Record for the right margin.
- * NOTE: This source was automatically generated.
- * @author Shawn Laubach (slaubach at apache dot org)
+ * Record for the right margin. * NOTE: This source was automatically generated. * @author Shawn Laubach (slaubach at apache dot org)
*/
+public class RightMarginRecord extends Record implements Margin
+{
+ public final static short sid = 0x27;
+ private double field_1_margin;
-
-public class RightMarginRecord
- extends Record implements Margin{
- public final static short sid = 0x27;
- private double field_1_margin;
-
- public RightMarginRecord()
- {
-
- }
+ public RightMarginRecord() { }
/**
- * Constructs a RightMargin record and sets its fields appropriately.
- *
- * @param id id must be 0x27 or an exception
- * will be throw upon validation
- * @param size size the size of the data area of the record
- * @param data data of the record (should not contain sid/len)
+ * Constructs a RightMargin record and sets its fields appropriately. * * @param id id must be 0x27 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len)
*/
-
- public RightMarginRecord(short id, short size, byte [] data)
- {
- super(id, size, data);
- }
+ public RightMarginRecord( short id, short size, byte[] data )
+ { super( id, size, data ); }
/**
- * Constructs a RightMargin record and sets its fields appropriately.
- *
- * @param id id must be 0x27 or an exception
- * will be throw upon validation
- * @param size size the size of the data area of the record
- * @param data data of the record (should not contain sid/len)
- * @param offset of the record's data
+ * Constructs a RightMargin record and sets its fields appropriately. * * @param id id must be 0x27 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len) * @param offset of the record's data
*/
-
- public RightMarginRecord(short id, short size, byte [] data, int offset)
- {
- super(id, size, data, offset);
- }
+ public RightMarginRecord( short id, short size, byte[] data, int offset )
+ { super( id, size, data, offset ); }
/**
- * Checks the sid matches the expected side for this record
- *
- * @param id the expected sid.
+ * Checks the sid matches the expected side for this record * * @param id the expected sid.
*/
-
- protected void validateSid(short id)
+ protected void validateSid( short id )
{
- if (id != sid)
+ if ( id != sid )
{
- throw new RecordFormatException("Not a RightMargin record");
+ throw new RecordFormatException( "Not a RightMargin record" );
}
}
- protected void fillFields(byte [] data, short size, int offset)
+ protected void fillFields( byte[] data, short size, int offset )
{
- field_1_margin = LittleEndian.getDouble(data, 0x0 + offset);
+ field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("[RightMargin]\n");
- buffer.append(" .margin = ") .append(" (").append(getMargin()).append(" )\n");
- buffer.append("[/RightMargin]\n");
+ buffer.append( "[RightMargin]\n" );
+ buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
+ buffer.append( "[/RightMargin]\n" );
return buffer.toString();
}
- public int serialize(int offset, byte[] data)
+ public int serialize( int offset, byte[] data )
{
- LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
- LittleEndian.putDouble(data, 4 + offset, field_1_margin);
+ LittleEndian.putShort( data, 0 + offset, sid );
+ LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
+ LittleEndian.putDouble( data, 4 + offset, field_1_margin );
return getRecordSize();
}
/**
* Size of record (exluding 4 byte header)
*/
+ public int getRecordSize() { return 4 + 8; }
- public int getRecordSize()
- {
- return 4 + 8;
- }
-
- public short getSid()
- {
- return this.sid;
- }
+ public short getSid() { return this.sid; }
/**
* Get the margin field for the RightMargin record.
*/
-
- public double getMargin()
- {
- return field_1_margin;
- }
+ public double getMargin() { return field_1_margin; }
/**
* Set the margin field for the RightMargin record.
*/
+ public void setMargin( double field_1_margin )
+ { this.field_1_margin = field_1_margin; }
- public void setMargin(double field_1_margin)
+ public Object clone()
{
- this.field_1_margin = field_1_margin;
- }
-
- public Object clone() {
RightMarginRecord rec = new RightMarginRecord();
rec.field_1_margin = this.field_1_margin;
return rec;
}
-
-}
+} // END OF CLASS \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/SSTDeserializer.java b/src/java/org/apache/poi/hssf/record/SSTDeserializer.java
index c79e43c40f..c8ddb7e8fe 100644
--- a/src/java/org/apache/poi/hssf/record/SSTDeserializer.java
+++ b/src/java/org/apache/poi/hssf/record/SSTDeserializer.java
@@ -110,7 +110,7 @@ class SSTDeserializer
//Since all of the characters will have been read, but the entire string (including formatting runs etc)
//hasnt, Compute the number of bytes to skip when the continue record starts
continueSkipBytes = offsetForContinuedRecord(0) - (remainingBytes - calculateByteCount(charsRead));
- }
+ }
}
processString( data, offset, charsRead );
offset += totalStringSize();
@@ -223,6 +223,7 @@ class SSTDeserializer
*/
static public void addToStringTable( BinaryTree strings, Integer integer, UnicodeString string )
{
+
if ( string.isRichText() )
string.setOptionFlags( (byte) ( string.getOptionFlags() & ( ~8 ) ) );
if ( string.isExtendedText() )
diff --git a/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java b/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
index 711f87d256..464e307c98 100755
--- a/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
@@ -33,7 +33,7 @@ import org.apache.poi.util.LittleEndian;
*/
public class SharedFormulaRecord
- extends Record
+ extends Record
{
public final static short sid = 0x4BC;
private short size = 0;
diff --git a/src/java/org/apache/poi/hssf/record/StringRecord.java b/src/java/org/apache/poi/hssf/record/StringRecord.java
index 9620ecd142..f920d1ed35 100644
--- a/src/java/org/apache/poi/hssf/record/StringRecord.java
+++ b/src/java/org/apache/poi/hssf/record/StringRecord.java
@@ -18,9 +18,8 @@
package org.apache.poi.hssf.record;
-import org.apache.poi.util.*;
-
-import java.io.IOException;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.StringUtil;
/**
* Supports the STRING record structure.
@@ -102,6 +101,11 @@ public class StringRecord
}
}
+ public boolean isInValueSection()
+ {
+ return true;
+ }
+
private int getStringLength()
{
return field_1_string_length;
@@ -129,12 +133,6 @@ public class StringRecord
return (field_2_unicode_flag == 1);
}
- public boolean isInValueSection()
- {
- return true;
- }
-
-
/**
* called by the class that is responsible for writing this sucker.
* Subclasses should implement this so that their data is passed back in a
@@ -207,7 +205,7 @@ public class StringRecord
buffer.append("[/STRING]\n");
return buffer.toString();
}
-
+
public Object clone() {
StringRecord rec = new StringRecord();
rec.field_1_string_length = this.field_1_string_length;
diff --git a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
index eae4362cae..9a29284d23 100644
--- a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
diff --git a/src/java/org/apache/poi/hssf/record/TopMarginRecord.java b/src/java/org/apache/poi/hssf/record/TopMarginRecord.java
index 749e358a16..1bf8efd1ac 100644
--- a/src/java/org/apache/poi/hssf/record/TopMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TopMarginRecord.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,46 +13,34 @@
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.*;
/**
* Record for the top margin.
* NOTE: This source was automatically generated.
+ *
* @author Shawn Laubach (slaubach at apache dot org)
*/
-
-public class TopMarginRecord
- extends Record implements Margin
+public class TopMarginRecord extends Record implements Margin
{
- public final static short sid = 0x28;
- private double field_1_margin;
-
-
- public TopMarginRecord()
- {
+ public final static short sid = 0x28;
+ private double field_1_margin;
- }
+ public TopMarginRecord() { }
/**
* Constructs a TopMargin record and sets its fields appropriately.
*
* @param id id must be 0x28 or an exception
- * will be throw upon validation
+ * will be throw upon validation
* @param size size the size of the data area of the record
* @param data data of the record (should not contain sid/len)
*/
-
- public TopMarginRecord(short id, short size, byte [] data)
- {
- super(id, size, data);
- }
+ public TopMarginRecord( short id, short size, byte[] data )
+ { super( id, size, data ); }
/**
* Constructs a TopMargin record and sets its fields appropriately.
@@ -64,85 +51,66 @@ public class TopMarginRecord
* @param data data of the record (should not contain sid/len)
* @param offset of the record's data
*/
-
- public TopMarginRecord(short id, short size, byte [] data, int offset)
- {
- super(id, size, data, offset);
- }
+ public TopMarginRecord( short id, short size, byte[] data, int offset )
+ { super( id, size, data, offset ); }
/**
* Checks the sid matches the expected side for this record
*
* @param id the expected sid.
*/
-
- protected void validateSid(short id)
+ protected void validateSid( short id )
{
- if (id != sid)
+ if ( id != sid )
{
- throw new RecordFormatException("Not a TopMargin record");
+ throw new RecordFormatException( "Not a TopMargin record" );
}
}
- protected void fillFields(byte [] data, short size, int offset)
+ protected void fillFields( byte[] data, short size, int offset )
{
- field_1_margin = LittleEndian.getDouble(data, 0x0 + offset);
+ field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("[TopMargin]\n");
- buffer.append(" .margin = ")
- .append(" (").append(getMargin()).append(" )\n");
- buffer.append("[/TopMargin]\n");
+ buffer.append( "[TopMargin]\n" );
+ buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
+ buffer.append( "[/TopMargin]\n" );
return buffer.toString();
}
- public int serialize(int offset, byte[] data)
+ public int serialize( int offset, byte[] data )
{
- LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
- LittleEndian.putDouble(data, 4 + offset, field_1_margin);
+ LittleEndian.putShort( data, 0 + offset, sid );
+ LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
+ LittleEndian.putDouble( data, 4 + offset, field_1_margin );
return getRecordSize();
}
/**
* Size of record (exluding 4 byte header)
*/
+ public int getRecordSize() { return 4 + 8; }
- public int getRecordSize()
- {
- return 4 + 8;
- }
-
- public short getSid()
- {
- return this.sid;
- }
+ public short getSid() { return this.sid; }
/**
* Get the margin field for the TopMargin record.
*/
-
- public double getMargin()
- {
- return field_1_margin;
- }
+ public double getMargin() { return field_1_margin; }
/**
* Set the margin field for the TopMargin record.
*/
+ public void setMargin( double field_1_margin )
+ { this.field_1_margin = field_1_margin; }
- public void setMargin(double field_1_margin)
+ public Object clone()
{
- this.field_1_margin = field_1_margin;
- }
-
- public Object clone() {
TopMarginRecord rec = new TopMarginRecord();
rec.field_1_margin = this.field_1_margin;
return rec;
}
-
-}
+} // END OF CLASS \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/UnicodeString.java b/src/java/org/apache/poi/hssf/record/UnicodeString.java
index 6e8dec474d..0f2f85d13f 100644
--- a/src/java/org/apache/poi/hssf/record/UnicodeString.java
+++ b/src/java/org/apache/poi/hssf/record/UnicodeString.java
@@ -18,11 +18,11 @@
package org.apache.poi.hssf.record;
-import java.io.UnsupportedEncodingException;
-
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
+import java.io.UnsupportedEncodingException;
+
/**
* Title: Unicode String<P>
* Description: Unicode String record. We implement these as a record, although
@@ -283,12 +283,10 @@ public class UnicodeString
// System.out.println("Unicode: We've got "+retval[2]+" for our option flag");
try {
- String unicodeString = new
-String(getString().getBytes("Unicode"),"Unicode");
+ String unicodeString = new String(getString().getBytes("Unicode"),"Unicode");
if (getOptionFlags() == 0)
{
- StringUtil.putCompressedUnicode(unicodeString, data, 0x3 +
-offset);
+ StringUtil.putCompressedUnicode(unicodeString, data, 0x3 +offset);
}
else
{
diff --git a/src/java/org/apache/poi/hssf/record/UnknownRecord.java b/src/java/org/apache/poi/hssf/record/UnknownRecord.java
index b761431f9b..d189b64c3e 100644
--- a/src/java/org/apache/poi/hssf/record/UnknownRecord.java
+++ b/src/java/org/apache/poi/hssf/record/UnknownRecord.java
@@ -28,16 +28,14 @@ import org.apache.poi.util.LittleEndian;
* Company: SuperLink Software, Inc.<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
- * @version 2.0-pre
+ * @author Glen Stampoultzis (glens at apache.org)
*/
public class UnknownRecord
extends Record
{
- private short sid = 0;
- private short size = 0;
- private byte[] thedata = null;
- int offset = 0;
+ private short sid = 0;
+ private byte[] thedata = null;
public UnknownRecord()
{
@@ -53,9 +51,8 @@ public class UnknownRecord
public UnknownRecord(short id, short size, byte [] data)
{
- this.sid = id;
- this.size = size;
- this.thedata = data;
+ sid = id;
+ thedata = data;
}
public UnknownRecord( short id, short size, byte[] data, int offset )
@@ -63,12 +60,11 @@ public class UnknownRecord
sid = id;
thedata = new byte[size];
System.arraycopy(data, offset, thedata, 0, size);
- }
+ }
/**
- * spit the record out AS IS. no interperatation or identification
+ * spit the record out AS IS. no interpretation or identification
*/
-
public int serialize(int offset, byte [] data)
{
if (thedata == null)
@@ -98,7 +94,7 @@ public class UnknownRecord
protected void fillFields(byte [] data, short sid)
{
this.sid = sid;
- this.thedata = data;
+ thedata = data;
}
/**
@@ -149,9 +145,7 @@ public class UnknownRecord
/** Unlike the other Record.clone methods this is a shallow clone*/
public Object clone() {
UnknownRecord rec = new UnknownRecord();
- rec.offset = offset;
rec.sid = sid;
- rec.size = size;
rec.thedata = thedata;
return rec;
}
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
new file mode 100644
index 0000000000..6eb9b111da
--- /dev/null
+++ b/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
@@ -0,0 +1,509 @@
+package org.apache.poi.hssf.record.aggregates;
+
+import org.apache.poi.hssf.record.ColumnInfoRecord;
+import org.apache.poi.hssf.record.Record;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Glen Stampoultzis
+ * @version $Id$
+ */
+public class ColumnInfoRecordsAggregate
+ extends Record
+{
+ int size = 0;
+ List records = null;
+
+ public ColumnInfoRecordsAggregate()
+ {
+ records = new ArrayList();
+ }
+
+ /** You never fill an aggregate */
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ }
+
+ /** Not required by an aggregate */
+ protected void validateSid(short id)
+ {
+ }
+
+ /** It's an aggregate... just made something up */
+ public short getSid()
+ {
+ return -1012;
+ }
+
+ public int getRecordSize()
+ {
+ return size;
+ }
+
+ public Iterator getIterator()
+ {
+ return records.iterator();
+ }
+
+ /**
+ * Performs a deep clone of the record
+ */
+ public Object clone()
+ {
+ ColumnInfoRecordsAggregate rec = new ColumnInfoRecordsAggregate();
+ for ( Iterator colIter = getIterator(); colIter.hasNext(); )
+ {
+ //return the cloned Row Record & insert
+ ColumnInfoRecord col = (ColumnInfoRecord) ( (ColumnInfoRecord) colIter.next() ).clone();
+ rec.insertColumn( col );
+ }
+ return rec;
+ }
+
+ /**
+ * Inserts a column into the aggregate (at the end of the list).
+ */
+ public void insertColumn( ColumnInfoRecord col )
+ {
+ size += col.getRecordSize();
+ records.add( col );
+ }
+
+ /**
+ * Inserts a column into the aggregate (at the position specified
+ * by <code>idx</code>.
+ */
+ public void insertColumn( int idx, ColumnInfoRecord col )
+ {
+ size += col.getRecordSize();
+ records.add( idx, col );
+ }
+
+ public int getNumColumns( )
+ {
+ return records.size();
+ }
+
+ /**
+ * called by the class that is responsible for writing this sucker.
+ * Subclasses should implement this so that their data is passed back in a
+ * byte array.
+ *
+ * @param offset offset to begin writing at
+ * @param data byte array containing instance data
+ * @return number of bytes written
+ */
+ public int serialize(int offset, byte [] data)
+ {
+ Iterator itr = records.iterator();
+ int pos = offset;
+
+ while (itr.hasNext())
+ {
+ pos += (( Record ) itr.next()).serialize(pos, data);
+ }
+ return pos - offset;
+ }
+
+ public int findStartOfColumnOutlineGroup(int idx)
+ {
+ // Find the start of the group.
+ ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get( idx );
+ int level = columnInfo.getOutlineLevel();
+ while (idx != 0)
+ {
+ ColumnInfoRecord prevColumnInfo = (ColumnInfoRecord) records.get( idx - 1 );
+ if (columnInfo.getFirstColumn() - 1 == prevColumnInfo.getLastColumn())
+ {
+ if (prevColumnInfo.getOutlineLevel() < level)
+ {
+ break;
+ }
+ idx--;
+ columnInfo = prevColumnInfo;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return idx;
+ }
+
+ public int findEndOfColumnOutlineGroup(int idx)
+ {
+ // Find the end of the group.
+ ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get( idx );
+ int level = columnInfo.getOutlineLevel();
+ while (idx < records.size() - 1)
+ {
+ ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) records.get( idx + 1 );
+ if (columnInfo.getLastColumn() + 1 == nextColumnInfo.getFirstColumn())
+ {
+ if (nextColumnInfo.getOutlineLevel() < level)
+ {
+ break;
+ }
+ idx++;
+ columnInfo = nextColumnInfo;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return idx;
+ }
+
+ public ColumnInfoRecord getColInfo(int idx)
+ {
+ return (ColumnInfoRecord) records.get( idx );
+ }
+
+ public ColumnInfoRecord writeHidden( ColumnInfoRecord columnInfo, int idx, boolean hidden )
+ {
+ int level = columnInfo.getOutlineLevel();
+ while (idx < records.size())
+ {
+ columnInfo.setHidden( hidden );
+ if (idx + 1 < records.size())
+ {
+ ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) records.get( idx + 1 );
+ if (columnInfo.getLastColumn() + 1 == nextColumnInfo.getFirstColumn())
+ {
+ if (nextColumnInfo.getOutlineLevel() < level)
+ break;
+ columnInfo = nextColumnInfo;
+ }
+ else
+ {
+ break;
+ }
+ }
+ idx++;
+ }
+ return columnInfo;
+ }
+
+ public boolean isColumnGroupCollapsed( int idx )
+ {
+ int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup( idx );
+ if (endOfOutlineGroupIdx >= records.size())
+ return false;
+ if (getColInfo(endOfOutlineGroupIdx).getLastColumn() + 1 != getColInfo(endOfOutlineGroupIdx + 1).getFirstColumn())
+ return false;
+ else
+ return getColInfo(endOfOutlineGroupIdx+1).getCollapsed();
+ }
+
+
+ public boolean isColumnGroupHiddenByParent( int idx )
+ {
+ // Look out outline details of end
+ int endLevel;
+ boolean endHidden;
+ int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup( idx );
+ if (endOfOutlineGroupIdx >= records.size())
+ {
+ endLevel = 0;
+ endHidden = false;
+ }
+ else if (getColInfo(endOfOutlineGroupIdx).getLastColumn() + 1 != getColInfo(endOfOutlineGroupIdx + 1).getFirstColumn())
+ {
+ endLevel = 0;
+ endHidden = false;
+ }
+ else
+ {
+ endLevel = getColInfo( endOfOutlineGroupIdx + 1).getOutlineLevel();
+ endHidden = getColInfo( endOfOutlineGroupIdx + 1).getHidden();
+ }
+
+ // Look out outline details of start
+ int startLevel;
+ boolean startHidden;
+ int startOfOutlineGroupIdx = findStartOfColumnOutlineGroup( idx );
+ if (startOfOutlineGroupIdx <= 0)
+ {
+ startLevel = 0;
+ startHidden = false;
+ }
+ else if (getColInfo(startOfOutlineGroupIdx).getFirstColumn() - 1 != getColInfo(startOfOutlineGroupIdx - 1).getLastColumn())
+ {
+ startLevel = 0;
+ startHidden = false;
+ }
+ else
+ {
+ startLevel = getColInfo( startOfOutlineGroupIdx - 1).getOutlineLevel();
+ startHidden = getColInfo( startOfOutlineGroupIdx - 1 ).getHidden();
+ }
+
+ if (endLevel > startLevel)
+ {
+ return endHidden;
+ }
+ else
+ {
+ return startHidden;
+ }
+ }
+
+ public void collapseColumn( short columnNumber )
+ {
+ int idx = findColumnIdx( columnNumber, 0 );
+ if (idx == -1)
+ return;
+
+ // Find the start of the group.
+ ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get( findStartOfColumnOutlineGroup( idx ) );
+
+ // Hide all the columns until the end of the group
+ columnInfo = writeHidden( columnInfo, idx, true );
+
+ // Write collapse field
+ setColumn( (short) ( columnInfo.getLastColumn() + 1 ), null, null, null, Boolean.TRUE);
+ }
+
+ public void expandColumn( short columnNumber )
+ {
+ int idx = findColumnIdx( columnNumber, 0 );
+ if (idx == -1)
+ return;
+
+ // If it is already exapanded do nothing.
+ if (!isColumnGroupCollapsed(idx))
+ return;
+
+ // Find the start of the group.
+ int startIdx = findStartOfColumnOutlineGroup( idx );
+ ColumnInfoRecord columnInfo = getColInfo( startIdx );
+
+ // Find the end of the group.
+ int endIdx = findEndOfColumnOutlineGroup( idx );
+ ColumnInfoRecord endColumnInfo = getColInfo( endIdx );
+
+ // expand:
+ // colapsed bit must be unset
+ // hidden bit gets unset _if_ surrounding groups are expanded you can determine
+ // this by looking at the hidden bit of the enclosing group. You will have
+ // to look at the start and the end of the current group to determine which
+ // is the enclosing group
+ // hidden bit only is altered for this outline level. ie. don't uncollapse contained groups
+ if (!isColumnGroupHiddenByParent( idx ))
+ {
+ for (int i = startIdx; i <= endIdx; i++)
+ {
+ if (columnInfo.getOutlineLevel() == getColInfo(i).getOutlineLevel())
+ getColInfo(i).setHidden( false );
+ }
+ }
+
+ // Write collapse field
+ setColumn( (short) ( columnInfo.getLastColumn() + 1 ), null, null, null, Boolean.FALSE);
+ }
+
+ /**
+ * creates the ColumnInfo Record and sets it to a default column/width
+ * @see org.apache.poi.hssf.record.ColumnInfoRecord
+ * @return record containing a ColumnInfoRecord
+ */
+ public static Record createColInfo()
+ {
+ ColumnInfoRecord retval = new ColumnInfoRecord();
+
+ retval.setColumnWidth(( short ) 2275);
+ // was: retval.setOptions(( short ) 6);
+ retval.setOptions(( short ) 2);
+ retval.setXFIndex(( short ) 0x0f);
+ return retval;
+ }
+
+
+ public void setColumn(short column, Short width, Integer level, Boolean hidden, Boolean collapsed)
+ {
+ ColumnInfoRecord ci = null;
+ int k = 0;
+
+ for (k = 0; k < records.size(); k++)
+ {
+ ci = ( ColumnInfoRecord ) records.get(k);
+ if ((ci.getFirstColumn() <= column)
+ && (column <= ci.getLastColumn()))
+ {
+ break;
+ }
+ ci = null;
+ }
+
+ if (ci != null)
+ {
+ boolean widthChanged = width != null && ci.getColumnWidth() != width.shortValue();
+ boolean levelChanged = level != null && ci.getOutlineLevel() != level.intValue();
+ boolean hiddenChanged = hidden != null && ci.getHidden() != hidden.booleanValue();
+ boolean collapsedChanged = collapsed != null && ci.getCollapsed() != collapsed.booleanValue();
+ boolean columnChanged = widthChanged || levelChanged || hiddenChanged || collapsedChanged;
+ if (!columnChanged)
+ {
+ // do nothing...nothing changed.
+ }
+ else if ((ci.getFirstColumn() == column)
+ && (ci.getLastColumn() == column))
+ { // if its only for this cell then
+ setColumnInfoFields( ci, width, level, hidden, collapsed );
+ }
+ else if ((ci.getFirstColumn() == column)
+ || (ci.getLastColumn() == column))
+ {
+ // okay so the width is different but the first or last column == the column we'return setting
+ // we'll just divide the info and create a new one
+ if (ci.getFirstColumn() == column)
+ {
+ ci.setFirstColumn(( short ) (column + 1));
+ }
+ else
+ {
+ ci.setLastColumn(( short ) (column - 1));
+ }
+ ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
+
+ nci.setFirstColumn(column);
+ nci.setLastColumn(column);
+ nci.setOptions(ci.getOptions());
+ nci.setXFIndex(ci.getXFIndex());
+ setColumnInfoFields( nci, width, level, hidden, collapsed );
+
+ insertColumn(k, nci);
+ }
+ else
+ {
+ //split to 3 records
+ short lastcolumn = ci.getLastColumn();
+ ci.setLastColumn(( short ) (column - 1));
+
+ ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
+ nci.setFirstColumn(column);
+ nci.setLastColumn(column);
+ nci.setOptions(ci.getOptions());
+ nci.setXFIndex(ci.getXFIndex());
+ setColumnInfoFields( nci, width, level, hidden, collapsed );
+ insertColumn(++k, nci);
+
+ nci = ( ColumnInfoRecord ) createColInfo();
+ nci.setFirstColumn((short)(column+1));
+ nci.setLastColumn(lastcolumn);
+ nci.setOptions(ci.getOptions());
+ nci.setXFIndex(ci.getXFIndex());
+ nci.setColumnWidth(ci.getColumnWidth());
+ insertColumn(++k, nci);
+ }
+ }
+ else
+ {
+
+ // okay so there ISN'T a column info record that cover's this column so lets create one!
+ ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
+
+ nci.setFirstColumn(column);
+ nci.setLastColumn(column);
+ setColumnInfoFields( nci, width, level, hidden, collapsed );
+ insertColumn(k, nci);
+ }
+ }
+
+ /**
+ * Sets all non null fields into the <code>ci</code> parameter.
+ */
+ private void setColumnInfoFields( ColumnInfoRecord ci, Short width, Integer level, Boolean hidden, Boolean collapsed )
+ {
+ if (width != null)
+ ci.setColumnWidth(width.shortValue());
+ if (level != null)
+ ci.setOutlineLevel( level.shortValue() );
+ if (hidden != null)
+ ci.setHidden( hidden.booleanValue() );
+ if (collapsed != null)
+ ci.setCollapsed( collapsed.booleanValue() );
+ }
+
+ public int findColumnIdx(int column, int fromIdx)
+ {
+ if (column < 0)
+ throw new IllegalArgumentException( "column parameter out of range: " + column );
+ if (fromIdx < 0)
+ throw new IllegalArgumentException( "fromIdx parameter out of range: " + fromIdx );
+
+ ColumnInfoRecord ci;
+ for (int k = fromIdx; k < records.size(); k++)
+ {
+ ci = ( ColumnInfoRecord ) records.get(k);
+ if ((ci.getFirstColumn() <= column)
+ && (column <= ci.getLastColumn()))
+ {
+ return k;
+ }
+ ci = null;
+ }
+ return -1;
+ }
+
+ public void collapseColInfoRecords( int columnIdx )
+ {
+ if (columnIdx == 0)
+ return;
+ ColumnInfoRecord previousCol = (ColumnInfoRecord) records.get( columnIdx - 1);
+ ColumnInfoRecord currentCol = (ColumnInfoRecord) records.get( columnIdx );
+ boolean adjacentColumns = previousCol.getLastColumn() == currentCol.getFirstColumn() - 1;
+ if (!adjacentColumns)
+ return;
+
+ boolean columnsMatch =
+ previousCol.getXFIndex() == currentCol.getXFIndex() &&
+ previousCol.getOptions() == currentCol.getOptions() &&
+ previousCol.getColumnWidth() == currentCol.getColumnWidth();
+
+ if (columnsMatch)
+ {
+ previousCol.setLastColumn( currentCol.getLastColumn() );
+ records.remove( columnIdx );
+ }
+ }
+
+ /**
+ * Creates an outline group for the specified columns.
+ * @param fromColumn group from this column (inclusive)
+ * @param toColumn group to this column (inclusive)
+ * @param indent if true the group will be indented by one level,
+ * if false indenting will be removed by one level.
+ */
+ public void groupColumnRange(short fromColumn, short toColumn, boolean indent)
+ {
+
+ // Set the level for each column
+ int fromIdx = 0;
+ for (int i = fromColumn; i <= toColumn; i++)
+ {
+ int level = 1;
+ int columnIdx = findColumnIdx( i, Math.max(0,fromIdx) );
+ if (columnIdx != -1)
+ {
+ level = ((ColumnInfoRecord)records.get( columnIdx )).getOutlineLevel();
+ if (indent) level++; else level--;
+ level = Math.max(0, level);
+ level = Math.min(7, level);
+ fromIdx = columnIdx - 1; // subtract 1 just in case this column is collapsed later.
+ }
+ setColumn((short)i, null, new Integer(level), null, null);
+ columnIdx = findColumnIdx( i, Math.max(0, fromIdx ) );
+ collapseColInfoRecords( columnIdx );
+ }
+
+ }
+
+
+}
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
index f2e9d7bc85..508bf85727 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.aggregates;
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
index aa12ce872d..32f25b312d 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
@@ -14,19 +14,16 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.aggregates;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord;
-import org.apache.poi.hssf.record.DBCellRecord;
-import org.apache.poi.hssf.record.UnknownRecord;
+import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
-import java.util.Iterator;
-import java.util.List;
/**
*
@@ -39,17 +36,14 @@ public class RowRecordsAggregate
{
int firstrow = -1;
int lastrow = -1;
- boolean firstdirty = false;
- boolean lastdirty = false;
Map records = null;
int size = 0;
- /** Creates a new instance of RowRecordsAggregate */
+ /** Creates a new instance of ValueRecordsAggregate */
public RowRecordsAggregate()
{
records = new TreeMap();
-
}
public void insertRow(RowRecord row)
@@ -73,12 +67,6 @@ public class RowRecordsAggregate
size -= row.getRecordSize();
// Integer integer = new Integer(row.getRowNumber());
- if (lastrow == row.getRowNumber()) {
- lastdirty = true;
- }
- if (firstrow == row.getRowNumber()) {
- firstdirty = true;
- }
records.remove(row);
}
@@ -99,20 +87,17 @@ public class RowRecordsAggregate
public int getFirstRowNum()
{
- if (firstdirty) {
- firstrow = findFirstRow();
- }
return firstrow;
}
public int getLastRowNum()
{
- if (lastdirty) {
- lastrow = findLastRow();
- }
return lastrow;
}
+ /*
+ * No need to go through all the records as we're just collecting RowRecords
+
public int construct(int offset, List records)
{
int k = 0;
@@ -132,86 +117,7 @@ public class RowRecordsAggregate
}
return k;
}
-
- /** Returns the number of row blocks.
- * <p/>The row blocks are goupings of rows that contain the DBCell record
- * after them
- */
- public int getRowBlockCount() {
- int size = records.size()/DBCellRecord.BLOCK_SIZE;
- if ((records.size() % DBCellRecord.BLOCK_SIZE) != 0)
- size++;
- return size;
- }
-
- public int getRowBlockSize(int block) {
- return 20 * getRowCountForBlock(block);
- }
-
- /** Returns the number of physical rows within a block*/
- public int getRowCountForBlock(int block) {
- int startIndex = block * DBCellRecord.BLOCK_SIZE;
- int endIndex = startIndex + DBCellRecord.BLOCK_SIZE - 1;
- if (endIndex >= records.size())
- endIndex = records.size()-1;
-
- return endIndex-startIndex+1;
- }
-
- /** Returns the physical row number of the first row in a block*/
- public int getStartRowNumberForBlock(int block) {
- //JMH Damn! I would like to directly index a record in the map rather than
- //iterating through it.
- int startIndex = block * DBCellRecord.BLOCK_SIZE;
- Iterator rowIter = records.values().iterator();
- RowRecord row = null;
- //Position the iterator at the start of the block
- for (int i=0; i<=startIndex;i++) {
- row = (RowRecord)rowIter.next();
- }
-
- return row.getRowNumber();
- }
-
- /** Returns the physical row number of the end row in a block*/
- public int getEndRowNumberForBlock(int block) {
- //JMH Damn! I would like to directly index a record in the map rather than
- //iterating through it.
- int endIndex = ((block + 1)*DBCellRecord.BLOCK_SIZE)-1;
- if (endIndex >= records.size())
- endIndex = records.size()-1;
-
- Iterator rowIter = records.values().iterator();
- RowRecord row = null;
- for (int i=0; i<=endIndex;i++) {
- row = (RowRecord)rowIter.next();
- }
- return row.getRowNumber();
- }
-
-
- /** Serializes a block of the rows */
- private int serializeRowBlock(final int block, final int offset, byte[] data) {
- final int startIndex = block*DBCellRecord.BLOCK_SIZE;
- final int endIndex = startIndex + DBCellRecord.BLOCK_SIZE;
-
- Iterator rowIterator = records.values().iterator();
- int pos = offset;
-
- //JMH TBD create an iterator that can start at a specific index.
- int i=0;
- for (;i<startIndex;i++)
- rowIterator.next();
- while(rowIterator.hasNext() && (i++ < endIndex)) {
- RowRecord row = (RowRecord)rowIterator.next();
- pos += row.serialize(pos, data);
- }
- return pos - offset;
- }
-
- public int serialize(int offset, byte [] data) {
- throw new RuntimeException("The serialize method that passes in cells should be used");
- }
+ */
/**
* called by the class that is responsible for writing this sucker.
@@ -223,38 +129,14 @@ public class RowRecordsAggregate
* @return number of bytes written
*/
- public int serialize(int offset, byte [] data, ValueRecordsAggregate cells)
+ public int serialize(int offset, byte [] data)
{
Iterator itr = records.values().iterator();
int pos = offset;
- //DBCells are serialized before row records.
- final int blockCount = getRowBlockCount();
- for (int block=0;block<blockCount;block++) {
- //Serialize a block of rows.
- //Hold onto the position of the first row in the block
- final int rowStartPos = pos;
- //Hold onto the size of this block that was serialized
- final int rowBlockSize = serializeRowBlock(block, pos, data);
- pos += rowBlockSize;
- //Serialize a block of cells for those rows
- final int startRowNumber = getStartRowNumberForBlock(block);
- final int endRowNumber = getEndRowNumberForBlock(block);
- DBCellRecord cellRecord = new DBCellRecord();
- //Note: Cell references start from the second row...
- int cellRefOffset = (rowBlockSize-20);
- for (int row=startRowNumber;row<=endRowNumber;row++) {
- if (cells.rowHasCells(row)) {
- final int rowCellSize = cells.serializeCellRow(row, pos, data);
- pos += rowCellSize;
- //Add the offset to the first cell for the row into the DBCellRecord.
- cellRecord.addCellOffset((short)cellRefOffset);
- cellRefOffset = rowCellSize;
- }
- }
- //Calculate Offset from the start of a DBCellRecord to the first Row
- cellRecord.setRowOffset(pos - rowStartPos);
- pos += cellRecord.serialize(pos, data);
+ while (itr.hasNext())
+ {
+ pos += (( Record ) itr.next()).serialize(pos, data);
}
return pos - offset;
}
@@ -301,52 +183,199 @@ public class RowRecordsAggregate
{
return records.values().iterator();
}
-
+
/**
- * used internally to refresh the "last row" when the last row is removed.
+ * Performs a deep clone of the record
*/
- private int findLastRow()
+ public Object clone()
+ {
+ RowRecordsAggregate rec = new RowRecordsAggregate();
+ for ( Iterator rowIter = getIterator(); rowIter.hasNext(); )
+ {
+ //return the cloned Row Record & insert
+ RowRecord row = (RowRecord) ( (RowRecord) rowIter.next() ).clone();
+ rec.insertRow( row );
+ }
+ return rec;
+ }
+
+
+ public int findStartOfRowOutlineGroup(int row)
+ {
+ // Find the start of the group.
+ RowRecord rowRecord = this.getRow( row );
+ int level = rowRecord.getOutlineLevel();
+ int currentRow = row;
+ while (this.getRow( currentRow ) != null)
+ {
+ rowRecord = this.getRow( currentRow );
+ if (rowRecord.getOutlineLevel() < level)
+ return currentRow + 1;
+ currentRow--;
+ }
+
+ return currentRow + 1;
+ }
+
+ public int findEndOfRowOutlineGroup( int row )
{
- int rownum = lastrow-1;
- RowRecord r = getRow(rownum);
+ int level = getRow( row ).getOutlineLevel();
+ int currentRow;
+ for (currentRow = row; currentRow < this.getLastRowNum(); currentRow++)
+ {
+ if (getRow(currentRow) == null || getRow(currentRow).getOutlineLevel() < level)
+ {
+ break;
+ }
+ }
- while (r == null && rownum >= 0)
+ return currentRow-1;
+ }
+
+ public int writeHidden( RowRecord rowRecord, int row, boolean hidden )
+ {
+ int level = rowRecord.getOutlineLevel();
+ while (rowRecord != null && this.getRow(row).getOutlineLevel() >= level)
{
- r = this.getRow(--rownum);
+ rowRecord.setZeroHeight( hidden );
+ row++;
+ rowRecord = this.getRow( row );
+ }
+ return row - 1;
+ }
+
+ public void collapseRow( int rowNumber )
+ {
+
+ // Find the start of the group.
+ int startRow = findStartOfRowOutlineGroup( rowNumber );
+ RowRecord rowRecord = (RowRecord) getRow( startRow );
+
+ // Hide all the columns until the end of the group
+ int lastRow = writeHidden( rowRecord, startRow, true );
+
+ // Write collapse field
+ if (getRow(lastRow + 1) != null)
+ {
+ getRow(lastRow + 1).setColapsed( true );
+ }
+ else
+ {
+ RowRecord row = createRow( lastRow + 1);
+ row.setColapsed( true );
+ insertRow( row );
}
- return rownum;
}
/**
- * used internally to refresh the "first row" when the first row is removed.
+ * Create a row record.
+ *
+ * @param row number
+ * @return RowRecord created for the passed in row number
+ * @see org.apache.poi.hssf.record.RowRecord
*/
+ public static RowRecord createRow(int row)
+ {
+ RowRecord rowrec = new RowRecord();
+
+ //rowrec.setRowNumber(( short ) row);
+ rowrec.setRowNumber(row);
+ rowrec.setHeight(( short ) 0xff);
+ rowrec.setOptimize(( short ) 0x0);
+ rowrec.setOptionFlags(( short ) 0x100); // seems necessary for outlining
+ rowrec.setXFIndex(( short ) 0xf);
+ return rowrec;
+ }
- private int findFirstRow()
+ public boolean isRowGroupCollapsed( int row )
{
- int rownum = firstrow+1;
- RowRecord r = getRow(rownum);
+ int collapseRow = findEndOfRowOutlineGroup( row ) + 1;
+
+ if (getRow(collapseRow) == null)
+ return false;
+ else
+ return getRow( collapseRow ).getColapsed();
+ }
- while (r == null && rownum <= getLastRowNum())
+ public void expandRow( int rowNumber )
+ {
+ int idx = rowNumber;
+ if (idx == -1)
+ return;
+
+ // If it is already expanded do nothing.
+ if (!isRowGroupCollapsed(idx))
+ return;
+
+ // Find the start of the group.
+ int startIdx = findStartOfRowOutlineGroup( idx );
+ RowRecord row = getRow( startIdx );
+
+ // Find the end of the group.
+ int endIdx = findEndOfRowOutlineGroup( idx );
+
+ // expand:
+ // colapsed bit must be unset
+ // hidden bit gets unset _if_ surrounding groups are expanded you can determine
+ // this by looking at the hidden bit of the enclosing group. You will have
+ // to look at the start and the end of the current group to determine which
+ // is the enclosing group
+ // hidden bit only is altered for this outline level. ie. don't uncollapse contained groups
+ if ( !isRowGroupHiddenByParent( idx ) )
{
- r = getRow(++rownum);
+ for ( int i = startIdx; i <= endIdx; i++ )
+ {
+ if ( row.getOutlineLevel() == getRow( i ).getOutlineLevel() )
+ getRow( i ).setZeroHeight( false );
+ else if (!isRowGroupCollapsed(i))
+ getRow( i ).setZeroHeight( false );
+ }
}
- if (rownum > getLastRowNum())
- return -1;
-
- return rownum;
+ // Write collapse field
+ getRow( endIdx + 1 ).setColapsed( false );
}
+ public boolean isRowGroupHiddenByParent( int row )
+ {
+ // Look out outline details of end
+ int endLevel;
+ boolean endHidden;
+ int endOfOutlineGroupIdx = findEndOfRowOutlineGroup( row );
+ if (getRow( endOfOutlineGroupIdx + 1 ) == null)
+ {
+ endLevel = 0;
+ endHidden = false;
+ }
+ else
+ {
+ endLevel = getRow( endOfOutlineGroupIdx + 1).getOutlineLevel();
+ endHidden = getRow( endOfOutlineGroupIdx + 1).getZeroHeight();
+ }
+
+ // Look out outline details of start
+ int startLevel;
+ boolean startHidden;
+ int startOfOutlineGroupIdx = findStartOfRowOutlineGroup( row );
+ if (startOfOutlineGroupIdx - 1 < 0 || getRow(startOfOutlineGroupIdx - 1) == null)
+ {
+ startLevel = 0;
+ startHidden = false;
+ }
+ else
+ {
+ startLevel = getRow( startOfOutlineGroupIdx - 1).getOutlineLevel();
+ startHidden = getRow( startOfOutlineGroupIdx - 1 ).getZeroHeight();
+ }
- /** Performs a deep clone of the record*/
- public Object clone() {
- RowRecordsAggregate rec = new RowRecordsAggregate();
- for (Iterator rowIter = getIterator(); rowIter.hasNext();) {
- //return the cloned Row Record & insert
- RowRecord row = (RowRecord)((RowRecord)rowIter.next()).clone();
- rec.insertRow(row);
- }
- return rec;
+ if (endLevel > startLevel)
+ {
+ return endHidden;
+ }
+ else
+ {
+ return startHidden;
+ }
}
}
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
index 8893f96dc0..c24c3dbed6 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
@@ -14,26 +14,21 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.aggregates;
import org.apache.poi.hssf.record.*;
-import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.util.DoubleList2d;
-import org.apache.poi.util.IntList;
-import org.apache.poi.util.IntList2d;
-import org.apache.poi.util.List2d;
import java.util.Iterator;
import java.util.List;
+import java.util.TreeMap;
/**
*
* Aggregate value records together. Things are easier to handle that way.
*
- * @author Andrew C. Oliver
+ * @author andy
* @author Glen Stampoultzis (glens at apache.org)
* @author Jason Height (jheight at chariot dot net dot au)
*/
@@ -42,110 +37,69 @@ public class ValueRecordsAggregate
extends Record
{
public final static short sid = -1000;
+ int firstcell = -1;
+ int lastcell = -1;
+ TreeMap records = null;
+// int size = 0;
- private final static int DEFAULT_ROWS=10000;
- private final static int DEFAULT_COLS=256;
+ /** Creates a new instance of ValueRecordsAggregate */
- IntList2d celltype = null;
- IntList2d xfs = null; // array of style types. Index of XF record
- DoubleList2d numericcells = null; // numeric and Shared string indicies.
- List2d formulaptgs = null; // array of arrays of FormulaRecordAggregate
- List2d stringvals = null; // array of actual string/formula string vals
- IntList populatedRows = null; //indicies of populated rows
- int physCells; //physical number of cells
-
- public CellValueRecordInterface getCell(int row, short col) {
- return constructRecord(row, col);
+ public ValueRecordsAggregate()
+ {
+ records = new TreeMap();
}
- public int getRecordSize() {
- int size = 0;
- Iterator irecs = getIterator();
-
- while (irecs.hasNext()) {
- size += (( Record ) irecs.next()).getRecordSize();
+ public void insertCell(CellValueRecordInterface cell)
+ {
+/* if (records.get(cell) == null)
+ {
+ size += (( Record ) cell).getRecordSize();
}
+ else
+ {
+ size += (( Record ) cell).getRecordSize()
+ - (( Record ) records.get(cell)).getRecordSize();
+ }*/
- return size;
- }
+ // XYLocator xy = new XYLocator(cell.getRow(), cell.getColumn());
+ Object o = records.put(cell, cell);
- public int serialize(int offset, byte [] data)
- {
- throw new RuntimeException("This method shouldnt be called. ValueRecordsAggregate.serializeCellRow() should be called from RowRecordsAggregate.");
+ if ((cell.getColumn() < firstcell) || (firstcell == -1))
+ {
+ firstcell = cell.getColumn();
+ }
+ if ((cell.getColumn() > lastcell) || (lastcell == -1))
+ {
+ lastcell = cell.getColumn();
+ }
}
- public ValueRecordsAggregate() {
- celltype = new IntList2d();
- xfs = new IntList2d();
- numericcells = new DoubleList2d();
- formulaptgs = new List2d();
- stringvals = new List2d();
- populatedRows = new IntList();
- physCells = 0;
- }
+ public void removeCell(CellValueRecordInterface cell)
+ {
+ // size -= (( Record ) cell).getRecordSize();
- public Iterator getIterator() {
- return new VRAIterator(this);
+ // XYLocator xy = new XYLocator(cell.getRow(), cell.getColumn());
+ records.remove(cell);
}
- /** Tallies a count of the size of the cell records
- * that are attached to the rows in the range specified.
- */
- public int getRowCellBlockSize(int startRow, int endRow) {
- //Make sure that the row has cells
- while (!rowHasCells(startRow) && (startRow <= endRow))
- startRow++;
- if (startRow > endRow) {
- //Couldnt find any cells between the row range provided.
- return 0;
- }
-
- Iterator cellRec = new VRAIterator(this, startRow, endRow);
- int size = 0;
- while (cellRec.hasNext()) {
- CellValueRecordInterface cell = (CellValueRecordInterface)cellRec.next();
- int row = cell.getRow();
- if ((row >=startRow) && (row <= endRow))
- size += ((Record)cell).getRecordSize();
- }
- return size;
+ public int getPhysicalNumberOfCells()
+ {
+ return records.size();
}
- /** Returns true if the row has cells attached to it */
- public boolean rowHasCells(int row)
+ public int getFirstCellNum()
{
- if (row == -1)
- return false;
-
- int col = 0;
- while (celltype.isAllocated( col, row))
- {
- if (celltype.get( col, row ) != 0)
- return true;
- col++;
- }
- return false;
+ return firstcell;
}
- /** Serializes the cells that are allocated to a certain row range*/
- public int serializeCellRow(final int row, int offset, byte [] data)
+ public int getLastCellNum()
{
- Iterator itr = new VRAIterator(this, row);
- int pos = offset;
-
- while (itr.hasNext())
- {
- CellValueRecordInterface cell = (CellValueRecordInterface)itr.next();
- pos += (( Record ) cell).serialize(pos, data);
- }
- return pos - offset;
+ return lastcell;
}
-
-
public int construct(int offset, List records)
{
- int k;
+ int k = 0;
FormulaRecordAggregate lastFormulaAggregate = null;
@@ -165,8 +119,10 @@ public class ValueRecordsAggregate
else if (rec instanceof StringRecord)
{
lastFormulaAggregate.setStringRecord((StringRecord)rec);
- }
- else if (rec instanceof SharedFormulaRecord) {
+ }
+ else if (rec instanceof SharedFormulaRecord)
+ {
+ //these follow the first formula in a group
lastFormulaAggregate.setSharedFormulaRecord((SharedFormulaRecord)rec);
}
else if (rec.isValue())
@@ -177,518 +133,140 @@ public class ValueRecordsAggregate
return k;
}
- public int getPhysicalNumberOfCells() {
- return physCells;
- }
-
- public int getPhysicalNumberOfCellsInRow(int row) {
- int count = -1;
- int col = -1;
-
- while (col > 0 || count == -1) {
- col = findNextPopulatedCell(row,col);
- count++;
- }
- return count;
- }
-
- public void setValue(int row, short cell, double val) {
- numericcells.set(cell, row, val);
- }
-
- public void setStyle(int row, short cell, short xf) {
- xfs.set(cell, row, xf);
- }
-
-
- public Iterator getRowCellIterator(int row) {
- return new VRAIterator(this, row);
- }
-
- public void removeRow(int row) {
- Iterator iterator = this.getRowCellIterator(row);
- while(iterator.hasNext()) {
- iterator.next();
- iterator.remove();
- }
- }
-
- public void removeCell(CellValueRecordInterface cell) {
- if (cell == null)
- return;
-
- int rownum = cell.getRow();
- int colnum = cell.getColumn();
-
- if (celltype.get( colnum, rownum ) != 0)
- {
- celltype.set( colnum, rownum, 0 );
- if (rowHasCells( rownum ))
- populatedRows.removeValue( populatedRows.indexOf( rownum ) );
- physCells--;
- }
- else
- {
- //this cell doesn't exist... the old code falls through so lets make this fall through too.
- }
- }
+ /**
+ * called by the class that is responsible for writing this sucker.
+ * Subclasses should implement this so that their data is passed back in a
+ * byte array.
+ *
+ * @param offset to begin writing at
+ * @param data byte array containing instance data
+ * @return number of bytes written
+ */
- public void insertCell( CellValueRecordInterface cell )
+ public int serialize(int offset, byte [] data)
{
- int rownum = cell.getRow();
- int colnum = cell.getColumn();
- int xf = cell.getXFIndex();
- int type = determineType(cell);
+ Iterator itr = records.values().iterator();
+ int pos = offset;
- if (!populatedRows.contains( rownum ))
+ while (itr.hasNext())
{
- populatedRows.add(rownum); //this means we must never have had this row inserted
- }
-
-// ensureRows(rownum);
-
-// IntList ctRow = (IntList)celltype.get(rownum);
-// IntList xfRow = (IntList)xfs.get(rownum);
-
-// adjustIntList(ctRow, colnum+1);
-// adjustIntList(xfRow, colnum+1);
-
- celltype.set(colnum, rownum, type);
- xfs.set( colnum, rownum, xf);
-
- insertCell(cell, type);
- }
-
- CellValueRecordInterface constructRecord(int row, int col) {
-
- if (celltype.get( col, row) == 0)
- throw new ArrayIndexOutOfBoundsException("No cell at position col" + col + ", row " + row + ".");
-// if (celltype.size() < row || ((IntList)celltype.get(row)).size() < col) {
-// throw new ArrayIndexOutOfBoundsException("constructRecord called with row = "+row+
-// "and col ="+col+" but there are only "+celltype.size()+" rows and "+
-// ((IntList)celltype.get(row)).size()+" cols!!");
-// }
-
- CellValueRecordInterface retval;
- int type = celltype.get( col, row );
-
- switch (type) {
- case HSSFCell.CELL_TYPE_NUMERIC:
- NumberRecord nrecord = new NumberRecord();
- nrecord.setColumn((short)col);
- nrecord.setRow(row);
- nrecord.setValue( numericcells.get( col, row));
- nrecord.setXFIndex((short)xfs.get( col, row ));
-// nrecord.setXFIndex((short)((IntList)xfs.get(row)).get(col));
- retval = nrecord;
- break;
- case HSSFCell.CELL_TYPE_STRING:
- LabelSSTRecord srecord = new LabelSSTRecord();
- srecord.setColumn((short)col);
- srecord.setRow(row);
- srecord.setSSTIndex((int) numericcells.get( col, row));
- srecord.setXFIndex((short)xfs.get( col, row ));
- retval=srecord;
- break;
- case HSSFCell.CELL_TYPE_BLANK:
- BlankRecord brecord = new BlankRecord();
- brecord.setColumn((short)col);
- brecord.setRow(row);
- brecord.setXFIndex((short)xfs.get( col, row ));
- retval=brecord;
- break;
- case HSSFCell.CELL_TYPE_FORMULA:
- /*
- FormulaRecord fr = new FormulaRecord();
- fr.setColumn((short)col);
- fr.setOptions((short)2);
-
- fr.setRow(row);
- fr.setXFIndex((short)xfs.get( col, row ));
- StringRecord st = null;
- String strval = (String)stringvals.get( col, row );
- List expressionlist = (List) formulaptgs.get( col, row);
- fr.setParsedExpression(expressionlist);
- fr.setExpressionLength(calculatePtgSize(expressionlist));
- if (strval != null) {
- st = new StringRecord();
- st.setString(strval);
- }
- FormulaRecordAggregate frarecord = new FormulaRecordAggregate(fr,st);
-
- retval= frarecord;
- break;
- */
- retval = (CellValueRecordInterface) formulaptgs.get( col, row );
- break;
- default:
- throw new RuntimeException("UnImplemented Celltype "+type);
- }
-
- return retval;
- }
-
- private short calculatePtgSize(List expressionlist)
- {
- short retval = 0;
- Iterator iter = expressionlist.iterator();
- while (iter.hasNext()) {
- retval += (short)((Ptg)iter.next()).getSize();
- }
- return retval;
- }
-
- private void insertCell(CellValueRecordInterface cell, int type)
- {
- int rownum = cell.getRow();
- int colnum = cell.getColumn();
-
-// DoubleList nmRow = (DoubleList)numericcells.get(rownum);
-
- switch (type) {
- case HSSFCell.CELL_TYPE_NUMERIC:
- NumberRecord nrecord = (NumberRecord)cell;
-// adjustDoubleList(nmRow, colnum+1);
- numericcells.set(colnum, rownum, nrecord.getValue());
- physCells++;
- break;
- case HSSFCell.CELL_TYPE_STRING:
- LabelSSTRecord srecord = (LabelSSTRecord)cell;
-// adjustDoubleList(nmRow, colnum+1);
- numericcells.set(colnum, rownum, srecord.getSSTIndex());
-// nmRow.set(colnum,srecord.getSSTIndex());
- physCells++;
- break;
- case HSSFCell.CELL_TYPE_FORMULA:
- FormulaRecordAggregate frarecord = (FormulaRecordAggregate)cell;
- formulaptgs.set( colnum, rownum, frarecord);
- physCells++;
- break;
- /*
-// List ptRow = (List)formulaptgs.get(rownum);
-// List stRow = (List)stringvals.get(rownum);
- FormulaRecordAggregate frarecord = (FormulaRecordAggregate)cell;
-// adjustDoubleList(nmRow, colnum+1);
-// adjustObjectList(ptRow, colnum+1);
-// adjustStringList(stRow, colnum+1);
- numericcells.set(colnum, rownum, frarecord.getFormulaRecord().getValue());
- formulaptgs.set( colnum, rownum, frarecord.getFormulaRecord().getParsedExpression() );
- StringRecord str = frarecord.getStringRecord();
- if ( str != null )
- stringvals.set( colnum, rownum, str.getString() );
- else
- stringvals.set( colnum, rownum, null );
- physCells++;
- break;
- */
- case HSSFCell.CELL_TYPE_BLANK:
- //BlankRecord brecord = (BlankRecord)cell;
- physCells++;
- break;
-
- default:
- throw new RuntimeException("UnImplemented Celltype "+cell.toString());
+ pos += (( Record ) itr.next()).serialize(pos, data);
}
+ return pos - offset;
}
+ /**
+ * called by the constructor, should set class level fields. Should throw
+ * runtime exception for bad/icomplete data.
+ *
+ * @param data raw data
+ * @param size size of data
+ * @param offset of the record's data (provided a big array of the file)
+ */
- private int determineType(CellValueRecordInterface cval)
+ protected void fillFields(byte [] data, short size, int offset)
{
- Record record = ( Record ) cval;
- int sid = record.getSid();
- int retval = 0;
-
- switch (sid)
- {
-
- case NumberRecord.sid :
- retval = HSSFCell.CELL_TYPE_NUMERIC;
- break;
-
- case BlankRecord.sid :
- retval = HSSFCell.CELL_TYPE_BLANK;
- break;
-
- case LabelSSTRecord.sid :
- retval = HSSFCell.CELL_TYPE_STRING;
- break;
-
- case FormulaRecordAggregate.sid :
- retval = HSSFCell.CELL_TYPE_FORMULA;
- break;
-
- case BoolErrRecord.sid :
- BoolErrRecord boolErrRecord = ( BoolErrRecord ) record;
-
- retval = (boolErrRecord.isBoolean())
- ? HSSFCell.CELL_TYPE_BOOLEAN
- : HSSFCell.CELL_TYPE_ERROR;
- break;
- }
- return retval;
}
-// private void ensureRows(int rownum) {
- //adjustRows(celltype, rownum+1, IntList.class);
-// adjustRows(xfs, rownum+1, IntList.class);
-// adjustRows(numericcells, rownum+1, DoubleList.class);
-// adjustRows(formulaptgs, rownum+1, ArrayList.class);
-// adjustRows(stringvals, rownum+1, ArrayList.class);
-
-// }
-
-// private void adjustRows(List list, int size, Class theclass) {
-// while (list.size() < size) {
-// try {
-// list.add(theclass.newInstance());
-// } catch (Exception e) {
-// throw new RuntimeException("Could Not Instantiate Row in adjustRows");
-// }
-// }
-// }
-
-// private void adjustIntList(IntList list, int size) {
-// while (list.size() < size) {
-// list.add(-1);
-// }
-// }
-//
-// private void adjustDoubleList(DoubleList list, int size) {
-// while (list.size() < size) {
-// list.add(-1);
-// }
-// }
-//
-// private void adjustObjectList(List list, int size) {
-// while (list.size() < size) {
-// list.add(new ArrayList());
-// }
-// }
-
-// private void adjustStringList(List list, int size) {
-// while (list.size() < size) {
-// list.add(new String());
-// }
-// }
-
/**
- * Find the next populated cell in the row starting from but not
- * including the current column
+ * called by constructor, should throw runtime exception in the event of a
+ * record passed with a differing ID.
*
- * @return the next valid column number
+ * @param id alleged id for this record
*/
- protected int findNextPopulatedCell(int row, int col) {
-
- int currentCol = col + 1;
- while (celltype.isAllocated( currentCol, row ))
- {
- if (celltype.get( currentCol, row) > 0)
- return currentCol;
- currentCol++;
- }
- return -1;
-
- /*
- IntList ctRow = (IntList) celltype.get(row);
- int retval = -1;
- if (ctRow.size() > col+1) {
- for (int k = col+1; k < ctRow.size() +1; k++) {
-
- if (k != ctRow.size()) {
- int val = ctRow.get(k);
- if (val != -1) {
- retval = k;
- break;
- } // end if (val !=...
-
- } //end if (k !=..
-
- } //end for
-
- } //end if (ctRow.size()...
- return retval;
- */
- }
-
-
-
- public short getSid() {
- return sid;
- }
-
-
- public void fillFields(byte[] data, short size, int offset) {
-
- }
-
- protected void validateSid(short sid) {
-
- }
-
-
-}
-
-class VRAIterator implements Iterator {
- private boolean hasNext;
- private ValueRecordsAggregate vra;
- private int popindex;
- private int row;
- private int rowlimit;
- CellValueRecordInterface current = null;
- CellValueRecordInterface next = null;
-
- public VRAIterator(ValueRecordsAggregate vra) {
- this(vra, 0, -1);
- }
-
- public VRAIterator(ValueRecordsAggregate vra, int row) {
- this(vra, row, row);
- }
-
- public VRAIterator(ValueRecordsAggregate vra, int startRow, int endRow) {
- this.vra = vra;
- this.row = startRow;
- this.rowlimit = endRow;
- this.popindex = vra.populatedRows.indexOf(row);
- if (this.popindex == -1) {
- if (vra.populatedRows.size() == 0)
- hasNext = false;
- else
- {
- int lastRow = vra.populatedRows.get(vra.populatedRows.size()-1);
- if (lastRow == -1)
- {
- hasNext = false;
- }
- else
- {
- for (int i = row; i <= lastRow; i++)
- {
- this.popindex = vra.populatedRows.indexOf(i);
- if (popindex != -1)
- break;
- }
- }
- if (popindex == -1)
- hasNext = false;
- else
- {
- next = findNextCell(null);
- hasNext = (next != null);
- }
- }
- } else if (vra.getPhysicalNumberOfCells() > 0) {
- next = findNextCell(null);
- hasNext = (next != null);
- }
+ protected void validateSid(short id)
+ {
}
+ /**
+ * return the non static version of the id for this record.
+ */
- public boolean hasNext() {
- return hasNext;
+ public short getSid()
+ {
+ return sid;
}
- public Object next() {
- current = next;
- next = findNextCell(current);
- if (next == null) {
- hasNext = false;
+ public int getRecordSize() {
+
+ int size = 0;
+ Iterator irecs = records.values().iterator();
+
+ while (irecs.hasNext()) {
+ size += (( Record ) irecs.next()).getRecordSize();
}
- return current;
- }
- public void remove() {
- vra.removeCell(current);
+ return size;
+// return size;
}
- private CellValueRecordInterface findNextCell(CellValueRecordInterface current) {
-// IntList ctRow = null;
- int rowNum = -1;
- int colNum = -1;
- int newCol = -1;
- boolean wasntFirst = false;
-
- if (current != null) {
- wasntFirst = true;
- rowNum = current.getRow();
- colNum = current.getColumn();
-// ctRow = ((IntList)vra.celltype.get(rowNum));
- }
-
- //if popindex = row iwth no cells, fast forward till we get to one with size > 0
- while (!vra.rowHasCells( rowNum ) && vra.populatedRows.size() > popindex) {
- if (wasntFirst == true) {
- throw new RuntimeException("CANT HAPPEN WASNTFIRST BUT WE'RE FASTFORWARDING!");
- }
- rowNum = vra.populatedRows.get(popindex);
- if (!vra.rowHasCells( rowNum )) {
- if ((rowlimit == -1)||(rowNum<=rowlimit)) {
- popindex++;
- } else {
- this.hasNext = false;
- }
- }
- }
- /*while ((ctRow == null || ctRow.size() == 0) && vra.populatedRows.size() > popindex) {
- if (wasntFirst == true) {
- throw new RuntimeException("CANT HAPPEN WASNTFIRST BUT WE'RE FASTFORWARDING!");
- }
- rowNum = vra.populatedRows.get(popindex);
- ctRow = (IntList)vra.celltype.get(rowNum);
- if (ctRow.size() == 0) {
- if ((rowlimit == -1)||(rowNum<=rowlimit)) {
- popindex++;
- } else {
- this.hasNext = false;
- }
- }
- } */
-
- if (rowNum == -1) {
- return null;
- }
-
- while (newCol == -1) {
- newCol = findNextPopulatedCell(rowNum,colNum);
- colNum = newCol;
- if (colNum == -1) { //end of row, forward one row
- popindex++;
- if (popindex < vra.populatedRows.size() && ((rowlimit == -1)||(rowNum<=rowlimit))) {
- rowNum = vra.populatedRows.get(popindex);
- //Return null if the row is out of range
- if ((rowlimit != -1) &&( rowNum > rowlimit))
- return null;
- } else {
- return null;
- }
- }
- }
-
- return vra.constructRecord(rowNum,colNum);
+ public Iterator getIterator()
+ {
+ return records.values().iterator();
}
- private int findNextPopulatedCell(int row, int col) {
-
- /*IntList ctRow = (IntList) vra.celltype.get(row);
- int retval = -1;
- if (ctRow.size() > col+1) {
- for (int k = col+1; k < ctRow.size() +1; k++) {
-
- if (k != ctRow.size()) {
- int val = ctRow.get(k);
-
- if (val != -1) {
- retval = k;
- break;
- } // end if (val !=...
-
- } //end if (k !=..
-
- } //end for
-
- } //end if (ctRow.size()...
- return retval;*/
- return vra.findNextPopulatedCell(row, col);
+ /** Performs a deep clone of the record*/
+ public Object clone() {
+ ValueRecordsAggregate rec = new ValueRecordsAggregate();
+ for (Iterator valIter = getIterator(); valIter.hasNext();) {
+ CellValueRecordInterface val = (CellValueRecordInterface)((CellValueRecordInterface)valIter.next()).clone();
+ rec.insertCell(val);
+ }
+ return rec;
}
-
}
+
+/*
+ * class XYLocator implements Comparable {
+ * private int row = 0;
+ * private int col = 0;
+ * public XYLocator(int row, int col) {
+ * this.row = row;
+ * this.col = col;
+ * }
+ *
+ * public int getRow() {
+ * return row;
+ * }
+ *
+ * public int getCol() {
+ * return col;
+ * }
+ *
+ * public int compareTo(Object obj) {
+ * XYLocator loc = (XYLocator)obj;
+ *
+ * if (this.getRow() == loc.getRow() &&
+ * this.getCol() == loc.getCol() )
+ * return 0;
+ *
+ * if (this.getRow() < loc.getRow())
+ * return -1;
+ *
+ * if (this.getRow() > loc.getRow())
+ * return 1;
+ *
+ * if (this.getCol() < loc.getCol())
+ * return -1;
+ *
+ * if (this.getCol() > loc.getCol())
+ * return 1;
+ *
+ * return -1;
+ *
+ * }
+ *
+ * public boolean equals(Object obj) {
+ * if (!(obj instanceof XYLocator)) return false;
+ *
+ * XYLocator loc = (XYLocator)obj;
+ * if (this.getRow() == loc.getRow()
+ * &&
+ * this.getCol() == loc.getCol()
+ * ) return true;
+ * return false;
+ * }
+ *
+ *
+ * }
+ */
diff --git a/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java b/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
index af6ea9e449..24d012577a 100644
--- a/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.BinaryTree;
diff --git a/src/java/org/apache/poi/hssf/record/formula/AddPtg.java b/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
index 28439f30f6..213862c88f 100644
--- a/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
@@ -1,6 +1,6 @@
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
/*
* AddPtg.java
diff --git a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
index 14ea1de6f1..c618305ea8 100644
--- a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
@@ -200,7 +198,7 @@ public class Area3DPtg extends Ptg
/**
* sets the first row to relative or not
- * @param rel specifies whether the first row is relative or not
+ * @param isRelative or not.
*/
public void setFirstRowRelative( boolean rel )
{
@@ -217,7 +215,7 @@ public class Area3DPtg extends Ptg
/**
* set whether the last row is relative or not
- * @param rel specifies whether the last row is relative
+ * @param last row relative
*/
public void setLastRowRelative( boolean rel )
{
@@ -283,7 +281,7 @@ public class Area3DPtg extends Ptg
ptg.field_3_last_row = field_3_last_row;
ptg.field_4_first_column = field_4_first_column;
ptg.field_5_last_column = field_5_last_column;
- ptg.setClass(ptgClass);
+ ptg.setClass(ptgClass);
return ptg;
}
diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
index dbaa4d943f..7fe37472f0 100644
--- a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * AreaPtg.java
- *
- * Created on November 17, 2001, 9:30 PM
- */
+
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
@@ -134,7 +128,7 @@ public class AreaPtg
}
/**
- * @param row last row number in the area
+ * @param last row number in the area
*/
public void setLastRow(short row)
{
@@ -230,7 +224,7 @@ public class AreaPtg
/**
* set whether the last row is relative or not
- * @param rel specifies whether the last row is relative or not
+ * @param last row relative
*/
public void setLastRowRelative(boolean rel) {
field_4_last_column=rowRelative.setShortBoolean(field_4_last_column,rel);
diff --git a/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java b/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
index 46786e718d..82df75a57e 100644
--- a/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * AttrPtg.java
- *
- * Created on November 21, 2001, 1:20 PM
- */
+
package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook;
diff --git a/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java b/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java
index 0342e921bd..8c597352de 100644
--- a/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * BoolPtg.java
- *
- * Created on Septemeber 26, 2002, 7:37 PM
- */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
diff --git a/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java b/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
index edc9ff21e2..a6e1cd85c0 100644
--- a/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * AddPtg.java
- *
- * Created on October 29, 2001, 7:48 PM
- */
+
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/ControlPtg.java b/src/java/org/apache/poi/hssf/record/formula/ControlPtg.java
index 2ad2e2c8bf..f708ffa9fb 100644
--- a/src/java/org/apache/poi/hssf/record/formula/ControlPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/ControlPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.record.formula;
public abstract class ControlPtg
diff --git a/src/java/org/apache/poi/hssf/record/formula/DividePtg.java b/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
index 2e4a59bf09..660d6df3b5 100644
--- a/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * DividePtg.java
- *
- * Created on November 4, 2001, 9:04 PM
- */
+
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java
index 99e9e1d0ad..434309dabd 100644
--- a/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java
@@ -1,6 +1,6 @@
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,17 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * EqualPtg.java
- *
- * Created on November 17, 2001, 12:51 PM
- */
package org.apache.poi.hssf.record.formula;
-import java.util.List;
-
import org.apache.poi.hssf.model.Workbook;
/**
diff --git a/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java b/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
index dba41b711e..1aafb985ec 100644
--- a/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
@@ -1,6 +1,6 @@
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * ExpPtg.java
- *
- * Created on November 25, 2001, 4:00 PM
- */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook;
diff --git a/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java b/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
index 6190d47966..8d9c1933c0 100644
--- a/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
@@ -98,4 +98,4 @@ public class FuncPtg extends AbstractFunctionPtg{
.append("</FunctionPtg>");
return buffer.toString();
}
-}
+} \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java b/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
index 351e19eb39..cca425fccd 100644
--- a/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
diff --git a/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java
index d0afec1bc4..6eddaf6d6f 100755
--- a/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java
@@ -1,19 +1,3 @@
-
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
/* ====================================================================
Copyright 2003-2004 Apache Software Foundation
@@ -31,8 +15,8 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hssf.record.formula;
+package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook;
@@ -40,32 +24,30 @@ import org.apache.poi.hssf.model.Workbook;
/**
* PTG class to implement greater or equal to
*
- * @author fred at stsci dot edu
+ * @author fred at stsci dot edu
*/
public class GreaterEqualPtg
- extends OperationPtg
+ extends OperationPtg
{
- public final static int SIZE = 1;
- public final static byte sid = 0x0c;
+ public final static int SIZE = 1;
+ public final static byte sid = 0x0c;
- /**
- * Creates new GreaterEqualPtg
- */
- public GreaterEqualPtg()
- {
+ /** Creates new GreaterEqualPtg */
+ public GreaterEqualPtg()
+ {
}
- public GreaterEqualPtg( byte[] data, int offset )
+ public GreaterEqualPtg(byte [] data, int offset)
{
+
// doesn't need anything
}
-
- public void writeBytes( byte[] array, int offset )
+ public void writeBytes(byte [] array, int offset)
{
- array[offset + 0] = sid;
+ array[ offset + 0 ] = sid;
}
public int getSize()
@@ -83,25 +65,24 @@ public class GreaterEqualPtg
return 2;
}
- public String toFormulaString( Workbook book )
+ public String toFormulaString(Workbook book)
{
return ">=";
}
- public String toFormulaString( String[] operands )
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append( operands[0] );
- buffer.append( toFormulaString( (Workbook) null ) );
- buffer.append( operands[1] );
+ public String toFormulaString(String[] operands) {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append(operands[ 0 ]);
+
+ buffer.append(toFormulaString((Workbook)null));
+ buffer.append(operands[ 1 ]);
+
return buffer.toString();
}
- public Object clone()
- {
- return new GreaterEqualPtg();
+ public Object clone() {
+ return new GreaterEqualPtg();
}
-
}
-
diff --git a/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java b/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java
index 625a32da11..6ab6607253 100644
--- a/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* GreaterThanPtg.java
@@ -95,10 +94,11 @@ public class GreaterThanPtg
/**
* Implementation of method from Ptg
+ * @param refs the Sheet References
*/
public String toFormulaString(Workbook book)
{
- return GreaterThanPtg.GREATERTHAN;
+ return this.GREATERTHAN;
}
/**
diff --git a/src/java/org/apache/poi/hssf/record/formula/IntPtg.java b/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
index 5819ef6cd7..588ef1a273 100644
--- a/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
@@ -1,6 +1,6 @@
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* IntPtg.java
diff --git a/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java
index 4230239a2d..75a0bc04e8 100755
--- a/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java
@@ -1,19 +1,3 @@
-
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
/* ====================================================================
Copyright 2003-2004 Apache Software Foundation
@@ -31,11 +15,13 @@
limitations under the License.
==================================================================== */
+
package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook;
+
/**
* Ptg class to implement less than or equal
*
@@ -52,6 +38,7 @@ public class LessEqualPtg
*/
public LessEqualPtg()
{
+
}
public LessEqualPtg( byte[] data, int offset )
@@ -97,6 +84,4 @@ public class LessEqualPtg
{
return new LessEqualPtg();
}
-
}
-
diff --git a/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java b/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java
index c8a23eb5f7..8cdc8eeef1 100644
--- a/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* LessThanPtg.java
@@ -104,10 +103,11 @@ public class LessThanPtg
/**
* Implementation of method from Ptg
+ * @param refs the Sheet References
*/
public String toFormulaString(Workbook book)
{
- return LessThanPtg.LESSTHAN;
+ return this.LESSTHAN;
}
/**
diff --git a/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java b/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
index 25bd60e57e..fa83d3a052 100644
--- a/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
@@ -1,6 +1,6 @@
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* MemErrPtg.java
diff --git a/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java b/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java
index d1d7531cae..e028522cbb 100644
--- a/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* Ptg.java
@@ -92,4 +91,4 @@ public class MemFuncPtg extends ControlPtg
field_1_len_ref_subexpression = (short)len;
}
-}
+} \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java b/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
index c3e7339076..707c449ffd 100644
--- a/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
diff --git a/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java b/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
index 6ab3036e1b..4eebecfcd7 100644
--- a/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
-/*
- * MultiplyPtg.java
- *
- * Created on November 4, 2001, 8:26 PM
- */
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/NamePtg.java b/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
index 41fb5e6928..80c4a62e42 100644
--- a/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * NamePtg.java
- *
- * Created on November 25, 2001, 3:30 PM
- */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
diff --git a/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java b/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java
index 67deba54d3..4e584e5d36 100644
--- a/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * NameXPtg.java
- *
- * Created on May 5, 2003
- */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
diff --git a/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java
index 9b55f4b883..723eacbe92 100755
--- a/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java
@@ -1,3 +1,4 @@
+
/* ====================================================================
Copyright 2003-2004 Apache Software Foundation
@@ -20,66 +21,67 @@ import org.apache.poi.hssf.model.Workbook;
/**
* Ptg class to implement not equal
- * @author fred at stsci dot edu
+ *
+ * @author fred at stsci dot edu
*/
-
public class NotEqualPtg
- extends OperationPtg
+ extends OperationPtg
{
- public final static int SIZE = 1;
- public final static byte sid = 0x0e;
-
- /** Creates new NotEqualPtg */
- public NotEqualPtg()
- {
-
- }
-
- public NotEqualPtg(byte [] data, int offset)
- {
-
- // doesn't need anything
- }
-
- public void writeBytes(byte [] array, int offset)
- {
- array[ offset + 0 ] = sid;
- }
-
- public int getSize()
- {
- return SIZE;
- }
-
- public int getType()
- {
- return TYPE_BINARY;
- }
-
- public int getNumberOfOperands()
- {
- return 2;
- }
-
- public String toFormulaString(Workbook book)
- {
- return "<>";
- }
-
- public String toFormulaString(String[] operands) {
- StringBuffer buffer = new StringBuffer();
-
-
- buffer.append(operands[ 0 ]);
- buffer.append(toFormulaString((Workbook)null));
- buffer.append(operands[ 1 ]);
- return buffer.toString();
- }
-
- public Object clone() {
- return new NotEqualPtg();
- }
+ public final static int SIZE = 1;
+ public final static byte sid = 0x0e;
+
+ /**
+ * Creates new NotEqualPtg
+ */
+ public NotEqualPtg()
+ {
+ }
+
+ public NotEqualPtg( byte[] data, int offset )
+ {
+ // doesn't need anything
+ }
+
+ public void writeBytes( byte[] array, int offset )
+ {
+ array[offset + 0] = sid;
+ }
+
+ public int getSize()
+ {
+ return SIZE;
+ }
+
+ public int getType()
+ {
+ return TYPE_BINARY;
+ }
+
+ public int getNumberOfOperands()
+ {
+ return 2;
+ }
+
+ public String toFormulaString( Workbook book )
+ {
+ return "<>";
+ }
+
+ public String toFormulaString( String[] operands )
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append( operands[0] );
+
+ buffer.append( toFormulaString( (Workbook) null ) );
+ buffer.append( operands[1] );
+
+ return buffer.toString();
+ }
+
+ public Object clone()
+ {
+ return new NotEqualPtg();
+ }
}
-
-
diff --git a/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java b/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java
index b92aac6253..b774dacfef 100644
--- a/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
diff --git a/src/java/org/apache/poi/hssf/record/formula/OperationPtg.java b/src/java/org/apache/poi/hssf/record/formula/OperationPtg.java
index 4d9bcc572d..9a7d490d79 100644
--- a/src/java/org/apache/poi/hssf/record/formula/OperationPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/OperationPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,16 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * OperationPtg.java
- *
- * Created on October 29, 2001, 7:53 PM
- */
package org.apache.poi.hssf.record.formula;
-import java.util.List;
+
/**
* defines a Ptg that is an operation instead of an operand
diff --git a/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java b/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java
index 3c58ea288d..96e6b8db29 100644
--- a/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.formula;
diff --git a/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java b/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java
index c94a11a1cb..1ff49deb50 100644
--- a/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * PowerPtg.java
- *
- * Created on November 17, 2001, 12:51 PM
- */
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/Ptg.java b/src/java/org/apache/poi/hssf/record/formula/Ptg.java
index 051ebff78f..a4d83f9d6e 100644
--- a/src/java/org/apache/poi/hssf/record/formula/Ptg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/Ptg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * Ptg.java
- *
- * Created on October 28, 2001, 6:30 PM
- */
package org.apache.poi.hssf.record.formula;
import java.util.List;
@@ -38,16 +31,16 @@ import org.apache.poi.hssf.model.Workbook;
public abstract class Ptg
{
+
+ /** convert infix order ptg list to rpn order ptg list
+ * @return List ptgs in RPN order
+ * @param infixPtgs List of ptgs in infix order
+ */
/* DO NOT REMOVE
*we keep this method in case we wish to change the way we parse
*It needs a getPrecedence in OperationsPtg
- /** convert infix order ptg list to rpn order ptg list
- * @return List ptgs in RPN order
- * @param infixPtgs List of ptgs in infix order
- */
- /*
public static List ptgsToRpn(List infixPtgs) {
java.util.Stack operands = new java.util.Stack();
java.util.List retval = new java.util.Stack();
diff --git a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
index 2c92503912..3299d4b00e 100644
--- a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.formula;
diff --git a/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java b/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
index 3780098073..17901bc0c7 100644
--- a/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * ValueReferencePtg.java
- *
- * Created on November 21, 2001, 5:27 PM
- */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
diff --git a/src/java/org/apache/poi/hssf/record/formula/StringPtg.java b/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
index 2ec0a5ffa5..18da5f5d9f 100644
--- a/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,11 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
import org.apache.poi.hssf.model.Workbook;
+import org.apache.poi.util.BitField;
import org.apache.poi.util.StringUtil;
/**
diff --git a/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java b/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java
index b3dde23cd1..c896c314c4 100644
--- a/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * SubtractPtg.java
- *
- * Created on November 4, 2001, 6:48 PM
- */
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java
index 0ce265a0d0..44a9214c18 100644
--- a/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java
index 8a6068199c..cf2090bf2a 100644
--- a/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record.formula;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java
index 47244a8329..c7a2f01107 100644
--- a/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
diff --git a/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
index c79f01d957..09794552f4 100644
--- a/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
+++ b/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,13 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
-/*
- * UnknownPtg.java
- *
- * Created on November 18, 2001, 1:22 PM
- */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook;
diff --git a/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java b/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java
index d5845d8881..d9e5824eff 100644
--- a/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java
+++ b/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
package org.apache.poi.hssf.usermodel;
import java.awt.*;
diff --git a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
index da8f6a8be8..4ddac6a6ad 100644
--- a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
+++ b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.util.POILogFactory;
diff --git a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
index 746c7c773b..50676754bd 100644
--- a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
+++ b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.util.POILogFactory;
@@ -168,6 +167,8 @@ public class EscherGraphics2d extends Graphics2D
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, ImageObserver imageobserver)
{
+ if (logger.check( POILogger.WARN ))
+ logger.log(POILogger.WARN,"drawImage() not supported");
return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null, imageobserver);
}
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, Color bgColor, ImageObserver imageobserver)
diff --git a/src/java/org/apache/poi/hssf/usermodel/FontDetails.java b/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
index 8ee0096586..bf44e7e716 100644
--- a/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
+++ b/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import java.util.HashMap;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFAnchor.java b/src/java/org/apache/poi/hssf/usermodel/HSSFAnchor.java
index 4aa98954cb..8a26c2b8ca 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFAnchor.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFAnchor.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
index f4969763dc..ef30fbd117 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
/*
* Cell.java
@@ -23,25 +23,15 @@
*/
package org.apache.poi.hssf.usermodel;
-import org.apache.poi.hssf.model.Workbook;
-import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.FormulaParser;
-import org.apache.poi.hssf.record.CellValueRecordInterface;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.LabelSSTRecord;
-import org.apache.poi.hssf.record.NumberRecord;
-import org.apache.poi.hssf.record.BlankRecord;
-import org.apache.poi.hssf.record.BoolErrRecord;
-import org.apache.poi.hssf.record.ExtendedFormatRecord;
+import org.apache.poi.hssf.model.Sheet;
+import org.apache.poi.hssf.model.Workbook;
+import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.hssf.util.SheetReferences;
-//import org.apache.poi.hssf.record.formula.FormulaParser;
-
-import java.util.Date;
import java.util.Calendar;
+import java.util.Date;
/**
* High level representation of a cell in a row of a spreadsheet.
@@ -71,7 +61,7 @@ public class HSSFCell
* @see #getCellType()
*/
- public final static int CELL_TYPE_NUMERIC = 1;
+ public final static int CELL_TYPE_NUMERIC = 0;
/**
* String Cell type (1)
@@ -79,7 +69,7 @@ public class HSSFCell
* @see #getCellType()
*/
- public final static int CELL_TYPE_STRING = 2;
+ public final static int CELL_TYPE_STRING = 1;
/**
* Formula Cell type (2)
@@ -87,7 +77,7 @@ public class HSSFCell
* @see #getCellType()
*/
- public final static int CELL_TYPE_FORMULA = 3;
+ public final static int CELL_TYPE_FORMULA = 2;
/**
* Blank Cell type (3)
@@ -95,7 +85,7 @@ public class HSSFCell
* @see #getCellType()
*/
- public final static int CELL_TYPE_BLANK = 4;
+ public final static int CELL_TYPE_BLANK = 3;
/**
* Boolean Cell type (4)
@@ -103,7 +93,7 @@ public class HSSFCell
* @see #getCellType()
*/
- public final static int CELL_TYPE_BOOLEAN = 5;
+ public final static int CELL_TYPE_BOOLEAN = 4;
/**
* Error Cell type (5)
@@ -111,11 +101,9 @@ public class HSSFCell
* @see #getCellType()
*/
- public final static int CELL_TYPE_ERROR = 6;
-
+ public final static int CELL_TYPE_ERROR = 5;
public final static short ENCODING_COMPRESSED_UNICODE = 0;
public final static short ENCODING_UTF_16 = 1;
-
private short cellNum;
private int cellType;
private HSSFCellStyle cellStyle;
@@ -128,7 +116,7 @@ public class HSSFCell
private Sheet sheet;
//private short row;
private int row;
-// private CellValueRecordInterface record;
+ private CellValueRecordInterface record;
/**
* Creates new Cell - Should only be called by HSSFRow. This creates a cell
@@ -161,25 +149,13 @@ public class HSSFCell
this.book = book;
this.sheet = sheet;
- BlankRecord rec = new BlankRecord();
- rec.setRow(row);
- rec.setColumn(cellNum);
-
- rec.setXFIndex((short)0xf);
-
- cellType = HSSFCell.CELL_TYPE_BLANK;
- sheet.addValueRecord(row,(CellValueRecordInterface)rec);
-
-
-
// Relying on the fact that by default the cellType is set to 0 which
// is different to CELL_TYPE_BLANK hence the following method call correctly
// creates a new blank cell.
- //setCellType(CELL_TYPE_BLANK, false);
-
- //ExtendedFormatRecord xf = book.getExFormatAt(0xf);
- //setCellStyle(new HSSFCellStyle(( short ) 0xf, xf));
+ setCellType(CELL_TYPE_BLANK, false);
+ ExtendedFormatRecord xf = book.getExFormatAt(0xf);
+ setCellStyle(new HSSFCellStyle(( short ) 0xf, xf));
}
/**
@@ -213,7 +189,7 @@ public class HSSFCell
errorValue = ( byte ) 0;
this.book = book;
this.sheet = sheet;
-/* switch (type)
+ switch (type)
{
case CELL_TYPE_NUMERIC :
@@ -262,7 +238,7 @@ public class HSSFCell
}
ExtendedFormatRecord xf = book.getExFormatAt(0xf);
- setCellStyle(new HSSFCellStyle(( short ) 0xf, xf)); */
+ setCellStyle(new HSSFCellStyle(( short ) 0xf, xf));
}
/**
@@ -279,7 +255,7 @@ public class HSSFCell
CellValueRecordInterface cval)
{
cellNum = cval.getColumn();
- //record = cval;
+ record = cval;
this.row = row;
cellType = determineType(cval);
cellStyle = null;
@@ -372,14 +348,8 @@ public class HSSFCell
public void setCellNum(short num)
{
- CellValueRecordInterface cval = sheet.getValueRecord(row, cellNum);
- if (cval != null) {
- sheet.removeValueRecord(this.row, cval);
- }
cellNum = num;
- sheet.addValueRecord(row, cval);
- //record.setColumn(num);
-
+ record.setColumn(num);
}
/**
@@ -441,16 +411,16 @@ public class HSSFCell
}
else
{
- frec = (FormulaRecordAggregate)sheet.getValueRecord(row, cellNum);
+ frec = ( FormulaRecordAggregate ) record;
}
frec.setColumn(getCellNum());
if (setValue)
{
frec.getFormulaRecord().setValue(getNumericCellValue());
}
-// frec.setXFIndex(( short ) cellStyle.getIndex());
+ frec.setXFIndex(( short ) cellStyle.getIndex());
frec.setRow(row);
- sheet.replaceValueRecord(frec);
+ record = frec;
break;
case CELL_TYPE_NUMERIC :
@@ -462,16 +432,16 @@ public class HSSFCell
}
else
{
- nrec = ( NumberRecord ) sheet.getValueRecord(row, cellNum);
+ nrec = ( NumberRecord ) record;
}
nrec.setColumn(getCellNum());
if (setValue)
{
nrec.setValue(getNumericCellValue());
}
- nrec.setXFIndex(sheet.getValueRecord(row,cellNum).getXFIndex());
+ nrec.setXFIndex(( short ) cellStyle.getIndex());
nrec.setRow(row);
- sheet.replaceValueRecord(nrec);
+ record = nrec;
break;
case CELL_TYPE_STRING :
@@ -483,11 +453,11 @@ public class HSSFCell
}
else
{
- lrec = ( LabelSSTRecord ) sheet.getValueRecord(row, cellNum);
+ lrec = ( LabelSSTRecord ) record;
}
lrec.setColumn(getCellNum());
lrec.setRow(row);
- lrec.setXFIndex(sheet.getValueRecord(row,cellNum).getXFIndex());
+ lrec.setXFIndex(( short ) cellStyle.getIndex());
if (setValue)
{
if ((getStringCellValue() != null)
@@ -507,7 +477,7 @@ public class HSSFCell
lrec.setSSTIndex(sst);
}
}
- sheet.replaceValueRecord(lrec);
+ record = lrec;
break;
case CELL_TYPE_BLANK :
@@ -519,21 +489,21 @@ public class HSSFCell
}
else
{
- brec = ( BlankRecord ) sheet.getValueRecord(row, cellNum);
+ brec = ( BlankRecord ) record;
}
brec.setColumn(getCellNum());
// During construction the cellStyle may be null for a Blank cell.
if (cellStyle != null)
{
- brec.setXFIndex(sheet.getValueRecord(row,cellNum).getXFIndex());
+ brec.setXFIndex(( short ) cellStyle.getIndex());
}
else
{
brec.setXFIndex(( short ) 0);
}
brec.setRow(row);
- sheet.replaceValueRecord(brec);
+ record = brec;
break;
case CELL_TYPE_BOOLEAN :
@@ -545,7 +515,7 @@ public class HSSFCell
}
else
{
- boolRec = ( BoolErrRecord ) sheet.getValueRecord(row, cellNum);
+ boolRec = ( BoolErrRecord ) record;
}
boolRec.setColumn(getCellNum());
if (setValue)
@@ -554,7 +524,7 @@ public class HSSFCell
}
boolRec.setXFIndex(( short ) cellStyle.getIndex());
boolRec.setRow(row);
- sheet.replaceValueRecord(boolRec);
+ record = boolRec;
break;
case CELL_TYPE_ERROR :
@@ -566,7 +536,7 @@ public class HSSFCell
}
else
{
- errRec = ( BoolErrRecord ) sheet.getValueRecord(row, cellNum);
+ errRec = ( BoolErrRecord ) record;
}
errRec.setColumn(getCellNum());
if (setValue)
@@ -575,17 +545,16 @@ public class HSSFCell
}
errRec.setXFIndex(( short ) cellStyle.getIndex());
errRec.setRow(row);
- sheet.replaceValueRecord(errRec);
+ record = errRec;
break;
}
if (cellType != this.cellType)
{
int loc = sheet.getLoc();
- //sheet.replaceValueRecord(record);
+ sheet.replaceValueRecord(record);
sheet.setLoc(loc);
}
- //sheet.setCellType(this.row, this.cellNum);
this.cellType = cellType;
}
@@ -616,7 +585,7 @@ public class HSSFCell
{
setCellType(CELL_TYPE_NUMERIC, false);
}
- sheet.setCellValue(row, cellNum, value);
+ (( NumberRecord ) record).setValue(value);
cellValue = value;
}
@@ -678,7 +647,7 @@ public class HSSFCell
{
index = book.addSSTString(value, true);
}
- sheet.setCellValue(row, cellNum, index);
+ (( LabelSSTRecord ) record).setSSTIndex(index);
stringValue = value;
}
}
@@ -689,12 +658,12 @@ public class HSSFCell
setCellType(CELL_TYPE_BLANK,false);
} else {
setCellType(CELL_TYPE_FORMULA,false);
- FormulaRecordAggregate rec = new FormulaRecordAggregate(new FormulaRecord(), null);
+ FormulaRecordAggregate rec = (FormulaRecordAggregate) record;
rec.getFormulaRecord().setOptions(( short ) 2);
rec.getFormulaRecord().setValue(0);
- rec.setRow(row);
- rec.setColumn(cellNum);
- rec.setXFIndex(( short ) 0x0f);
+
+ //only set to default if there is no extended format index already set
+ if (rec.getXFIndex() == (short)0) rec.setXFIndex(( short ) 0x0f);
FormulaParser fp = new FormulaParser(formula+";",book);
fp.parse();
Ptg[] ptg = fp.getRPNPtg();
@@ -705,17 +674,13 @@ public class HSSFCell
rec.getFormulaRecord().pushExpressionToken(ptg[ k ]);
}
rec.getFormulaRecord().setExpressionLength(( short ) size);
-
- sheet.replaceValueRecord(rec);
- //sheet.setCellFormula(row, cellNum, options, value
//Workbook.currentBook = null;
}
}
public String getCellFormula() {
//Workbook.currentBook=book;
- String retval = FormulaParser.toFormulaString(book,
- ((FormulaRecordAggregate)sheet.getValueRecord(row,cellNum)).getFormulaRecord().getParsedExpression());
+ String retval = FormulaParser.toFormulaString(book, ((FormulaRecordAggregate)record).getFormulaRecord().getParsedExpression());
//Workbook.currentBook=null;
return retval;
}
@@ -827,12 +792,12 @@ public class HSSFCell
public void setCellValue(boolean value)
{
- /*if ((cellType != CELL_TYPE_BOOLEAN ) && ( cellType != CELL_TYPE_FORMULA))
+ if ((cellType != CELL_TYPE_BOOLEAN ) && ( cellType != CELL_TYPE_FORMULA))
{
setCellType(CELL_TYPE_BOOLEAN, false);
}
(( BoolErrRecord ) record).setValue(value);
- booleanValue = value; */
+ booleanValue = value;
}
/**
@@ -846,11 +811,11 @@ public class HSSFCell
public void setCellErrorValue(byte value)
{
- /*if ((cellType != CELL_TYPE_ERROR) && (cellType != CELL_TYPE_FORMULA))
+ if ((cellType != CELL_TYPE_ERROR) && (cellType != CELL_TYPE_FORMULA))
{
setCellType(CELL_TYPE_ERROR, false);
}
- (( BoolErrRecord ) record).setValue(value);*/
+ (( BoolErrRecord ) record).setValue(value);
errorValue = value;
}
@@ -904,8 +869,7 @@ public class HSSFCell
public void setCellStyle(HSSFCellStyle style)
{
cellStyle = style;
-
- sheet.setCellStyle(row, cellNum, style.getIndex());
+ record.setXFIndex(style.getIndex());
}
/**
@@ -955,7 +919,7 @@ public class HSSFCell
protected CellValueRecordInterface getCellValueRecord()
{
- return sheet.getValueRecord(row, cellNum);
+ return record;
}
/**
@@ -970,7 +934,6 @@ public class HSSFCell
throw new RuntimeException("You cannot reference columns with an index of less then 0.");
}
}
-
/**
* Sets this cell as the active cell for the worksheet
@@ -980,5 +943,4 @@ public class HSSFCell
this.sheet.setActiveCellRow(this.row);
this.sheet.setActiveCellCol(this.cellNum);
}
-
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
index ab2e3fe766..b33fae4254 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,13 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * HSSFCellStyle.java
- *
- * Created on September 30, 2001, 3:47 PM
- */
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.ExtendedFormatRecord;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java b/src/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java
index 5d1f9bcf52..0cbba3d10f 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.ddf.EscherRecord;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java b/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
index d2d8dcdfd3..029cc77ff5 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.ddf.EscherClientAnchorRecord;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java
index c5bedc380f..7cd244468f 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* HSSFDataFormat.java
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
index e5aef673a4..985ba7648c 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
+
/*
* DateUtil.java
@@ -33,6 +33,7 @@ import java.util.GregorianCalendar;
* @author Michael Harhen
* @author Glen Stampoultzis (glens at apache.org)
* @author Dan Sherman (dsherman at isisph.com)
+ * @author Hack Kampbjorn (hak at 2mba.dk)
*/
public class HSSFDateUtil
@@ -68,9 +69,19 @@ public class HSSFDateUtil
}
else
{
+ // Because of daylight time saving we cannot use
+ // date.getTime() - calStart.getTimeInMillis()
+ // as the difference in milliseconds between 00:00 and 04:00
+ // can be 3, 4 or 5 hours but Excel expects it to always
+ // be 4 hours.
+ // E.g. 2004-03-28 04:00 CEST - 2004-03-28 00:00 CET is 3 hours
+ // and 2004-10-31 04:00 CET - 2004-10-31 00:00 CEST is 5 hours
+ double fraction = (((calStart.get(Calendar.HOUR_OF_DAY) * 60
+ + calStart.get(Calendar.MINUTE)
+ ) * 60 + calStart.get(Calendar.SECOND)
+ ) * 1000 + calStart.get(Calendar.MILLISECOND)
+ ) / ( double ) DAY_MILLISECONDS;
calStart = dayStart(calStart);
- double fraction = (date.getTime() - calStart.getTime().getTime())
- / ( double ) DAY_MILLISECONDS;
return fraction + ( double ) absoluteDay(calStart)
- CAL_1900_ABSOLUTE;
@@ -96,10 +107,20 @@ public class HSSFDateUtil
* Given an Excel date with either 1900 or 1904 date windowing,
* converts it to a java.util.Date.
*
+ * NOTE: If the default <code>TimeZone</code> in Java uses Daylight
+ * Saving Time then the conversion back to an Excel date may not give
+ * the same value, that is the comparison
+ * <CODE>excelDate == getExcelDate(getJavaDate(excelDate,false))</CODE>
+ * is not always true. For example if default timezone is
+ * <code>Europe/Copenhagen</code>, on 2004-03-28 the minute after
+ * 01:59 CET is 03:00 CEST, if the excel date represents a time between
+ * 02:00 and 03:00 then it is converted to past 03:00 summer time
+ *
* @param date The Excel date.
* @param use1904windowing true if date uses 1904 windowing,
* or false if using 1900 date windowing.
* @return Java representation of the date, or null if date is not a valid Excel date
+ * @see java.util.TimeZone
*/
public static Date getJavaDate(double date, boolean use1904windowing) {
if (isValidExcelDate(date)) {
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFErrorConstants.java b/src/java/org/apache/poi/hssf/usermodel/HSSFErrorConstants.java
index 5d640375da..e31dcea2ca 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFErrorConstants.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFErrorConstants.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* HSSFErrorConstants.java
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
index c98c70cc13..f910309a47 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* HSSFFont.java
@@ -128,7 +127,7 @@ public class HSSFFont
/**
* set the name for the font (i.e. Arial)
- * @param name the name of the font to use
+ * @param name String representing the name of the font to use
* @see #FONT_ARIAL
*/
@@ -163,7 +162,7 @@ public class HSSFFont
/**
* set the font height in unit's of 1/20th of a point. Maybe you might want to
* use the setFontHeightInPoints which matches to the familiar 10, 12, 14 etc..
- * @param height in 1/20ths of a point
+ * @param short - height in 1/20ths of a point
* @see #setFontHeightInPoints(short)
*/
@@ -174,7 +173,7 @@ public class HSSFFont
/**
* set the font height
- * @param height in the familiar unit of measure - points
+ * @param short - height in the familiar unit of measure - points
* @see #setFontHeight(short)
*/
@@ -208,7 +207,7 @@ public class HSSFFont
/**
* set whether to use italics or not
- * @param italic use italics or not
+ * @param italics or not
*/
public void setItalic(boolean italic)
@@ -322,7 +321,7 @@ public class HSSFFont
/**
* set type of text underlining to use
- * @param underline the underlining type to use
+ * @param underline type
* @see #U_NONE
* @see #U_SINGLE
* @see #U_DOUBLE
@@ -357,4 +356,5 @@ public class HSSFFont
"}";
}
+
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
index 5ae6bcbc39..16f65f6db8 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
@@ -30,9 +29,6 @@ import org.apache.poi.hssf.record.FooterRecord;
* that return the characters used to represent these. One can also change the
* fonts by using similar methods.
* <P>
- * To get an instance of HSSFFooter for a HSSFSheet is to call <a
- * href="HSSFSheet.html#getFooter()">getFooter()</a> on the sheet.
- * <p>
* @author Shawn Laubach (slaubach at apache dot org)
*/
public class HSSFFooter extends Object {
@@ -97,7 +93,7 @@ public class HSSFFooter extends Object {
/**
* Sets the left string.
- * @param newLeft The string to set as the left side.
+ * @newLeft The string to set as the left side.
*/
public void setLeft(String newLeft) {
left = newLeft;
@@ -114,7 +110,7 @@ public class HSSFFooter extends Object {
/**
* Sets the center string.
- * @param newCenter The string to set as the center.
+ * @newLeft The string to set as the center.
*/
public void setCenter(String newCenter) {
center = newCenter;
@@ -131,7 +127,7 @@ public class HSSFFooter extends Object {
/**
* Sets the right string.
- * @param newRight The string to set as the right side.
+ * @newLeft The string to set as the right side.
*/
public void setRight(String newRight) {
right = newRight;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
index d610a180f8..5324b5c8c9 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel;
@@ -30,9 +28,6 @@ import org.apache.poi.hssf.record.HeaderRecord;
* that return the characters used to represent these. One can also change the
* fonts by using similar methods.
* <P>
- * To get an instance of HSSFHeader for a HSSFSheet is to call <a
- * href="HSSFSheet.html#getHeader()">getHeader()</a> on the sheet.
- * <p>
* @author Shawn Laubach (slaubach at apache dot org)
*/
public class HSSFHeader extends Object {
@@ -97,7 +92,7 @@ public class HSSFHeader extends Object {
/**
* Sets the left string.
- * @param newLeft The string to set as the left side.
+ * @newLeft The string to set as the left side.
*/
public void setLeft(String newLeft) {
left = newLeft;
@@ -114,7 +109,7 @@ public class HSSFHeader extends Object {
/**
* Sets the center string.
- * @param newCenter The string to set as the center.
+ * @newLeft The string to set as the center.
*/
public void setCenter(String newCenter) {
center = newCenter;
@@ -131,7 +126,7 @@ public class HSSFHeader extends Object {
/**
* Sets the right string.
- * @param newRight The string to set as the right side.
+ * @newLeft The string to set as the right side.
*/
public void setRight(String newRight) {
right = newRight;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
index c26d7bbe8d..4f2c9bb6ca 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,14 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.util.RangeAddress;
-import org.apache.poi.hssf.util.SheetReferences;
/**
* Title: High Level Represantion of Named Range <P>
@@ -38,8 +35,8 @@ public class HSSFName {
*
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createName()
* @param name the Name Record
- * @param book lowlevel Workbook object associated with the sheet.
- */
+ * @param book - lowlevel Workbook object associated with the sheet.
+ * @param book the Workbook */
protected HSSFName(Workbook book, NameRecord name) {
this.book = book;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
index 911a45be5a..c6de0bb6d2 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.PaletteRecord;
@@ -86,8 +85,8 @@ public class HSSFPalette
* @return The closest color or null if there are no custom
* colors currently defined.
*/
- public HSSFColor findSimilarColor(byte red, byte green, byte blue)
- {
+ public HSSFColor findSimilarColor(byte red, byte green, byte blue)
+ {
HSSFColor result = null;
int minColorDistance = Integer.MAX_VALUE;
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
@@ -104,6 +103,19 @@ public class HSSFPalette
}
/**
+ * Sets the color at the given offset
+ *
+ * @param index the palette index, between 0x8 to 0x40 inclusive
+ * @param red the RGB red component, between 0 and 255 inclusive
+ * @param green the RGB green component, between 0 and 255 inclusive
+ * @param blue the RGB blue component, between 0 and 255 inclusive
+ */
+ public void setColorAtIndex(short index, byte red, byte green, byte blue)
+ {
+ palette.setColor(index, red, green, blue);
+ }
+
+ /**
* Adds a new color into an empty color slot.
* @param red The red component
* @param green The green component
@@ -128,19 +140,6 @@ public class HSSFPalette
throw new RuntimeException("Could not find free color index");
}
- /**
- * Sets the color at the given offset
- *
- * @param index the palette index, between 0x8 to 0x40 inclusive
- * @param red the RGB red component, between 0 and 255 inclusive
- * @param green the RGB green component, between 0 and 255 inclusive
- * @param blue the RGB blue component, between 0 and 255 inclusive
- */
- public void setColorAtIndex(short index, byte red, byte green, byte blue)
- {
- palette.setColor(index, red, green, blue);
- }
-
private static class CustomColor extends HSSFColor
{
private short byteOffset;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
index f3daf5200a..c80982baec 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import java.util.ArrayList;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
index 87aff2123a..1163bab980 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java
index 76273a2934..8db0c3f47f 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPrintSetup.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2003-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,331 +14,348 @@
limitations under the License.
==================================================================== */
+
package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.PrintSetupRecord;
-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;
+/**
+ * Used to modify the print setup.
+ * <P>
+ * Paper size constants have been added for the ones I have access
+ * to. They follow as:<br>
+ * public static final short LETTER_PAPERSIZE = 1;<br>
+ * public static final short LEGAL_PAPERSIZE = 5;<br>
+ * public static final short EXECUTIVE_PAPERSIZE = 7;<br>
+ * public static final short A4_PAPERSIZE = 9;<br>
+ * public static final short A5_PAPERSIZE = 11;<br>
+ * public static final short ENVELOPE_10_PAPERSIZE = 20;<br>
+ * public static final short ENVELOPE_DL_PAPERSIZE = 27;<br>
+ * public static final short ENVELOPE_CS_PAPERSIZE = 28;<br>
+ * public static final short ENVELOPE_MONARCH_PAPERSIZE = 37;<br>
+ * <P>
+ * @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;
PrintSetupRecord printSetupRecord;
- /**
- * Constructor. Takes the low level print setup record.
- * @param printSetupRecord the low level print setup record
- */
- protected HSSFPrintSetup (PrintSetupRecord printSetupRecord)
- {
- this.printSetupRecord = printSetupRecord;
- }
- /**
- * Set the paper size.
- * @param size the paper size.
- */
- public void setPaperSize (short size)
- {
- printSetupRecord.setPaperSize (size);
- }
- /**
- * Set the scale.
- * @param scale the scale to use
- */
- public void setScale (short scale)
- {
- printSetupRecord.setScale (scale);
- }
- /**
- * Set the page numbering start.
- * @param start the page numbering start
- */
- public void setPageStart (short start)
- {
- printSetupRecord.setPageStart (start);
- }
- /**
- * Set the number of pages wide to fit the sheet in
- * @param width the number of pages
- */
- public void setFitWidth (short width)
- {
- printSetupRecord.setFitWidth (width);
- }
- /**
- * Set the number of pages high to fit the sheet in
- * @param height the number of pages
- */
- public void setFitHeight (short height)
- {
- printSetupRecord.setFitHeight (height);
- }
- /**
- * Sets the options flags. Not advisable to do it directly.
- * @param options The bit flags for the options
- */
- public void setOptions (short options)
- {
- printSetupRecord.setOptions (options);
- }
- /**
- * Set whether to go left to right or top down in ordering
- * @param ltor left to right
- */
- public void setLeftToRight (boolean ltor)
- {
- printSetupRecord.setLeftToRight (ltor);
- }
- /**
- * Set whether to print in landscape
- * @param ls landscape
- */
- public void setLandscape (boolean ls)
- {
- printSetupRecord.setLandscape (!ls);
- }
- /**
- * Valid settings. I'm not for sure.
- * @param valid Valid
- */
- public void setValidSettings (boolean valid)
- {
- printSetupRecord.setValidSettings (valid);
- }
- /**
- * Set whether it is black and white
- * @param mono Black and white
- */
- public void setNoColor (boolean mono)
- {
- printSetupRecord.setNoColor (mono);
- }
- /**
- * Set whether it is in draft mode
- * @param d draft
- */
- public void setDraft (boolean d)
- {
- printSetupRecord.setDraft (d);
- }
- /**
- * Print the include notes
- * @param printnotes print the notes
- */
- public void setNotes (boolean printnotes)
- {
- printSetupRecord.setNotes (printnotes);
- }
- /**
- * Set no orientation. ?
- * @param orientation Orientation.
- */
- public void setNoOrientation (boolean orientation)
- {
- printSetupRecord.setNoOrientation (orientation);
- }
- /**
- * Set whether to use page start
- * @param page Use page start
- */
- public void setUsePage (boolean page)
- {
- printSetupRecord.setUsePage (page);
- }
- /**
- * Sets the horizontal resolution.
- * @param resolution horizontal resolution
- */
- public void setHResolution (short resolution)
- {
- printSetupRecord.setHResolution (resolution);
- }
- /**
- * Sets the vertical resolution.
- * @param resolution vertical resolution
- */
- public void setVResolution (short resolution)
- {
- printSetupRecord.setVResolution (resolution);
- }
- /**
- * Sets the header margin.
- * @param headermargin header margin
- */
- public void setHeaderMargin (double headermargin)
- {
- printSetupRecord.setHeaderMargin (headermargin);
- }
- /**
- * Sets the footer margin.
- * @param footermargin footer margin
- */
- public void setFooterMargin (double footermargin)
- {
- printSetupRecord.setFooterMargin (footermargin);
- }
- /**
- * Sets the number of copies.
- * @param copies number of copies
- */
- public void setCopies (short copies)
- {
- printSetupRecord.setCopies (copies);
- }
- /**
- * Returns the paper size.
- * @return paper size
- */
- public short getPaperSize ()
- {
- return printSetupRecord.getPaperSize ();
- }
- /**
- * Returns the scale.
- * @return scale
- */
- public short getScale ()
- {
- return printSetupRecord.getScale ();
- }
- /**
- * Returns the page start.
- * @return page start
- */
- public short getPageStart ()
- {
- return printSetupRecord.getPageStart ();
- }
- /**
- * Returns the number of pages wide to fit sheet in.
- * @return number of pages wide to fit sheet in
- */
- public short getFitWidth ()
- {
- return printSetupRecord.getFitWidth ();
- }
- /**
- * Returns the number of pages high to fit the sheet in.
- * @return number of pages high to fit the sheet in
- */
- public short getFitHeight ()
- {
- return printSetupRecord.getFitHeight ();
- }
- /**
- * Returns the bit flags for the options.
- * @return bit flags for the options
- */
- public short getOptions ()
- {
- return printSetupRecord.getOptions ();
- }
- /**
- * Returns the left to right print order.
- * @return left to right print order
- */
- public boolean getLeftToRight ()
- {
- return printSetupRecord.getLeftToRight ();
- }
- /**
- * Returns the landscape mode.
- * @return landscape mode
- */
- public boolean getLandscape ()
- {
- return !printSetupRecord.getLandscape ();
- }
- /**
- * Returns the valid settings.
- * @return valid settings
- */
- public boolean getValidSettings ()
- {
- return printSetupRecord.getValidSettings ();
- }
- /**
- * Returns the black and white setting.
- * @return black and white setting
- */
- public boolean getNoColor ()
- {
- return printSetupRecord.getNoColor ();
- }
- /**
- * Returns the draft mode.
- * @return draft mode
- */
- public boolean getDraft ()
- {
- return printSetupRecord.getDraft ();
- }
- /**
- * Returns the print notes.
- * @return print notes
- */
- public boolean getNotes ()
- {
- return printSetupRecord.getNotes ();
- }
- /**
- * Returns the no orientation.
- * @return no orientation
- */
- public boolean getNoOrientation ()
- {
- return printSetupRecord.getNoOrientation ();
- }
- /**
- * Returns the use page numbers.
- * @return use page numbers
- */
- public boolean getUsePage ()
- {
- return printSetupRecord.getUsePage ();
- }
- /**
- * Returns the horizontal resolution.
- * @return horizontal resolution
- */
- public short getHResolution ()
- {
- return printSetupRecord.getHResolution ();
- }
- /**
- * Returns the vertical resolution.
- * @return vertical resolution
- */
- public short getVResolution ()
- {
- return printSetupRecord.getVResolution ();
- }
- /**
- * Returns the header margin.
- * @return header margin
- */
- public double getHeaderMargin ()
- {
- return printSetupRecord.getHeaderMargin ();
- }
- /**
- * Returns the footer margin.
- * @return footer margin
- */
- public double getFooterMargin ()
- {
- return printSetupRecord.getFooterMargin ();
- }
- /**
- * Returns the number of copies.
- * @return number of copies
- */
- public short getCopies ()
- {
- return printSetupRecord.getCopies ();
- }
-}
+
+ /**
+ * Constructor. Takes the low level print setup record.
+ * @param printSetupRecord the low level print setup record
+ */
+ protected HSSFPrintSetup(PrintSetupRecord printSetupRecord) {
+ this.printSetupRecord = printSetupRecord;
+ }
+
+ /**
+ * Set the paper size.
+ * @param size the paper size.
+ */
+ public void setPaperSize(short size) {
+ printSetupRecord.setPaperSize(size);
+ }
+
+ /**
+ * Set the scale.
+ * @param scale the scale to use
+ */
+ public void setScale(short scale) {
+ printSetupRecord.setScale(scale);
+ }
+
+ /**
+ * Set the page numbering start.
+ * @param start the page numbering start
+ */
+ public void setPageStart(short start) {
+ printSetupRecord.setPageStart(start);
+ }
+
+ /**
+ * Set the number of pages wide to fit the sheet in
+ * @param width the number of pages
+ */
+ public void setFitWidth(short width) {
+ printSetupRecord.setFitWidth(width);
+ }
+
+ /**
+ * Set the number of pages high to fit the sheet in
+ * @param height the number of pages
+ */
+ public void setFitHeight(short height) {
+ printSetupRecord.setFitHeight(height);
+ }
+
+ /**
+ * Sets the options flags. Not advisable to do it directly.
+ * @param options The bit flags for the options
+ */
+ public void setOptions(short options) {
+ printSetupRecord.setOptions(options);
+ }
+
+ /**
+ * Set whether to go left to right or top down in ordering
+ * @param ltor left to right
+ */
+ public void setLeftToRight(boolean ltor) {
+ printSetupRecord.setLeftToRight(ltor);
+ }
+
+ /**
+ * Set whether to print in landscape
+ * @param ls landscape
+ */
+ public void setLandscape(boolean ls) {
+ printSetupRecord.setLandscape(!ls);
+ }
+
+ /**
+ * Valid settings. I'm not for sure.
+ * @param valid Valid
+ */
+ public void setValidSettings(boolean valid) {
+ printSetupRecord.setValidSettings(valid);
+ }
+
+ /**
+ * Set whether it is black and white
+ * @param mono Black and white
+ */
+ public void setNoColor(boolean mono) {
+ printSetupRecord.setNoColor(mono);
+ }
+
+ /**
+ * Set whether it is in draft mode
+ * @param d draft
+ */
+ public void setDraft(boolean d) {
+ printSetupRecord.setDraft(d);
+ }
+
+ /**
+ * Print the include notes
+ * @param printnotes print the notes
+ */
+ public void setNotes(boolean printnotes) {
+ printSetupRecord.setNotes(printnotes);
+ }
+
+ /**
+ * Set no orientation. ?
+ * @param orientation Orientation.
+ */
+ public void setNoOrientation(boolean orientation) {
+ printSetupRecord.setNoOrientation(orientation);
+ }
+
+ /**
+ * Set whether to use page start
+ * @param page Use page start
+ */
+ public void setUsePage(boolean page) {
+ printSetupRecord.setUsePage(page);
+ }
+
+ /**
+ * Sets the horizontal resolution.
+ * @param resolution horizontal resolution
+ */
+ public void setHResolution(short resolution) {
+ printSetupRecord.setHResolution(resolution);
+ }
+
+ /**
+ * Sets the vertical resolution.
+ * @param resolution vertical resolution
+ */
+ public void setVResolution(short resolution) {
+ printSetupRecord.setVResolution(resolution);
+ }
+
+ /**
+ * Sets the header margin.
+ * @param headermargin header margin
+ */
+ public void setHeaderMargin(double headermargin) {
+ printSetupRecord.setHeaderMargin(headermargin);
+ }
+
+ /**
+ * Sets the footer margin.
+ * @param footermargin footer margin
+ */
+ public void setFooterMargin(double footermargin) {
+ printSetupRecord.setFooterMargin(footermargin);
+ }
+
+ /**
+ * Sets the number of copies.
+ * @param copies number of copies
+ */
+ public void setCopies(short copies) {
+ printSetupRecord.setCopies(copies);
+ }
+
+ /**
+ * Returns the paper size.
+ * @return paper size
+ */
+ public short getPaperSize() {
+ return printSetupRecord.getPaperSize();
+ }
+
+ /**
+ * Returns the scale.
+ * @return scale
+ */
+ public short getScale() {
+ return printSetupRecord.getScale();
+ }
+
+ /**
+ * Returns the page start.
+ * @return page start
+ */
+ public short getPageStart() {
+ return printSetupRecord.getPageStart();
+ }
+
+ /**
+ * Returns the number of pages wide to fit sheet in.
+ * @return number of pages wide to fit sheet in
+ */
+ public short getFitWidth() {
+ return printSetupRecord.getFitWidth();
+ }
+
+ /**
+ * Returns the number of pages high to fit the sheet in.
+ * @return number of pages high to fit the sheet in
+ */
+ public short getFitHeight() {
+ return printSetupRecord.getFitHeight();
+ }
+
+ /**
+ * Returns the bit flags for the options.
+ * @return bit flags for the options
+ */
+ public short getOptions() {
+ return printSetupRecord.getOptions();
+ }
+
+ /**
+ * Returns the left to right print order.
+ * @return left to right print order
+ */
+ public boolean getLeftToRight() {
+ return printSetupRecord.getLeftToRight();
+ }
+
+ /**
+ * Returns the landscape mode.
+ * @return landscape mode
+ */
+ public boolean getLandscape() {
+ return !printSetupRecord.getLandscape();
+ }
+
+ /**
+ * Returns the valid settings.
+ * @return valid settings
+ */
+ public boolean getValidSettings() {
+ return printSetupRecord.getValidSettings();
+ }
+
+ /**
+ * Returns the black and white setting.
+ * @return black and white setting
+ */
+ public boolean getNoColor() {
+ return printSetupRecord.getNoColor();
+ }
+
+ /**
+ * Returns the draft mode.
+ * @return draft mode
+ */
+ public boolean getDraft() {
+ return printSetupRecord.getDraft();
+ }
+
+ /**
+ * Returns the print notes.
+ * @return print notes
+ */
+ public boolean getNotes() {
+ return printSetupRecord.getNotes();
+ }
+
+ /**
+ * Returns the no orientation.
+ * @return no orientation
+ */
+ public boolean getNoOrientation() {
+ return printSetupRecord.getNoOrientation();
+ }
+
+ /**
+ * Returns the use page numbers.
+ * @return use page numbers
+ */
+ public boolean getUsePage() {
+ return printSetupRecord.getUsePage();
+ }
+
+ /**
+ * Returns the horizontal resolution.
+ * @return horizontal resolution
+ */
+ public short getHResolution() {
+ return printSetupRecord.getHResolution();
+ }
+
+ /**
+ * Returns the vertical resolution.
+ * @return vertical resolution
+ */
+ public short getVResolution() {
+ return printSetupRecord.getVResolution();
+ }
+
+ /**
+ * Returns the header margin.
+ * @return header margin
+ */
+ public double getHeaderMargin() {
+ return printSetupRecord.getHeaderMargin();
+ }
+
+ /**
+ * Returns the footer margin.
+ * @return footer margin
+ */
+ public double getFooterMargin() {
+ return printSetupRecord.getFooterMargin();
+ }
+
+ /**
+ * Returns the number of copies.
+ * @return number of copies
+ */
+ public short getCopies() {
+ return printSetupRecord.getCopies();
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
index f1014a5a83..351a5809df 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import java.util.Map;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
index 544de39e44..c84df9032e 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
/*
* HSSFRow.java
@@ -27,7 +25,6 @@ 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.hssf.record.aggregates.ValueRecordsAggregate;
import java.util.HashMap;
import java.util.Iterator;
@@ -49,7 +46,7 @@ public class HSSFRow
public final static int INITIAL_CAPACITY = 5;
//private short rowNum;
private int rowNum;
- //private ValueRecordsAggregate cells;
+ private HashMap cells;
// private short firstcell = -1;
// private short lastcell = -1;
@@ -57,7 +54,7 @@ public class HSSFRow
* reference to low level representation
*/
- //private RowRecord row;
+ private RowRecord row;
/**
* reference to containing low level Workbook
@@ -81,23 +78,24 @@ public class HSSFRow
* @param book low-level Workbook object containing the sheet that contains this row
* @param sheet low-level Sheet object that contains this Row
* @param rowNum the row number of this row (0 based)
- * @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int)
+ * @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(short)
*/
//protected HSSFRow(Workbook book, Sheet sheet, short rowNum)
protected HSSFRow(Workbook book, Sheet sheet, int rowNum)
{
this.rowNum = rowNum;
- //cells = new HashMap(10); // new ArrayList(INITIAL_CAPACITY);
+ cells = new HashMap(10); // new ArrayList(INITIAL_CAPACITY);
this.book = book;
this.sheet = sheet;
- //row = new RowRecord();
- //row.setHeight((short) 0xff);
- //row.setLastCol((short) -1);
- //row.setFirstCol((short) -1);
+ row = new RowRecord();
+ row.setOptionFlags( (short)0x100 ); // seems necessary for outlining to work.
+ row.setHeight((short) 0xff);
+ row.setLastCol((short) -1);
+ row.setFirstCol((short) -1);
// row.setRowNumber(rowNum);
- //setRowNum(rowNum);
+ setRowNum(rowNum);
}
/**
@@ -107,16 +105,16 @@ public class HSSFRow
* @param book low-level Workbook object containing the sheet that contains this row
* @param sheet low-level Sheet object that contains this Row
* @param record the low level api object this row should represent
- * @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int)
+ * @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(short)
*/
protected HSSFRow(Workbook book, Sheet sheet, RowRecord record)
{
//this.rowNum = rowNum;
- //cells = new HashMap(); // ArrayList(INITIAL_CAPACITY);
+ cells = new HashMap(); // ArrayList(INITIAL_CAPACITY);
this.book = book;
this.sheet = sheet;
- //row = record;
+ row = record;
// row.setHeight(record.getHeight());
// row.setRowNumber(rowNum);
@@ -140,8 +138,8 @@ public class HSSFRow
{
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column);
- //addCell(cell);
- //sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
+ addCell(cell);
+ sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
return cell;
}
@@ -176,15 +174,15 @@ public class HSSFRow
CellValueRecordInterface cval = cell.getCellValueRecord();
sheet.removeValueRecord(getRowNum(), cval);
- //cells.remove(new Integer(cell.getCellNum()));
+ cells.remove(new Integer(cell.getCellNum()));
- if (cell.getCellNum() == getLastCol(rowNum))
+ if (cell.getCellNum() == row.getLastCol())
{
- sheet.getRow(rowNum).setLastCol(findLastCell(sheet.getRow(rowNum).getLastCol()));
+ row.setLastCol(findLastCell(row.getLastCol()));
}
- if (cell.getCellNum() == getFirstCol(rowNum))
+ if (cell.getCellNum() == row.getFirstCol())
{
- setFirstCol(findFirstCell(getFirstCol(rowNum)));
+ row.setFirstCol(findFirstCell(row.getFirstCol()));
}
}
@@ -201,7 +199,7 @@ public class HSSFRow
addCell(hcell);
- sheet.addValueRecord(getRowNum(),cell);
+ // sheet.addValueRecord(getRowNum(),cell.getCellValueRecord());
return hcell;
}
@@ -214,10 +212,10 @@ public class HSSFRow
public void setRowNum(int rowNum)
{
this.rowNum = rowNum;
- //if (row != null)
- //{
- // row.setRowNumber(rowNum); // used only for KEY comparison (HSSFRow)
- //}
+ if (row != null)
+ {
+ row.setRowNumber(rowNum); // used only for KEY comparison (HSSFRow)
+ }
}
/**
@@ -237,44 +235,26 @@ public class HSSFRow
private void addCell(HSSFCell cell)
{
- if (getFirstCol(rowNum) == -1)
+ if (row.getFirstCol() == -1)
{
- setFirstCol(cell.getCellNum());
+ row.setFirstCol(cell.getCellNum());
}
- if (getLastCol(rowNum) == -1)
+ if (row.getLastCol() == -1)
{
- setLastCol(cell.getCellNum());
+ row.setLastCol(cell.getCellNum());
}
- //cells.put(new Integer(cell.getCellNum()), cell);
- sheet.addValueRecord(this.rowNum, cell.getCellValueRecord());
+ cells.put(new Integer(cell.getCellNum()), cell);
- if (cell.getCellNum() < getFirstCol(rowNum))
+ if (cell.getCellNum() < row.getFirstCol())
{
- setFirstCol(cell.getCellNum());
+ row.setFirstCol(cell.getCellNum());
}
- if (cell.getCellNum() > getLastCol(rowNum))
+ if (cell.getCellNum() > row.getLastCol())
{
- setLastCol(cell.getCellNum());
+ row.setLastCol(cell.getCellNum());
}
}
- private void setLastCol(short cell) {
- sheet.setLastColForRow(rowNum, cell);
- }
-
- private void setFirstCol(short cell) {
- sheet.setFirstColForRow(rowNum, cell);
- }
-
- private short getLastCol(int row) {
- return sheet.getLastColForRow(row);
- }
-
- private short getFirstCol(int row) {
- return sheet.getFirstColForRow(row);
- }
-
-
/**
* get the hssfcell representing a given column (logical cell) 0-based. If you
* ask for a cell that is not defined....you get a null.
@@ -285,11 +265,6 @@ public class HSSFRow
public HSSFCell getCell(short cellnum)
{
- HSSFCell retval = null;
- CellValueRecordInterface cval = sheet.getValueRecord(rowNum, cellnum);
- if (cval != null) {
- retval = new HSSFCell(book, sheet, rowNum, cval);
- }
/* for (int k = 0; k < cells.size(); k++)
{
@@ -300,7 +275,7 @@ public class HSSFRow
return cell;
}
}*/
- return retval;
+ return (HSSFCell) cells.get(new Integer(cellnum));
}
/**
@@ -313,7 +288,7 @@ public class HSSFRow
if (getPhysicalNumberOfCells() == 0)
return -1;
else
- return getFirstCol(rowNum);
+ return row.getFirstCol();
}
/**
@@ -326,7 +301,7 @@ public class HSSFRow
if (getPhysicalNumberOfCells() == 0)
return -1;
else
- return getLastCol(rowNum);
+ return row.getLastCol();
}
@@ -338,13 +313,11 @@ public class HSSFRow
public int getPhysicalNumberOfCells()
{
- // sheet.get
-// if (cells == null)
-// {
-// return 0; // shouldn't be possible but it is due to missing API support for BLANK/MULBLANK
-// }
-// return cells.size();
- return sheet.getPhysicalNumberOfRows();
+ if (cells == null)
+ {
+ return 0; // shouldn't be possible but it is due to missing API support for BLANK/MULBLANK
+ }
+ return cells.size();
}
/**
@@ -357,8 +330,8 @@ public class HSSFRow
{
// row.setOptionFlags(
- sheet.getRow(rowNum).setBadFontHeight(true);
- sheet.getRow(rowNum).setHeight(height);
+ row.setBadFontHeight(true);
+ row.setHeight(height);
}
/**
@@ -370,8 +343,8 @@ public class HSSFRow
{
// row.setOptionFlags(
- sheet.getRow(rowNum).setBadFontHeight(true);
- sheet.getRow(rowNum).setHeight((short) (height * 20));
+ row.setBadFontHeight(true);
+ row.setHeight((short) (height * 20));
}
/**
@@ -381,7 +354,7 @@ public class HSSFRow
public short getHeight()
{
- return sheet.getRow(rowNum).getHeight();
+ return row.getHeight();
}
/**
@@ -391,7 +364,7 @@ public class HSSFRow
public float getHeightInPoints()
{
- return (sheet.getRow(rowNum).getHeight() / 20);
+ return (row.getHeight() / 20);
}
/**
@@ -403,7 +376,7 @@ public class HSSFRow
protected RowRecord getRowRecord()
{
- return sheet.getRow(rowNum);
+ return row;
}
/**
@@ -447,7 +420,7 @@ public class HSSFRow
public Iterator cellIterator()
{
- return new RowCellIterator(this.book, this.sheet, this.rowNum);
+ return cells.values().iterator();
}
public int compareTo(Object obj)
@@ -484,36 +457,3 @@ public class HSSFRow
return false;
}
}
-
-
-class RowCellIterator implements Iterator {
- Iterator cells;
- Workbook book;
- Sheet sheet;
- int row;
-
- public RowCellIterator(Workbook book, Sheet sheet, int row) {
- this.sheet = sheet;
- this.book = book;
- this.row = row;
- cells = this.sheet.rowCellIterator(row);
- }
-
- public boolean hasNext() {
- return cells.hasNext();
- }
-
- public Object next() {
- HSSFCell retval = null;
- if (cells.hasNext()) {
- retval = new HSSFCell(book, sheet, row, ((CellValueRecordInterface)cells.next()));
- }
- return retval;
- }
-
- public void remove() {
- cells.remove();
- }
-
-
-}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java b/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java
index 1ffd110b55..557ab6ce77 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java
index b35de8c9a0..b4d29f566f 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import java.util.List;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
index f43a6c8f49..a95c18d629 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import java.util.ArrayList;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index b65dfc8cde..c381e1f1a3 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
/*
* HSSFSheet.java
@@ -23,18 +21,19 @@
*/
package org.apache.poi.hssf.usermodel;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.io.PrintWriter;
-
+import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.util.Region;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
-import org.apache.poi.ddf.EscherRecord;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeMap;
/**
* High level representation of a worksheet.
@@ -73,9 +72,7 @@ public class HSSFSheet
*/
private Sheet sheet;
- // private TreeMap rows;
-// private RowRecordsAggregate rows;
-// private ValueRecordsAggregate vra;
+ private TreeMap rows;
private Workbook book;
private int firstrow;
private int lastrow;
@@ -92,7 +89,7 @@ public class HSSFSheet
protected HSSFSheet(Workbook book)
{
sheet = Sheet.createSheet();
- //rows = new TreeMap(); // new ArrayList(INITIAL_CAPACITY);
+ rows = new TreeMap(); // new ArrayList(INITIAL_CAPACITY);
this.book = book;
}
@@ -108,7 +105,7 @@ public class HSSFSheet
protected HSSFSheet(Workbook book, Sheet sheet)
{
this.sheet = sheet;
- //rows = new TreeMap();
+ rows = new TreeMap();
this.book = book;
setPropertiesFromSheet(sheet);
}
@@ -124,7 +121,7 @@ public class HSSFSheet
private void setPropertiesFromSheet(Sheet sheet)
{
-/* int sloc = sheet.getLoc();
+ int sloc = sheet.getLoc();
RowRecord row = sheet.getNextRow();
while (row != null)
@@ -133,13 +130,12 @@ public class HSSFSheet
row = sheet.getNextRow();
}
- sheet.setLoc(sloc);*/
-
- /*
+ sheet.setLoc(sloc);
CellValueRecordInterface cval = sheet.getNextValueRecord();
long timestart = System.currentTimeMillis();
- log.log(DEBUG, "Time at start of cell creating in HSSF sheet = ",
+ if (log.check( POILogger.DEBUG ))
+ log.log(DEBUG, "Time at start of cell creating in HSSF sheet = ",
new Long(timestart));
HSSFRow lastrow = null;
@@ -155,10 +151,12 @@ public class HSSFSheet
if ( hrow != null )
{
lastrow = hrow;
- log.log( DEBUG, "record id = " + Integer.toHexString( ( (Record) cval ).getSid() ) );
+ if (log.check( POILogger.DEBUG ))
+ log.log( DEBUG, "record id = " + Integer.toHexString( ( (Record) cval ).getSid() ) );
hrow.createCellFromRecord( cval );
cval = sheet.getNextValueRecord();
- log.log( DEBUG, "record took ",
+ if (log.check( POILogger.DEBUG ))
+ log.log( DEBUG, "record took ",
new Long( System.currentTimeMillis() - cellstart ) );
}
else
@@ -166,9 +164,9 @@ public class HSSFSheet
cval = null;
}
}
- */
-// log.log(DEBUG, "total sheet cell creation took ",
-// new Long(System.currentTimeMillis() - timestart));
+ if (log.check( POILogger.DEBUG ))
+ log.log(DEBUG, "total sheet cell creation took ",
+ new Long(System.currentTimeMillis() - timestart));
}
/**
@@ -179,8 +177,6 @@ public class HSSFSheet
* @see org.apache.poi.hssf.usermodel.HSSFRow
* @see #removeRow(HSSFRow)
*/
-
- //public HSSFRow createRow(short rownum)
public HSSFRow createRow(int rownum)
{
HSSFRow row = new HSSFRow(book, sheet, rownum);
@@ -196,13 +192,13 @@ public class HSSFSheet
* @return HSSFRow high level representation
*/
-/* private HSSFRow createRowFromRecord(RowRecord row)
+ private HSSFRow createRowFromRecord(RowRecord row)
{
HSSFRow hrow = new HSSFRow(book, sheet, row);
addRow(hrow, false);
return hrow;
- }*/
+ }
/**
* Remove a row from this sheet. All cells contained in the row are removed as well
@@ -213,35 +209,35 @@ public class HSSFSheet
public void removeRow(HSSFRow row)
{
sheet.setLoc(sheet.getDimsLoc());
-// if (rows.size() > 0)
-// {
-// rows.remove(row);
- // if (row.getRowNum() == getLastRowNum())
- // {
- // lastrow = findLastRow(lastrow);
- // }
- // if (row.getRowNum() == getFirstRowNum())
- // {
- // firstrow = findFirstRow(firstrow);
- // }
- //Iterator iter = row.cellIterator();
-
-/* while (iter.hasNext())
+ if (rows.size() > 0)
+ {
+ rows.remove(row);
+ if (row.getRowNum() == getLastRowNum())
+ {
+ lastrow = findLastRow(lastrow);
+ }
+ if (row.getRowNum() == getFirstRowNum())
+ {
+ firstrow = findFirstRow(firstrow);
+ }
+ Iterator iter = row.cellIterator();
+
+ while (iter.hasNext())
{
HSSFCell cell = (HSSFCell) iter.next();
sheet.removeValueRecord(row.getRowNum(),
cell.getCellValueRecord());
- }*/
+ }
sheet.removeRow(row.getRowRecord());
- //}
+ }
}
/**
* used internally to refresh the "last row" when the last row is removed.
*/
-/* private int findLastRow(int lastrow)
+ private int findLastRow(int lastrow)
{
int rownum = lastrow - 1;
HSSFRow r = getRow(rownum);
@@ -251,13 +247,13 @@ public class HSSFSheet
r = getRow(--rownum);
}
return rownum;
- }*/
+ }
/**
* used internally to refresh the "first row" when the first row is removed.
*/
- /*private int findFirstRow(int firstrow)
+ private int findFirstRow(int firstrow)
{
int rownum = firstrow + 1;
HSSFRow r = getRow(rownum);
@@ -271,7 +267,7 @@ public class HSSFSheet
return -1;
return rownum;
- } */
+ }
/**
* add a row to the sheet
@@ -281,22 +277,19 @@ public class HSSFSheet
private void addRow(HSSFRow row, boolean addLow)
{
- //rows.put(row, row);
- if (addLow) {
- RowRecord rec = sheet.getRow(row.getRowNum());
- if (rec == null) {
- rec = new RowRecord();
- sheet.addRow(sheet.createRow(row.getRowNum()));
- }
+ rows.put(row, row);
+ if (addLow)
+ {
+ sheet.addRow(row.getRowRecord());
}
-/* if (row.getRowNum() > getLastRowNum())
+ if (row.getRowNum() > getLastRowNum())
{
lastrow = row.getRowNum();
}
if (row.getRowNum() < getFirstRowNum())
{
firstrow = row.getRowNum();
- }*/
+ }
}
/**
@@ -308,9 +301,11 @@ public class HSSFSheet
public HSSFRow getRow(int rownum)
{
- HSSFRow retval = new HSSFRow(book, sheet, this.sheet.getRow(rownum));
+ HSSFRow row = new HSSFRow();
- return retval;
+ //row.setRowNum((short) rownum);
+ row.setRowNum( rownum);
+ return (HSSFRow) rows.get(row);
}
/**
@@ -319,7 +314,7 @@ public class HSSFSheet
public int getPhysicalNumberOfRows()
{
- return sheet.getPhysicalNumberOfRows();
+ return rows.size();
}
/**
@@ -329,7 +324,7 @@ public class HSSFSheet
public int getFirstRowNum()
{
- return sheet.getFirstRow();
+ return firstrow;
}
/**
@@ -339,7 +334,7 @@ public class HSSFSheet
public int getLastRowNum()
{
- return sheet.getLastRow();
+ return lastrow;
}
/**
@@ -556,7 +551,7 @@ public class HSSFSheet
public Iterator rowIterator()
{
- return new SheetRowIterator(this, this.book);
+ return rows.values().iterator();
}
/**
@@ -777,60 +772,82 @@ public class HSSFSheet
* @param newPrintGridlines boolean to turn on or off the printing of
* gridlines
*/
- public void setPrintGridlines(boolean newPrintGridlines) {
- getSheet().getPrintGridlines().setPrintGridlines(newPrintGridlines);
+ public void setPrintGridlines( boolean newPrintGridlines )
+ {
+ getSheet().getPrintGridlines().setPrintGridlines( newPrintGridlines );
}
/**
* Gets the print setup object.
* @return The user model for the print setup object.
*/
- public HSSFPrintSetup getPrintSetup() {
- return new HSSFPrintSetup(getSheet().getPrintSetup());
+ public HSSFPrintSetup getPrintSetup()
+ {
+ return new HSSFPrintSetup( getSheet().getPrintSetup() );
}
/**
* Gets the user model for the document header.
* @return The Document header.
*/
- public HSSFHeader getHeader() {
- return new HSSFHeader(getSheet().getHeader());
+ public HSSFHeader getHeader()
+ {
+ return new HSSFHeader( getSheet().getHeader() );
}
/**
* Gets the user model for the document footer.
* @return The Document footer.
*/
- public HSSFFooter getFooter() {
- return new HSSFFooter(getSheet().getFooter());
- }
-
- /**
- * Sets whether sheet is selected.
- * @param sel Whether to select the sheet or deselect the sheet.
- */
- public void setSelected(boolean sel) {
- getSheet().setSelected(sel);
- }
-
- /**
- * Gets the size of the margin in inches.
- * @param margin which margin to get
- * @return the size of the margin
- */
- public double getMargin(short margin) {
- return getSheet().getMargin(margin);
- }
-
- /**
- * Sets the size of the margin in inches.
- * @param margin which margin to get
- * @param size the size of the margin
- */
- public void setMargin(short margin, double size) {
- getSheet().setMargin(margin, size);
- }
+ public HSSFFooter getFooter()
+ {
+ return new HSSFFooter( getSheet().getFooter() );
+ }
+
+ /**
+ * Sets whether sheet is selected.
+ * @param sel Whether to select the sheet or deselect the sheet.
+ */
+ public void setSelected( boolean sel )
+ {
+ getSheet().setSelected( sel );
+ }
+
+ /**
+ * Gets the size of the margin in inches.
+ * @param margin which margin to get
+ * @return the size of the margin
+ */
+ public double getMargin( short margin )
+ {
+ return getSheet().getMargin( margin );
+ }
+
+ /**
+ * Sets the size of the margin in inches.
+ * @param margin which margin to get
+ * @param size the size of the margin
+ */
+ public void setMargin( short margin, double size )
+ {
+ getSheet().setMargin( margin, size );
+ }
+ /**
+ * Answer whether protection is enabled or disabled
+ * @return true => protection enabled; false => protection disabled
+ */
+ public boolean getProtect() {
+ return getSheet().getProtect().getProtect();
+ }
+
+ /**
+ * Sets the protection on enabled or disabled
+ * @param protect true => protection enabled; false => protection disabled
+ */
+ public void setProtect(boolean protect) {
+ getSheet().getProtect().setProtect(protect);
+ }
/**
* Sets the zoom magnication for the sheet. The zoom is expressed as a
@@ -852,22 +869,6 @@ public class HSSFSheet
sclRecord.setDenominator((short)denominator);
getSheet().setSCLRecord(sclRecord);
}
-
- /**
- * Answer whether protection is enabled or disabled
- * @return true => protection enabled; false => protection disabled
- */
- public boolean getProtect() {
- return getSheet().getProtect().getProtect();
- }
-
- /**
- * Sets the protection on enabled or disabled
- * @param protect true => protection enabled; false => protection disabled
- */
- public void setProtect(boolean protect) {
- getSheet().getProtect().setProtect(protect);
- }
/**
* Shifts the merged regions left or right depending on mode
@@ -877,40 +878,40 @@ public class HSSFSheet
* @param endRow
* @param n
* @param isRow
- */
+ */
protected void shiftMerged(int startRow, int endRow, int n, boolean isRow) {
List shiftedRegions = new ArrayList();
//move merged regions completely if they fall within the new region boundaries when they are shifted
for (int i = 0; i < this.getNumMergedRegions(); i++) {
Region merged = this.getMergedRegionAt(i);
-
+
boolean inStart = (merged.getRowFrom() >= startRow || merged.getRowTo() >= startRow);
boolean inEnd = (merged.getRowTo() <= endRow || merged.getRowFrom() <= endRow);
-
+
//dont check if it's not within the shifted area
if (! (inStart && inEnd)) continue;
-
- //only shift if the region outside the shifted rows is not merged too
+
+ //only shift if the region outside the shifted rows is not merged too
if (!merged.contains(startRow-1, (short)0) && !merged.contains(endRow+1, (short)0)){
- merged.setRowFrom(merged.getRowFrom()+n);
+ merged.setRowFrom(merged.getRowFrom()+n);
merged.setRowTo(merged.getRowTo()+n);
//have to remove/add it back
shiftedRegions.add(merged);
this.removeMergedRegion(i);
i = i -1; // we have to back up now since we removed one
-
+
}
-
+
}
-
+
//readd so it doesn't get shifted again
Iterator iterator = shiftedRegions.iterator();
while (iterator.hasNext()) {
Region region = (Region)iterator.next();
-
+
this.addMergedRegion(region);
}
-
+
}
/**
@@ -935,13 +936,12 @@ public class HSSFSheet
* Shifts rows between startRow and endRow n number of rows.
* If you use a negative number, it will shift rows up.
* Code ensures that rows don't wrap around
- *
+ *
* <p>
* Additionally shifts merged regions that are completely defined in these
* rows (ie. merged 2 cells on a row to be shifted).
* <p>
- * TODO Might want to add bounds checking here
- *
+ * TODO Might want to add bounds checking here
* @param startRow the row to start shifting
* @param endRow the row to end shifting
* @param n the number of rows to shift
@@ -964,19 +964,19 @@ public class HSSFSheet
inc = -1;
}
- shiftMerged(startRow, endRow, n, true);
- sheet.shiftRowBreaks(startRow, endRow, n);
-
+ shiftMerged(startRow, endRow, n, true);
+ sheet.shiftRowBreaks(startRow, endRow, n);
+
for ( int rowNum = s; rowNum >= startRow && rowNum <= endRow && rowNum >= 0 && rowNum < 65536; rowNum += inc )
{
HSSFRow row = getRow( rowNum );
- HSSFRow row2Replace = getRow( rowNum + n );
+ HSSFRow row2Replace = getRow( rowNum + n );
if ( row2Replace == null )
row2Replace = createRow( rowNum + n );
-
+
HSSFCell cell;
-
+
// Removes the cells before over writting them.
@@ -991,10 +991,10 @@ public class HSSFSheet
if (copyRowHeight) {
row2Replace.setHeight(row.getHeight());
}
-
+
if (resetOriginalRowHeight) {
row.setHeight((short)0xff);
- }
+ }
}
for ( short col = row.getFirstCellNum(); col <= row.getLastCellNum(); col++ )
{
@@ -1092,7 +1092,7 @@ public class HSSFSheet
* @return whether formulas are displayed
*/
public boolean isDisplayFormulas() {
- return sheet.isDisplayFormulas();
+ return sheet.isDisplayFormulas();
}
/**
@@ -1108,9 +1108,9 @@ public class HSSFSheet
* @return whether RowColHeadings are displayed
*/
public boolean isDisplayRowColHeadings() {
- return sheet.isDisplayRowColHeadings();
+ return sheet.isDisplayRowColHeadings();
}
-
+
/**
* Sets a page break at the indicated row
* @param row
@@ -1128,7 +1128,7 @@ public class HSSFSheet
public boolean isRowBroken(int row) {
return sheet.isRowBroken(row);
}
-
+
/**
* Removes the page break at the indicated row
* @param row
@@ -1136,13 +1136,13 @@ public class HSSFSheet
public void removeRowBreak(int row) {
sheet.removeRowBreak(row);
}
-
+
/**
* Retrieves all the horizontal page breaks
* @return
*/
public int[] getRowBreaks(){
- //we can probably cache this information, but this should be a sparsely used function
+ //we can probably cache this information, but this should be a sparsely used function
int[] returnValue = new int[sheet.getNumRowBreaks()];
Iterator iterator = sheet.getRowBreaks();
int i = 0;
@@ -1158,7 +1158,7 @@ public class HSSFSheet
* @return
*/
public short[] getColumnBreaks(){
- //we can probably cache this information, but this should be a sparsely used function
+ //we can probably cache this information, but this should be a sparsely used function
short[] returnValue = new short[sheet.getNumColumnBreaks()];
Iterator iterator = sheet.getColumnBreaks();
int i = 0;
@@ -1168,8 +1168,8 @@ public class HSSFSheet
}
return returnValue;
}
-
-
+
+
/**
* Sets a page break at the indicated column
* @param column
@@ -1187,7 +1187,7 @@ public class HSSFSheet
public boolean isColumnBroken(short column) {
return sheet.isColumnBroken(column);
}
-
+
/**
* Removes a page break at the indicated column
* @param column
@@ -1195,7 +1195,7 @@ public class HSSFSheet
public void removeColumnBreak(short column) {
sheet.removeColumnBreak(column);
}
-
+
/**
* Runs a bounds check for row numbers
* @param row
@@ -1204,7 +1204,7 @@ public class HSSFSheet
if (row > 65535) throw new IllegalArgumentException("Maximum row number is 65535");
if (row < 0) throw new IllegalArgumentException("Minumum row number is 0");
}
-
+
/**
* Runs a bounds check for column numbers
* @param column
@@ -1253,32 +1253,47 @@ public class HSSFSheet
return patriarch;
}
-}
+ /**
+ * Expands or collapses a column group.
+ *
+ * @param columnNumber One of the columns in the group.
+ * @param collapsed true = collapse group, false = expand group.
+ */
+ public void setColumnGroupCollapsed( short columnNumber, boolean collapsed )
+ {
+ sheet.setColumnGroupCollapsed( columnNumber, collapsed );
+ }
-class SheetRowIterator implements Iterator {
- Iterator rows;
- Workbook book;
- Sheet sheet;
+ /**
+ * Create an outline for the provided column range.
+ *
+ * @param fromColumn beginning of the column range.
+ * @param toColumn end of the column range.
+ */
+ public void groupColumn(short fromColumn, short toColumn)
+ {
+ sheet.groupColumnRange( fromColumn, toColumn, true );
+ }
- public SheetRowIterator(HSSFSheet sheet, Workbook book) {
- this.sheet = sheet.getSheet();
- this.book = book;
- rows = this.sheet.rowRecordIterator();
+ public void ungroupColumn( short fromColumn, short toColumn )
+ {
+ sheet.groupColumnRange( fromColumn, toColumn, false );
}
- public boolean hasNext() {
- return rows.hasNext();
+ public void groupRow(int fromRow, int toRow)
+ {
+ sheet.groupRowRange( fromRow, toRow, true );
}
- public Object next() {
- HSSFRow retval = null;
- if (rows.hasNext()) {
- retval = new HSSFRow(book, sheet, (RowRecord)rows.next());
- }
- return retval;
+ public void ungroupRow(int fromRow, int toRow)
+ {
+ sheet.groupRowRange( fromRow, toRow, false );
}
- public void remove() {
- rows.remove();
+ public void setRowGroupCollapsed( int row, boolean collapse )
+ {
+ sheet.setRowGroupCollapsed( row, collapse );
}
+
+
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
index 4f51233678..9969cdcdad 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java b/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
index 8f9d21ed06..e357ba9495 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
index 4b93d1b12d..f4f8002d91 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
/*
* HSSFWorkbook.java
@@ -23,7 +22,15 @@
*/
package org.apache.poi.hssf.usermodel;
-import org.apache.poi.util.POILogFactory;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+
import org.apache.poi.hssf.eventmodel.EventRecordFactory;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook;
@@ -37,17 +44,9 @@ import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Stack;
-
/**
* High level representation of a workbook. This is the first object most users
* will construct whether they are reading or writing a workbook. It is also the
@@ -86,16 +85,16 @@ public class HSSFWorkbook
*/
private ArrayList sheets;
-
+
/**
* this holds the HSSFName objects attached to this workbook
*/
private ArrayList names;
-
+
/**
* holds whether or not to preserve other nodes in the POIFS. Used
- * for macros and embedded objects.
+ * for macros and embedded objects.
*/
private boolean preserveNodes;
@@ -112,7 +111,7 @@ public class HSSFWorkbook
* someplace else.
*/
private HSSFDataFormat formatter;
-
+
private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class);
/**
@@ -136,7 +135,7 @@ public class HSSFWorkbook
* low level models. If you're reading in a workbook...start here.
*
* @param fs the POI filesystem that contains the Workbook stream.
- * @param preserveNodes whether to preseve other nodes, such as
+ * @param preserveNodes whether to preseve other nodes, such as
* macros. This takes more memory, so only say yes if you
* need to.
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem
@@ -147,16 +146,20 @@ public class HSSFWorkbook
throws IOException
{
this.preserveNodes = preserveNodes;
-
+
if (preserveNodes) {
- this.poifs = fs;
+ this.poifs = fs;
}
sheets = new ArrayList(INITIAL_CAPACITY);
names = new ArrayList(INITIAL_CAPACITY);
-
+
InputStream stream = fs.createDocumentInputStream("Workbook");
-
+
+ EventRecordFactory factory = new EventRecordFactory();
+
+
+
List records = RecordFactory.createRecords(stream);
workbook = Workbook.createWorkbook(records);
@@ -177,7 +180,7 @@ public class HSSFWorkbook
// workbook.setSheetName(sheets.size() -1, "Sheet"+sheets.size());
}
-
+
for (int i = 0 ; i < workbook.getNumNames() ; ++i){
HSSFName name = new HSSFName(workbook, workbook.getNameRecord(i));
names.add(name);
@@ -193,7 +196,7 @@ public class HSSFWorkbook
* inputstream.
*
* @param s the POI filesystem that contains the Workbook stream.
- * @param preserveNodes whether to preseve other nodes, such as
+ * @param preserveNodes whether to preseve other nodes, such as
* macros. This takes more memory, so only say yes if you
* need to.
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem
@@ -217,28 +220,28 @@ public class HSSFWorkbook
// none currently
}
-
+
/**
* sets the order of appearance for a given sheet.
*
* @param sheetname the name of the sheet to reorder
* @param pos the position that we want to insert the sheet into (0 based)
*/
-
+
public void setSheetOrder(String sheetname, int pos ) {
workbook.setSheetOrder(sheetname, pos);
}
-
+
public final static byte ENCODING_COMPRESSED_UNICODE = 0;
public final static byte ENCODING_UTF_16 = 1;
-
-
+
+
/**
* set the sheet name.
* Will throw IllegalArgumentException if the name is greater than 31 chars
* or contains /\?*[]
- * @param sheet sheet number (0 based)
- * @param name sheet name
+ * @param sheet number (0 based)
+ * @param sheet name
*/
public void setSheetName(int sheet, String name)
@@ -252,17 +255,17 @@ public class HSSFWorkbook
{
throw new RuntimeException("Sheet out of bounds");
}
-
+
switch ( encoding ) {
case ENCODING_COMPRESSED_UNICODE:
case ENCODING_UTF_16:
break;
-
+
default:
// TODO java.io.UnsupportedEncodingException
throw new RuntimeException( "Unsupported encoding" );
}
-
+
workbook.setSheetName( sheet, name, encoding );
}
@@ -290,14 +293,14 @@ public class HSSFWorkbook
/** Returns the index of the sheet by his name
* @param name the sheet name
* @return index of the sheet (0 based)
- */
+ */
public int getSheetIndex(String name)
{
int retval = workbook.getSheetIndex(name);
-
+
return retval;
}
-
+
/**
* create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
* the high level representation. Use this to create new sheets.
@@ -505,16 +508,16 @@ public class HSSFWorkbook
if (removingRange )
{
if (nameRecord != null)
- workbook.removeName(findExistingRowColHeaderNameRecordIdx(sheetIndex));
+ workbook.removeName(findExistingRowColHeaderNameRecordIdx(sheetIndex+1));
return;
}
if ( nameRecord == null )
{
- nameRecord = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_TITLE, externSheetIndex+1);
+ nameRecord = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_TITLE, sheetIndex+1);
//does a lot of the house keeping for builtin records, like setting lengths to zero etc
isNewRecord = true;
}
-
+
short definitionTextLength = settingRowAndColumn ? (short)0x001a : (short)0x000b;
nameRecord.setDefinitionTextLength(definitionTextLength);
@@ -728,10 +731,10 @@ public class HSSFWorkbook
{
byte[] bytes = getBytes();
POIFSFileSystem fs = new POIFSFileSystem();
-
+
fs.createDocument(new ByteArrayInputStream(bytes), "Workbook");
- if (preserveNodes) {
+ if (preserveNodes) {
List excepts = new ArrayList(1);
excepts.add("Workbook");
copyNodes(this.poifs,fs,excepts);
@@ -756,6 +759,12 @@ public class HSSFWorkbook
{
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "HSSFWorkbook.getBytes()");
+
+ // before getting the workbook size we must tell the sheets that
+ // serialization is about to occur.
+ for (int k = 0; k < sheets.size(); k++)
+ ((HSSFSheet) sheets.get(k)).getSheet().preSerialize();
+
int wbsize = workbook.getSize();
// log.debug("REMOVEME: old sizing method "+workbook.serialize().length);
@@ -765,10 +774,10 @@ public class HSSFWorkbook
for (int k = 0; k < sheets.size(); k++)
{
workbook.setSheetBof(k, totalsize);
-
- // sheetbytes.add((( HSSFSheet ) sheets.get(k)).getSheet().getSize());
totalsize += ((HSSFSheet) sheets.get(k)).getSheet().getSize();
}
+
+
/* if (totalsize < 4096)
{
totalsize = 4096;
@@ -806,61 +815,61 @@ public class HSSFWorkbook
{
return workbook;
}
-
+
/** gets the total number of named ranges in the workboko
* @return number of named ranges
- */
+ */
public int getNumberOfNames(){
int result = names.size();
return result;
}
-
+
/** gets the Named range
* @param index position of the named range
* @return named range high level
- */
+ */
public HSSFName getNameAt(int index){
HSSFName result = (HSSFName) names.get(index);
-
+
return result;
}
-
+
/** gets the named range name
* @param index the named range index (0 based)
* @return named range name
- */
+ */
public String getNameName(int index){
String result = getNameAt(index).getNameName();
-
+
return result;
}
-
+
/**
* Sets the printarea for the sheet provided
* <p>
* i.e. Reference = $A$1:$B$2
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
- * @param reference Valid name Reference for the Print Area
+ * @param reference Valid name Reference for the Print Area
*/
public void setPrintArea(int sheetIndex, String reference)
{
NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
-
+
if (name == null)
name = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
//adding one here because 0 indicates a global named region; doesnt make sense for print areas
-
+
short externSheetIndex = getWorkbook().checkExternSheet(sheetIndex);
- name.setExternSheetNumber(externSheetIndex);
+ name.setExternSheetNumber(externSheetIndex);
name.setAreaReference(reference);
-
-
+
+
}
-
+
/**
* For the Convenience of Java Programmers maintaining pointers.
- * @see #setPrintArea(int, String)
+ * @see setPrintArea(int, String)
* @param sheetIndex Zero-based sheet index (0 = First Sheet)
* @param startColumn Column to begin printarea
* @param endColumn Column to end the printarea
@@ -869,57 +878,57 @@ public class HSSFWorkbook
*/
public void setPrintArea(int sheetIndex, int startColumn, int endColumn,
int startRow, int endRow) {
-
- //using absolute references because they dont get copied and pasted anyway
+
+ //using absolute references because they dont get copied and pasted anyway
CellReference cell = new CellReference(startRow, startColumn, true, true);
String reference = cell.toString();
-
+
cell = new CellReference(endRow, endColumn, true, true);
reference = reference+":"+cell.toString();
-
- setPrintArea(sheetIndex, reference);
+
+ setPrintArea(sheetIndex, reference);
}
-
-
+
+
/**
* Retrieves the reference for the printarea of the specified sheet, the sheet name is appended to the reference even if it was not specified.
- * @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
+ * @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
* @return String Null if no print area has been defined
- */
+ */
public String getPrintArea(int sheetIndex)
{
- NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
+ NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
if (name == null) return null;
//adding one here because 0 indicates a global named region; doesnt make sense for print areas
-
+
return name.getAreaReference(workbook);
- }
-
+ }
+
/**
* Delete the printarea for the sheet specified
* @param sheetIndex Zero-based sheet index (0 = First Sheet)
*/
public void removePrintArea(int sheetIndex) {
- getWorkbook().removeBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
+ getWorkbook().removeBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
}
-
+
/** creates a new named range and add it to the model
* @return named range high level
- */
+ */
public HSSFName createName(){
NameRecord nameRecord = workbook.createName();
-
+
HSSFName newName = new HSSFName(workbook, nameRecord);
-
+
names.add(newName);
-
- return newName;
+
+ return newName;
}
-
+
/** gets the named range index by his name
* @param name named range name
- * @return named range index
- */
+ * @return named range index
+ */
public int getNameIndex(String name)
{
int retval = -1;
@@ -940,10 +949,10 @@ public class HSSFWorkbook
/** remove the named range by his index
* @param index named range index (0 based)
- */
+ */
public void removeName(int index){
names.remove(index);
- workbook.removeName(index);
+ workbook.removeName(index);
}
/**
@@ -957,29 +966,29 @@ public class HSSFWorkbook
formatter = new HSSFDataFormat(workbook);
return formatter;
}
-
+
/** remove the named range by his name
* @param name named range name
- */
+ */
public void removeName(String name){
int index = getNameIndex(name);
-
- removeName(index);
-
+
+ removeName(index);
+
}
public HSSFPalette getCustomPalette()
{
return new HSSFPalette(workbook.getCustomPalette());
}
-
+
/**
* Copies nodes from one POIFS to the other minus the excepts
* @param source is the source POIFS to copy from
- * @param target is the target POIFS to copy to
- * @param excepts is a list of Strings specifying what nodes NOT to copy
+ * @param target is the target POIFS to copy to
+ * @param excepts is a list of Strings specifying what nodes NOT to copy
*/
- private void copyNodes(POIFSFileSystem source, POIFSFileSystem target,
+ private void copyNodes(POIFSFileSystem source, POIFSFileSystem target,
List excepts) throws IOException {
//System.err.println("CopyNodes called");
@@ -987,13 +996,13 @@ public class HSSFWorkbook
DirectoryEntry newRoot = target.getRoot();
Iterator entries = root.getEntries();
-
+
while (entries.hasNext()) {
Entry entry = (Entry)entries.next();
if (!isInList(entry.getName(), excepts)) {
copyNodeRecursively(entry,newRoot);
}
- }
+ }
}
private boolean isInList(String entry, List list) {
@@ -1005,18 +1014,18 @@ public class HSSFWorkbook
return false;
}
- private void copyNodeRecursively(Entry entry, DirectoryEntry target)
+ private void copyNodeRecursively(Entry entry, DirectoryEntry target)
throws IOException {
//System.err.println("copyNodeRecursively called with "+entry.getName()+
// ","+target.getName());
- DirectoryEntry newTarget = null;
+ DirectoryEntry newTarget = null;
if (entry.isDirectoryEntry()) {
newTarget = target.createDirectory(entry.getName());
Iterator entries = ((DirectoryEntry)entry).getEntries();
while (entries.hasNext()) {
copyNodeRecursively((Entry)entries.next(),newTarget);
- }
+ }
} else {
DocumentEntry dentry = (DocumentEntry)entry;
DocumentInputStream dstream = new DocumentInputStream(dentry);
@@ -1025,6 +1034,7 @@ public class HSSFWorkbook
}
}
+ /** Test only. Do not use */
public void insertChartRecord()
{
int loc = workbook.findFirstRecordLocBySid(SSTRecord.sid);
diff --git a/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java b/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
index f5fb909229..23f0b0cf19 100644
--- a/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
+++ b/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
@@ -1,6 +1,5 @@
-
/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
+ Copyright 2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel;
import java.util.*;
diff --git a/src/java/org/apache/poi/hssf/usermodel/package.html b/src/java/org/apache/poi/hssf/usermodel/package.html
index bf30a9b1cb..36add03e01 100755
--- a/src/java/org/apache/poi/hssf/usermodel/package.html
+++ b/src/java/org/apache/poi/hssf/usermodel/package.html
@@ -15,6 +15,7 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
+@see org.apache.poi.hssf
@see org.apache.poi.hssf.eventmodel
</body>
</html>
diff --git a/src/java/org/apache/poi/hssf/util/AreaReference.java b/src/java/org/apache/poi/hssf/util/AreaReference.java
index 654bea1e52..f9c5e80fd6 100644
--- a/src/java/org/apache/poi/hssf/util/AreaReference.java
+++ b/src/java/org/apache/poi/hssf/util/AreaReference.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.util;
@@ -78,4 +77,4 @@ private int dim;
}
return retval;
}
-}
+} \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/util/CellReference.java b/src/java/org/apache/poi/hssf/util/CellReference.java
index efe06b1646..623f8175a1 100644
--- a/src/java/org/apache/poi/hssf/util/CellReference.java
+++ b/src/java/org/apache/poi/hssf/util/CellReference.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.util;
diff --git a/src/java/org/apache/poi/hssf/util/HSSFColor.java b/src/java/org/apache/poi/hssf/util/HSSFColor.java
index d85a4d4cbb..95df2bba78 100644
--- a/src/java/org/apache/poi/hssf/util/HSSFColor.java
+++ b/src/java/org/apache/poi/hssf/util/HSSFColor.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.util;
diff --git a/src/java/org/apache/poi/hssf/util/RKUtil.java b/src/java/org/apache/poi/hssf/util/RKUtil.java
index 664fc61bdf..018744b152 100644
--- a/src/java/org/apache/poi/hssf/util/RKUtil.java
+++ b/src/java/org/apache/poi/hssf/util/RKUtil.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.util;
diff --git a/src/java/org/apache/poi/hssf/util/RangeAddress.java b/src/java/org/apache/poi/hssf/util/RangeAddress.java
index bd85aa8992..f2daf6a513 100644
--- a/src/java/org/apache/poi/hssf/util/RangeAddress.java
+++ b/src/java/org/apache/poi/hssf/util/RangeAddress.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.util;
diff --git a/src/java/org/apache/poi/hssf/util/Region.java b/src/java/org/apache/poi/hssf/util/Region.java
index 46af38c7c6..7906a2a6f3 100644
--- a/src/java/org/apache/poi/hssf/util/Region.java
+++ b/src/java/org/apache/poi/hssf/util/Region.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.util;
@@ -153,7 +152,7 @@ public class Region
/**
* Answers: "is the row/column inside this range?"
*
- * @return true if the cell is in the range and false if it is not
+ * @returns boolean - true if the cell is in the range and false if it is not
*/
public boolean contains(int row, short col)
@@ -209,7 +208,7 @@ public class Region
}
/**
- * @return the area contained by this region (number of cells)
+ * @returns the area contained by this region (number of cells)
*/
public int getArea()
diff --git a/src/java/org/apache/poi/hssf/util/SheetReferences.java b/src/java/org/apache/poi/hssf/util/SheetReferences.java
index d3f8bbf7f8..275b637aac 100644
--- a/src/java/org/apache/poi/hssf/util/SheetReferences.java
+++ b/src/java/org/apache/poi/hssf/util/SheetReferences.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -14,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.util;
diff --git a/src/java/org/apache/poi/hssf/util/package.html b/src/java/org/apache/poi/hssf/util/package.html
index fb7112a928..2eb3f97cbb 100755
--- a/src/java/org/apache/poi/hssf/util/package.html
+++ b/src/java/org/apache/poi/hssf/util/package.html
@@ -16,6 +16,6 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
-@see org.apache.poi.hssf.usermodel
+@see org.apache.poi.usermodel
</body>
</html>
diff --git a/src/java/org/apache/poi/poifs/common/package.html b/src/java/org/apache/poi/poifs/common/package.html
index 1728888ccc..0f78cd59e8 100755
--- a/src/java/org/apache/poi/poifs/common/package.html
+++ b/src/java/org/apache/poi/poifs/common/package.html
@@ -15,6 +15,7 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
+@see org.apache.poi.hssf
@see org.apache.poi.hpsf
</body>
</html>
diff --git a/src/java/org/apache/poi/poifs/dev/package.html b/src/java/org/apache/poi/poifs/dev/package.html
index 31e6903979..4284e2c4e6 100755
--- a/src/java/org/apache/poi/poifs/dev/package.html
+++ b/src/java/org/apache/poi/poifs/dev/package.html
@@ -16,5 +16,6 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
+@see org.apache.poi.poifs
</body>
</html>
diff --git a/src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java b/src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java
index e10f28a294..f22f4d330c 100644
--- a/src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java
+++ b/src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java
@@ -226,9 +226,9 @@ public class POIFSDocumentPath
* <p>Returns the path's parent or <code>null</code> if this path
* is the root path.</p>
*
- * @return path of parent, or null if this path is the root path
- *
+ * @author Rainer Klute (klute@rainer-klute.de)
* @since 2002-01-24
+ * @return path of parent, or null if this path is the root path
*/
public POIFSDocumentPath getParent()
@@ -250,9 +250,10 @@ public class POIFSDocumentPath
* <p>Returns a string representation of the path. Components are
* separated by the platform-specific file separator.</p>
*
- * @return string representation
- *
+ * @author Rainer Klute (klute@rainer-klute.de)
* @since 2002-01-24
+ *
+ * @return string representation
*/
public String toString()
diff --git a/src/java/org/apache/poi/poifs/storage/package.html b/src/java/org/apache/poi/poifs/storage/package.html
index b6740daeff..3aaca0fdef 100755
--- a/src/java/org/apache/poi/poifs/storage/package.html
+++ b/src/java/org/apache/poi/poifs/storage/package.html
@@ -16,6 +16,7 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
+@see org.apache.poi.poifs
@see org.apache.poi.poifs.filesystem
</body>
</html>
diff --git a/src/java/org/apache/poi/util/POILogger.java b/src/java/org/apache/poi/util/POILogger.java
index b4a89409b9..b5e9778202 100644
--- a/src/java/org/apache/poi/util/POILogger.java
+++ b/src/java/org/apache/poi/util/POILogger.java
@@ -44,7 +44,6 @@ public abstract class POILogger
* package scope so it cannot be instantiated outside of the util
* package. You need a POILogger? Go to the POILogFactory for one
*
- * @param log the object that does the real work of logging
*/
POILogger()
{}
diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java
index d66280c24b..cf84496ac7 100644
--- a/src/java/org/apache/poi/util/StringUtil.java
+++ b/src/java/org/apache/poi/util/StringUtil.java
@@ -18,9 +18,8 @@
package org.apache.poi.util;
import java.io.UnsupportedEncodingException;
-import java.text.NumberFormat;
import java.text.FieldPosition;
-import java.util.Arrays;
+import java.text.NumberFormat;
/**
* Title: String Utility Description: Collection of string handling utilities
*
@@ -45,16 +44,16 @@ public class StringUtil {
*
* { 0x16, 0x00 } -0x16
*
- *@param string the byte array to be converted
- *@param offset the initial offset into the
- * byte array. it is assumed that string[ offset ] and string[ offset +
- * 1 ] contain the first 16-bit unicode character
- *@param len the length of the final string
- *@return the converted string
- *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for
+ * @param string the byte array to be converted
+ * @param offset the initial offset into the
+ * byte array. it is assumed that string[ offset ] and string[ offset +
+ * 1 ] contain the first 16-bit unicode character
+ * @param len the length of the final string
+ * @return the converted string
+ * @exception ArrayIndexOutOfBoundsException if offset is out of bounds for
* the byte array (i.e., is negative or is greater than or equal to
* string.length)
- *@exception IllegalArgumentException if len is too large (i.e.,
+ * @exception IllegalArgumentException if len is too large (i.e.,
* there is not enough data in string to create a String of that
* length)
*/
diff --git a/src/java/org/apache/poi/util/package.html b/src/java/org/apache/poi/util/package.html
index 7f573b5ff8..92cec45c20 100755
--- a/src/java/org/apache/poi/util/package.html
+++ b/src/java/org/apache/poi/util/package.html
@@ -16,6 +16,7 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul>
<!-- Put @see and @since tags down here. -->
+@see org.apache.poi.hssf
@see org.apache.poi.hpsf
</body>
</html>