Merged REL_2_BRANCH to head.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353586 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2004-08-23 08:52:54 +00:00
parent f94bad29e3
commit eeef2a1b12
188 changed files with 4072 additions and 3775 deletions

3
NOTICE Normal file
View File

@ -0,0 +1,3 @@
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).

View File

@ -643,9 +643,45 @@ FORREST_HOME environment variable!</echo>
description="Generates the documentation and reports"/> description="Generates the documentation and reports"/>
<target name="jar" depends="compile" description="Creates jar files for distribution"> <target name="jar" depends="compile" description="Creates jar files for distribution">
<jar basedir="${main.output.dir}" destfile="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar"/> <jar basedir="${main.output.dir}" destfile="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar">
<jar basedir="${contrib.output.dir}" destfile="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar"/> <manifest>
<jar basedir="${scratchpad.output.dir}" destfile="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar"/> <attribute name="Built-By" value="${user.name}"/>
<section name="common">
<attribute name="Specification-Title" value="Jakarta POI"/>
<attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
<attribute name="Specification-Vendor" value="Apache"/>
<attribute name="Implementation-Title" value="Jakarta POI"/>
<attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
<attribute name="Implementation-Vendor" value="Apache"/>
</section>
</manifest>
</jar>
<jar basedir="${contrib.output.dir}" destfile="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<section name="common">
<attribute name="Specification-Title" value="Jakarta POI"/>
<attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
<attribute name="Specification-Vendor" value="Apache"/>
<attribute name="Implementation-Title" value="Jakarta POI"/>
<attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
<attribute name="Implementation-Vendor" value="Apache"/>
</section>
</manifest>
</jar>
<jar basedir="${scratchpad.output.dir}" destfile="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<section name="common">
<attribute name="Specification-Title" value="Jakarta POI"/>
<attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
<attribute name="Specification-Vendor" value="Apache"/>
<attribute name="Implementation-Title" value="Jakarta POI"/>
<attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
<attribute name="Implementation-Vendor" value="Apache"/>
</section>
</manifest>
</jar>
</target> </target>
<target name="dist" depends="compile,site,jar" description="Creates the entire distribution into build/dist"> <target name="dist" depends="compile,site,jar" description="Creates the entire distribution into build/dist">

View File

@ -421,7 +421,7 @@ most likely fail. No big deal. </li>
</ul> </ul>
</section> </section>
<section><title>Logging facility</title> <section><title>Logging facility</title>
<p>POI can dynamically select it's logging implementation. POI tries to <p>POI can dynamically select its logging implementation. POI tries to
create a logger using the System property named "org.apache.poi.util.POILogger". create a logger using the System property named "org.apache.poi.util.POILogger".
Out of the box this can be set to one of three values: Out of the box this can be set to one of three values:
</p> </p>
@ -477,9 +477,7 @@ yet. When it does something, we'll document it.</p>
<p>Further effort on HSSF is going to focus on the following major areas: </p> <p>Further effort on HSSF is going to focus on the following major areas: </p>
<ul> <ul>
<li>Performance: A lot of work is going on in CVS and mailing lists for greatly improving the <li>Performance: POI currently uses a lot of memory for large sheets.</li>
memory efficiency of POI, as well as improving speed. Many approaches have been suggested, and a lot of code as been written.
It now needs a lot of testing and bugfixing. </li>
<li>Charts: This is a hard problem, with very little documentation.</li> <li>Charts: This is a hard problem, with very little documentation.</li>
</ul> </ul>
<p><link href="../getinvolved/index.html"> So jump in! </link> </p> <p><link href="../getinvolved/index.html"> So jump in! </link> </p>

View File

@ -44,6 +44,7 @@
<li><link href="#DrawingShapes">Drawing Shapes.</link></li> <li><link href="#DrawingShapes">Drawing Shapes.</link></li>
<li><link href="#StylingShapes">Styling Shapes.</link></li> <li><link href="#StylingShapes">Styling Shapes.</link></li>
<li><link href="#Graphics2d">Shapes and Graphics2d.</link></li> <li><link href="#Graphics2d">Shapes and Graphics2d.</link></li>
<li><link href="#Outlining">Outlining.</link></li>
</ul> </ul>
</section> </section>
<section><title>Features</title> <section><title>Features</title>
@ -901,7 +902,42 @@
using the POI logging infrastructure (disabled by default). using the POI logging infrastructure (disabled by default).
</p> </p>
</section> </section>
<anchor id="Outlining"/>
<section>
<title>Outlining</title>
<p>
Outlines are great for grouping sections of information
together and can be added easily to columns and rows
using the POI API. Here's how:
</p>
<source>
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 14 );
sheet1.groupRow( 16, 19 );
sheet1.groupColumn( (short)4, (short)7 );
sheet1.groupColumn( (short)9, (short)12 );
sheet1.groupColumn( (short)10, (short)11 );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
</source>
<p>
To collapse (or expand) an outline use the following calls:
</p>
<source>
sheet1.setRowGroupCollapsed( 7, true );
sheet1.setColumnGroupCollapsed( (short)4, true );
</source>
<p>
The row/column you choose should contain an already
created group. It can be anywhere within the group.
</p>
</section>
</section> </section>
</section> </section>
</body> </body>

View File

@ -12,6 +12,18 @@
<changes> <changes>
<release version="2.5.1-FINAL" date="29 Feburary 2004">
<action dev="POI-DEVELOPERS" type="add" context="All">Outlining support</action>
<action dev="POI-DEVELOPERS" type="fix" context="All">27574 - [PATCH] HSSFDateUtil.getExcelDate() is one hour off when DST changes</action>
<action dev="POI-DEVELOPERS" type="fix" context="All">26465 - [PATCH] wrong lastrow entry</action>
<action dev="POI-DEVELOPERS" type="fix" context="All">28203 - [PATCH] Unable to open read-write excel file including forms</action>
</release>
<release version="2.5-FINAL" date="29 Feburary 2004">
<action dev="POI-DEVELOPERS" type="add" context="All">Add support for the Escher file format</action>
<action dev="POI-DEVELOPERS" type="fix" context="All">27005 java.lang.IndexOutOfBoundsException during Workbook.cloneSheet()</action>
</release>
<release version="2.0-FINAL" date="26 Janurary 2004"> <release version="2.0-FINAL" date="26 Janurary 2004">
<action dev="POI-DEVELOPERS" type="update" context="All">No changes</action> <action dev="POI-DEVELOPERS" type="update" context="All">No changes</action>
</release> </release>

View File

@ -0,0 +1,284 @@
/* ====================================================================
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.
==================================================================== */
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* Creates outlines.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class Outlines
{
private Outlines(){}
public static void main(String[] args)
throws IOException
{
createCase1( "outline1.xls" );
System.out.println( "outline1.xls written. Two expanded groups." );
createCase2( "outline2.xls" );
System.out.println( "outline2.xls written. Two groups. Inner group collapsed." );
createCase3( "outline3.xls" );
System.out.println( "outline3.xls written. Two groups. Both collapsed." );
createCase4( "outline4.xls" );
System.out.println( "outline4.xls written. Two groups. Collapsed then inner group expanded." );
createCase5( "outline5.xls" );
System.out.println( "outline5.xls written. Two groups. Collapsed then reexpanded." );
createCase6( "outline6.xls" );
System.out.println( "outline6.xls written. Two groups with matching end points. Second group collapsed." );
createCase7( "outline7.xls" );
System.out.println( "outline7.xls written. Row outlines." );
createCase8( "outline8.xls" );
System.out.println( "outline8.xls written. Row outlines. Inner group collapsed." );
createCase9( "outline9.xls" );
System.out.println( "outline9.xls written. Row outlines. Both collapsed." );
createCase10( "outline10.xls" );
System.out.println( "outline10.xls written. Row outlines. Collapsed then inner group expanded." );
createCase11( "outline11.xls" );
System.out.println( "outline11.xls written. Row outlines. Collapsed then expanded." );
createCase12( "outline12.xls" );
System.out.println( "outline12.xls written. Row outlines. Two row groups with matching end points. Second group collapsed." );
createCase13( "outline13.xls" );
System.out.println( "outline13.xls written. Mixed bag." );
}
private static void createCase1( String filename ) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupColumn( (short)4, (short)7 );
for (int row = 0; row < 200; row++)
{
HSSFRow r = sheet1.createRow( row );
for (int column = 0; column < 200; column++)
{
HSSFCell c = r.createCell( (short) column );
c.setCellValue( column );
}
}
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase2( String filename ) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupColumn( (short)2, (short)10 );
sheet1.groupColumn( (short)4, (short)7 );
sheet1.setColumnGroupCollapsed( (short)4, true );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase3( String filename ) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupColumn( (short)2, (short)10 );
sheet1.groupColumn( (short)4, (short)7 );
sheet1.setColumnGroupCollapsed( (short)4, true );
sheet1.setColumnGroupCollapsed( (short)2, true );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase4( String filename ) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupColumn( (short)2, (short)10 );
sheet1.groupColumn( (short)4, (short)7 );
sheet1.setColumnGroupCollapsed( (short)4, true );
sheet1.setColumnGroupCollapsed( (short)2, true );
sheet1.setColumnGroupCollapsed( (short)4, false );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase5( String filename ) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupColumn( (short)2, (short)10 );
sheet1.groupColumn( (short)4, (short)7 );
sheet1.setColumnGroupCollapsed( (short)4, true );
sheet1.setColumnGroupCollapsed( (short)2, true );
sheet1.setColumnGroupCollapsed( (short)4, false );
sheet1.setColumnGroupCollapsed( (short)3, false );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase6( String filename ) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupColumn( (short)2, (short)10 );
sheet1.groupColumn( (short)4, (short)10 );
sheet1.setColumnGroupCollapsed( (short)4, true );
sheet1.setColumnGroupCollapsed( (short)2, true );
sheet1.setColumnGroupCollapsed( (short)3, false );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase7( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 10 );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase8( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 10 );
sheet1.setRowGroupCollapsed( 7, true );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase9( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 10 );
sheet1.setRowGroupCollapsed( 7, true );
sheet1.setRowGroupCollapsed( 5, true );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase10( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 10 );
sheet1.setRowGroupCollapsed( 7, true );
sheet1.setRowGroupCollapsed( 5, true );
sheet1.setRowGroupCollapsed( 8, false );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase11( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 10 );
sheet1.setRowGroupCollapsed( 7, true );
sheet1.setRowGroupCollapsed( 5, true );
sheet1.setRowGroupCollapsed( 8, false );
sheet1.setRowGroupCollapsed( 14, false );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase12( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 14 );
sheet1.setRowGroupCollapsed( 7, true );
sheet1.setRowGroupCollapsed( 5, true );
sheet1.setRowGroupCollapsed( 6, false );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
private static void createCase13( String filename )
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 14 );
sheet1.groupRow( 16, 19 );
sheet1.groupColumn( (short)4, (short)7 );
sheet1.groupColumn( (short)9, (short)12 );
sheet1.groupColumn( (short)10, (short)11 );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
}

View File

@ -44,6 +44,8 @@ public class ReadWriteWorkbook
HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0); HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(2); HSSFRow row = sheet.getRow(2);
if (row == null)
row = sheet.createRow(2);
HSSFCell cell = row.getCell((short)3); HSSFCell cell = row.getCell((short)3);
if (cell == null) if (cell == null)
cell = row.createCell((short)3); cell = row.createCell((short)3);

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* BiffViewer.java * BiffViewer.java
* *
@ -91,7 +90,7 @@ public class BiffViewer {
public static Record[] createRecords(InputStream in, boolean dump) public static Record[] createRecords(InputStream in, boolean dump)
throws RecordFormatException { throws RecordFormatException {
ArrayList records = new ArrayList(); ArrayList records = new ArrayList();
//Record last_record = null; // Record last_record = null;
int loc = 0; int loc = 0;
RecordDetails activeRecord = null; RecordDetails activeRecord = null;
@ -103,8 +102,6 @@ public class BiffViewer {
do { do {
rectype = LittleEndian.readShort(in); rectype = LittleEndian.readShort(in);
int startloc = loc; int startloc = loc;
// System.out.println("============================================");
// System.out.println("Offset 0x" + Integer.toHexString(loc) + " (" + loc + ")");
loc += 2; loc += 2;
if (rectype != 0) { if (rectype != 0) {
short recsize = LittleEndian.readShort(in); short recsize = LittleEndian.readShort(in);
@ -148,8 +145,8 @@ public class BiffViewer {
System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")"); System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize ); System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
System.out.println( record.toString() ); System.out.println( record.toString() );
}
}
private static void dumpContinueRecord(Record last_record, boolean dump, byte[] data) throws IOException { private static void dumpContinueRecord(Record last_record, boolean dump, byte[] data) throws IOException {
if (last_record == null) { if (last_record == null) {
@ -227,14 +224,11 @@ public class BiffViewer {
* up non-debug operations. * up non-debug operations.
* *
*/ */
private static Record createRecord( short rectype, short size, private static Record createRecord( short rectype, short size,
byte[] data ) byte[] data )
{ {
Record retval = null; Record retval = null;
Record[] realretval = null;
// int irectype = rectype;
switch ( rectype ) switch ( rectype )
{ {
@ -587,14 +581,14 @@ public class BiffViewer {
retval = new PaneRecord( rectype, size, data ); retval = new PaneRecord( rectype, size, data );
break; break;
case SharedFormulaRecord.sid: case SharedFormulaRecord.sid:
retval = new SharedFormulaRecord( rectype, size, data); retval = new SharedFormulaRecord( rectype, size, data);
break; break;
case ObjRecord.sid: case ObjRecord.sid:
retval = new ObjRecord( rectype, size, data); retval = new ObjRecord( rectype, size, data);
break; break;
case TextObjectRecord.sid: case TextObjectRecord.sid:
retval = new TextObjectRecord( rectype, size, data); retval = new TextObjectRecord( rectype, size, data);
break; break;
case HorizontalPageBreakRecord.sid: case HorizontalPageBreakRecord.sid:
retval = new HorizontalPageBreakRecord( rectype, size, data); retval = new HorizontalPageBreakRecord( rectype, size, data);
break; break;
@ -674,7 +668,7 @@ public class BiffViewer {
this.data = data; this.data = data;
this.record = record; this.record = record;
} }
public short getRectype() public short getRectype()
{ {
return rectype; return rectype;
@ -705,3 +699,4 @@ public class BiffViewer {
} }
} }

View File

@ -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

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;

View File

@ -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

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* FormulaViewer.java - finds formulas in a BIFF8 file and attempts to parse them and * FormulaViewer.java - finds formulas in a BIFF8 file and attempts to parse them and

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,17 +13,19 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import org.apache.poi.hssf.usermodel.*; import java.io.InputStream;
import org.apache.poi.hssf.util.Region; import java.io.IOException;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; 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 * File for HSSF testing/examples
@ -38,9 +39,11 @@ import java.io.IOException;
public class HSSF public class HSSF
{ {
private String filename = null;
// private POIFSFileSystem fs = null; // private POIFSFileSystem fs = null;
// private InputStream stream = null; private InputStream stream = null;
// private Record[] records = null; private Record[] records = null;
protected HSSFWorkbook hssfworkbook = null; protected HSSFWorkbook hssfworkbook = null;
/** /**
@ -57,6 +60,7 @@ public class HSSF
public HSSF(String filename) public HSSF(String filename)
throws IOException throws IOException
{ {
this.filename = filename;
POIFSFileSystem fs = POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream(filename)); new POIFSFileSystem(new FileInputStream(filename));
@ -94,13 +98,13 @@ public class HSSF
f.setFontHeightInPoints(( short ) 12); f.setFontHeightInPoints(( short ) 12);
f.setColor(( short ) 0xA); f.setColor(( short ) 0xA);
f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); f.setBoldweight(f.BOLDWEIGHT_BOLD);
f2.setFontHeightInPoints(( short ) 10); f2.setFontHeightInPoints(( short ) 10);
f2.setColor(( short ) 0xf); f2.setColor(( short ) 0xf);
f2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); f2.setBoldweight(f2.BOLDWEIGHT_BOLD);
cs.setFont(f); cs.setFont(f);
cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)")); 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.setFillPattern(( short ) 1); // fill w fg
cs2.setFillForegroundColor(( short ) 0xA); cs2.setFillForegroundColor(( short ) 0xA);
cs2.setFont(f2); cs2.setFont(f2);
@ -116,7 +120,7 @@ public class HSSF
// r.setRowNum(( short ) rownum); // r.setRowNum(( short ) rownum);
for (short cellnum = ( short ) 0; cellnum < 50; cellnum += 2) 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 c.setCellValue(rownum * 10000 + cellnum
+ ((( double ) rownum / 1000) + ((( double ) rownum / 1000)
+ (( double ) cellnum / 10000))); + (( double ) cellnum / 10000)));
@ -124,7 +128,8 @@ public class HSSF
{ {
c.setCellStyle(cs); c.setCellStyle(cs);
} }
c = r.createCell(( short ) (cellnum + 1)); c = r.createCell(( short ) (cellnum + 1),
HSSFCell.CELL_TYPE_STRING);
c.setCellValue("TEST"); c.setCellValue("TEST");
s.setColumnWidth(( short ) (cellnum + 1), s.setColumnWidth(( short ) (cellnum + 1),
( short ) ((50 * 8) / (( double ) 1 / 20))); ( short ) ((50 * 8) / (( double ) 1 / 20)));
@ -139,11 +144,10 @@ public class HSSF
rownum++; rownum++;
rownum++; rownum++;
r = s.createRow(rownum); r = s.createRow(rownum);
cs3.setBorderBottom(HSSFCellStyle.BORDER_THICK); cs3.setBorderBottom(cs3.BORDER_THICK);
for (short cellnum = ( short ) 0; cellnum < 50; cellnum++) 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.setCellValue(0);
c.setCellStyle(cs3); c.setCellStyle(cs3);
@ -164,6 +168,30 @@ public class HSSF
out.close(); out.close();
} }
/**
* 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 * Method main
* *
@ -256,7 +284,7 @@ public class HSSF
try try
{ {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
new HSSF(args[ 0 ], true); HSSF hssf = new HSSF(args[ 0 ], true);
System.out System.out
.println("" + (System.currentTimeMillis() - time) .println("" + (System.currentTimeMillis() - time)

View File

@ -16,5 +16,6 @@ For overviews, tutorials, examples, guides, and tool documentation, please see:
</ul> </ul>
<!-- Put @see and @since tags down here. --> <!-- Put @see and @since tags down here. -->
@see org.apache.poi.hssf
</body> </body>
</html> </html>

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventmodel; package org.apache.poi.hssf.eventmodel;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventmodel; package org.apache.poi.hssf.eventmodel;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventmodel; package org.apache.poi.hssf.eventmodel;
import java.io.InputStream; import java.io.InputStream;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventmodel; package org.apache.poi.hssf.eventmodel;
import org.apache.poi.hssf.model.Model; import org.apache.poi.hssf.model.Model;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventusermodel; 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 * a listener supporting this interface and register it with the HSSFRequest (associating
* it with Record SID's). * it with Record SID's).
* *
* @see HSSFEventFactory * @see org.apache.poi.hssf.eventmodel.HSSFEventFactory
* @see HSSFRequest * @see org.apache.poi.hssf.eventmodel.HSSFRequest
* @see AbortableHSSFListener * @see org.apache.poi.hssf.HSSFUserException
* *
* @author Carey Sublette (careysub@earthling.net) * @author Carey Sublette (careysub@earthling.net)
* *

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventusermodel; package org.apache.poi.hssf.eventusermodel;
@ -127,6 +126,7 @@ public class HSSFEventFactory
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem#createDocumentInputStream(String) * @see org.apache.poi.poifs.filesystem.POIFSFileSystem#createDocumentInputStream(String)
* @param req an Instance of HSSFRequest which has your registered listeners * @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
* @param in a DocumentInputStream obtained from POIFS's POIFSFileSystem object
* @return numeric user-specified result code. * @return numeric user-specified result code.
*/ */

View File

@ -14,7 +14,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventusermodel; 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 * a listener supporting this interface and register it with the HSSFRequest (associating
* it with Record SID's). * it with Record SID's).
* *
* @see org.apache.poi.hssf.eventusermodel.HSSFEventFactory * @see org.apache.poi.hssf.eventmodel.HSSFEventFactory
* @see org.apache.poi.hssf.eventusermodel.HSSFRequest * @see org.apache.poi.hssf.eventmodel.HSSFRequest
* @author acoliver@apache.org * @author acoliver@apache.org
*/ */

View File

@ -14,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventusermodel; 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 * An HSSFRequest object should be constructed registering an instance or multiple
* instances of HSSFListener with each Record.sid you wish to listen for. * instances of HSSFListener with each Record.sid you wish to listen for.
* *
* @see org.apache.poi.hssf.eventusermodel.HSSFEventFactory * @see org.apache.poi.hssf.eventmodel.HSSFEventFactory
* @see org.apache.poi.hssf.eventusermodel.HSSFRequest * @see org.apache.poi.hssf.eventmodel.HSSFListener
* @see org.apache.poi.hssf.dev.EFHSSF * @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 Andrew C. Oliver (acoliver at apache dot org)
* @author Carey Sublette (careysub@earthling.net) * @author Carey Sublette (careysub@earthling.net)
*/ */

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.eventusermodel; package org.apache.poi.hssf.eventusermodel;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;

View File

@ -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; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherRecord;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.EscherDggRecord; import org.apache.poi.ddf.EscherDggRecord;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;

File diff suppressed because it is too large Load Diff

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,8 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,13 +13,14 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.SheetReferences; 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.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;
@ -55,7 +55,8 @@ import java.util.Locale;
* @version 1.0-pre * @version 1.0-pre
*/ */
public class Workbook implements Model { public class Workbook implements Model
{
private static final int DEBUG = POILogger.DEBUG; private static final int DEBUG = POILogger.DEBUG;
// public static Workbook currentBook = null; // public static Workbook currentBook = null;
@ -97,7 +98,7 @@ public class Workbook implements Model {
protected int numfonts = 0; // hold the number of font records protected int numfonts = 0; // hold the number of font records
private short maxformatid = -1; // holds the max format id private short maxformatid = -1; // holds the max format id
private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used 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); private static POILogger log = POILogFactory.getLogger(Workbook.class);
@ -649,7 +650,7 @@ public class Workbook implements Model {
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "Returning SST for index=", new Integer(str), log.log(DEBUG, "Returning SST for index=", new Integer(str),
" String= ", retval); " String= ", retval);
return retval; return retval;
} }
@ -674,30 +675,20 @@ public class Workbook implements Model {
* *
* @return byte array containing the HSSF-only portions of the POIFS file. * @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() { // public byte [] serialize() {
// log.log(DEBUG, "Serializing Workbook!"); // log.log(DEBUG, "Serializing Workbook!");
// byte[] retval = null; // byte[] retval = null;
// //
// // ArrayList bytes = new ArrayList(records.size()); //// ArrayList bytes = new ArrayList(records.size());
// int arraysize = getSize(); // int arraysize = getSize();
// int pos = 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;
// // }
// retval = new byte[ arraysize ]; // retval = new byte[ arraysize ];
// for (int k = 0; k < records.size(); k++) { // 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); // 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()) { // if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
// pos += record.serialize(pos, retval); // rec.length; // pos += record.serialize(pos, retval); // rec.length;
// } // }
@ -724,7 +715,7 @@ public class Workbook implements Model {
int sstPos = 0; int sstPos = 0;
for ( int k = 0; k < records.size(); k++ ) for ( int k = 0; k < records.size(); k++ )
{ {
Record record = records.get( k ); 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() ) if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
@ -766,7 +757,8 @@ public class Workbook implements Model {
} }
} }
return retval; return retval;
} }
/** /**
* creates the BOF record * creates the BOF record
* @see org.apache.poi.hssf.record.BOFRecord * @see org.apache.poi.hssf.record.BOFRecord
@ -2063,24 +2055,24 @@ public class Workbook implements Model {
*/ */
public PaletteRecord getCustomPalette() public PaletteRecord getCustomPalette()
{ {
PaletteRecord palette; PaletteRecord palette;
int palettePos = records.getPalettepos(); int palettePos = records.getPalettepos();
if (palettePos != -1) { if (palettePos != -1) {
Record rec = records.get(palettePos); Record rec = records.get(palettePos);
if (rec instanceof PaletteRecord) { if (rec instanceof PaletteRecord) {
palette = (PaletteRecord) rec; palette = (PaletteRecord) rec;
} else throw new RuntimeException("InternalError: Expected PaletteRecord but got a '"+rec+"'"); } else throw new RuntimeException("InternalError: Expected PaletteRecord but got a '"+rec+"'");
} }
else else
{ {
palette = createPalette(); palette = createPalette();
//Add the palette record after the bof which is always the first record //Add the palette record after the bof which is always the first record
records.add(1, palette); records.add(1, palette);
records.setPalettepos(1); records.setPalettepos(1);
} }
return palette; return palette;
} }
/** /**
* Creates a drawing group record. If it already exists then it's left * Creates a drawing group record. If it already exists then it's left
* alone. * alone.
@ -2131,6 +2123,6 @@ public class Workbook implements Model {
{ {
return drawingManager; return drawingManager;
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.ddf.DefaultEscherRecordFactory; import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordFactory; import org.apache.poi.ddf.EscherRecordFactory;
@ -36,6 +32,7 @@ import java.util.List;
* must be subclassed for maximum benefit. * must be subclassed for maximum benefit.
* *
* @author Glen Stampoultzis (glens at apache.org) * @author Glen Stampoultzis (glens at apache.org)
* @author Michael Zalewski (zalewski at optonline.net)
*/ */
public abstract class AbstractEscherHolderRecord public abstract class AbstractEscherHolderRecord
extends Record extends Record
@ -122,13 +119,13 @@ public abstract class AbstractEscherHolderRecord
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
final String nl = System.getProperty("line.separator"); final String nl = System.getProperty("line.separator");
buffer.append("[" + getRecordName() + "]" + nl); buffer.append('[' + getRecordName() + ']' + nl);
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{ {
EscherRecord r = (EscherRecord) iterator.next(); EscherRecord r = (EscherRecord) iterator.next();
buffer.append(r.toString()); buffer.append(r.toString());
} }
buffer.append("[/" + getRecordName() + "]" + nl); buffer.append("[/" + getRecordName() + ']' + nl);
return buffer.toString(); return buffer.toString();
} }
@ -137,29 +134,49 @@ public abstract class AbstractEscherHolderRecord
public int serialize(int offset, byte[] data) 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); System.arraycopy( rawData, 0, data, offset + 4, rawData.length );
return rawData.length;
} }
else else
{ {
collapseShapeInformation();
LittleEndian.putShort(data, 0 + offset, getSid());
LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
int pos = offset + 4; int pos = offset + 4;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{ {
EscherRecord r = (EscherRecord) iterator.next(); 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) * Size of record (including 4 byte header)
*/ */
@ -167,12 +184,10 @@ public abstract class AbstractEscherHolderRecord
{ {
if (escherRecords.size() == 0 && rawData != null) if (escherRecords.size() == 0 && rawData != null)
{ {
return rawData.length; return rawData.length + 4;
} }
else else
{ {
collapseShapeInformation();
int size = 4; int size = 4;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) 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(); public abstract short getSid();

View File

@ -137,7 +137,7 @@ public class BOFRecord
/** /**
* Version number - for BIFF8 should be 0x06 * Version number - for BIFF8 should be 0x06
* @see #VERSION * @see #VERSION
* @param version to be set * @param short version to be set
*/ */
public void setVersion(short version) public void setVersion(short version)
@ -153,7 +153,7 @@ public class BOFRecord
* @see #TYPE_CHART * @see #TYPE_CHART
* @see #TYPE_EXCEL_4_MACRO * @see #TYPE_EXCEL_4_MACRO
* @see #TYPE_WORKSPACE_FILE * @see #TYPE_WORKSPACE_FILE
* @param type to be set * @param short type to be set
*/ */
public void setType(short type) public void setType(short type)
@ -164,7 +164,7 @@ public class BOFRecord
/** /**
* build that wrote this file * build that wrote this file
* @see #BUILD * @see #BUILD
* @param build number to set * @param short build number to set
*/ */
public void setBuild(short build) public void setBuild(short build)
@ -175,7 +175,7 @@ public class BOFRecord
/** /**
* Year of the build that wrote this file * Year of the build that wrote this file
* @see #BUILD_YEAR * @see #BUILD_YEAR
* @param year year to set * @param short build year to set
*/ */
public void setBuildYear(short year) public void setBuildYear(short year)
@ -186,7 +186,7 @@ public class BOFRecord
/** /**
* set the history bit mask (not very useful) * set the history bit mask (not very useful)
* @see #HISTORY_MASK * @see #HISTORY_MASK
* @param bitmask to set for the history * @param int bitmask to set for the history
*/ */
public void setHistoryBitMask(int bitmask) public void setHistoryBitMask(int bitmask)
@ -198,7 +198,7 @@ public class BOFRecord
* set the minimum version required to read this file * set the minimum version required to read this file
* *
* @see #VERSION * @see #VERSION
* @param version to set * @param int version to set
*/ */
public void setRequiredVersion(int version) public void setRequiredVersion(int version)

View File

@ -82,7 +82,7 @@ public class BookBoolRecord
/** /**
* set the save ext links flag * set the save ext links flag
* *
* @param flag (0/1 -off/on) * @param short flag (0/1 -off/on)
*/ */
public void setSaveLinkValues(short flag) public void setSaveLinkValues(short flag)

View File

@ -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); throw new RuntimeException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value);
} }
} }
//public short getRow() //public short getRow()
public int getRow() public int getRow()
{ {

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -22,130 +20,121 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.*; import org.apache.poi.util.*;
/** /**
* Record for the bottom margin. * Record for the bottom margin.
* NOTE: This source was automatically generated. * NOTE: This source was automatically generated.
*
* @author Shawn Laubach (slaubach at apache dot org) * @author Shawn Laubach (slaubach at apache dot org)
*/ */
public class BottomMarginRecord public class BottomMarginRecord
extends Record implements Margin extends Record implements Margin
{ {
public final static short sid = 0x29; public final static short sid = 0x29;
private double field_1_margin; private double field_1_margin;
public BottomMarginRecord()
{
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. * Constructs a BottomMargin record and sets its fields appropriately.
* *
* @param id id must be 0x29 or an exception * @param id id must be 0x29 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 size size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @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 );
}
public BottomMarginRecord(short id, short size, byte [] data) /**
{ * Checks the sid matches the expected side for this record
super(id, size, data); *
} * @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 )
* Constructs a BottomMargin record and sets its fields appropriately. {
* field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
* @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) public String toString()
{ {
super(id, size, data, offset); 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 )
* Checks the sid matches the expected side for this record {
* LittleEndian.putShort( data, 0 + offset, sid );
* @param id the expected sid. LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
*/ LittleEndian.putDouble( data, 4 + offset, field_1_margin );
protected void validateSid(short id) return getRecordSize();
{ }
if (id != sid)
{
throw new RecordFormatException("Not a BottomMargin record");
}
}
protected void fillFields(byte [] data, short size, int offset) /**
{ * Size of record (exluding 4 byte header)
field_1_margin = LittleEndian.getDouble(data, 0x0 + offset); */
public int getRecordSize()
{
return 4 + 8;
}
} public short getSid()
{
return this.sid;
}
public String toString() /**
{ * Get the margin field for the BottomMargin record.
StringBuffer buffer = new StringBuffer(); */
public double getMargin()
{
return field_1_margin;
}
buffer.append("[BottomMargin]\n"); /**
* Set the margin field for the BottomMargin record.
*/
public void setMargin( double field_1_margin )
{
this.field_1_margin = field_1_margin;
}
buffer.append(" .margin = ") public Object clone()
.append(" (").append(getMargin()).append(" )\n"); {
BottomMarginRecord rec = new BottomMarginRecord();
rec.field_1_margin = this.field_1_margin;
return rec;
}
buffer.append("[/BottomMargin]\n"); } // END OF CLASS
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;
}
}

View File

@ -158,7 +158,7 @@ public class BoundSheetRecord
/** /**
* Set the sheetname for this sheet. (this appears in the tabs at the bottom) * Set the sheetname for this sheet. (this appears in the tabs at the bottom)
* @param sheetname the name of the sheet * @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 ) public void setSheetname( String sheetname )

View File

@ -65,7 +65,7 @@ public class CodepageRecord
* @param id id must be 0x42 or an exception will be throw upon validation * @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 size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @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) public CodepageRecord(short id, short size, byte [] data, int offset)
@ -90,7 +90,7 @@ public class CodepageRecord
* set the codepage for this workbook * set the codepage for this workbook
* *
* @see #CODEPAGE * @see #CODEPAGE
* @param cp the codepage to set * @param codepage - the codepage to set
*/ */
public void setCodepage(short cp) public void setCodepage(short cp)

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
public interface CustomField public interface CustomField

View File

@ -21,18 +21,16 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
* Title: DBCell Record * Title: DBCell Record (Currently read only. Not required.)
* Description: Used by Excel and other MS apps to quickly find rows in the sheets.<P> * 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> * 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 Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height
* @version 2.0-pre * @version 2.0-pre
*/ */
public class DBCellRecord public class DBCellRecord
extends Record extends Record
{ {
public final static int BLOCK_SIZE = 32;
public final static short sid = 0xd7; public final static short sid = 0xd7;
private int field_1_row_offset; private int field_1_row_offset;
private short[] field_2_cell_offsets; private short[] field_2_cell_offsets;
@ -182,7 +180,7 @@ public class DBCellRecord
LittleEndian.putInt(data, 4 + offset, getRowOffset()); LittleEndian.putInt(data, 4 + offset, getRowOffset());
for (int k = 0; k < getNumCellOffsets(); k++) 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(); return getRecordSize();
} }
@ -192,11 +190,6 @@ public class DBCellRecord
return 8 + (getNumCellOffsets() * 2); 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() public short getSid()
{ {
return this.sid; return this.sid;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
public class DrawingGroupRecord extends AbstractEscherHolderRecord public class DrawingGroupRecord extends AbstractEscherHolderRecord

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
public class DrawingSelectionRecord extends AbstractEscherHolderRecord public class DrawingSelectionRecord extends AbstractEscherHolderRecord

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;

View File

@ -29,7 +29,6 @@ import org.apache.poi.util.LittleEndian;
* Extended SST table info subrecord<P> * Extended SST table info subrecord<P>
* contains the elements of "info" in the SST's array field<P> * contains the elements of "info" in the SST's array field<P>
* @author Andrew C. Oliver (acoliver at apache dot org) * @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height
* @version 2.0-pre * @version 2.0-pre
* @see org.apache.poi.hssf.record.ExtSSTRecord * @see org.apache.poi.hssf.record.ExtSSTRecord
*/ */

View File

@ -30,7 +30,7 @@ import java.util.ArrayList;
* position relative to the start of the SST record. * position relative to the start of the SST record.
* REFERENCE: PG 313 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> * 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 Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height * @author Jason Height (jheight at apache dot org)
* @version 2.0-pre * @version 2.0-pre
* @see org.apache.poi.hssf.record.ExtSSTInfoSubRecord * @see org.apache.poi.hssf.record.ExtSSTInfoSubRecord
*/ */
@ -162,18 +162,16 @@ public class ExtSSTRecord
for (int k = 0; k < getNumInfoRecords(); k++) for (int k = 0; k < getNumInfoRecords(); k++)
{ {
ExtSSTInfoSubRecord rec = getInfoRecordAt(k); ExtSSTInfoSubRecord rec = getInfoRecordAt(k);
int length = rec.serialize(pos + offset, data); pos += rec.serialize(pos + offset, data);
pos += length;
} }
return pos; return pos;
} }
/** Returns the size of this record */ /** Returns the size of this record */
public int getRecordSize() public int getRecordSize()
{ {
return 6+8*getNumInfoRecords(); return 6 + 8*getNumInfoRecords();
} }
public static final int getNumberOfInfoRecsForStrings(int numStrings) { public static final int getNumberOfInfoRecsForStrings(int numStrings) {

View File

@ -604,8 +604,8 @@ public class ExtendedFormatRecord
* set whether or not to use the pattern in this XF instead of the parent XF. * set whether or not to use the pattern in this XF instead of the parent XF.
* (foregrount/background) * (foregrount/background)
* *
* @param pattern true if this XF has a different pattern value than its parent, * @param pattern- true if this XF has a different pattern value than its parent,
* false otherwise. * false otherwise.
* @see #setIndentionOptions(short) * @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. * 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, * @param options- true if this XF has a different locking or hidden value than its parent,
* false otherwise. * false otherwise.
* @see #setIndentionOptions(short) * @see #setIndentionOptions(short)
*/ */

View File

@ -29,128 +29,132 @@ import java.util.ArrayList;
* @author Libin Roman (Vista Portal LDT. Developer) * @author Libin Roman (Vista Portal LDT. Developer)
* @version 1.0-pre * @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(); 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 );
}
/** /**
* Constructs a Extern Sheet record and sets its fields appropriately. * 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 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 size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @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 )
{ public ExternSheetRecord(short id, short size, byte[] data) {
super( id, size, data, offset ); 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);
}
/** /**
* called by constructor, should throw runtime exception in the event of a * called by constructor, should throw runtime exception in the event of a
* record passed with a differing ID. * record passed with a differing ID.
* *
* @param id alleged id for this record */ * @param id alleged id for this record
protected void validateSid( short id ) */
{ protected void validateSid(short id) {
if ( id != sid ) if (id != sid) {
{ throw new RecordFormatException("NOT An ExternSheet RECORD");
throw new RecordFormatException( "NOT An ExternSheet RECORD" );
} }
} }
/** /**
* called by the constructor, should set class level fields. Should throw * called by the constructor, should set class level fields. Should throw
* runtime exception for bad/icomplete data. * runtime exception for bad/icomplete data.
* *
* @param data raw data * @param data raw data
* @param size size of data * @param size size of data
* @param offset of the record's data (provided a big array of the file) */ * @param offset of the record's data (provided a big array of the file)
protected void fillFields( byte[] data, short size, int offset ) */
{ protected void fillFields(byte [] data, short size, int offset) {
field_2_REF_structures = new ArrayList(); field_2_REF_structures = new ArrayList();
field_1_number_of_REF_sturcutres = LittleEndian.getShort( data, 0 + offset );
field_1_number_of_REF_sturcutres = LittleEndian.getShort(data, 0 + offset);
int pos = 2 + offset; int pos = 2 + offset;
for ( int i = 0; i < field_1_number_of_REF_sturcutres; ++i ) for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) {
{ ExternSheetSubRecord rec = new ExternSheetSubRecord((short)0, (short)6 , data , pos);
ExternSheetSubRecord rec = new ExternSheetSubRecord( (short) 0, (short) 6, data, pos );
pos += 6; 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 * sets the number of the REF structors , that is in Excel file
* @param numStruct number of REF structs */ * @param numStruct number of REF structs
public void setNumOfREFStructures( short numStruct ) */
{ public void setNumOfREFStructures(short numStruct) {
field_1_number_of_REF_sturcutres = numStruct; field_1_number_of_REF_sturcutres = numStruct;
} }
/** /**
* return the number of the REF structors , that is in Excel file * return the number of the REF structors , that is in Excel file
* @return number of REF structs */ * @return number of REF structs
public short getNumOfREFStructures() */
{ public short getNumOfREFStructures() {
return field_1_number_of_REF_sturcutres; return field_1_number_of_REF_sturcutres;
} }
/** /**
* adds REF struct (ExternSheetSubRecord) * adds REF struct (ExternSheetSubRecord)
* @param rec REF struct */ * @param rec REF struct
public void addREFRecord( ExternSheetSubRecord rec ) */
{ public void addREFRecord(ExternSheetSubRecord rec) {
field_2_REF_structures.add( rec ); field_2_REF_structures.add(rec);
} }
/** returns the number of REF Records, which is in model /** returns the number of REF Records, which is in model
* @return number of REF records */ * @return number of REF records
public int getNumOfREFRecords() */
{ public int getNumOfREFRecords() {
return field_2_REF_structures.size(); return field_2_REF_structures.size();
} }
/** returns the REF record (ExternSheetSubRecord) /** returns the REF record (ExternSheetSubRecord)
* @param elem index to place * @param elem index to place
* @return REF record */ * @return REF record
public ExternSheetSubRecord getREFRecordAt( int elem ) */
{ public ExternSheetSubRecord getREFRecordAt(int elem) {
ExternSheetSubRecord result = (ExternSheetSubRecord) field_2_REF_structures.get( elem ); ExternSheetSubRecord result = ( ExternSheetSubRecord ) field_2_REF_structures.get(elem);
return result; return result;
} }
public String toString() public String toString() {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append( "[EXTERNSHEET]\n" );
buffer.append( " numOfRefs = " ).append( getNumOfREFStructures() ).append( "\n" ); buffer.append("[EXTERNSHEET]\n");
for ( int k = 0; k < this.getNumOfREFRecords(); k++ ) buffer.append(" numOfRefs = ").append(getNumOfREFStructures()).append("\n");
{ for (int k=0; k < this.getNumOfREFRecords(); k++) {
buffer.append( "refrec #" ).append( k ).append( '\n' ); buffer.append("refrec #").append(k).append('\n');
buffer.append( getREFRecordAt( k ).toString() ); buffer.append(getREFRecordAt(k).toString());
buffer.append( "----refrec #" ).append( k ).append( '\n' ); buffer.append("----refrec #").append(k).append('\n');
} }
buffer.append( "[/EXTERNSHEET]\n" ); buffer.append("[/EXTERNSHEET]\n");
return buffer.toString(); return buffer.toString();
} }
/** /**
* called by the class that is responsible for writing this sucker. * called by the class that is responsible for writing this sucker.
* Subclasses should implement this so that their data is passed back in a * 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 offset to begin writing at
* @param data byte array containing instance data * @param data byte array containing instance data
* @return number of bytes written */ * @return number of bytes written
public int serialize( int offset, byte[] data ) */
{ public int serialize(int offset, byte [] data) {
LittleEndian.putShort( data, 0 + offset, sid ); LittleEndian.putShort(data, 0 + offset, sid);
LittleEndian.putShort( data, 2 + offset, (short) ( 2 + ( getNumOfREFRecords() * 6 ) ) ); LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecords() *6)));
LittleEndian.putShort( data, 4 + offset, getNumOfREFStructures() );
int pos = 6; LittleEndian.putShort(data, 4 + offset, getNumOfREFStructures());
for ( int k = 0; k < getNumOfREFRecords(); k++ )
{ int pos = 6 ;
ExternSheetSubRecord record = getREFRecordAt( k );
System.arraycopy( record.serialize(), 0, data, pos + offset, 6 ); for (int k = 0; k < getNumOfREFRecords(); k++) {
pos += 6; ExternSheetSubRecord record = getREFRecordAt(k);
System.arraycopy(record.serialize(), 0, data, pos + offset, 6);
pos +=6;
} }
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() public int getRecordSize() {
{
return 4 + 2 + getNumOfREFRecords() * 6; return 4 + 2 + getNumOfREFRecords() * 6;
} }
/** /**
* return the non static version of the id for this record. */ * return the non static version of the id for this record.
public short getSid() */
{ public short getSid() {
return this.sid; return this.sid;
} }
} }

View File

@ -305,14 +305,6 @@ public class FormulaRecord
return field_8_parsed_expr; return field_8_parsed_expr;
} }
/**
* 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 * called by constructor, should throw runtime exception in the event of a
* record passed with a differing ID. * record passed with a differing ID.

View File

@ -185,13 +185,6 @@ public class IndexRecord
return 20 + (getNumDbcells() * 4); 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() public short getSid()
{ {
return this.sid; return this.sid;

View File

@ -114,15 +114,14 @@ public class LabelRecord
field_4_string_len = LittleEndian.getShort(data, 6 + offset); field_4_string_len = LittleEndian.getShort(data, 6 + offset);
field_5_unicode_flag = data[ 8 + offset ]; field_5_unicode_flag = data[ 8 + offset ];
if (field_4_string_len > 0) { if (field_4_string_len > 0) {
if (isUnCompressedUnicode()) if (isUnCompressedUnicode()) {
{ field_6_value = StringUtil.getFromUnicodeLE(data, 9 + offset,
field_6_value = StringUtil.getFromUnicodeLE(data, 9 + offset, field_4_string_len);
field_4_string_len); }
} else {
else field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset,
{ getStringLength());
field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength()); }
}
} else field_6_value = null; } else field_6_value = null;
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.*; import org.apache.poi.util.*;
/** /**
@ -27,16 +23,12 @@ import org.apache.poi.util.*;
* NOTE: This source was automatically generated. * NOTE: This source was automatically generated.
* @author Shawn Laubach (slaubach at apache dot org) * @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 public LeftMarginRecord() { }
extends Record implements Margin{
public final static short sid = 0x26;
private double field_1_margin;
public LeftMarginRecord()
{
}
/** /**
* Constructs a LeftMargin record and sets its fields appropriately. * 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 size size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public LeftMarginRecord( short id, short size, byte[] data )
public LeftMarginRecord(short id, short size, byte [] data) { super( id, size, data ); }
{
super(id, size, data);
}
/** /**
* Constructs a LeftMargin record and sets its fields appropriately. * Constructs a LeftMargin record and sets its fields appropriately.
*
* @param id id must be 0x26 or an exception * @param id id must be 0x26 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 size size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
* @param offset of the record's data * @param offset of the record's data
*/ */
public LeftMarginRecord( short id, short size, byte[] data, int offset )
public LeftMarginRecord(short id, short size, byte [] data, int offset) { super( id, size, data, 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. * @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() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[LeftMargin]\n"); buffer.append( "[LeftMargin]\n" );
buffer.append(" .margin = ") .append(" (").append(getMargin()).append(" )\n"); buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
buffer.append("[/LeftMargin]\n"); buffer.append( "[/LeftMargin]\n" );
return buffer.toString(); 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, 0 + offset, sid );
LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
LittleEndian.putDouble(data, 4 + offset, field_1_margin); LittleEndian.putDouble( data, 4 + offset, field_1_margin );
return getRecordSize(); return getRecordSize();
} }
/** /**
* Size of record (exluding 4 byte header) * Size of record (exluding 4 byte header)
*/ */
public int getRecordSize() {
public int getRecordSize() return 4 + 8;
{
return 4 + 8;
} }
public short getSid() public short getSid() {
{
return this.sid; return this.sid;
} }
/** /**
* Get the margin field for the LeftMargin record. * Get the margin field for the LeftMargin record.
*/ */
public double getMargin() {
public double getMargin()
{
return field_1_margin; return field_1_margin;
} }
/** /**
* Set the margin field for the LeftMargin record. * 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; this.field_1_margin = field_1_margin;
} }
public Object clone() { public Object clone()
{
LeftMarginRecord rec = new LeftMarginRecord(); LeftMarginRecord rec = new LeftMarginRecord();
rec.field_1_margin = this.field_1_margin; rec.field_1_margin = this.field_1_margin;
return rec; return rec;
} }
} // END OF CLASS
}

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; 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. * NOTE: This source wass automatically generated.
*
* @author Shawn Laubach (slaubach at apache dot org) * @author Shawn Laubach (slaubach at apache dot org)
*/ */
public interface Margin
public interface Margin{ {
/** /**
* Get the margin field for the Margin. * Get the margin field for the Margin.
*/ */
public double getMargin(); public double getMargin();
/** /**
* Set the margin field for the Margin. * Set the margin field for the Margin.
*/ */
public void setMargin( double field_1_margin );
public void setMargin(double field_1_margin); } // END OF CLASS
}

View File

@ -24,19 +24,18 @@ import java.util.Iterator;
import org.apache.poi.util.LittleEndian; 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 * Description: Optional record defining a square area of cells to "merged" into
* one cell. <P> * one cell. <br>
* REFERENCE: NONE (UNDOCUMENTED PRESENTLY) <P> * REFERENCE: NONE (UNDOCUMENTED PRESENTLY) <br>
* @author Andrew C. Oliver (acoliver at apache dot org) * @author Andrew C. Oliver (acoliver at apache dot org)
* @version 2.0-pre * @version 2.0-pre
*/ */
public class MergeCellsRecord public class MergeCellsRecord
extends Record extends Record
{ {
public final static short sid = 0xe5; public final static short sid = 0xe5;
private short field_1_num_areas;
private ArrayList field_2_regions; private ArrayList field_2_regions;
public MergeCellsRecord() public MergeCellsRecord()
@ -72,11 +71,11 @@ public class MergeCellsRecord
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(byte [] data, short size, int offset)
{ {
field_1_num_areas = LittleEndian.getShort(data, 0 + offset); short numAreas = LittleEndian.getShort(data, 0 + offset);
field_2_regions = new ArrayList(field_1_num_areas + 10); field_2_regions = new ArrayList(numAreas + 10);
int pos = 2; int pos = 2;
for (int k = 0; k < field_1_num_areas; k++) for (int k = 0; k < numAreas; k++)
{ {
MergedRegion region = MergedRegion region =
new MergedRegion(LittleEndian new MergedRegion(LittleEndian
@ -98,7 +97,9 @@ public class MergeCellsRecord
public short getNumAreas() 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 * 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. * 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) * (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 * @param numareas number of areas
*/ */
public void setNumAreas(short numareas) public void setNumAreas(short numareas)
{ {
field_1_num_areas = numareas;
} }
/** /**
@ -138,7 +140,6 @@ public class MergeCellsRecord
colto); colto);
field_2_regions.add(region); field_2_regions.add(region);
field_1_num_areas++;
return field_2_regions.size() - 1; return field_2_regions.size() - 1;
} }
@ -150,7 +151,6 @@ public class MergeCellsRecord
public void removeAreaAt(int area) public void removeAreaAt(int area)
{ {
field_2_regions.remove(area); field_2_regions.remove(area);
field_1_num_areas--;
} }
/** /**
@ -209,9 +209,9 @@ public class MergeCellsRecord
retval.append("[MERGEDCELLS]").append("\n"); retval.append("[MERGEDCELLS]").append("\n");
retval.append(" .sid =").append(sid).append("\n"); retval.append(" .sid =").append(sid).append("\n");
retval.append(" .numregions =").append(field_1_num_areas) retval.append(" .numregions =").append(getNumAreas())
.append("\n"); .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); MergedRegion region = ( MergedRegion ) field_2_regions.get(k);
@ -288,8 +288,7 @@ public class MergeCellsRecord
} }
public Object clone() { public Object clone() {
MergeCellsRecord rec = new MergeCellsRecord(); MergeCellsRecord rec = new MergeCellsRecord();
rec.field_1_num_areas = field_1_num_areas;
rec.field_2_regions = new ArrayList(); rec.field_2_regions = new ArrayList();
Iterator iterator = field_2_regions.iterator(); Iterator iterator = field_2_regions.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {

View File

@ -924,7 +924,8 @@ public class NameRecord extends Record {
.append("\n"); .append("\n");
buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text ) buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text )
.append("\n"); .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"); buffer.append("[/NAME]\n");
return buffer.toString(); return buffer.toString();

View File

@ -168,8 +168,8 @@ public class PaletteRecord
* If the given index is greater than the current last color index, * 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. * 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 * @param i the index to set; if this index is less than 0x8 or greater than
* greater than 0x40, then no modification is made * 0x40, then no modification is made
*/ */
public void setColor(short byteIndex, byte red, byte green, byte blue) public void setColor(short byteIndex, byte red, byte green, byte blue)
{ {

View File

@ -18,15 +18,13 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import java.io.InputStream;
import java.io.IOException;
import java.util.*;
import java.lang.reflect.Constructor;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.*;
/** /**
* Title: Record Factory<P> * Title: Record Factory<P>
* Description: Takes a stream and outputs an array of Record objects.<P> * Description: Takes a stream and outputs an array of Record objects.<P>
@ -75,9 +73,9 @@ public class RecordFactory
FormulaRecord.class, BoolErrRecord.class, ExternSheetRecord.class, FormulaRecord.class, BoolErrRecord.class, ExternSheetRecord.class,
NameRecord.class, LeftMarginRecord.class, RightMarginRecord.class, NameRecord.class, LeftMarginRecord.class, RightMarginRecord.class,
TopMarginRecord.class, BottomMarginRecord.class, TopMarginRecord.class, BottomMarginRecord.class,
PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
DrawingRecord.class, DrawingGroupRecord.class, DrawingSelectionRecord.class, DrawingRecord.class, DrawingGroupRecord.class, DrawingSelectionRecord.class,
ObjRecord.class, TextObjectRecord.class, ObjRecord.class, TextObjectRecord.class,
PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class
}; };
} else { } else {
@ -329,6 +327,7 @@ public class RecordFactory
} }
catch (Exception illegalArgumentException) catch (Exception illegalArgumentException)
{ {
illegalArgumentException.printStackTrace();
throw new RecordFormatException( throw new RecordFormatException(
"Unable to determine record types"); "Unable to determine record types");
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -22,123 +20,82 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.*; import org.apache.poi.util.*;
/** /**
* Record for the right margin. * Record for the right margin. * NOTE: This source was automatically generated. * @author Shawn Laubach (slaubach at apache dot org)
* 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 RightMarginRecord() { }
public class RightMarginRecord
extends Record implements Margin{
public final static short sid = 0x27;
private double field_1_margin;
public RightMarginRecord()
{
}
/** /**
* Constructs a RightMargin record and sets its fields appropriately. * 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 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 )
public RightMarginRecord(short id, short size, byte [] data) { super( id, size, data ); }
{
super(id, size, data);
}
/** /**
* Constructs a RightMargin record and sets its fields appropriately. * 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
*
* @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 )
public RightMarginRecord(short id, short size, byte [] data, int offset) { super( id, size, data, 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.
*
* @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() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[RightMargin]\n"); buffer.append( "[RightMargin]\n" );
buffer.append(" .margin = ") .append(" (").append(getMargin()).append(" )\n"); buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
buffer.append("[/RightMargin]\n"); buffer.append( "[/RightMargin]\n" );
return buffer.toString(); 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, 0 + offset, sid );
LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
LittleEndian.putDouble(data, 4 + offset, field_1_margin); LittleEndian.putDouble( data, 4 + offset, field_1_margin );
return getRecordSize(); return getRecordSize();
} }
/** /**
* Size of record (exluding 4 byte header) * Size of record (exluding 4 byte header)
*/ */
public int getRecordSize() { return 4 + 8; }
public int getRecordSize() public short getSid() { return this.sid; }
{
return 4 + 8;
}
public short getSid()
{
return this.sid;
}
/** /**
* Get the margin field for the RightMargin record. * 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. * 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(); RightMarginRecord rec = new RightMarginRecord();
rec.field_1_margin = this.field_1_margin; rec.field_1_margin = this.field_1_margin;
return rec; return rec;
} }
} // END OF CLASS
}

View File

@ -110,7 +110,7 @@ class SSTDeserializer
//Since all of the characters will have been read, but the entire string (including formatting runs etc) //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 //hasnt, Compute the number of bytes to skip when the continue record starts
continueSkipBytes = offsetForContinuedRecord(0) - (remainingBytes - calculateByteCount(charsRead)); continueSkipBytes = offsetForContinuedRecord(0) - (remainingBytes - calculateByteCount(charsRead));
} }
} }
processString( data, offset, charsRead ); processString( data, offset, charsRead );
offset += totalStringSize(); offset += totalStringSize();
@ -223,6 +223,7 @@ class SSTDeserializer
*/ */
static public void addToStringTable( BinaryTree strings, Integer integer, UnicodeString string ) static public void addToStringTable( BinaryTree strings, Integer integer, UnicodeString string )
{ {
if ( string.isRichText() ) if ( string.isRichText() )
string.setOptionFlags( (byte) ( string.getOptionFlags() & ( ~8 ) ) ); string.setOptionFlags( (byte) ( string.getOptionFlags() & ( ~8 ) ) );
if ( string.isExtendedText() ) if ( string.isExtendedText() )

View File

@ -33,7 +33,7 @@ import org.apache.poi.util.LittleEndian;
*/ */
public class SharedFormulaRecord public class SharedFormulaRecord
extends Record extends Record
{ {
public final static short sid = 0x4BC; public final static short sid = 0x4BC;
private short size = 0; private short size = 0;

View File

@ -18,9 +18,8 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.*; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
import java.io.IOException;
/** /**
* Supports the STRING record structure. * Supports the STRING record structure.
@ -102,6 +101,11 @@ public class StringRecord
} }
} }
public boolean isInValueSection()
{
return true;
}
private int getStringLength() private int getStringLength()
{ {
return field_1_string_length; return field_1_string_length;
@ -129,12 +133,6 @@ public class StringRecord
return (field_2_unicode_flag == 1); return (field_2_unicode_flag == 1);
} }
public boolean isInValueSection()
{
return true;
}
/** /**
* called by the class that is responsible for writing this sucker. * called by the class that is responsible for writing this sucker.
* Subclasses should implement this so that their data is passed back in a * Subclasses should implement this so that their data is passed back in a
@ -207,7 +205,7 @@ public class StringRecord
buffer.append("[/STRING]\n"); buffer.append("[/STRING]\n");
return buffer.toString(); return buffer.toString();
} }
public Object clone() { public Object clone() {
StringRecord rec = new StringRecord(); StringRecord rec = new StringRecord();
rec.field_1_string_length = this.field_1_string_length; rec.field_1_string_length = this.field_1_string_length;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFRichTextString;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.*; import org.apache.poi.util.*;
/** /**
* Record for the top margin. * Record for the top margin.
* NOTE: This source was automatically generated. * NOTE: This source was automatically generated.
*
* @author Shawn Laubach (slaubach at apache dot org) * @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; public final static short sid = 0x28;
private double field_1_margin; private double field_1_margin;
public TopMarginRecord() { }
public TopMarginRecord()
{
}
/** /**
* Constructs a TopMargin record and sets its fields appropriately. * Constructs a TopMargin record and sets its fields appropriately.
* *
* @param id id must be 0x28 or an exception * @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 size size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public TopMarginRecord( short id, short size, byte[] data )
public TopMarginRecord(short id, short size, byte [] data) { super( id, size, data ); }
{
super(id, size, data);
}
/** /**
* Constructs a TopMargin record and sets its fields appropriately. * 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 data data of the record (should not contain sid/len)
* @param offset of the record's data * @param offset of the record's data
*/ */
public TopMarginRecord( short id, short size, byte[] data, int offset )
public TopMarginRecord(short id, short size, byte [] data, int offset) { super( id, size, data, 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. * @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() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[TopMargin]\n"); buffer.append( "[TopMargin]\n" );
buffer.append(" .margin = ") buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
.append(" (").append(getMargin()).append(" )\n"); buffer.append( "[/TopMargin]\n" );
buffer.append("[/TopMargin]\n");
return buffer.toString(); 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, 0 + offset, sid );
LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
LittleEndian.putDouble(data, 4 + offset, field_1_margin); LittleEndian.putDouble( data, 4 + offset, field_1_margin );
return getRecordSize(); return getRecordSize();
} }
/** /**
* Size of record (exluding 4 byte header) * Size of record (exluding 4 byte header)
*/ */
public int getRecordSize() { return 4 + 8; }
public int getRecordSize() public short getSid() { return this.sid; }
{
return 4 + 8;
}
public short getSid()
{
return this.sid;
}
/** /**
* Get the margin field for the TopMargin record. * 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. * 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(); TopMarginRecord rec = new TopMarginRecord();
rec.field_1_margin = this.field_1_margin; rec.field_1_margin = this.field_1_margin;
return rec; return rec;
} }
} // END OF CLASS
}

View File

@ -18,11 +18,11 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import java.io.UnsupportedEncodingException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
import java.io.UnsupportedEncodingException;
/** /**
* Title: Unicode String<P> * Title: Unicode String<P>
* Description: Unicode String record. We implement these as a record, although * 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"); // System.out.println("Unicode: We've got "+retval[2]+" for our option flag");
try { try {
String unicodeString = new String unicodeString = new String(getString().getBytes("Unicode"),"Unicode");
String(getString().getBytes("Unicode"),"Unicode");
if (getOptionFlags() == 0) if (getOptionFlags() == 0)
{ {
StringUtil.putCompressedUnicode(unicodeString, data, 0x3 + StringUtil.putCompressedUnicode(unicodeString, data, 0x3 +offset);
offset);
} }
else else
{ {

View File

@ -28,16 +28,14 @@ import org.apache.poi.util.LittleEndian;
* Company: SuperLink Software, Inc.<P> * Company: SuperLink Software, Inc.<P>
* @author Andrew C. Oliver (acoliver at apache dot org) * @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au) * @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre * @author Glen Stampoultzis (glens at apache.org)
*/ */
public class UnknownRecord public class UnknownRecord
extends Record extends Record
{ {
private short sid = 0; private short sid = 0;
private short size = 0; private byte[] thedata = null;
private byte[] thedata = null;
int offset = 0;
public UnknownRecord() public UnknownRecord()
{ {
@ -53,9 +51,8 @@ public class UnknownRecord
public UnknownRecord(short id, short size, byte [] data) public UnknownRecord(short id, short size, byte [] data)
{ {
this.sid = id; sid = id;
this.size = size; thedata = data;
this.thedata = data;
} }
public UnknownRecord( short id, short size, byte[] data, int offset ) public UnknownRecord( short id, short size, byte[] data, int offset )
@ -63,12 +60,11 @@ public class UnknownRecord
sid = id; sid = id;
thedata = new byte[size]; thedata = new byte[size];
System.arraycopy(data, offset, thedata, 0, 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) public int serialize(int offset, byte [] data)
{ {
if (thedata == null) if (thedata == null)
@ -98,7 +94,7 @@ public class UnknownRecord
protected void fillFields(byte [] data, short sid) protected void fillFields(byte [] data, short sid)
{ {
this.sid = 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*/ /** Unlike the other Record.clone methods this is a shallow clone*/
public Object clone() { public Object clone() {
UnknownRecord rec = new UnknownRecord(); UnknownRecord rec = new UnknownRecord();
rec.offset = offset;
rec.sid = sid; rec.sid = sid;
rec.size = size;
rec.thedata = thedata; rec.thedata = thedata;
return rec; return rec;
} }

View File

@ -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 );
}
}
}

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.aggregates; package org.apache.poi.hssf.record.aggregates;

View File

@ -14,19 +14,16 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.aggregates; package org.apache.poi.hssf.record.aggregates;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord; 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.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Iterator;
import java.util.List;
/** /**
* *
@ -39,17 +36,14 @@ public class RowRecordsAggregate
{ {
int firstrow = -1; int firstrow = -1;
int lastrow = -1; int lastrow = -1;
boolean firstdirty = false;
boolean lastdirty = false;
Map records = null; Map records = null;
int size = 0; int size = 0;
/** Creates a new instance of RowRecordsAggregate */ /** Creates a new instance of ValueRecordsAggregate */
public RowRecordsAggregate() public RowRecordsAggregate()
{ {
records = new TreeMap(); records = new TreeMap();
} }
public void insertRow(RowRecord row) public void insertRow(RowRecord row)
@ -73,12 +67,6 @@ public class RowRecordsAggregate
size -= row.getRecordSize(); size -= row.getRecordSize();
// Integer integer = new Integer(row.getRowNumber()); // Integer integer = new Integer(row.getRowNumber());
if (lastrow == row.getRowNumber()) {
lastdirty = true;
}
if (firstrow == row.getRowNumber()) {
firstdirty = true;
}
records.remove(row); records.remove(row);
} }
@ -99,20 +87,17 @@ public class RowRecordsAggregate
public int getFirstRowNum() public int getFirstRowNum()
{ {
if (firstdirty) {
firstrow = findFirstRow();
}
return firstrow; return firstrow;
} }
public int getLastRowNum() public int getLastRowNum()
{ {
if (lastdirty) {
lastrow = findLastRow();
}
return lastrow; return lastrow;
} }
/*
* No need to go through all the records as we're just collecting RowRecords
public int construct(int offset, List records) public int construct(int offset, List records)
{ {
int k = 0; int k = 0;
@ -132,86 +117,7 @@ public class RowRecordsAggregate
} }
return k; 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. * called by the class that is responsible for writing this sucker.
@ -223,38 +129,14 @@ public class RowRecordsAggregate
* @return number of bytes written * @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(); Iterator itr = records.values().iterator();
int pos = offset; int pos = offset;
//DBCells are serialized before row records. while (itr.hasNext())
final int blockCount = getRowBlockCount(); {
for (int block=0;block<blockCount;block++) { pos += (( Record ) itr.next()).serialize(pos, data);
//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);
} }
return pos - offset; return pos - offset;
} }
@ -301,52 +183,199 @@ public class RowRecordsAggregate
{ {
return records.values().iterator(); 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()
{ {
int rownum = lastrow-1; RowRecordsAggregate rec = new RowRecordsAggregate();
RowRecord r = getRow(rownum); for ( Iterator rowIter = getIterator(); rowIter.hasNext(); )
while (r == null && rownum >= 0)
{ {
r = this.getRow(--rownum); //return the cloned Row Record & insert
RowRecord row = (RowRecord) ( (RowRecord) rowIter.next() ).clone();
rec.insertRow( row );
} }
return rownum; return rec;
}
/**
* used internally to refresh the "first row" when the first row is removed.
*/
private int findFirstRow()
{
int rownum = firstrow+1;
RowRecord r = getRow(rownum);
while (r == null && rownum <= getLastRowNum())
{
r = getRow(++rownum);
}
if (rownum > getLastRowNum())
return -1;
return rownum;
} }
/** Performs a deep clone of the record*/ public int findStartOfRowOutlineGroup(int row)
public Object clone() { {
RowRecordsAggregate rec = new RowRecordsAggregate(); // Find the start of the group.
for (Iterator rowIter = getIterator(); rowIter.hasNext();) { RowRecord rowRecord = this.getRow( row );
//return the cloned Row Record & insert int level = rowRecord.getOutlineLevel();
RowRecord row = (RowRecord)((RowRecord)rowIter.next()).clone(); int currentRow = row;
rec.insertRow(row); while (this.getRow( currentRow ) != null)
} {
return rec; rowRecord = this.getRow( currentRow );
if (rowRecord.getOutlineLevel() < level)
return currentRow + 1;
currentRow--;
}
return currentRow + 1;
}
public int findEndOfRowOutlineGroup( int row )
{
int level = getRow( row ).getOutlineLevel();
int currentRow;
for (currentRow = row; currentRow < this.getLastRowNum(); currentRow++)
{
if (getRow(currentRow) == null || getRow(currentRow).getOutlineLevel() < level)
{
break;
}
}
return currentRow-1;
}
public int writeHidden( RowRecord rowRecord, int row, boolean hidden )
{
int level = rowRecord.getOutlineLevel();
while (rowRecord != null && this.getRow(row).getOutlineLevel() >= level)
{
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 );
}
}
/**
* 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;
}
public boolean isRowGroupCollapsed( int row )
{
int collapseRow = findEndOfRowOutlineGroup( row ) + 1;
if (getRow(collapseRow) == null)
return false;
else
return getRow( collapseRow ).getColapsed();
}
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 ) )
{
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 );
}
}
// 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();
}
if (endLevel > startLevel)
{
return endHidden;
}
else
{
return startHidden;
}
} }
} }

View File

@ -14,26 +14,21 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.aggregates; package org.apache.poi.hssf.record.aggregates;
import org.apache.poi.hssf.record.*; 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.Iterator;
import java.util.List; import java.util.List;
import java.util.TreeMap;
/** /**
* *
* Aggregate value records together. Things are easier to handle that way. * 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 Glen Stampoultzis (glens at apache.org)
* @author Jason Height (jheight at chariot dot net dot au) * @author Jason Height (jheight at chariot dot net dot au)
*/ */
@ -42,110 +37,69 @@ public class ValueRecordsAggregate
extends Record extends Record
{ {
public final static short sid = -1000; 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; /** Creates a new instance of ValueRecordsAggregate */
private final static int DEFAULT_COLS=256;
IntList2d celltype = null; public ValueRecordsAggregate()
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 int getRecordSize() {
int size = 0;
Iterator irecs = getIterator();
while (irecs.hasNext()) {
size += (( Record ) irecs.next()).getRecordSize();
}
return size;
}
public int serialize(int offset, byte [] data)
{ {
throw new RuntimeException("This method shouldnt be called. ValueRecordsAggregate.serializeCellRow() should be called from RowRecordsAggregate."); records = new TreeMap();
} }
public ValueRecordsAggregate() { public void insertCell(CellValueRecordInterface cell)
celltype = new IntList2d();
xfs = new IntList2d();
numericcells = new DoubleList2d();
formulaptgs = new List2d();
stringvals = new List2d();
populatedRows = new IntList();
physCells = 0;
}
public Iterator getIterator() {
return new VRAIterator(this);
}
/** 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;
}
/** Returns true if the row has cells attached to it */
public boolean rowHasCells(int row)
{ {
if (row == -1) /* if (records.get(cell) == null)
return false;
int col = 0;
while (celltype.isAllocated( col, row))
{ {
if (celltype.get( col, row ) != 0) size += (( Record ) cell).getRecordSize();
return true;
col++;
} }
return false; else
}
/** Serializes the cells that are allocated to a certain row range*/
public int serializeCellRow(final int row, int offset, byte [] data)
{
Iterator itr = new VRAIterator(this, row);
int pos = offset;
while (itr.hasNext())
{ {
CellValueRecordInterface cell = (CellValueRecordInterface)itr.next(); size += (( Record ) cell).getRecordSize()
pos += (( Record ) cell).serialize(pos, data); - (( Record ) records.get(cell)).getRecordSize();
}*/
// XYLocator xy = new XYLocator(cell.getRow(), cell.getColumn());
Object o = records.put(cell, cell);
if ((cell.getColumn() < firstcell) || (firstcell == -1))
{
firstcell = cell.getColumn();
}
if ((cell.getColumn() > lastcell) || (lastcell == -1))
{
lastcell = cell.getColumn();
} }
return pos - offset;
} }
public void removeCell(CellValueRecordInterface cell)
{
// size -= (( Record ) cell).getRecordSize();
// XYLocator xy = new XYLocator(cell.getRow(), cell.getColumn());
records.remove(cell);
}
public int getPhysicalNumberOfCells()
{
return records.size();
}
public int getFirstCellNum()
{
return firstcell;
}
public int getLastCellNum()
{
return lastcell;
}
public int construct(int offset, List records) public int construct(int offset, List records)
{ {
int k; int k = 0;
FormulaRecordAggregate lastFormulaAggregate = null; FormulaRecordAggregate lastFormulaAggregate = null;
@ -165,8 +119,10 @@ public class ValueRecordsAggregate
else if (rec instanceof StringRecord) else if (rec instanceof StringRecord)
{ {
lastFormulaAggregate.setStringRecord((StringRecord)rec); 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); lastFormulaAggregate.setSharedFormulaRecord((SharedFormulaRecord)rec);
} }
else if (rec.isValue()) else if (rec.isValue())
@ -177,518 +133,140 @@ public class ValueRecordsAggregate
return k; return k;
} }
public int getPhysicalNumberOfCells() { /**
return physCells; * 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 int getPhysicalNumberOfCellsInRow(int row) { public int serialize(int offset, byte [] data)
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.
}
}
public void insertCell( CellValueRecordInterface cell )
{ {
int rownum = cell.getRow(); Iterator itr = records.values().iterator();
int colnum = cell.getColumn(); int pos = offset;
int xf = cell.getXFIndex();
int type = determineType(cell);
if (!populatedRows.contains( rownum )) while (itr.hasNext())
{ {
populatedRows.add(rownum); //this means we must never have had this row inserted pos += (( Record ) itr.next()).serialize(pos, data);
} }
return pos - offset;
// 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);
} }
/**
* 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)
*/
CellValueRecordInterface constructRecord(int row, int col) { protected void fillFields(byte [] data, short size, int offset)
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());
}
}
private int determineType(CellValueRecordInterface cval)
{
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 * called by constructor, should throw runtime exception in the event of a
* including the current column * 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; protected void validateSid(short id)
while (celltype.isAllocated( currentCol, row )) {
{ }
if (celltype.get( currentCol, row) > 0)
return currentCol; /**
currentCol++; * return the non static version of the id for this record.
*/
public short getSid()
{
return sid;
}
public int getRecordSize() {
int size = 0;
Iterator irecs = records.values().iterator();
while (irecs.hasNext()) {
size += (( Record ) irecs.next()).getRecordSize();
} }
return -1;
/* return size;
IntList ctRow = (IntList) celltype.get(row); // return size;
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 Iterator getIterator()
{
public short getSid() { return records.values().iterator();
return sid;
} }
/** Performs a deep clone of the record*/
public void fillFields(byte[] data, short size, int offset) { 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;
} }
protected void validateSid(short sid) {
}
} }
class VRAIterator implements Iterator { /*
private boolean hasNext; * class XYLocator implements Comparable {
private ValueRecordsAggregate vra; * private int row = 0;
private int popindex; * private int col = 0;
private int row; * public XYLocator(int row, int col) {
private int rowlimit; * this.row = row;
CellValueRecordInterface current = null; * this.col = col;
CellValueRecordInterface next = null; * }
*
public VRAIterator(ValueRecordsAggregate vra) { * public int getRow() {
this(vra, 0, -1); * return row;
} * }
*
public VRAIterator(ValueRecordsAggregate vra, int row) { * public int getCol() {
this(vra, row, row); * return col;
} * }
*
public VRAIterator(ValueRecordsAggregate vra, int startRow, int endRow) { * public int compareTo(Object obj) {
this.vra = vra; * XYLocator loc = (XYLocator)obj;
this.row = startRow; *
this.rowlimit = endRow; * if (this.getRow() == loc.getRow() &&
this.popindex = vra.populatedRows.indexOf(row); * this.getCol() == loc.getCol() )
if (this.popindex == -1) { * return 0;
if (vra.populatedRows.size() == 0) *
hasNext = false; * if (this.getRow() < loc.getRow())
else * return -1;
{ *
int lastRow = vra.populatedRows.get(vra.populatedRows.size()-1); * if (this.getRow() > loc.getRow())
if (lastRow == -1) * return 1;
{ *
hasNext = false; * if (this.getCol() < loc.getCol())
} * return -1;
else *
{ * if (this.getCol() > loc.getCol())
for (int i = row; i <= lastRow; i++) * return 1;
{ *
this.popindex = vra.populatedRows.indexOf(i); * return -1;
if (popindex != -1) *
break; * }
} *
} * public boolean equals(Object obj) {
if (popindex == -1) * if (!(obj instanceof XYLocator)) return false;
hasNext = false; *
else * XYLocator loc = (XYLocator)obj;
{ * if (this.getRow() == loc.getRow()
next = findNextCell(null); * &&
hasNext = (next != null); * this.getCol() == loc.getCol()
} * ) return true;
} * return false;
} else if (vra.getPhysicalNumberOfCells() > 0) { * }
next = findNextCell(null); *
hasNext = (next != null); *
} * }
} */
public boolean hasNext() {
return hasNext;
}
public Object next() {
current = next;
next = findNextCell(current);
if (next == null) {
hasNext = false;
}
return current;
}
public void remove() {
vra.removeCell(current);
}
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);
}
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);
}
}

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.BinaryTree; import org.apache.poi.util.BinaryTree;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* AddPtg.java * AddPtg.java

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
@ -200,7 +198,7 @@ public class Area3DPtg extends Ptg
/** /**
* sets the first row to relative or not * 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 ) public void setFirstRowRelative( boolean rel )
{ {
@ -217,7 +215,7 @@ public class Area3DPtg extends Ptg
/** /**
* set whether the last row is relative or not * 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 ) 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_3_last_row = field_3_last_row;
ptg.field_4_first_column = field_4_first_column; ptg.field_4_first_column = field_4_first_column;
ptg.field_5_last_column = field_5_last_column; ptg.field_5_last_column = field_5_last_column;
ptg.setClass(ptgClass); ptg.setClass(ptgClass);
return ptg; return ptg;
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* AreaPtg.java
*
* Created on November 17, 2001, 9:30 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; 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) public void setLastRow(short row)
{ {
@ -230,7 +224,7 @@ public class AreaPtg
/** /**
* set whether the last row is relative or not * 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) { public void setLastRowRelative(boolean rel) {
field_4_last_column=rowRelative.setShortBoolean(field_4_last_column,rel); field_4_last_column=rowRelative.setShortBoolean(field_4_last_column,rel);

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* AttrPtg.java
*
* Created on November 21, 2001, 1:20 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* BoolPtg.java
*
* Created on Septemeber 26, 2002, 7:37 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* AddPtg.java
*
* Created on October 29, 2001, 7:48 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List; import java.util.List;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
public abstract class ControlPtg public abstract class ControlPtg

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* DividePtg.java
*
* Created on November 4, 2001, 9:04 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List; import java.util.List;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* EqualPtg.java
*
* Created on November 17, 2001, 12:51 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* ExpPtg.java
*
* Created on November 25, 2001, 4:00 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
@ -98,4 +98,4 @@ public class FuncPtg extends AbstractFunctionPtg{
.append("</FunctionPtg>"); .append("</FunctionPtg>");
return buffer.toString(); return buffer.toString();
} }
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;

View File

@ -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 Copyright 2003-2004 Apache Software Foundation
@ -31,8 +15,8 @@
limitations under the License. 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; 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 * PTG class to implement greater or equal to
* *
* @author fred at stsci dot edu * @author fred at stsci dot edu
*/ */
public class GreaterEqualPtg public class GreaterEqualPtg
extends OperationPtg extends OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x0c; public final static byte sid = 0x0c;
/** /** Creates new GreaterEqualPtg */
* Creates new GreaterEqualPtg
*/ public GreaterEqualPtg()
public GreaterEqualPtg()
{ {
} }
public GreaterEqualPtg( byte[] data, int offset ) public GreaterEqualPtg(byte [] data, int offset)
{ {
// doesn't need anything // 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() public int getSize()
@ -83,25 +65,24 @@ public class GreaterEqualPtg
return 2; return 2;
} }
public String toFormulaString( Workbook book ) public String toFormulaString(Workbook book)
{ {
return ">="; return ">=";
} }
public String toFormulaString( String[] operands ) public String toFormulaString(String[] operands) {
{ StringBuffer buffer = new StringBuffer();
StringBuffer buffer = new StringBuffer();
buffer.append( operands[0] ); buffer.append(operands[ 0 ]);
buffer.append( toFormulaString( (Workbook) null ) );
buffer.append( operands[1] ); buffer.append(toFormulaString((Workbook)null));
buffer.append(operands[ 1 ]);
return buffer.toString(); return buffer.toString();
} }
public Object clone() public Object clone() {
{ return new GreaterEqualPtg();
return new GreaterEqualPtg();
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -14,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* GreaterThanPtg.java * GreaterThanPtg.java
@ -95,10 +94,11 @@ public class GreaterThanPtg
/** /**
* Implementation of method from Ptg * Implementation of method from Ptg
* @param refs the Sheet References
*/ */
public String toFormulaString(Workbook book) public String toFormulaString(Workbook book)
{ {
return GreaterThanPtg.GREATERTHAN; return this.GREATERTHAN;
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* IntPtg.java * IntPtg.java

View File

@ -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 Copyright 2003-2004 Apache Software Foundation
@ -31,11 +15,13 @@
limitations under the License. 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; import org.apache.poi.hssf.model.Workbook;
/** /**
* Ptg class to implement less than or equal * Ptg class to implement less than or equal
* *
@ -52,6 +38,7 @@ public class LessEqualPtg
*/ */
public LessEqualPtg() public LessEqualPtg()
{ {
} }
public LessEqualPtg( byte[] data, int offset ) public LessEqualPtg( byte[] data, int offset )
@ -97,6 +84,4 @@ public class LessEqualPtg
{ {
return new LessEqualPtg(); return new LessEqualPtg();
} }
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* LessThanPtg.java * LessThanPtg.java
@ -104,10 +103,11 @@ public class LessThanPtg
/** /**
* Implementation of method from Ptg * Implementation of method from Ptg
* @param refs the Sheet References
*/ */
public String toFormulaString(Workbook book) public String toFormulaString(Workbook book)
{ {
return LessThanPtg.LESSTHAN; return this.LESSTHAN;
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* MemErrPtg.java * MemErrPtg.java

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/* /*
* Ptg.java * Ptg.java
@ -92,4 +91,4 @@ public class MemFuncPtg extends ControlPtg
field_1_len_ref_subexpression = (short)len; field_1_len_ref_subexpression = (short)len;
} }
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* MultiplyPtg.java
*
* Created on November 4, 2001, 8:26 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List; import java.util.List;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* NamePtg.java
*
* Created on November 25, 2001, 3:30 PM
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* NameXPtg.java
*
* Created on May 5, 2003
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;

View File

@ -1,3 +1,4 @@
/* ==================================================================== /* ====================================================================
Copyright 2003-2004 Apache Software Foundation Copyright 2003-2004 Apache Software Foundation
@ -20,66 +21,67 @@ import org.apache.poi.hssf.model.Workbook;
/** /**
* Ptg class to implement not equal * Ptg class to implement not equal
* @author fred at stsci dot edu *
* @author fred at stsci dot edu
*/ */
public class NotEqualPtg public class NotEqualPtg
extends OperationPtg extends OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x0e; public final static byte sid = 0x0e;
/** Creates new NotEqualPtg */ /**
public NotEqualPtg() * Creates new NotEqualPtg
{ */
public NotEqualPtg()
{
}
} public NotEqualPtg( byte[] data, int offset )
{
// doesn't need anything
}
public NotEqualPtg(byte [] data, int offset) public void writeBytes( byte[] array, int offset )
{ {
array[offset + 0] = sid;
}
// doesn't need anything public int getSize()
} {
return SIZE;
}
public void writeBytes(byte [] array, int offset) public int getType()
{ {
array[ offset + 0 ] = sid; return TYPE_BINARY;
} }
public int getSize() public int getNumberOfOperands()
{ {
return SIZE; return 2;
} }
public int getType() public String toFormulaString( Workbook book )
{ {
return TYPE_BINARY; return "<>";
} }
public int getNumberOfOperands() public String toFormulaString( String[] operands )
{ {
return 2; StringBuffer buffer = new StringBuffer();
}
public String toFormulaString(Workbook book) buffer.append( operands[0] );
{
return "<>";
}
public String toFormulaString(String[] operands) {
StringBuffer buffer = new StringBuffer();
buffer.append( toFormulaString( (Workbook) null ) );
buffer.append(operands[ 0 ]); buffer.append( operands[1] );
buffer.append(toFormulaString((Workbook)null));
buffer.append(operands[ 1 ]);
return buffer.toString();
}
public Object clone() { return buffer.toString();
return new NotEqualPtg(); }
}
public Object clone()
{
return new NotEqualPtg();
}
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;

Some files were not shown because too many files have changed in this diff Show More