Merged revisions 614211 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk ........ r614211 | nick | 2008-01-22 15:48:51 +0100 (Tue, 22 Jan 2008) | 1 line Fix from bug #41726 - support signed offsets from relative areas and references ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@614831 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45cb22b13a
commit
ceb863a1d1
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
<!-- Don't forget to update status.xml too! -->
|
<!-- Don't forget to update status.xml too! -->
|
||||||
<release version="3.0.2-FINAL" date="2008-??-??">
|
<release version="3.0.2-FINAL" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">41726 - Fix how we handle signed cell offsets in relative areas and references</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">44233 - Support for getting and setting a flag on the sheet, which tells excel to re-calculate all formulas on it at next reload</action>
|
<action dev="POI-DEVELOPERS" type="add">44233 - Support for getting and setting a flag on the sheet, which tells excel to re-calculate all formulas on it at next reload</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44201 - Enable cloning of sheets with data validation rules</action>
|
<action dev="POI-DEVELOPERS" type="fix">44201 - Enable cloning of sheets with data validation rules</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44200 - Enable cloning of sheets with notes</action>
|
<action dev="POI-DEVELOPERS" type="fix">44200 - Enable cloning of sheets with notes</action>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<!-- Don't forget to update changes.xml too! -->
|
<!-- Don't forget to update changes.xml too! -->
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.0.2-FINAL" date="2008-??-??">
|
<release version="3.0.2-FINAL" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">41726 - Fix how we handle signed cell offsets in relative areas and references</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">44233 - Support for getting and setting a flag on the sheet, which tells excel to re-calculate all formulas on it at next reload</action>
|
<action dev="POI-DEVELOPERS" type="add">44233 - Support for getting and setting a flag on the sheet, which tells excel to re-calculate all formulas on it at next reload</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44201 - Enable cloning of sheets with data validation rules</action>
|
<action dev="POI-DEVELOPERS" type="fix">44201 - Enable cloning of sheets with data validation rules</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44200 - Enable cloning of sheets with notes</action>
|
<action dev="POI-DEVELOPERS" type="fix">44200 - Enable cloning of sheets with notes</action>
|
||||||
|
@ -156,8 +156,8 @@ public class SharedFormulaRecord
|
|||||||
|
|
||||||
protected void fillFields(RecordInputStream in)
|
protected void fillFields(RecordInputStream in)
|
||||||
{
|
{
|
||||||
field_1_first_row = in.readShort();
|
field_1_first_row = in.readUShort();
|
||||||
field_2_last_row = in.readShort();
|
field_2_last_row = in.readUShort();
|
||||||
field_3_first_column = in.readUByte();
|
field_3_first_column = in.readUByte();
|
||||||
field_4_last_column = in.readUByte();
|
field_4_last_column = in.readUByte();
|
||||||
field_5_reserved = in.readShort();
|
field_5_reserved = in.readShort();
|
||||||
@ -200,48 +200,48 @@ public class SharedFormulaRecord
|
|||||||
Ptg ptg = (Ptg) field_7_parsed_expr.get(k);
|
Ptg ptg = (Ptg) field_7_parsed_expr.get(k);
|
||||||
if (ptg instanceof RefNPtg) {
|
if (ptg instanceof RefNPtg) {
|
||||||
RefNPtg refNPtg = (RefNPtg)ptg;
|
RefNPtg refNPtg = (RefNPtg)ptg;
|
||||||
ptg = new ReferencePtg( (short)(formulaRow + refNPtg.getRow()),
|
ptg = new ReferencePtg(fixupRelativeRow(formulaRow,refNPtg.getRow(),refNPtg.isRowRelative()),
|
||||||
(byte)(formulaColumn + refNPtg.getColumn()),
|
fixupRelativeColumn(formulaColumn,refNPtg.getColumn(),refNPtg.isColRelative()),
|
||||||
refNPtg.isRowRelative(),
|
refNPtg.isRowRelative(),
|
||||||
refNPtg.isColRelative());
|
refNPtg.isColRelative());
|
||||||
} else if (ptg instanceof RefNVPtg) {
|
} else if (ptg instanceof RefNVPtg) {
|
||||||
RefNVPtg refNVPtg = (RefNVPtg)ptg;
|
RefNVPtg refNVPtg = (RefNVPtg)ptg;
|
||||||
ptg = new RefVPtg( (short)(formulaRow + refNVPtg.getRow()),
|
ptg = new RefVPtg(fixupRelativeRow(formulaRow,refNVPtg.getRow(),refNVPtg.isRowRelative()),
|
||||||
(byte)(formulaColumn + refNVPtg.getColumn()),
|
fixupRelativeColumn(formulaColumn,refNVPtg.getColumn(),refNVPtg.isColRelative()),
|
||||||
refNVPtg.isRowRelative(),
|
refNVPtg.isRowRelative(),
|
||||||
refNVPtg.isColRelative());
|
refNVPtg.isColRelative());
|
||||||
} else if (ptg instanceof RefNAPtg) {
|
} else if (ptg instanceof RefNAPtg) {
|
||||||
RefNAPtg refNAPtg = (RefNAPtg)ptg;
|
RefNAPtg refNAPtg = (RefNAPtg)ptg;
|
||||||
ptg = new RefAPtg( (short)(formulaRow + refNAPtg.getRow()),
|
ptg = new RefAPtg( fixupRelativeRow(formulaRow,refNAPtg.getRow(),refNAPtg.isRowRelative()),
|
||||||
(byte)(formulaColumn + refNAPtg.getColumn()),
|
fixupRelativeColumn(formulaColumn,refNAPtg.getColumn(),refNAPtg.isColRelative()),
|
||||||
refNAPtg.isRowRelative(),
|
refNAPtg.isRowRelative(),
|
||||||
refNAPtg.isColRelative());
|
refNAPtg.isColRelative());
|
||||||
} else if (ptg instanceof AreaNPtg) {
|
} else if (ptg instanceof AreaNPtg) {
|
||||||
AreaNPtg areaNPtg = (AreaNPtg)ptg;
|
AreaNPtg areaNPtg = (AreaNPtg)ptg;
|
||||||
ptg = new AreaPtg((short)(formulaRow + areaNPtg.getFirstRow()),
|
ptg = new AreaPtg(fixupRelativeRow(formulaRow,areaNPtg.getFirstRow(),areaNPtg.isFirstRowRelative()),
|
||||||
(short)(formulaRow + areaNPtg.getLastRow()),
|
fixupRelativeRow(formulaRow,areaNPtg.getLastRow(),areaNPtg.isLastRowRelative()),
|
||||||
(short)(formulaColumn + areaNPtg.getFirstColumn()),
|
fixupRelativeColumn(formulaColumn,areaNPtg.getFirstColumn(),areaNPtg.isFirstColRelative()),
|
||||||
(short)(formulaColumn + areaNPtg.getLastColumn()),
|
fixupRelativeColumn(formulaColumn,areaNPtg.getLastColumn(),areaNPtg.isLastColRelative()),
|
||||||
areaNPtg.isFirstRowRelative(),
|
areaNPtg.isFirstRowRelative(),
|
||||||
areaNPtg.isLastRowRelative(),
|
areaNPtg.isLastRowRelative(),
|
||||||
areaNPtg.isFirstColRelative(),
|
areaNPtg.isFirstColRelative(),
|
||||||
areaNPtg.isLastColRelative());
|
areaNPtg.isLastColRelative());
|
||||||
} else if (ptg instanceof AreaNVPtg) {
|
} else if (ptg instanceof AreaNVPtg) {
|
||||||
AreaNVPtg areaNVPtg = (AreaNVPtg)ptg;
|
AreaNVPtg areaNVPtg = (AreaNVPtg)ptg;
|
||||||
ptg = new AreaVPtg((short)(formulaRow + areaNVPtg.getFirstRow()),
|
ptg = new AreaVPtg(fixupRelativeRow(formulaRow,areaNVPtg.getFirstRow(),areaNVPtg.isFirstRowRelative()),
|
||||||
(short)(formulaRow + areaNVPtg.getLastRow()),
|
fixupRelativeRow(formulaRow,areaNVPtg.getLastRow(),areaNVPtg.isLastRowRelative()),
|
||||||
(short)(formulaColumn + areaNVPtg.getFirstColumn()),
|
fixupRelativeColumn(formulaColumn,areaNVPtg.getFirstColumn(),areaNVPtg.isFirstColRelative()),
|
||||||
(short)(formulaColumn + areaNVPtg.getLastColumn()),
|
fixupRelativeColumn(formulaColumn,areaNVPtg.getLastColumn(),areaNVPtg.isLastColRelative()),
|
||||||
areaNVPtg.isFirstRowRelative(),
|
areaNVPtg.isFirstRowRelative(),
|
||||||
areaNVPtg.isLastRowRelative(),
|
areaNVPtg.isLastRowRelative(),
|
||||||
areaNVPtg.isFirstColRelative(),
|
areaNVPtg.isFirstColRelative(),
|
||||||
areaNVPtg.isLastColRelative());
|
areaNVPtg.isLastColRelative());
|
||||||
} else if (ptg instanceof AreaNAPtg) {
|
} else if (ptg instanceof AreaNAPtg) {
|
||||||
AreaNAPtg areaNAPtg = (AreaNAPtg)ptg;
|
AreaNAPtg areaNAPtg = (AreaNAPtg)ptg;
|
||||||
ptg = new AreaAPtg((short)(formulaRow + areaNAPtg.getFirstRow()),
|
ptg = new AreaAPtg(fixupRelativeRow(formulaRow,areaNAPtg.getFirstRow(),areaNAPtg.isFirstRowRelative()),
|
||||||
(short)(formulaRow + areaNAPtg.getLastRow()),
|
fixupRelativeRow(formulaRow,areaNAPtg.getLastRow(),areaNAPtg.isLastRowRelative()),
|
||||||
(short)(formulaColumn + areaNAPtg.getFirstColumn()),
|
fixupRelativeColumn(formulaColumn,areaNAPtg.getFirstColumn(),areaNAPtg.isFirstColRelative()),
|
||||||
(short)(formulaColumn + areaNAPtg.getLastColumn()),
|
fixupRelativeColumn(formulaColumn,areaNAPtg.getLastColumn(),areaNAPtg.isLastColRelative()),
|
||||||
areaNAPtg.isFirstRowRelative(),
|
areaNAPtg.isFirstRowRelative(),
|
||||||
areaNAPtg.isLastRowRelative(),
|
areaNAPtg.isLastRowRelative(),
|
||||||
areaNAPtg.isFirstColRelative(),
|
areaNAPtg.isFirstColRelative(),
|
||||||
@ -257,6 +257,21 @@ public class SharedFormulaRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private short fixupRelativeColumn(int currentcolumn, short column, boolean relative) {
|
||||||
|
if(relative) {
|
||||||
|
if((column&128)!=0) column=(short)(column-256);
|
||||||
|
column+=currentcolumn;
|
||||||
|
}
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private short fixupRelativeRow(int currentrow, short row, boolean relative) {
|
||||||
|
if(relative) {
|
||||||
|
row+=currentrow;
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mirroring formula records so it is registered in the ValueRecordsAggregate
|
* Mirroring formula records so it is registered in the ValueRecordsAggregate
|
||||||
*/
|
*/
|
||||||
|
BIN
src/testcases/org/apache/poi/hssf/data/SharedFormulaTest.xls
Normal file
BIN
src/testcases/org/apache/poi/hssf/data/SharedFormulaTest.xls
Normal file
Binary file not shown.
@ -1127,6 +1127,17 @@ extends TestCase {
|
|||||||
cell.setCellFormula("IF(A1=\"A\",1,)");
|
cell.setCellFormula("IF(A1=\"A\",1,)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSharedFormula() throws Exception {
|
||||||
|
String readFilename = System.getProperty("HSSF.testdata.path");
|
||||||
|
File inFile = new File(readFilename+"/SharedFormulaTest.xls");
|
||||||
|
FileInputStream fis = new FileInputStream(inFile);
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook(fis);
|
||||||
|
|
||||||
|
assertEquals("A$1*2", wb.getSheetAt(0).getRow(1).getCell((short)1).toString());
|
||||||
|
assertEquals("$A11*2", wb.getSheetAt(0).getRow(11).getCell((short)1).toString());
|
||||||
|
assertEquals("DZ2*2", wb.getSheetAt(0).getRow(1).getCell((short)128).toString());
|
||||||
|
assertEquals("B32770*2", wb.getSheetAt(0).getRow(32768).getCell((short)1).toString());
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
System.out
|
System.out
|
||||||
|
Loading…
Reference in New Issue
Block a user