aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2017-01-19 07:44:25 +0000
committerJaven O'Neal <onealj@apache.org>2017-01-19 07:44:25 +0000
commitf055f995498ab1739957abe10644f292feeb151b (patch)
treeed1d487d0c0b71a22b4a01e3f90d1597447b9c5d /src/testcases/org/apache/poi/ss
parent53818803cade814b365f4e42c06a7b84d84e9ba5 (diff)
downloadpoi-f055f995498ab1739957abe10644f292feeb151b.tar.gz
poi-f055f995498ab1739957abe10644f292feeb151b.zip
bug 60601: unlink hyperlinks from a sheet if all hyperlinks have been removed. Patch from Joachim Piketz
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1779426 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
index 4e7179109b..8e010a6c05 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
@@ -1231,6 +1231,29 @@ public abstract class BaseTestSheet {
workbook.close();
}
+
+ @Test
+ public void removeAllHyperlinks() throws IOException {
+ Workbook workbook = _testDataProvider.createWorkbook();
+ Hyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.URL);
+ hyperlink.setAddress("https://poi.apache.org/");
+ Sheet sheet = workbook.createSheet();
+ Cell cell = sheet.createRow(5).createCell(1);
+ cell.setHyperlink(hyperlink);
+
+ assertEquals(1, workbook.getSheetAt(0).getHyperlinkList().size());
+ // Save a workbook with a hyperlink
+ Workbook workbook2 = _testDataProvider.writeOutAndReadBack(workbook);
+ assertEquals(1, workbook2.getSheetAt(0).getHyperlinkList().size());
+
+ // Remove all hyperlinks from a saved workbook
+ workbook2.getSheetAt(0).getRow(5).getCell(1).removeHyperlink();
+ assertEquals(0, workbook2.getSheetAt(0).getHyperlinkList().size());
+
+ // Verify that hyperlink was removed from workbook after writing out
+ Workbook workbook3 = _testDataProvider.writeOutAndReadBack(workbook2);
+ assertEquals(0, workbook3.getSheetAt(0).getHyperlinkList().size());
+ }
@Test