]> source.dussan.org Git - poi.git/commitdiff
support for hyperlinks in SXSSF
authorYegor Kozlov <yegor@apache.org>
Tue, 12 Jul 2011 15:18:29 +0000 (15:18 +0000)
committerYegor Kozlov <yegor@apache.org>
Tue, 12 Jul 2011 15:18:29 +0000 (15:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145629 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/streaming/TestSXSSFHyperlink.java [new file with mode: 0755]

index aad9a5367f66c4e36dd7968b2084a54811c3e9cd..801b21875671f8fd71f762e3595121e8219a874f 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta4" date="2011-??-??">
+           <action dev="poi-developers" type="add">Support for hyperlinks in SXSSF</action>
            <action dev="poi-developers" type="fix">49933 - Word 6/95 documents with sections cause ArrayIndexOutOfBoundsException</action>
            <action dev="poi-developers" type="add">51469 - XSSF support for row styles, to match existing HSSF functionality</action>
            <action dev="poi-developers" type="fix">51476 - Correct XSSF cell formatting in HTML export</action>
index b6423189aca6e51054fdadfd3530de7222369266..bd57fc3ded4bb2251bb72f461edc53f16437fc60 100644 (file)
@@ -26,7 +26,8 @@ import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.formula.FormulaParseException;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.usermodel.XSSFHyperlink;
 
 /**
  * Streaming version of XSSFRow implementing the "BigGridDemo" strategy.
@@ -570,6 +571,15 @@ public class SXSSFCell implements Cell
     public void setHyperlink(Hyperlink link)
     {
         setProperty(Property.HYPERLINK,link);
+
+        XSSFHyperlink xssfobj = (XSSFHyperlink)link;
+        // Assign to us
+        CellReference ref = new CellReference(getRowIndex(), getColumnIndex());
+        xssfobj.getCTHyperlink().setRef( ref.formatAsString()  );
+
+        // Add to the lists
+        ((SXSSFSheet)getSheet())._sh.addHyperlink(xssfobj);
+
     }
 
     /**
index 42c70e8c839341b004c25f1a3aba1bbe30c7febc..1185b562a4efa7d0b75ee76aa7c57e14c6a1bd1f 100644 (file)
@@ -917,7 +917,7 @@ public final class XSSFCell implements Cell {
         link.setCellReference( new CellReference(_row.getRowNum(), _cellNum).formatAsString() );
 
         // Add to the lists
-        getSheet().setCellHyperlink(link);
+        getSheet().addHyperlink(link);
     }
 
     /**
index c472911e8e16435ba7bef1608392090a8085ca30..21fd54b844dcfeee9b2b54977e1df944010b8d1d 100644 (file)
@@ -88,9 +88,9 @@ public class XSSFHyperlink implements Hyperlink {
     }
 
     /**
-     * Returns the underlying hyperlink object
+     * @return the underlying CTHyperlink object
      */
-    protected CTHyperlink getCTHyperlink() {
+    public CTHyperlink getCTHyperlink() {
         return _ctHyperlink;
     }
 
index 19ea45a3f122f53b05a58c8946c04231e0eb1eed..24cd2ba24514869f4db2f2324aadc6af91b1a5ac 100644 (file)
@@ -2501,7 +2501,13 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
         comment.setColumn(cellReference.getCol());
     }
 
-    protected void setCellHyperlink(XSSFHyperlink hyperlink) {
+    /**
+     * Register a hyperlink in the collection of hyperlinks on this sheet
+     *
+     * @param hyperlink the link to add
+     */
+    @Internal
+    public void addHyperlink(XSSFHyperlink hyperlink) {
         hyperlinks.add(hyperlink);
     }
 
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/streaming/TestSXSSFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/streaming/TestSXSSFHyperlink.java
new file mode 100755 (executable)
index 0000000..ed8b91b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    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.xssf.usermodel.streaming;
+
+import org.apache.poi.ss.usermodel.BaseTestCell;
+import org.apache.poi.ss.usermodel.BaseTestHyperlink;
+import org.apache.poi.xssf.SXSSFITestDataProvider;
+
+/**
+ * Test setting hyperlinks in SXSSF
+ *
+ * @author Yegor Kozlov
+ */
+public class TestSXSSFHyperlink extends BaseTestHyperlink {
+
+    public TestSXSSFHyperlink() {
+        super(SXSSFITestDataProvider.instance);
+    }
+
+}
\ No newline at end of file