Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-06-17 Thread via GitHub


AntonOellerer closed pull request #640: Fix ClassCastException inserting a 
paragraph into header or footer (bug 69042)
URL: https://github.com/apache/poi/pull/640


-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-06-17 Thread via GitHub


pjfanning commented on PR #640:
URL: https://github.com/apache/poi/pull/640#issuecomment-2173566189

   My preference is to make as few changes as possible to POI. It is a 20 year 
old project and it is very easy to break stuff when attempting to make changes.


-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-05-28 Thread via GitHub


AntonOellerer commented on PR #640:
URL: https://github.com/apache/poi/pull/640#issuecomment-2134992067

   I did some more work around this problem and discovered that the problem 
might actually lie somewhere else, as 
`XWPFDocument.insertNewParagraph(XmlCursor)` should not be invoked if the 
parent object is actually a `XWPFHeaderFooter`, instead we should use 
`XWPFHeaderFooter.insertNewParagraph(XmlCursor)`.
   What is your opinion on this @pjfanning ?


-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-05-28 Thread via GitHub


AntonOellerer commented on PR #640:
URL: https://github.com/apache/poi/pull/640#issuecomment-2134480141

   Thank you for the review, I added `breaks`/`returns` where necessary!


-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-05-27 Thread via GitHub


pjfanning commented on code in PR #640:
URL: https://github.com/apache/poi/pull/640#discussion_r1616341778


##
poi-ooxml/src/test/java/org/apache/poi/xwpf/TestXWPFBugs.java:
##
@@ -25,9 +25,7 @@ Licensed to the Apache Software Foundation (ASF) under one or 
more
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-
 import javax.crypto.Cipher;
-

Review Comment:
   Can you add back this new line?



-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-05-27 Thread via GitHub


pjfanning commented on code in PR #640:
URL: https://github.com/apache/poi/pull/640#discussion_r1616341503


##
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java:
##
@@ -912,6 +920,53 @@ private void insertElementIntoCell(XWPFTableCell 
tableCell, IBodyElement iBodyEl
 }
 }
 
+private void insertIntoTables(IBodyElement iBodyElement, Deque 
path, CTTbl ctTbl, List tables) {
+for (XWPFTable xwpfTable : tables) {
+if (ctTbl == xwpfTable.getCTTbl()) {
+insertElementIntoTable(xwpfTable, iBodyElement, path);
+}
+}
+}
+
+private void insertIntoHeadersFooters(IBodyElement iBodyElement, 
CTHdrFtrImpl ctHdrFtrImpl) {
+for (XWPFHeader header : headers) {
+if (ctHdrFtrImpl == header._getHdrFtr()) {
+insertIntoHeaderFooter(iBodyElement, header);

Review Comment:
   same issue as above about break call when you match in the if and likewise 
in next for loop.



-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



Re: [PR] Fix ClassCastException inserting a paragraph into header or footer (bug 69042) [poi]

2024-05-27 Thread via GitHub


pjfanning commented on code in PR #640:
URL: https://github.com/apache/poi/pull/640#discussion_r1616341166


##
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java:
##
@@ -912,6 +920,53 @@ private void insertElementIntoCell(XWPFTableCell 
tableCell, IBodyElement iBodyEl
 }
 }
 
+private void insertIntoTables(IBodyElement iBodyElement, Deque 
path, CTTbl ctTbl, List tables) {
+for (XWPFTable xwpfTable : tables) {
+if (ctTbl == xwpfTable.getCTTbl()) {
+insertElementIntoTable(xwpfTable, iBodyElement, path);
+}

Review Comment:
   shouldn't you break when you match in the `if`?



-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org