You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2018/04/25 20:14:07 UTC
svn commit: r1830115 - in /poi:
site/src/documentation/content/xdocs/status.xml
trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java
trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Author: centic
Date: Wed Apr 25 20:14:07 2018
New Revision: 1830115
URL: http://svn.apache.org/viewvc?rev=1830115&view=rev
Log:
Fix setting active cell in .xls by populating field_6_refs whenever row/column changes, this fixes bug 61905
Modified:
poi/site/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1830115&r1=1830114&r2=1830115&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Wed Apr 25 20:14:07 2018
@@ -68,6 +68,7 @@
<summary-item>Provide new ooxml-schemas-1.4.jar</summary-item>
</summary>
<actions>
+ <action dev="PD" type="fix" fixes-bug="61905" module="HSSF">HSSFWorkbook.setActiveCell() does not actually make the cell selected in Excel</action>
<action dev="PD" type="fix" fixes-bug="61459" module="HSLF">HSLFShape.getShapeName() returns name of shapeType and not the shape name</action>
<action dev="PD" type="add" fixes-bug="62319" breaks-compatibility="true" module="SL Common">Decommission XSLF-/PowerPointExtractor</action>
<action dev="PD" type="add" fixes-bug="62092" module="SL Common">Text not extracted from grouped text shapes in HSLF</action>
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java?rev=1830115&r1=1830114&r2=1830115&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java Wed Apr 25 20:14:07 2018
@@ -79,6 +79,7 @@ public final class SelectionRecord exten
*/
public void setActiveCellRow(int row) {
field_2_row_active_cell = row;
+ resetField6();
}
/**
@@ -87,6 +88,14 @@ public final class SelectionRecord exten
*/
public void setActiveCellCol(short col) {
field_3_col_active_cell = col;
+ resetField6();
+ }
+
+ private void resetField6() {
+ // this is necessary in Excel to actually make Workbook.setActiveCell() take effect
+ field_6_refs = new CellRangeAddress8Bit[] {
+ new CellRangeAddress8Bit(field_2_row_active_cell, field_2_row_active_cell, field_3_col_active_cell, field_3_col_active_cell),
+ };
}
/**
@@ -130,17 +139,15 @@ public final class SelectionRecord exten
@Override
public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append("[SELECTION]\n");
- sb.append(" .pane = ").append(HexDump.byteToHex(getPane())).append("\n");
- sb.append(" .activecellrow = ").append(HexDump.shortToHex(getActiveCellRow())).append("\n");
- sb.append(" .activecellcol = ").append(HexDump.shortToHex(getActiveCellCol())).append("\n");
- sb.append(" .activecellref = ").append(HexDump.shortToHex(getActiveCellRef())).append("\n");
- sb.append(" .numrefs = ").append(HexDump.shortToHex(field_6_refs.length)).append("\n");
- sb.append("[/SELECTION]\n");
- return sb.toString();
+ return "[SELECTION]\n" +
+ " .pane = " + HexDump.byteToHex(getPane()) + "\n" +
+ " .activecellrow = " + HexDump.shortToHex(getActiveCellRow()) + "\n" +
+ " .activecellcol = " + HexDump.shortToHex(getActiveCellCol()) + "\n" +
+ " .activecellref = " + HexDump.shortToHex(getActiveCellRef()) + "\n" +
+ " .numrefs = " + HexDump.shortToHex(field_6_refs.length) + "\n" +
+ "[/SELECTION]\n";
}
+
@Override
protected int getDataSize() {
return 9 // 1 byte + 4 shorts
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1830115&r1=1830114&r2=1830115&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Wed Apr 25 20:14:07 2018
@@ -50,6 +50,7 @@ import org.apache.poi.POIXMLDocumentPart
import org.apache.poi.POIXMLException;
import org.apache.poi.POIXMLProperties;
import org.apache.poi.common.usermodel.HyperlinkType;
+import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -64,6 +65,7 @@ import org.apache.poi.openxml4j.opc.Pack
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.ConditionalFormattingEvaluator;
import org.apache.poi.ss.formula.EvaluationConditionalFormatRule;
@@ -79,6 +81,7 @@ import org.apache.poi.ss.formula.functio
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.CellUtil;
@@ -3293,4 +3296,31 @@ public final class TestXSSFBugs extends
sheet.autoSizeColumn(i);
}
}
+
+ @Test
+ public void test61905xlsx() throws IOException {
+ Workbook wb = new XSSFWorkbook();
+ checkActiveSheet(wb, XSSFITestDataProvider.instance);
+ wb.close();
+ }
+
+ @Test
+ public void test61905xls() throws IOException {
+ Workbook wb = new HSSFWorkbook();
+ checkActiveSheet(wb, HSSFITestDataProvider.instance);
+ wb.close();
+ }
+
+ private void checkActiveSheet(Workbook wb, ITestDataProvider instance) throws IOException {
+ Sheet sheet = wb.createSheet("new sheet");
+ sheet.setActiveCell(new CellAddress("E11"));
+ assertEquals("E11", sheet.getActiveCell().formatAsString());
+
+ Workbook wbBack = instance.writeOutAndReadBack(wb);
+ sheet = wbBack.getSheetAt(0);
+ assertEquals("E11", sheet.getActiveCell().formatAsString());
+ wbBack.close();
+
+ //wb.write(new FileOutputStream("c:/temp/61905." + instance.getStandardFileNameExtension()));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org