diff options
author | Dominik Stadler <centic@apache.org> | 2020-03-08 20:17:08 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2020-03-08 20:17:08 +0000 |
commit | 77fbcb788d818e8042b54b63c0c9f2bbf42856a4 (patch) | |
tree | 20783568d4c78d25b8c126b37de9ef8f797f406e | |
parent | a7d96dcb734ce2ea24e1d9670774f116c1f937d5 (diff) | |
download | poi-77fbcb788d818e8042b54b63c0c9f2bbf42856a4.tar.gz poi-77fbcb788d818e8042b54b63c0c9f2bbf42856a4.zip |
Try to use https for poi.apache.org everywhere
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874981 13f79535-47bb-0310-9956-ffa450edef68
34 files changed, 190 insertions, 185 deletions
diff --git a/maven/ooxml-schemas.pom b/maven/ooxml-schemas.pom index c43315187f..ae4621e9a1 100644 --- a/maven/ooxml-schemas.pom +++ b/maven/ooxml-schemas.pom @@ -28,9 +28,9 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>OOXML schemas</name> - <description>XmlBeans generated from the Ecma supplied xsds: + <description>XmlBeans generated from the Ecma supplied xsds: http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%20Part%204%20(DOCX).zip</description> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <mailingLists> <mailingList> diff --git a/maven/ooxml-security.pom b/maven/ooxml-security.pom index 81886d177f..e092464abe 100644 --- a/maven/ooxml-security.pom +++ b/maven/ooxml-security.pom @@ -31,7 +31,7 @@ <description> XmlBeans generated from various supplied xsds for encryption and signing: http://msdn.microsoft.com/en-us/library/dd925810(v=office.12).aspx - http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%202%20(PDF).zip + http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%202%20(PDF).zip http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd http://uri.etsi.org/01903/v1.3.2/XAdES.xsd http://uri.etsi.org/01903/v1.4.1/XAdESv141.xsd @@ -39,7 +39,7 @@ http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcmitype.xsd </description> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <mailingLists> <mailingList> diff --git a/maven/poi-examples.pom b/maven/poi-examples.pom index 7d285a4c36..70bb701037 100644 --- a/maven/poi-examples.pom +++ b/maven/poi-examples.pom @@ -28,7 +28,7 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>Apache POI</name> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <description>Apache POI Examples</description> <mailingLists> diff --git a/maven/poi-excelant.pom b/maven/poi-excelant.pom index 1543d49c84..d33f32b101 100644 --- a/maven/poi-excelant.pom +++ b/maven/poi-excelant.pom @@ -28,7 +28,7 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>Apache POI</name> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <description>Apache POI Excel Ant Tasks</description> <mailingLists> @@ -73,6 +73,6 @@ <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.8.2</version> - </dependency> + </dependency> </dependencies> </project> diff --git a/maven/poi-ooxml-schemas.pom b/maven/poi-ooxml-schemas.pom index 555c500c58..1aa4eb1024 100644 --- a/maven/poi-ooxml-schemas.pom +++ b/maven/poi-ooxml-schemas.pom @@ -28,7 +28,7 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>Apache POI</name> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <description>Apache POI - Java API To Access Microsoft Format Files</description> <repositories> diff --git a/maven/poi-ooxml.pom b/maven/poi-ooxml.pom index 7c35710975..6f2e240de9 100644 --- a/maven/poi-ooxml.pom +++ b/maven/poi-ooxml.pom @@ -28,7 +28,7 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>Apache POI</name> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <description>Apache POI - Java API To Access Microsoft Format Files</description> <mailingLists> diff --git a/maven/poi-scratchpad.pom b/maven/poi-scratchpad.pom index 7b932a81b4..0a155edf03 100644 --- a/maven/poi-scratchpad.pom +++ b/maven/poi-scratchpad.pom @@ -28,7 +28,7 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>Apache POI</name> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <description>Apache POI - Java API To Access Microsoft Format Files</description> <mailingLists> diff --git a/maven/poi.pom b/maven/poi.pom index 367d308120..ef709c4261 100644 --- a/maven/poi.pom +++ b/maven/poi.pom @@ -28,7 +28,7 @@ <version>@VERSION@</version> <packaging>jar</packaging> <name>Apache POI</name> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <description>Apache POI - Java API To Access Microsoft Format Files</description> <mailingLists> diff --git a/osgi/bundle.info b/osgi/bundle.info index 1886a0aef8..bad445c3c1 100644 --- a/osgi/bundle.info +++ b/osgi/bundle.info @@ -35,4 +35,4 @@ When practical, we donate components directly to those projects for POI-enabling them. \u001B[1mSEE ALSO\u001B[0m - \u001B[36mhttp://poi.apache.org/\u001B[0m + \u001B[36mhttps://poi.apache.org/\u001B[0m diff --git a/osgi/pom.xml b/osgi/pom.xml index 6f57c36374..01777f3c0f 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -35,7 +35,7 @@ <description> OSGi bundle that contains Apache POI, and the dependencies. </description> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <version>${poi.version}</version> <properties> diff --git a/sonar/pom.xml b/sonar/pom.xml index ae84fd73d7..71043ff79a 100644 --- a/sonar/pom.xml +++ b/sonar/pom.xml @@ -7,7 +7,7 @@ <version>4.1.3-SNAPSHOT</version> <name>Apache POI - the Java API for Microsoft Documents</name> <description>Maven build of Apache POI for Sonar checks</description> - <url>http://poi.apache.org/</url> + <url>https://poi.apache.org/</url> <mailingLists> <mailingList> diff --git a/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java b/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java index d25282897d..41ccbe0b03 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java +++ b/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java @@ -434,7 +434,7 @@ public final class ApacheconEU08 { tp.get(i).getTextRuns().get(0).setFontSize(24d); tp.get(i).setIndentLevel(1); } - + box2.setAnchor(new Rectangle(36, 126, 648, 400)); } @@ -449,7 +449,7 @@ public final class ApacheconEU08 { TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY); box2.setText( - "http://poi.apache.org/hslf/\r" + + "https://poi.apache.org/hslf/\r" + "http://people.apache.org/~yegor"); box2.setAnchor(new Rectangle(108, 306, 504, 138)); } diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java index a6502df304..4c9429c252 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java @@ -55,7 +55,7 @@ public class Hyperlinks { cell = sheet.createRow(0).createCell(0); cell.setCellValue("URL Link"); HSSFHyperlink link = helper.createHyperlink(HyperlinkType.URL); - link.setAddress("http://poi.apache.org/"); + link.setAddress("https://poi.apache.org/"); cell.setHyperlink(link); cell.setCellStyle(hlink_style); diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java b/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java index 56caa60ff2..6f981018a1 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java @@ -14,7 +14,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ package org.apache.poi.xslf.usermodel; @@ -37,8 +37,8 @@ public class Tutorial6 { shape1.setAnchor(new Rectangle(50, 50, 200, 50)); XSLFTextRun r1 = shape1.addNewTextParagraph().addNewTextRun(); XSLFHyperlink link1 = r1.createHyperlink(); - r1.setText("http://poi.apache.org"); // visible text - link1.setAddress("http://poi.apache.org"); // link address + r1.setText("https://poi.apache.org"); // visible text + link1.setAddress("https://poi.apache.org"); // link address XSLFTextBox shape2 = slide1.createTextBox(); shape2.setAnchor(new Rectangle(300, 50, 200, 50)); diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java index dd7e370d1b..8aaecb4f1a 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java @@ -53,8 +53,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * now includes the SXSSF which handles all of this for you, you should * be using that instead! This code remains mostly for historical interest. * <p> - * See <a "http://poi.apache.org/spreadsheet/how-to.html#sxssf"> - * http://poi.apache.org/spreadsheet/how-to.html#sxssf</a>. + * See <a "https://poi.apache.org/spreadsheet/how-to.html#sxssf"> + * https://poi.apache.org/spreadsheet/how-to.html#sxssf</a>. * <p> * If you really want to use this approach, which is also the one that SXSSF * does for you, it works as follows: @@ -72,8 +72,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * to all rows in the document. Older rows that are no longer in the window * become inaccessible, as they are written to the disk. * </p> - * See <a "http://poi.apache.org/spreadsheet/how-to.html#sxssf"> - * http://poi.apache.org/spreadsheet/how-to.html#sxssf</a>. + * See <a "https://poi.apache.org/spreadsheet/how-to.html#sxssf"> + * https://poi.apache.org/spreadsheet/how-to.html#sxssf</a>. */ public final class BigGridDemo { private static final String XML_ENCODING = "UTF-8"; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java index 34586fb97e..e5663ecf42 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java @@ -54,7 +54,7 @@ public class HyperlinkExample { cell.setCellValue("URL Link"); Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL); - link.setAddress("http://poi.apache.org/"); + link.setAddress("https://poi.apache.org/"); cell.setHyperlink(link); cell.setCellStyle(hlink_style); diff --git a/src/java/org/apache/poi/hssf/package-info.java b/src/java/org/apache/poi/hssf/package-info.java index eb95f0d058..43f8bcbe65 100644 --- a/src/java/org/apache/poi/hssf/package-info.java +++ b/src/java/org/apache/poi/hssf/package-info.java @@ -18,6 +18,6 @@ /** * Horrible SpreadSheet Format API's for reading/writting Excel files using pure Java. * - * @see <a href="http://poi.apache.org/components/spreadsheet/index.html">Overview, tutorials, examples, guides, and tool documentation</a> + * @see <a href="https://poi.apache.org/components/spreadsheet/index.html">Overview, tutorials, examples, guides, and tool documentation</a> */ package org.apache.poi.hssf; diff --git a/src/java/org/apache/poi/poifs/crypt/package-info.java b/src/java/org/apache/poi/poifs/crypt/package-info.java index 924b54ec15..df27963002 100644 --- a/src/java/org/apache/poi/poifs/crypt/package-info.java +++ b/src/java/org/apache/poi/poifs/crypt/package-info.java @@ -29,7 +29,7 @@ * <li>the {@link org.apache.poi.poifs.crypt.xor xor} package contains classes for the xor obfuscation of biff/H**F formats</li> * </ul> * - * @see <a href="http://poi.apache.org/encryption.html">Apache POI - Encryption support</a> + * @see <a href="https://poi.apache.org/encryption.html">Apache POI - Encryption support</a> * @see <a href="http://msdn.microsoft.com/en-us/library/dd952186(v=office.12).aspx">ECMA-376 Document Encryption</a> */ package org.apache.poi.poifs.crypt;
\ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index c57db95506..ef52cc5933 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -267,7 +267,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su /** * Constructs a XSSFWorkbook object given a OpenXML4J <code>Package</code> object, - * see <a href="http://poi.apache.org/oxml4j/">http://poi.apache.org/oxml4j/</a>. + * see <a href="https://poi.apache.org/oxml4j/">https://poi.apache.org/oxml4j/</a>. * * <p>Once you have finished working with the Workbook, you should close the package * by calling either {@link #close()} or {@link OPCPackage#close()}, to avoid diff --git a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java index d83de633cf..0a893b1503 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java @@ -211,7 +211,7 @@ public class TestXSLFBugs { XSLFTextRun r = p.addNewTextRun(); p.addLineBreak(); r.setText("Apache POI"); - r.createHyperlink().setAddress("http://poi.apache.org"); + r.createHyperlink().setAddress("https://poi.apache.org"); // create hyperlink pointing to a page, which isn't available at the time of importing the content r = p.addNewTextRun(); r.setText("Slide 2"); @@ -233,7 +233,7 @@ public class TestXSLFBugs { XSLFTextParagraph p = shape.getTextParagraphs().get(1); XSLFHyperlink h1 = p.getTextRuns().get(0).getHyperlink(); assertNotNull(h1); - assertEquals("http://poi.apache.org", h1.getAddress()); + assertEquals("https://poi.apache.org", h1.getAddress()); XSLFHyperlink h2 = p.getTextRuns().get(2).getHyperlink(); assertNotNull(h2); // relative url will be resolved to an absolute url, therefore this doesn't equals to "slide2.xml" @@ -724,8 +724,8 @@ public class TestXSLFBugs { @Test public void bug59434() throws IOException { - String url1 = "http://poi.apache.org/changes.html"; - String url2 = "http://poi.apache.org/faq.html"; + String url1 = "https://poi.apache.org/changes.html"; + String url2 = "https://poi.apache.org/faq.html"; XMLSlideShow ppt1 = new XMLSlideShow(); PictureData pd1 = ppt1.addPicture(slTests.readFile("tomcat.png"), PictureType.PNG); PictureData pd2 = ppt1.addPicture(slTests.readFile("santa.wmf"), PictureType.WMF); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java index 4c4152badb..08dfe3913a 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java @@ -56,7 +56,7 @@ public class TestXSLFHyperlink { XSLFHyperlink link3 = cell3.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink(); assertNotNull(link3); assertEquals("mailto:dev@poi.apache.org?subject=Hi%20There", link3.getAddress()); - + ppt.close(); } @@ -99,7 +99,7 @@ public class TestXSLFHyperlink { assertEquals(id2, rel2.getId()); assertEquals(TargetMode.INTERNAL, rel2.getTargetMode()); assertEquals(XSLFRelation.SLIDE.getRelation(), rel2.getRelationshipType()); - + ppt.close(); } @@ -174,7 +174,7 @@ public class TestXSLFHyperlink { assertNotNull(hl5); assertEquals("firstslide", hl5.getXmlObject().getAction().split("=")[1]); assertEquals(HyperlinkType.DOCUMENT, hl5.getType()); - + ppt2.close(); } }
\ No newline at end of file diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java index 463322a535..4dae58a238 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java @@ -265,7 +265,7 @@ public final class TestXSSFCell extends BaseTestXCell { XSSFWorkbook wb2 = (XSSFWorkbook)_testDataProvider.writeOutAndReadBack(wb1); row = wb2.getSheetAt(0).getRow(0); assertCellsWithMissingR(row); - + wb2.close(); wb1.close(); } @@ -338,7 +338,7 @@ public final class TestXSSFCell extends BaseTestXCell { wbRef.close(); wb.close(); } - + @Test public void test56170() throws IOException { final Workbook wb1 = XSSFTestDataSamples.openSampleWorkbook("56170.xlsx"); @@ -346,7 +346,7 @@ public final class TestXSSFCell extends BaseTestXCell { Workbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1); Cell cell; - + // add some contents to table so that the table will need expansion Row row = sheet.getRow(0); Workbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2); @@ -363,7 +363,7 @@ public final class TestXSSFCell extends BaseTestXCell { cell.setCellValue("demo3"); Workbook wb9 = XSSFTestDataSamples.writeOutAndReadBack(wb8); - + row = sheet.getRow(1); cell = row.createCell(0); cell.setCellValue("demo1"); @@ -373,7 +373,7 @@ public final class TestXSSFCell extends BaseTestXCell { cell.setCellValue("demo3"); Workbook wb10 = XSSFTestDataSamples.writeOutAndReadBack(wb9); - + // expand table XSSFTable table = sheet.getTables().get(0); final CellReference startRef = table.getStartCellReference(); @@ -395,7 +395,7 @@ public final class TestXSSFCell extends BaseTestXCell { wb2.close(); wb1.close(); } - + @Test public void test56170Reproduce() throws IOException { try (Workbook wb = new XSSFWorkbook()) { @@ -437,11 +437,11 @@ public final class TestXSSFCell extends BaseTestXCell { private void validateRow(Row row) { // trigger bug with CArray handling ((XSSFRow)row).onDocumentWrite(); - + for(Cell cell : row) { assertNotNull(cell.toString()); } - } + } @Test public void testBug56644ReturnNull() throws IOException { @@ -526,59 +526,59 @@ public final class TestXSSFCell extends BaseTestXCell { } private XSSFCell srcCell, destCell; //used for testCopyCellFrom_CellCopyPolicy - + @Test public final void testCopyCellFrom_CellCopyPolicy_default() { setUp_testCopyCellFrom_CellCopyPolicy(); - + // default copy policy final CellCopyPolicy policy = new CellCopyPolicy(); destCell.copyCellFrom(srcCell, policy); - + assertEquals(CellType.FORMULA, destCell.getCellType()); assertEquals("2+3", destCell.getCellFormula()); assertEquals(srcCell.getCellStyle(), destCell.getCellStyle()); } - + @Test public final void testCopyCellFrom_CellCopyPolicy_value() { setUp_testCopyCellFrom_CellCopyPolicy(); - + // Paste values only final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build(); destCell.copyCellFrom(srcCell, policy); assertEquals(CellType.NUMERIC, destCell.getCellType()); } - + @Test public final void testCopyCellFrom_CellCopyPolicy_formulaWithUnregisteredUDF() { setUp_testCopyCellFrom_CellCopyPolicy(); - + srcCell.setCellFormula("MYFUNC2(123, $A5, Sheet1!$B7)"); - + // Copy formula verbatim (no shifting). This is okay because copyCellFrom is Internal. // Users should use higher-level copying functions to row- or column-shift formulas. final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(true).build(); destCell.copyCellFrom(srcCell, policy); assertEquals("MYFUNC2(123, $A5, Sheet1!$B7)", destCell.getCellFormula()); } - + @Test public final void testCopyCellFrom_CellCopyPolicy_style() { setUp_testCopyCellFrom_CellCopyPolicy(); srcCell.setCellValue((String) null); - + // Paste styles only final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellValue(false).build(); destCell.copyCellFrom(srcCell, policy); assertEquals(srcCell.getCellStyle(), destCell.getCellStyle()); - + // Old cell value should not have been overwritten assertNotEquals(CellType.BLANK, destCell.getCellType()); assertEquals(CellType.BOOLEAN, destCell.getCellType()); assertTrue(destCell.getBooleanCellValue()); } - + @Test public final void testCopyCellFrom_CellCopyPolicy_copyHyperlink() throws IOException { setUp_testCopyCellFrom_CellCopyPolicy(); @@ -587,7 +587,7 @@ public final class TestXSSFCell extends BaseTestXCell { srcCell.setCellValue("URL LINK"); Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL); - link.setAddress("http://poi.apache.org/"); + link.setAddress("https://poi.apache.org/"); srcCell.setHyperlink(link); // Set link cell style (optional) @@ -607,7 +607,7 @@ public final class TestXSSFCell extends BaseTestXCell { new CellAddress(srcCell).formatAsString(), links.get(0).getCellRef()); assertEquals("destination hyperlink", new CellAddress(destCell).formatAsString(), links.get(1).getCellRef()); - + wb.close(); } @@ -628,7 +628,7 @@ public final class TestXSSFCell extends BaseTestXCell { srcCell.setCellValue("URL LINK"); Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL); - link.setAddress("http://poi.apache.org/"); + link.setAddress("https://poi.apache.org/"); destCell.setHyperlink(link); // Set link cell style (optional) @@ -651,36 +651,36 @@ public final class TestXSSFCell extends BaseTestXCell { assertEquals("number of hyperlinks on sheet", 1, links.size()); assertEquals("source hyperlink", new CellAddress(destCell).formatAsString(), links.get(0).getCellRef()); - + // Merge destCell's hyperlink to srcCell. Since destCell does have a hyperlink, this should copy destCell's hyperlink to srcCell. srcCell.copyCellFrom(destCell, policy); assertNotNull(srcCell.getHyperlink()); assertNotNull(destCell.getHyperlink()); - + links = srcCell.getSheet().getHyperlinkList(); assertEquals("number of hyperlinks on sheet", 2, links.size()); assertEquals("dest hyperlink", new CellAddress(destCell).formatAsString(), links.get(0).getCellRef()); assertEquals("source hyperlink", new CellAddress(srcCell).formatAsString(), links.get(1).getCellRef()); - + wb.close(); } - + private void setUp_testCopyCellFrom_CellCopyPolicy() { @SuppressWarnings("resource") final XSSFWorkbook wb = new XSSFWorkbook(); final XSSFRow row = wb.createSheet("Sheet1").createRow(0); srcCell = row.createCell(0); destCell = row.createCell(1); - + srcCell.setCellFormula("2+3"); - + final CellStyle style = wb.createCellStyle(); style.setBorderTop(BorderStyle.THICK); style.setFillBackgroundColor((short) 5); srcCell.setCellStyle(style); - + destCell.setCellValue(true); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java index 0a7cf4a2f5..faadec0b62 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java @@ -57,7 +57,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { XSSFSheet sheet = workbook.createSheet(); XSSFRow row = sheet.createRow(0); XSSFCreationHelper createHelper = workbook.getCreationHelper(); - + String[] urls = { "http://apache.org", "www.apache.org", @@ -273,12 +273,12 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { } } } - + @Override public XSSFHyperlink copyHyperlink(Hyperlink link) { return new XSSFHyperlink(link); } - + @Test public void testCopyHSSFHyperlink() throws IOException { HSSFWorkbook hssfworkbook = new HSSFWorkbook(); @@ -290,15 +290,15 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { hlink.setLastRow(6); hlink.setLabel("label"); XSSFHyperlink xlink = new XSSFHyperlink(hlink); - + assertEquals("http://poi.apache.org/", xlink.getAddress()); assertEquals(new CellReference(2, 3), new CellReference(xlink.getCellRef())); // Are HSSFHyperlink.label and XSSFHyperlink.tooltip the same? If so, perhaps one of these needs renamed for a consistent Hyperlink interface // assertEquals("label", xlink.getTooltip()); - + hssfworkbook.close(); } - + /* bug 59775: XSSFHyperlink has wrong type if it contains a location (CTHyperlink#getLocation) * URLs with a hash mark (#) are still URL hyperlinks, not document links */ @@ -310,27 +310,27 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { CellAddress A3 = new CellAddress("A3"); CellAddress A4 = new CellAddress("A4"); CellAddress A7 = new CellAddress("A7"); - + XSSFHyperlink link = sh.getHyperlink(A2); assertEquals("address", "A2", link.getCellRef()); assertEquals("link type", HyperlinkType.URL, link.getType()); assertEquals("link target", "http://twitter.com/#!/apacheorg", link.getAddress()); - + link = sh.getHyperlink(A3); assertEquals("address", "A3", link.getCellRef()); assertEquals("link type", HyperlinkType.URL, link.getType()); assertEquals("link target", "http://www.bailii.org/databases.html#ie", link.getAddress()); - + link = sh.getHyperlink(A4); assertEquals("address", "A4", link.getCellRef()); assertEquals("link type", HyperlinkType.URL, link.getType()); 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", HyperlinkType.DOCUMENT, link.getType()); assertEquals("link target", "Sheet1", link.getAddress()); - + wb.close(); } diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java index cb9b102bd9..a63ca0c256 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java @@ -65,7 +65,7 @@ public final class TestXWPFDocument { // } } assertTrue(found); - + pack.close(); doc.close(); } @@ -195,12 +195,17 @@ public final class TestXWPFDocument { public void testAddHyperlink() throws IOException { try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx")) { XWPFParagraph p = doc.createParagraph(); - XWPFHyperlinkRun h = p.createHyperlinkRun("http://poi.apache.org/"); + XWPFHyperlinkRun h = p.createHyperlinkRun("https://poi.apache.org/"); h.setText("Apache POI"); - assertEquals("http://poi.apache.org/", h.getHyperlink(doc).getURL()); + assertEquals("https://poi.apache.org/", h.getHyperlink(doc).getURL()); assertEquals(p.getRuns().size(), 1); assertEquals(p.getRuns().get(0), h); + + h = p.createHyperlinkRun("https://poi.apache.org/"); + h.setText("Apache POI"); + + assertEquals("rId8", h.getHyperlinkId()); } } @@ -456,14 +461,14 @@ public final class TestXWPFDocument { doc.close(); } - + @Test public void testEnforcedWith() throws IOException { try (XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("EnforcedWith.docx")) { assertTrue(docx.isEnforcedProtection()); } } - + @Test @Ignore("XWPF should be able to write to a new Stream when opened Read-Only") public void testWriteFromReadOnlyOPC() throws Exception { diff --git a/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java b/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java index c6353dae6d..09dca86a51 100644 --- a/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java @@ -32,7 +32,7 @@ import org.junit.Test; public final class TestPublisherTextExtractor { private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance(); - private static final String SAMPLE_TEXT = + private static final String SAMPLE_TEXT = "This is some text on the first page\n" + "It\u2019s in times new roman, font size 10, all normal\n" + "" + @@ -154,7 +154,7 @@ public final class TestPublisherTextExtractor { */ @Test public void testWithHyperlinks() throws Exception { - InputStream linkAt = _samples.openResourceAsStream("LinkAt10.pub"); + InputStream linkAt = _samples.openResourceAsStream("LinkAt10.pub"); HPBFDocument doc = new HPBFDocument(linkAt); PublisherTextExtractor ext = new PublisherTextExtractor(doc); diff --git a/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestQuillContents.java b/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestQuillContents.java index 31349cdbc9..d386664dce 100644 --- a/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestQuillContents.java +++ b/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestQuillContents.java @@ -68,7 +68,7 @@ public final class TestQuillContents { assertEquals("STSH", qc.getBits()[3].getThingType()); assertEquals("STSH", qc.getBits()[3].getBitType()); assertEquals(2, qc.getBits()[3].getOptA()); - + doc.close(); } @@ -85,7 +85,7 @@ public final class TestQuillContents { String t = text.getText(); assertStartsWith(t, "This is some text on the first page"); assertEndsWith(t, "Within doc to page 1\r"); - + doc.close(); } @@ -148,7 +148,7 @@ public final class TestQuillContents { assertEquals(0x22000000, plc12.getPlcValB()[0]); assertEquals(0x05, plc12.getPlcValA()[1]); assertEquals(0x04, plc12.getPlcValB()[1]); - + doc.close(); } @@ -253,7 +253,7 @@ public final class TestQuillContents { assertEquals(0x000004, plc16.getPlcValB()[4]); assertEquals(0x000004, plc16.getPlcValA()[5]); assertEquals(0x000004, plc16.getPlcValB()[5]); - + doc.close(); } @@ -272,7 +272,7 @@ public final class TestQuillContents { assertEquals(0, plc18.getNumberOfHyperlinks()); assertEquals(0, plc18.getTextStartAt(0)); assertEquals(601, plc18.getAllTextEndAt()); - + doc.close(); } @@ -347,7 +347,7 @@ public final class TestQuillContents { assertEquals(10, hlBit.getTextStartAt(0)); assertEquals(15, hlBit.getAllTextEndAt()); assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0)); - + doc.close(); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java index 73cef448f2..59a54dfe2e 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java @@ -91,7 +91,7 @@ public final class TestHyperlink { assertEquals("Open Jakarta POI HSSF module test ", links.get(0).getLabel()); assertEquals("http://jakarta.apache.org/poi/hssf/", links.get(0).getAddress()); assertEquals("Jakarta HSSF", rawText.substring(links.get(0).getStartIndex(), links.get(0).getEndIndex()-1)); - + ppt.close(); } @@ -115,7 +115,7 @@ public final class TestHyperlink { hl3.linkToSlide(slide1); HSLFTextRun r4 = ppt1.createSlide().createTextBox().setText("page4"); HSLFHyperlink hl4 = r4.createHyperlink(); - hl4.linkToUrl("http://poi.apache.org"); + hl4.linkToUrl("https://poi.apache.org"); HSLFTextBox tb5 = ppt1.createSlide().createTextBox(); tb5.setText("page5"); HSLFHyperlink hl5 = tb5.createHyperlink(); @@ -146,7 +146,7 @@ public final class TestHyperlink { HSLFTextBox tb4 = (HSLFTextBox)slides.get(3).getShapes().get(0); hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink(); assertNotNull(hl4); - assertEquals("http://poi.apache.org", hl4.getLabel()); + assertEquals("https://poi.apache.org", hl4.getLabel()); assertEquals(HyperlinkType.URL, hl4.getType()); tb5 = (HSLFTextBox)slides.get(4).getShapes().get(0); @@ -154,10 +154,10 @@ public final class TestHyperlink { assertNotNull(hl5); assertEquals(InteractiveInfoAtom.LINK_FirstSlide, hl5.getInfo().getInteractiveInfoAtom().getHyperlinkType()); assertEquals(HyperlinkType.DOCUMENT, hl5.getType()); - + ppt2.close(); } - + private static List<HSLFHyperlink> findHyperlinks(List<HSLFTextParagraph> paras) { List<HSLFHyperlink> links = new ArrayList<>(); for (HSLFTextParagraph p : paras) { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 00828e4305..9bcde6ed37 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2693,7 +2693,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { try (Workbook wb = openSampleWorkbook("46515.xls")) { // Get structure from webservice - String urlString = "http://poi.apache.org/components/spreadsheet/images/calendar.jpg"; + String urlString = "https://poi.apache.org/components/spreadsheet/images/calendar.jpg"; URL structURL = new URL(urlString); BufferedImage bimage; try { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java index d2f26ffec7..30c85cbe3d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java @@ -29,13 +29,13 @@ import org.junit.Test; /** * Tests to show that our documentation at - * http://poi.apache.org/hssf/eval.html + * https://poi.apache.org/hssf/eval.html * all actually works as we'd expect them to */ public final class TestFormulaEvaluatorDocs { /** - * http://poi.apache.org/hssf/eval.html#EvaluateAll + * https://poi.apache.org/hssf/eval.html#EvaluateAll */ @Test public void testEvaluateAll() throws IOException { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java index 382a1f3f0b..39d20c1ebd 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java @@ -124,7 +124,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { * link.setTextMark("'Target Sheet-1'!A1"); //HSSF-specific * or * link.setAddress("'Target Sheet-1'!A1"); //common between XSSF and HSSF - * @throws IOException + * @throws IOException */ @Test public void testCreateDocumentLink() throws IOException { @@ -155,7 +155,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb); wb.close(); - + sheet = wbBack.getSheet("Hyperlinks"); cell = sheet.getRow(0).getCell(0); @@ -169,7 +169,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertNotNull(link); assertEquals("'Hyperlinks'!A1", link.getTextMark()); assertEquals("'Hyperlinks'!A1", link.getAddress()); - + wbBack.close(); } @@ -208,7 +208,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { cell.setHyperlink(link); HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb); - + wb.close(); sheet = wbBack.getSheet("Hyperlinks"); @@ -217,7 +217,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { link = cell.getHyperlink(); assertNotNull(link); assertEquals("testfolder\\test.PDF", link.getAddress()); - + wbBack.close(); } @@ -266,12 +266,12 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals(5, link2_shifted.getFirstRow()); assertEquals(5, link2_shifted.getLastRow()); } - + @Override public HSSFHyperlink copyHyperlink(Hyperlink link) { return new HSSFHyperlink(link); } - + /* @Test public void testCopyXSSFHyperlink() throws IOException { @@ -282,12 +282,12 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { xlink.setCellReference("D3"); xlink.setTooltip("tooltip"); HSSFHyperlink hlink = new HSSFHyperlink(xlink); - + assertEquals("http://poi.apache.org/", hlink.getAddress()); assertEquals("D3", new CellReference(hlink.getFirstRow(), hlink.getFirstColumn()).formatAsString()); // Are HSSFHyperlink.label and XSSFHyperlink.tooltip the same? If so, perhaps one of these needs renamed for a consistent Hyperlink interface // assertEquals("tooltip", hlink.getLabel()); - + wb.close(); }*/ } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java index 0d928f0809..e6913c19a0 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -808,7 +808,7 @@ public abstract class BaseTestCell { Cell cell3 = row.createCell(2); Hyperlink link3 = helper.createHyperlink(HyperlinkType.URL); - link3.setAddress("http://poi.apache.org/"); + link3.setAddress("https://poi.apache.org/"); cell3.setHyperlink(link3); assertNotNull(cell3.getHyperlink()); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestHyperlink.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestHyperlink.java index d5b71758c7..54b306e039 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestHyperlink.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestHyperlink.java @@ -54,7 +54,7 @@ public abstract class BaseTestHyperlink { cell = sheet.createRow(0).createCell((short) 0); cell.setCellValue("URL Link"); link = createHelper.createHyperlink(HyperlinkType.URL); - link.setAddress("http://poi.apache.org/"); + link.setAddress("https://poi.apache.org/"); cell.setHyperlink(link); //link to a file in the current directory @@ -90,17 +90,17 @@ public abstract class BaseTestHyperlink { sheet = wb2.getSheetAt(0); link = sheet.getRow(0).getCell(0).getHyperlink(); - assertEquals("http://poi.apache.org/", link.getAddress()); + assertEquals("https://poi.apache.org/", link.getAddress()); link = sheet.getRow(1).getCell(0).getHyperlink(); assertEquals("hyperinks-beta4-dump.txt", link.getAddress()); link = sheet.getRow(2).getCell(0).getHyperlink(); assertEquals("mailto:poi@apache.org?subject=Hyperlinks", link.getAddress()); link = sheet.getRow(3).getCell(0).getHyperlink(); assertEquals("'Target Sheet'!A1", link.getAddress()); - + wb2.close(); } - + // copy a hyperlink via the copy constructor @Test public void testCopyHyperlink() throws IOException { @@ -117,32 +117,32 @@ public abstract class BaseTestHyperlink { cell2 = row.createCell(1); cell1.setCellValue("URL Link"); link1 = createHelper.createHyperlink(HyperlinkType.URL); - link1.setAddress("http://poi.apache.org/"); + link1.setAddress("https://poi.apache.org/"); cell1.setHyperlink(link1); - + link2 = copyHyperlink(link1); - + // Change address (type is not changeable) link2.setAddress("http://apache.org/"); cell2.setHyperlink(link2); - - // Make sure hyperlinks were deep-copied, and modifying one does not modify the other. + + // Make sure hyperlinks were deep-copied, and modifying one does not modify the other. assertNotSame(link1, link2); assertNotEquals(link1, link2); - assertEquals("http://poi.apache.org/", link1.getAddress()); + assertEquals("https://poi.apache.org/", link1.getAddress()); assertEquals("http://apache.org/", link2.getAddress()); assertEquals(link1, cell1.getHyperlink()); assertEquals(link2, cell2.getHyperlink()); - + // Make sure both hyperlinks were added to the sheet @SuppressWarnings("unchecked") final List<Hyperlink> actualHyperlinks = (List<Hyperlink>) sheet.getHyperlinkList(); assertEquals(2, actualHyperlinks.size()); assertEquals(link1, actualHyperlinks.get(0)); assertEquals(link2, actualHyperlinks.get(1)); - + wb.close(); } - + public abstract Hyperlink copyHyperlink(Hyperlink link); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java index 0e9224f813..5ee7566a5e 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java @@ -74,18 +74,18 @@ public abstract class BaseTestSheetShiftColumns { textCell.setCellValue("TEXT"); textCell.setCellStyle(newCenterBottomStyle()); - sheet2 = workbook.createSheet("sheet2"); - row = sheet2.createRow(0); row.createCell(0, CellType.NUMERIC).setCellValue(10); - row.createCell(1, CellType.NUMERIC).setCellValue(11); - row.createCell(2, CellType.FORMULA).setCellFormula("SUM(sheet1!B3:C3)"); - row = sheet2.createRow(1); - row.createCell(0, CellType.NUMERIC).setCellValue(21); - row.createCell(1, CellType.NUMERIC).setCellValue(22); - row.createCell(2, CellType.NUMERIC).setCellValue(23); + sheet2 = workbook.createSheet("sheet2"); + row = sheet2.createRow(0); row.createCell(0, CellType.NUMERIC).setCellValue(10); + row.createCell(1, CellType.NUMERIC).setCellValue(11); + row.createCell(2, CellType.FORMULA).setCellFormula("SUM(sheet1!B3:C3)"); + row = sheet2.createRow(1); + row.createCell(0, CellType.NUMERIC).setCellValue(21); + row.createCell(1, CellType.NUMERIC).setCellValue(22); + row.createCell(2, CellType.NUMERIC).setCellValue(23); row = sheet2.createRow(2); row.createCell(0, CellType.FORMULA).setCellFormula("sheet1!A4+sheet1!C2+A2"); - row.createCell(1, CellType.FORMULA).setCellFormula("SUM(sheet1!A3:$C3)"); - row = sheet2.createRow(3); + row.createCell(1, CellType.FORMULA).setCellFormula("SUM(sheet1!A3:$C3)"); + row = sheet2.createRow(3); row.createCell(0, CellType.STRING).setCellValue("dummy"); } @@ -116,7 +116,7 @@ public abstract class BaseTestSheetShiftColumns { Cell textCell = sheet1.getRow(6).getCell(3); assertEquals(textCell.getStringCellValue(), "TEXT"); assertEquals(textCell.getCellStyle().getAlignment(), HorizontalAlignment.CENTER); - + // other sheet String formulaC1 = sheet2.getRow(0).getCell(2).getCellFormula(); // SUM(sheet1!B3:C3) assertEquals("SUM(sheet1!C3:D3)", formulaC1); @@ -155,7 +155,7 @@ public abstract class BaseTestSheetShiftColumns { Cell newb6Null = sheet1.getRow(5).getCell(1); assertNull(newb6Null); } - + @Test(expected = IllegalStateException.class) public void testShiftTwoColumnsLeft() { sheet1.shiftColumns(1, 2, -2); @@ -186,7 +186,7 @@ public abstract class BaseTestSheetShiftColumns { cell = row.createCell(1); // CellAddress=B1, shifted to B4 cell.setCellStyle(hlinkStyle); - createHyperlink(helper, cell, HyperlinkType.URL, "http://poi.apache.org/"); + createHyperlink(helper, cell, HyperlinkType.URL, "https://poi.apache.org/"); // row0 will be shifted on top of row1, so this URL should be removed // from the workbook @@ -225,7 +225,7 @@ public abstract class BaseTestSheetShiftColumns { verifyHyperlink(shiftedRow.getCell(3), HyperlinkType.DOCUMENT, "test!E1"); // URL, EMAIL, and FILE links anchored on a shifted cell should be moved - verifyHyperlink(shiftedRow.getCell(4), HyperlinkType.URL, "http://poi.apache.org/"); + verifyHyperlink(shiftedRow.getCell(4), HyperlinkType.URL, "https://poi.apache.org/"); // Make sure hyperlinks were moved and not copied assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0)); @@ -331,7 +331,7 @@ public abstract class BaseTestSheetShiftColumns { protected abstract Workbook openWorkbook(String spreadsheetFileName) throws IOException; protected abstract Workbook getReadBackWorkbook(Workbook wb) throws IOException; - + protected static final String AMDOCS = "Amdocs"; protected static final String AMDOCS_TEST = "Amdocs:\ntest\n"; @@ -344,7 +344,7 @@ public abstract class BaseTestSheetShiftColumns { assertNotNull(comment); assertEquals(AMDOCS, comment.getAuthor()); assertEquals(AMDOCS_TEST, comment.getString().getString()); - + sheet.shiftColumns(0, 1, 1); // comment in column 0 is gone @@ -374,19 +374,19 @@ public abstract class BaseTestSheetShiftColumns { assertEquals(AMDOCS_TEST, comment.getString().getString()); wbBack.close(); } - + // transposed version of TestXSSFSheetShiftRows.testBug54524() @Test public void testBug54524() throws IOException { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet(); - Row firstRow = sheet.createRow(0); + Row firstRow = sheet.createRow(0); firstRow.createCell(0).setCellValue(""); firstRow.createCell(1).setCellValue(1); firstRow.createCell(2).setCellValue(2); firstRow.createCell(3).setCellFormula("SUM(B1:C1)"); firstRow.createCell(4).setCellValue("X"); - + sheet.shiftColumns(3, 5, -1); Cell cell = CellUtil.getCell(sheet.getRow(0), 1); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java index 732435af09..389f909a97 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java @@ -97,7 +97,7 @@ public abstract class BaseTestSheetShiftRows { assertEquals(s.getRow(5).getPhysicalNumberOfCells(), 2); wb3.close(); - + // Read the first file again Workbook wb4 = _testDataProvider.openSampleWorkbook(sampleName); s = wb4.getSheetAt( 0 ); @@ -192,7 +192,7 @@ public abstract class BaseTestSheetShiftRows { // Ensure that the changes were persisted Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1); wb1.close(); - + sheet = wb2.getSheet("Sheet1"); assertEquals(4, sheet.getLastRowNum()); @@ -217,7 +217,7 @@ public abstract class BaseTestSheetShiftRows { // by shifting rows... if(!(wb2 instanceof HSSFWorkbook)) { assertEquals(2, sheet.getLastRowNum()); - + // Verify comments are in the position expected assertNull("Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()), sheet.getCellComment(new CellAddress(0,0))); @@ -229,7 +229,7 @@ public abstract class BaseTestSheetShiftRows { assertEquals(comment1,"comment top row3 (index2)\n"); String comment2 = sheet.getCellComment(new CellAddress(2,0)).getString().getString(); assertEquals(comment2,"comment top row4 (index3)\n"); - + wb2.close(); } @@ -274,7 +274,7 @@ public abstract class BaseTestSheetShiftRows { name4 = wb.getName("name4"); assertEquals("A1", name4.getRefersToFormula()); - + wb.close(); } @@ -304,31 +304,31 @@ public abstract class BaseTestSheetShiftRows { // populate sheet cells for (int i = 0; i < 10; i++) { Row row = sheet.createRow(i); - + for (int j = 0; j < 10; j++) { Cell cell = row.createCell(j, CellType.STRING); cell.setCellValue(i + "x" + j); } } - + CellRangeAddress A4_B7 = CellRangeAddress.valueOf("A4:B7"); CellRangeAddress C4_D7 = CellRangeAddress.valueOf("C4:D7"); assertEquals(0, sheet.addMergedRegion(A4_B7)); assertEquals(1, sheet.addMergedRegion(C4_D7)); - + assumeTrue(sheet.getLastRowNum() > 8); - + // Insert a row in the middle of both merged regions. sheet.shiftRows(4, sheet.getLastRowNum(), 1); - + // all regions should still start at row 3, and elongate by 1 row List<CellRangeAddress> expectedMergedRegions = new ArrayList<>(); CellRangeAddress A4_B8 = CellRangeAddress.valueOf("A4:B8"); //A4:B7 should be elongated by 1 row CellRangeAddress C4_D8 = CellRangeAddress.valueOf("C4:D8"); //C4:B7 should be elongated by 1 row expectedMergedRegions.add(A4_B8); expectedMergedRegions.add(C4_D8); - + // This test is written as expected-to-fail and should be rewritten // as expected-to-pass when the bug is fixed. // FIXME: remove try, catch, and testPassesNow, skipTest when test passes @@ -340,8 +340,8 @@ public abstract class BaseTestSheetShiftRows { } wb.close(); } - - + + /** * See bug #34023 @@ -498,7 +498,7 @@ public abstract class BaseTestSheetShiftRows { wb.close(); } - + /** * Unified test for: * bug 46742: XSSFSheet.shiftRows should shift hyperlinks @@ -509,7 +509,7 @@ public abstract class BaseTestSheetShiftRows { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet("test"); Row row = sheet.createRow(0); - + // How to create hyperlinks // https://poi.apache.org/spreadsheet/quick-guide.html#Hyperlinks CreationHelper helper = wb.getCreationHelper(); @@ -524,55 +524,55 @@ public abstract class BaseTestSheetShiftRows { Cell cell = row.createCell(0); cell.setCellStyle(hlinkStyle); createHyperlink(helper, cell, HyperlinkType.DOCUMENT, "test!E1"); - + // URL cell = row.createCell(1); // CellAddress=B1, shifted to B4 cell.setCellStyle(hlinkStyle); - createHyperlink(helper, cell, HyperlinkType.URL, "http://poi.apache.org/"); - + createHyperlink(helper, cell, HyperlinkType.URL, "https://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, 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, HyperlinkType.FILE, "54524.xlsx"); - + cell = wb.createSheet("other").createRow(0).createCell(0); // CellAddress=Other!A1, will be unaffected cell.setCellStyle(hlinkStyle); createHyperlink(helper, cell, HyperlinkType.URL, "http://apache.org/"); - + int startRow = 0; int endRow = 0; int n = 3; sheet.shiftRows(startRow, endRow, n); - + Workbook read = _testDataProvider.writeOutAndReadBack(wb); wb.close(); - + Sheet sh = read.getSheet("test"); - + Row shiftedRow = sh.getRow(3); - + // 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), HyperlinkType.DOCUMENT, "test!E1"); - + // URL, EMAIL, and FILE links anchored on a shifted cell should be moved - verifyHyperlink(shiftedRow.getCell(1), HyperlinkType.URL, "http://poi.apache.org/"); - + verifyHyperlink(shiftedRow.getCell(1), HyperlinkType.URL, "https://poi.apache.org/"); + // Make sure hyperlinks were moved and not copied assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0)); assertNull("URL hyperlink should be moved, not copied", sh.getHyperlink(0, 1)); - + // Make sure hyperlink in overwritten row is deleted assertEquals(3, sh.getHyperlinkList().size()); CellAddress unexpectedLinkAddress = new CellAddress("C4"); @@ -583,26 +583,26 @@ public abstract class BaseTestSheetShiftRows { "been deleted when Row 1 was shifted on top of it."); } } - + // Make sure unaffected rows are not shifted Cell unaffectedCell = sh.getRow(20).getCell(3); assertTrue(cellHasHyperlink(unaffectedCell)); 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, HyperlinkType.URL, "http://apache.org/"); - + read.close(); } - + //@Ignore("bug 56454: Incorrectly handles merged regions that do not contain column 0") @Test public void shiftRowsWithMergedRegionsThatDoNotContainColumnZero() throws IOException { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet("test"); - + // populate sheet cells for (int i = 0; i < 10; i++) { Row row = sheet.createRow(i); @@ -633,7 +633,7 @@ public abstract class BaseTestSheetShiftRows { } catch (AssertionError e) { skipTest(e); } - + wb.close(); } @@ -740,32 +740,32 @@ public abstract class BaseTestSheetShiftRows { wb.close(); } - + @Test public void test61840_shifting_rows_up_does_not_produce_REF_errors() throws IOException { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet(); Cell cell = sheet.createRow(4).createCell(0); - + cell.setCellFormula("(B5-C5)/B5"); sheet.shiftRows(4, 4, -1); - + // Cell objects created before a row shift are still valid. // The row number of those cell references will be shifted if // the cell is within the shift range. assertEquals("(B4-C4)/B4", cell.getCellFormula()); - + // New cell references are also valid. Cell shiftedCell = sheet.getRow(3).getCell(0); assertNotNull(shiftedCell); assertEquals("(B4-C4)/B4", shiftedCell.getCellFormula()); - + wb.close(); } - - - - + + + + private void createHyperlink(CreationHelper helper, Cell cell, HyperlinkType linkType, String ref) { cell.setCellValue(ref); @@ -773,14 +773,14 @@ public abstract class BaseTestSheetShiftRows { link.setAddress(ref); cell.setHyperlink(link); } - + private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) { assertTrue(cellHasHyperlink(cell)); Hyperlink link = cell.getHyperlink(); assertEquals(linkType, link.getType()); assertEquals(ref, link.getAddress()); } - + private boolean cellHasHyperlink(Cell cell) { return (cell != null) && (cell.getHyperlink() != null); } |