import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import com.microsoft.schemas.vml.CTShape;
import org.apache.poi.ooxml.POIXMLDocumentPart;
return false;
}
+ /**
+ * Remove the comment at cellRef location, if one exists
+ *
+ * @param rowNums the rows for which all comments will be removed
+ * @since POI 5.2.0
+ */
+ public void removeCommentsFromRows(XSSFSheet sheet, Set<Integer> rowNums) {
+ CTCommentList lst = getCTComments().getCommentList();
+ XSSFVMLDrawing vml = sheet.getVMLDrawing(false);
+ for (CTComment comment : lst.getCommentArray()) {
+ String strRef = comment.getRef();
+ CellAddress ref = new CellAddress(strRef);
+
+ // is this comment part of the current row?
+ if(rowNums.contains(ref.getRow())) {
+ removeComment(ref);
+ if (vml != null) {
+ vml.removeCommentShape(ref.getRow(), ref.getColumn());
+ }
+ }
+ }
+ }
+
/**
* Returns the underlying CTComments list xmlbean
*
// also remove any comments associated with this row
if (sheetComments != null) {
- CTCommentList lst = sheetComments.getCTComments().getCommentList();
- for (CTComment comment : lst.getCommentArray()) {
- String strRef = comment.getRef();
- CellAddress ref = new CellAddress(strRef);
-
- // is this comment part of the current row?
- if(rowsToRemoveSet.contains(ref.getRow())) {
- sheetComments.removeComment(ref);
- vml.removeCommentShape(ref.getRow(), ref.getColumn());
- }
- }
+ sheetComments.removeCommentsFromRows(this, rowsToRemoveSet);
}
// also remove any hyperlinks associated with this row
return (crow == row && ccol == col);
}
- protected boolean removeCommentShape(int row, int col){
+ /**
+ * Internal use only
+ */
+ @Internal
+ public boolean removeCommentShape(int row, int col){
XmlCursor cur = root.getXml().newCursor();
for (boolean found = cur.toFirstChild(); found; found = cur.toNextSibling()) {
XmlObject itm = cur.getObject();