aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-11-19 14:26:15 +0000
committerPJ Fanning <fanningpj@apache.org>2021-11-19 14:26:15 +0000
commitb4f36926dc1d91374dbdc01e8f897f821e38eb86 (patch)
treef2f5b40ba17209919925bc062590cb1ebcd409fa
parent8c0d90c60cbdaf7c3fd15929cba7c05cf383c2b2 (diff)
downloadpoi-b4f36926dc1d91374dbdc01e8f897f821e38eb86.tar.gz
poi-b4f36926dc1d91374dbdc01e8f897f821e38eb86.zip
try to make CommentsTable more extensible
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895176 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java10
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java13
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java4
3 files changed, 27 insertions, 0 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
index ff8fad93ce..0223f60926 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
@@ -91,7 +91,17 @@ public interface Comments {
* 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
+ * @see #commentUpdated(XSSFComment)
* @since POI 5.2.0
*/
void referenceUpdated(CellAddress oldReference, XSSFComment comment);
+
+ /**
+ * Called after the comment is updated, so that
+ * we can reflect that in our cache
+ * @param comment the comment to replace in the commentRefs map
+ * @since POI 5.2.0
+ * @see #referenceUpdated(CellAddress, XSSFComment)
+ */
+ void commentUpdated(XSSFComment comment);
}
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 f4a5493436..9b3a2f888b 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
@@ -141,6 +141,7 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments {
* 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
+ * @see #commentUpdated(XSSFComment)
* @since POI 5.2.0
*/
@Override
@@ -151,6 +152,18 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments {
}
}
+ /**
+ * Called after the comment is updated, so that
+ * we can reflect that in our cache
+ * @param comment the comment to replace in the commentRefs map
+ * @since POI 5.2.0
+ * @see #referenceUpdated(CellAddress, XSSFComment)
+ */
+ @Override
+ public void commentUpdated(XSSFComment comment) {
+ //no-op in this implementation
+ }
+
@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 93ae75fa69..b0fb430712 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
@@ -92,6 +92,7 @@ public class XSSFComment implements Comment {
@Override
public void setAuthor(String author) {
_comment.setAuthorId(_comments.findAuthor(author));
+ _comments.commentUpdated(this);
}
/**
@@ -152,6 +153,7 @@ public class XSSFComment implements Comment {
}
}
}
+ _comments.commentUpdated(this);
}
@Override
@@ -182,6 +184,7 @@ public class XSSFComment implements Comment {
avoidXmlbeansCorruptPointer(_vmlShape);
}
+ _comments.commentUpdated(this);
}
/**
@@ -232,6 +235,7 @@ public class XSSFComment implements Comment {
}
_str = (XSSFRichTextString)string;
_comment.setText(_str.getCTRst());
+ _comments.commentUpdated(this);
}
public void setString(String string) {