naruto-lgtm commented on code in PR #1580:
URL: https://github.com/apache/poi/pull/1580#discussion_r4651344246


##########
poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java:
##########
@@ -324,6 +324,21 @@ public void removeRow(Row row) {
                 _firstrow = -1;
                 _lastrow = -1;
             }
+
+            // also remove any comment located in that row
+            removeCommentsInRow(hrow.getRowNum());
+        }
+    }
+
+    private void removeCommentsInRow(int rowNum) {

Review Comment:
   Done. HSSFSheet.removeComment(patriarch, comment) finds the container that 
actually holds the comment, patriarch or group, and removes it there; 
HSSFCell.removeCellComment goes through it, and moveCommentsForRowShift now 
reuses findCellCommentLocations instead of its own top-level walk, so grouped 
comments shift as well. No third copy of the logic.



##########
poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFSheet.java:
##########
@@ -1116,6 +1117,30 @@ void bug59135() throws IOException {
         }
     }
 
+    @Test
+    void removeRowRemovesComments() throws IOException {

Review Comment:
   Added all three. removeRowRemovesCommentInShapeGroup, 
removeRowLeavesASheetWithoutADrawingAlone (patriarch stays null, before and 
after a write) and removeRowWithoutACommentDoesNotAggregateTheDrawing; 
removeRowRemovesComments now also asserts the NoteRecord rows and the TXO 
strings in the written stream, read before anything aggregates the drawing. The 
group test and the aggregation test both fail on the previous commit, as do the 
new assertions in removeRowRemovesComments.
   
   One note on the group test: HSSFShapeGroup has no createComment, so the 
helper wires the comment into the group the way HSSFShapeGroup.onCreate does. 
Happy to switch it to a sample file if you would rather not have that in a test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to