summaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-11-17 13:08:48 +0000
committerPJ Fanning <fanningpj@apache.org>2021-11-17 13:08:48 +0000
commitfa703eccfb6921ec105139bcb43d4ce60f703a8a (patch)
tree30fe0ae5f1c4f2b4399dab3bf2f751ca9076877d /poi-ooxml
parentfd1b5c87cf7ec8aad5905c844dcba1e95f9bbc17 (diff)
downloadpoi-fa703eccfb6921ec105139bcb43d4ce60f703a8a.tar.gz
poi-fa703eccfb6921ec105139bcb43d4ce60f703a8a.zip
try to make comments table more extensible
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java22
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java5
2 files changed, 23 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
index 876339f2fa..c3b122ad9a 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
@@ -30,6 +30,7 @@ import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
import org.apache.poi.util.Units;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFComment;
@@ -99,9 +100,12 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments {
/**
* Called after the reference is updated, so that
* we can reflect that in our cache
- * @param oldReference the comment to remove from the commentRefs map
- * @param comment the comment to replace in the commentRefs map
+ * @param oldReference the comment to remove from the commentRefs map
+ * @param comment the comment to replace in the commentRefs map
+ * @deprecated use {@link #referenceUpdated(CellAddress, XSSFComment)}
*/
+ @Deprecated
+ @Removal(version = "6.0.0")
public void referenceUpdated(CellAddress oldReference, CTComment comment) {
if(commentRefs != null) {
commentRefs.remove(oldReference);
@@ -109,6 +113,20 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments {
}
}
+ /**
+ * Called after the reference is updated, so that
+ * we can reflect that in our cache
+ * @param oldReference the comment to remove from the commentRefs map
+ * @param comment the comment to replace in the commentRefs map
+ * @since POI 5.2.0
+ */
+ public void referenceUpdated(CellAddress oldReference, XSSFComment comment) {
+ if(commentRefs != null) {
+ commentRefs.remove(oldReference);
+ commentRefs.put(comment.getAddress(), comment.getCTComment());
+ }
+ }
+
@Override
public int getNumberOfComments() {
return comments.getCommentList().sizeOfCommentArray();
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java
index 369a8bdc05..96920c2345 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java
@@ -163,7 +163,7 @@ public class XSSFComment implements Comment {
}
_comment.setRef(address.formatAsString());
- _comments.referenceUpdated(oldRef, _comment);
+ _comments.referenceUpdated(oldRef, this);
if (_vmlShape != null) {
CTClientData clientData = _vmlShape.getClientDataArray(0);
@@ -244,8 +244,9 @@ public class XSSFComment implements Comment {
/**
* @return the xml bean holding this comment's properties
+ * @since POI 5.2.0 (was protected before POI 5.2.0)
*/
- protected CTComment getCTComment(){
+ public CTComment getCTComment(){
return _comment;
}