]> source.dussan.org Git - poi.git/commitdiff
bug 60601: unset hyperlinks after removing them individually from the DOM
authorJaven O'Neal <onealj@apache.org>
Thu, 19 Jan 2017 09:01:39 +0000 (09:01 +0000)
committerJaven O'Neal <onealj@apache.org>
Thu, 19 Jan 2017 09:01:39 +0000 (09:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1779437 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

index d6fc4353e6c953e8457ba6ff12041ec500a14548..61a56a10246eba3c1f91e424b44356d8155f628a 100644 (file)
@@ -3485,15 +3485,16 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet  {
             worksheet.getHyperlinks().setHyperlinkArray(ctHls);
         }
         else {
-            // For some reason, we have to remove the hyperlinks one by one from the CTHyperlinks array
-            // rather than unsetting or resetting the hyperlink array.
-            //worksheet.getHyperlinks().setHyperlinkArray(new CTHyperlink[0]);
-            //worksheet.unsetHyperlinks();
             if (worksheet.getHyperlinks() != null) {
                 final int count = worksheet.getHyperlinks().sizeOfHyperlinkArray();
                 for (int i=count-1; i>=0; i--) {
                     worksheet.getHyperlinks().removeHyperlink(i);
                 }
+                // For some reason, we have to remove the hyperlinks one by one from the CTHyperlinks array
+                // before unsetting the hyperlink array.
+                // Resetting the hyperlink array seems to break some XML nodes.
+                //worksheet.getHyperlinks().setHyperlinkArray(new CTHyperlink[0]);
+                worksheet.unsetHyperlinks();
             } else {
                 // nothing to do
             }