poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1753040 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/hssf/usermodel/ testcases/org/apache/poi/ss/usermodel/
Date Sun, 17 Jul 2016 09:32:29 GMT
Author: onealj
Date: Sun Jul 17 09:32:29 2016
New Revision: 1753040

URL: http://svn.apache.org/viewvc?rev=1753040&view=rev
Log:
bug 59783: replace deprecated Hyperlink.LINK_* and Hyperlink.getType usage

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1753040&r1=1753039&r2=1753040&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Sun Jul 17 09:32:29 2016
@@ -1109,15 +1109,15 @@ public class HSSFCell implements Cell {
         link.setFirstColumn(_record.getColumn());
         link.setLastColumn(_record.getColumn());
 
-        switch(link.getType()){
-            case HSSFHyperlink.LINK_EMAIL:
-            case HSSFHyperlink.LINK_URL:
+        switch(link.getTypeEnum()){
+            case EMAIL:
+            case URL:
                 link.setLabel("url");
                 break;
-            case HSSFHyperlink.LINK_FILE:
+            case FILE:
                 link.setLabel("file");
                 break;
-            case HSSFHyperlink.LINK_DOCUMENT:
+            case DOCUMENT:
                 link.setLabel("place");
                 break;
             default:

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java?rev=1753040&r1=1753039&r2=1753040&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java Sun
Jul 17 09:32:29 2016
@@ -71,7 +71,7 @@ public final class TestXSSFHyperlink ext
                 "http://apache.org/default.php?s=isTramsformed&submit=Search&la=*&li=*"};
         for(int i = 0; i < urls.length; i++){
             String s = urls[i];
-            XSSFHyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
+            XSSFHyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
             link.setAddress(s);
 
             XSSFCell cell = row.createCell(i);
@@ -111,7 +111,7 @@ public final class TestXSSFHyperlink ext
                 "\\poi"};
         for(String s : invalidURLs){
             try {
-                createHelper.createHyperlink(Hyperlink.LINK_URL).setAddress(s);
+                createHelper.createHyperlink(HyperlinkType.URL).setAddress(s);
                 fail("expected IllegalArgumentException: " + s);
             } catch (IllegalArgumentException e){
 
@@ -153,7 +153,7 @@ public final class TestXSSFHyperlink ext
         Row r17 = sheet.createRow(17);
         Cell r17c = r17.createCell(2);
 
-        Hyperlink hyperlink = createHelper.createHyperlink(Hyperlink.LINK_URL);
+        Hyperlink hyperlink = createHelper.createHyperlink(HyperlinkType.URL);
         hyperlink.setAddress("http://poi.apache.org/spreadsheet/");
         hyperlink.setLabel("POI SS Link");
         r17c.setHyperlink(hyperlink);
@@ -161,8 +161,8 @@ public final class TestXSSFHyperlink ext
         assertEquals(5, sheet.getNumHyperlinks());
         doTestHyperlinkContents(sheet);
 
-        assertEquals(Hyperlink.LINK_URL,
-                sheet.getRow(17).getCell(2).getHyperlink().getType());
+        assertEquals(HyperlinkType.URL,
+                sheet.getRow(17).getCell(2).getHyperlink().getTypeEnum());
         assertEquals("POI SS Link",
                 sheet.getRow(17).getCell(2).getHyperlink().getLabel());
         assertEquals("http://poi.apache.org/spreadsheet/",
@@ -182,8 +182,8 @@ public final class TestXSSFHyperlink ext
         assertEquals(5, sheet.getNumHyperlinks());
         doTestHyperlinkContents(sheet);
 
-        assertEquals(Hyperlink.LINK_URL,
-                sheet.getRow(17).getCell(2).getHyperlink().getType());
+        assertEquals(HyperlinkType.URL,
+                sheet.getRow(17).getCell(2).getHyperlink().getTypeEnum());
         assertEquals("POI SS Link",
                 sheet.getRow(17).getCell(2).getHyperlink().getLabel());
         assertEquals("http://poi.apache.org/spreadsheet/",
@@ -200,32 +200,32 @@ public final class TestXSSFHyperlink ext
         assertNotNull(sheet.getRow(16).getCell(2).getHyperlink());
 
         // First is a link to poi
-        assertEquals(Hyperlink.LINK_URL,
-                sheet.getRow(3).getCell(2).getHyperlink().getType());
+        assertEquals(HyperlinkType.URL,
+                sheet.getRow(3).getCell(2).getHyperlink().getTypeEnum());
         assertEquals(null,
                 sheet.getRow(3).getCell(2).getHyperlink().getLabel());
         assertEquals("http://poi.apache.org/",
                 sheet.getRow(3).getCell(2).getHyperlink().getAddress());
 
         // Next is an internal doc link
-        assertEquals(Hyperlink.LINK_DOCUMENT,
-                sheet.getRow(14).getCell(2).getHyperlink().getType());
+        assertEquals(HyperlinkType.DOCUMENT,
+                sheet.getRow(14).getCell(2).getHyperlink().getTypeEnum());
         assertEquals("Internal hyperlink to A2",
                 sheet.getRow(14).getCell(2).getHyperlink().getLabel());
         assertEquals("Sheet1!A2",
                 sheet.getRow(14).getCell(2).getHyperlink().getAddress());
 
         // Next is a file
-        assertEquals(Hyperlink.LINK_FILE,
-                sheet.getRow(15).getCell(2).getHyperlink().getType());
+        assertEquals(HyperlinkType.FILE,
+                sheet.getRow(15).getCell(2).getHyperlink().getTypeEnum());
         assertEquals(null,
                 sheet.getRow(15).getCell(2).getHyperlink().getLabel());
         assertEquals("WithVariousData.xlsx",
                 sheet.getRow(15).getCell(2).getHyperlink().getAddress());
 
         // Last is a mailto
-        assertEquals(Hyperlink.LINK_EMAIL,
-                sheet.getRow(16).getCell(2).getHyperlink().getType());
+        assertEquals(HyperlinkType.EMAIL,
+                sheet.getRow(16).getCell(2).getHyperlink().getTypeEnum());
         assertEquals(null,
                 sheet.getRow(16).getCell(2).getHyperlink().getLabel());
         assertEquals("mailto:dev@poi.apache.org?subject=XSSF%20Hyperlinks",
@@ -242,13 +242,13 @@ public final class TestXSSFHyperlink ext
 
         assertEquals(sh1.getNumberOfComments(), sh2.getNumberOfComments());
         XSSFHyperlink l1 = sh1.getHyperlink(0, 1);
-        assertEquals(XSSFHyperlink.LINK_DOCUMENT, l1.getType());
+        assertEquals(HyperlinkType.DOCUMENT, l1.getTypeEnum());
         assertEquals("B1", l1.getCellRef());
         assertEquals("Sort on Titel", l1.getTooltip());
 
         XSSFHyperlink l2 = sh2.getHyperlink(0, 1);
         assertEquals(l1.getTooltip(), l2.getTooltip());
-        assertEquals(XSSFHyperlink.LINK_DOCUMENT, l2.getType());
+        assertEquals(HyperlinkType.DOCUMENT, l2.getTypeEnum());
         assertEquals("B1", l2.getCellRef());
     }
 
@@ -313,22 +313,22 @@ public final class TestXSSFHyperlink ext
         
         XSSFHyperlink link = sh.getHyperlink(A2);
         assertEquals("address", "A2", link.getCellRef());
-        assertEquals("link type", Hyperlink.LINK_URL, link.getType());
+        assertEquals("link type", HyperlinkType.URL, link.getTypeEnum());
         assertEquals("link target", "http://twitter.com/#!/apacheorg", link.getAddress());
         
         link = sh.getHyperlink(A3);
         assertEquals("address", "A3", link.getCellRef());
-        assertEquals("link type", Hyperlink.LINK_URL, link.getType());
+        assertEquals("link type", HyperlinkType.URL, link.getTypeEnum());
         assertEquals("link target", "http://www.bailii.org/databases.html#ie", link.getAddress());
         
         link = sh.getHyperlink(A4);
         assertEquals("address", "A4", link.getCellRef());
-        assertEquals("link type", Hyperlink.LINK_URL, link.getType());
+        assertEquals("link type", HyperlinkType.URL, link.getTypeEnum());
         assertEquals("link target", "https://en.wikipedia.org/wiki/Apache_POI#See_also",
link.getAddress());
         
         link = sh.getHyperlink(A7);
         assertEquals("address", "A7", link.getCellRef());
-        assertEquals("link type", Hyperlink.LINK_DOCUMENT, link.getType());
+        assertEquals("link type", HyperlinkType.DOCUMENT, link.getTypeEnum());
         assertEquals("link target", "Sheet1", link.getAddress());
         
         wb.close();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java?rev=1753040&r1=1753039&r2=1753040&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java Sun Jul 17
09:32:29 2016
@@ -20,10 +20,10 @@ package org.apache.poi.hssf.usermodel;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import org.junit.Test;
 
 import java.io.IOException;
 
+import org.apache.poi.common.usermodel.HyperlinkType;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.BaseTestHyperlink;
@@ -34,6 +34,7 @@ import org.apache.poi.xssf.usermodel.XSS
 import org.apache.poi.xssf.usermodel.XSSFHyperlink;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 */
+import org.junit.Test;
 
 /**
  * Tests HSSFHyperlink.
@@ -64,7 +65,7 @@ public final class TestHSSFHyperlink ext
         assertEquals("POI", link.getLabel());
         assertEquals("POI", cell.getRichStringCellValue().getString());
         assertEquals("http://poi.apache.org/", link.getAddress());
-        assertEquals(HSSFHyperlink.LINK_URL, link.getType());
+        assertEquals(HyperlinkType.URL, link.getTypeEnum());
 
         cell = sheet.getRow(8).getCell(0);
         link = cell.getHyperlink();
@@ -72,7 +73,7 @@ public final class TestHSSFHyperlink ext
         assertEquals("HSSF", link.getLabel());
         assertEquals("HSSF", cell.getRichStringCellValue().getString());
         assertEquals("http://poi.apache.org/hssf/", link.getAddress());
-        assertEquals(HSSFHyperlink.LINK_URL, link.getType());
+        assertEquals(HyperlinkType.URL, link.getTypeEnum());
 
         sheet = wb.getSheet("Emails");
         cell = sheet.getRow(4).getCell(0);
@@ -81,7 +82,7 @@ public final class TestHSSFHyperlink ext
         assertEquals("dev", link.getLabel());
         assertEquals("dev", cell.getRichStringCellValue().getString());
         assertEquals("mailto:dev@poi.apache.org", link.getAddress());
-        assertEquals(HSSFHyperlink.LINK_EMAIL, link.getType());
+        assertEquals(HyperlinkType.EMAIL, link.getTypeEnum());
 
         sheet = wb.getSheet("Internal");
         cell = sheet.getRow(4).getCell(0);
@@ -91,7 +92,7 @@ public final class TestHSSFHyperlink ext
         assertEquals("Link To First Sheet", cell.getRichStringCellValue().getString());
         assertEquals("WebLinks!A1", link.getTextMark());
         assertEquals("WebLinks!A1", link.getAddress());
-        assertEquals(HSSFHyperlink.LINK_DOCUMENT, link.getType());
+        assertEquals(HyperlinkType.DOCUMENT, link.getTypeEnum());
     }
 
     @Test
@@ -141,14 +142,14 @@ public final class TestHSSFHyperlink ext
         //cell A1 has a link to 'Target Sheet-1'!A1
         cell = sheet.createRow(0).createCell(0);
         cell.setCellValue("Worksheet Link");
-        link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
+        link = new HSSFHyperlink(HyperlinkType.DOCUMENT);
         link.setTextMark("'Target Sheet'!A1");
         cell.setHyperlink(link);
 
         //cell B1 has a link to cell A1 on the same sheet
         cell = sheet.createRow(1).createCell(0);
         cell.setCellValue("Worksheet Link");
-        link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
+        link = new HSSFHyperlink(HyperlinkType.DOCUMENT);
         link.setAddress("'Hyperlinks'!A1");
         cell.setHyperlink(link);
 
@@ -202,7 +203,7 @@ public final class TestHSSFHyperlink ext
 
         cell = sheet.createRow(1).createCell(0);
         cell.setCellValue("File Link");
-        link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE);
+        link = new HSSFHyperlink(HyperlinkType.FILE);
         link.setAddress("testfolder\\test.PDF");
         cell.setHyperlink(link);
 
@@ -239,7 +240,7 @@ public final class TestHSSFHyperlink ext
         assertEquals(2, link1.getLastRow());
 
         //assign a hyperlink to A4
-        HSSFHyperlink link2 = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
+        HSSFHyperlink link2 = new HSSFHyperlink(HyperlinkType.DOCUMENT);
         link2.setAddress("Sheet2!A2");
         HSSFCell cell2 = sheet.getRow(3).getCell(0);
         cell2.setHyperlink(link2);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java?rev=1753040&r1=1753039&r2=1753040&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java Sun Jul
17 09:32:29 2016
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.poi.common.usermodel.HyperlinkType;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.util.CellAddress;
@@ -514,32 +515,32 @@ public abstract class BaseTestSheetShift
         // CellAddress=A1, shifted to A4
         Cell cell = row.createCell(0);
         cell.setCellStyle(hlinkStyle);
-        createHyperlink(helper, cell, Hyperlink.LINK_DOCUMENT, "test!E1");
+        createHyperlink(helper, cell, HyperlinkType.DOCUMENT, "test!E1");
         
         // URL
         cell = row.createCell(1);
         // CellAddress=B1, shifted to B4
         cell.setCellStyle(hlinkStyle);
-        createHyperlink(helper, cell, Hyperlink.LINK_URL, "http://poi.apache.org/");
+        createHyperlink(helper, cell, HyperlinkType.URL, "http://poi.apache.org/");
         
         // row0 will be shifted on top of row1, so this URL should be removed from the workbook
         Row overwrittenRow = sheet.createRow(3);
         cell = overwrittenRow.createCell(2);
         // CellAddress=C4, will be overwritten (deleted)
         cell.setCellStyle(hlinkStyle);
-        createHyperlink(helper, cell, Hyperlink.LINK_EMAIL, "mailto:poi@apache.org");
+        createHyperlink(helper, cell, HyperlinkType.EMAIL, "mailto:poi@apache.org");
         
         // hyperlinks on this row are unaffected by the row shifting, so the hyperlinks should
not move
         Row unaffectedRow = sheet.createRow(20);
         cell = unaffectedRow.createCell(3);
         // CellAddress=D21, will be unaffected
         cell.setCellStyle(hlinkStyle);
-        createHyperlink(helper, cell, Hyperlink.LINK_FILE, "54524.xlsx");
+        createHyperlink(helper, cell, HyperlinkType.FILE, "54524.xlsx");
         
         cell = wb.createSheet("other").createRow(0).createCell(0);
         // CellAddress=Other!A1, will be unaffected
         cell.setCellStyle(hlinkStyle);
-        createHyperlink(helper, cell, Hyperlink.LINK_URL, "http://apache.org/");
+        createHyperlink(helper, cell, HyperlinkType.URL, "http://apache.org/");
         
         int startRow = 0;
         int endRow = 0;
@@ -555,10 +556,10 @@ public abstract class BaseTestSheetShift
         
         // document link anchored on a shifted cell should be moved
         // Note that hyperlinks do not track what they point to, so this hyperlink should
still refer to test!E1
-        verifyHyperlink(shiftedRow.getCell(0), Hyperlink.LINK_DOCUMENT, "test!E1");
+        verifyHyperlink(shiftedRow.getCell(0), HyperlinkType.DOCUMENT, "test!E1");
         
         // URL, EMAIL, and FILE links anchored on a shifted cell should be moved
-        verifyHyperlink(shiftedRow.getCell(1), Hyperlink.LINK_URL, "http://poi.apache.org/");
+        verifyHyperlink(shiftedRow.getCell(1), HyperlinkType.URL, "http://poi.apache.org/");
         
         // Make sure hyperlinks were moved and not copied
         assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
@@ -578,12 +579,12 @@ public abstract class BaseTestSheetShift
         // Make sure unaffected rows are not shifted
         Cell unaffectedCell = sh.getRow(20).getCell(3);
         assertTrue(cellHasHyperlink(unaffectedCell));
-        verifyHyperlink(unaffectedCell, Hyperlink.LINK_FILE, "54524.xlsx");
+        verifyHyperlink(unaffectedCell, HyperlinkType.FILE, "54524.xlsx");
         
         // Make sure cells on other sheets are not affected
         unaffectedCell = read.getSheet("other").getRow(0).getCell(0);
         assertTrue(cellHasHyperlink(unaffectedCell));
-        verifyHyperlink(unaffectedCell, Hyperlink.LINK_URL, "http://apache.org/");
+        verifyHyperlink(unaffectedCell, HyperlinkType.URL, "http://apache.org/");
         
         read.close();
     }
@@ -678,17 +679,17 @@ public abstract class BaseTestSheetShift
         wb.close();
     }
 
-    private void createHyperlink(CreationHelper helper, Cell cell, int linkType, String ref)
{
+    private void createHyperlink(CreationHelper helper, Cell cell, HyperlinkType linkType,
String ref) {
         cell.setCellValue(ref);
         Hyperlink link = helper.createHyperlink(linkType);
         link.setAddress(ref);
         cell.setHyperlink(link);
     }
     
-    private void verifyHyperlink(Cell cell, int linkType, String ref) {
+    private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) {
         assertTrue(cellHasHyperlink(cell));
         Hyperlink link = cell.getHyperlink();
-        assertEquals(linkType, link.getType());
+        assertEquals(linkType, link.getTypeEnum());
         assertEquals(ref, link.getAddress());
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message