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