You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2015/11/23 13:47:24 UTC
svn commit: r1715794 -
/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
Author: onealj
Date: Mon Nov 23 12:47:24 2015
New Revision: 1715794
URL: http://svn.apache.org/viewvc?rev=1715794&view=rev
Log:
bug 58365: patch from Hannes Erven. Update XSSFSheetXMLHandler.java to use CellAddress instead of CellReference/String
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java?rev=1715794&r1=1715793&r2=1715794&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java Mon Nov 23 12:47:24 2015
@@ -22,6 +22,7 @@ import java.util.Queue;
import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -105,7 +106,7 @@ public class XSSFSheetXMLHandler extends
private StringBuffer formula = new StringBuffer();
private StringBuffer headerFooter = new StringBuffer();
- private Queue<CellReference> commentCellRefs;
+ private Queue<CellAddress> commentCellRefs;
/**
* Accepts objects needed while parsing.
@@ -162,9 +163,9 @@ public class XSSFSheetXMLHandler extends
@SuppressWarnings("deprecation")
private void init() {
if (commentsTable != null) {
- commentCellRefs = new LinkedList<CellReference>();
+ commentCellRefs = new LinkedList<CellAddress>();
for (CTComment comment : commentsTable.getCTComments().getCommentList().getCommentArray()) {
- commentCellRefs.add(new CellReference(comment.getRef()));
+ commentCellRefs.add(new CellAddress(comment.getRef()));
}
}
}
@@ -362,7 +363,7 @@ public class XSSFSheetXMLHandler extends
// Do we have a comment for this cell?
checkForEmptyCellComments(EmptyCellCommentsCheckType.CELL);
- XSSFComment comment = commentsTable != null ? commentsTable.findCellComment(cellRef) : null;
+ XSSFComment comment = commentsTable != null ? commentsTable.findCellComment(new CellAddress(cellRef)) : null;
// Output
output.cell(cellRef, thisStr, comment);
@@ -443,17 +444,17 @@ public class XSSFSheetXMLHandler extends
}
}
- CellReference nextCommentCellRef;
+ CellAddress nextCommentCellRef;
do {
- CellReference cellRef = new CellReference(this.cellRef);
- CellReference peekCellRef = commentCellRefs.peek();
+ CellAddress cellRef = new CellAddress(this.cellRef);
+ CellAddress peekCellRef = commentCellRefs.peek();
if (type == EmptyCellCommentsCheckType.CELL && cellRef.equals(peekCellRef)) {
// remove the comment cell ref from the list if we're about to handle it alongside the cell content
commentCellRefs.remove();
return;
} else {
// fill in any gaps if there are empty cells with comment mixed in with non-empty cells
- int comparison = cellRefComparator.compare(peekCellRef, cellRef);
+ int comparison = peekCellRef.compareTo(cellRef);
if (comparison > 0 && type == EmptyCellCommentsCheckType.END_OF_ROW && peekCellRef.getRow() <= rowNum) {
nextCommentCellRef = commentCellRefs.remove();
outputEmptyCellComment(nextCommentCellRef);
@@ -472,10 +473,9 @@ public class XSSFSheetXMLHandler extends
/**
* Output an empty-cell comment.
*/
- private void outputEmptyCellComment(CellReference cellRef) {
- String cellRefString = cellRef.formatAsString();
- XSSFComment comment = commentsTable.findCellComment(cellRefString);
- output.cell(cellRefString, null, comment);
+ private void outputEmptyCellComment(CellAddress cellRef) {
+ XSSFComment comment = commentsTable.findCellComment(cellRef);
+ output.cell(cellRef.formatAsString(), null, comment);
}
private enum EmptyCellCommentsCheckType {
@@ -483,19 +483,6 @@ public class XSSFSheetXMLHandler extends
END_OF_ROW,
END_OF_SHEET_DATA
}
- private static final Comparator<CellReference> cellRefComparator = new Comparator<CellReference>() {
- @Override
- public int compare(CellReference o1, CellReference o2) {
- int result = compare(o1.getRow(), o2.getRow());
- if (result == 0) {
- result = compare(o1.getCol(), o2.getCol());
- }
- return result;
- }
- public int compare(int x, int y) {
- return (x < y) ? -1 : ((x == y) ? 0 : 1);
- }
- };
/**
* You need to implement this to handle the results
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org