Author: fanningpj
Date: Fri Nov 19 18:09:57 2021
New Revision: 1895182
URL: http://svn.apache.org/viewvc?rev=1895182&view=rev
Log:
try to make CommentsTable more extensible
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java?rev=1895182&r1=1895181&r2=1895182&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
(original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
Fri Nov 19 18:09:57 2021
@@ -17,9 +17,9 @@
package org.apache.poi.xssf.model;
import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.xssf.usermodel.XSSFComment;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
import java.util.Iterator;
@@ -54,7 +54,7 @@ public interface Comments {
* @return cell comment if one exists, otherwise returns null
* @since POI 5.2.0
*/
- public XSSFComment findCellComment(XSSFSheet sheet, CellAddress
cellAddress);
+ public XSSFComment findCellComment(Sheet sheet, CellAddress cellAddress);
/**
* Remove the comment at cellRef location, if one exists
@@ -84,7 +84,7 @@ public interface Comments {
* @return new XSSFComment
* @since POI 5.2.0
*/
- XSSFComment createNewComment(XSSFSheet sheet, ClientAnchor clientAnchor);
+ XSSFComment createNewComment(Sheet sheet, ClientAnchor clientAnchor);
/**
* Called after the reference is updated, so that
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java?rev=1895182&r1=1895181&r2=1895182&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
Fri Nov 19 18:09:57 2021
@@ -25,9 +25,11 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import com.microsoft.schemas.vml.CTShape;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
@@ -212,13 +214,13 @@ public class CommentsTable extends POIXM
* @since POI 5.2.0
*/
@Override
- public XSSFComment findCellComment(XSSFSheet sheet, CellAddress
cellAddress) {
+ public XSSFComment findCellComment(Sheet sheet, CellAddress cellAddress) {
CTComment ctComment = getCTComment(cellAddress);
if(ctComment == null) {
return null;
}
- XSSFVMLDrawing vml = sheet.getVMLDrawing(false);
+ XSSFVMLDrawing vml = sheet instanceof XSSFSheet ?
((XSSFSheet)sheet).getVMLDrawing(false) : null;
return new XSSFComment(this, ctComment,
vml == null ? null :
vml.findCommentShape(cellAddress.getRow(), cellAddress.getColumn()));
}
@@ -257,10 +259,10 @@ public class CommentsTable extends POIXM
* @since POI 5.2.0
*/
@Override
- public XSSFComment createNewComment(XSSFSheet sheet, ClientAnchor
clientAnchor) {
- XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
- com.microsoft.schemas.vml.CTShape vmlShape = vml.newCommentShape();
- if (clientAnchor instanceof XSSFClientAnchor &&
((XSSFClientAnchor)clientAnchor).isSet()) {
+ public XSSFComment createNewComment(Sheet sheet, ClientAnchor
clientAnchor) {
+ XSSFVMLDrawing vml = sheet instanceof XSSFSheet ?
((XSSFSheet)sheet).getVMLDrawing(true) : null;
+ CTShape vmlShape = vml == null ? null : vml.newCommentShape();
+ if (vmlShape != null && clientAnchor instanceof XSSFClientAnchor &&
((XSSFClientAnchor)clientAnchor).isSet()) {
// convert offsets from emus to pixels since we get a
// DrawingML-anchor
// but create a VML Drawing
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]