Create Hyperlink interface, based on HSSFHyperlink. Stub out for XSSF, but have yet to implement. (See WithMoreVariousData.xlsx for all the different kinds when implementing)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@644797 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
95756c5472
commit
a937f6c3d2
@ -17,6 +17,7 @@
|
||||
package org.apache.poi.hssf.usermodel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.CreationHelper;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
|
||||
public class HSSFCreationHelper implements CreationHelper {
|
||||
private HSSFWorkbook workbook;
|
||||
@ -39,4 +40,11 @@ public class HSSFCreationHelper implements CreationHelper {
|
||||
public HSSFDataFormat createDataFormat() {
|
||||
return dataFormat;
|
||||
}
|
||||
|
||||
public HSSFHyperlink createHyperlink(int type, Sheet sheetFor) {
|
||||
return createHyperlink(type);
|
||||
}
|
||||
public HSSFHyperlink createHyperlink(int type) {
|
||||
return new HSSFHyperlink(type);
|
||||
}
|
||||
}
|
||||
|
@ -16,22 +16,15 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.hssf.usermodel;
|
||||
|
||||
import org.apache.poi.hssf.record.EscherAggregate;
|
||||
import org.apache.poi.hssf.record.NoteRecord;
|
||||
import org.apache.poi.hssf.record.TextObjectRecord;
|
||||
import org.apache.poi.hssf.record.HyperlinkRecord;
|
||||
import org.apache.poi.ddf.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import org.apache.poi.ss.usermodel.Hyperlink;
|
||||
|
||||
/**
|
||||
* Represents an Excel hyperlink.
|
||||
*
|
||||
* @author Yegor Kozlov (yegor at apache dot org)
|
||||
*/
|
||||
public class HSSFHyperlink {
|
||||
public class HSSFHyperlink implements Hyperlink {
|
||||
|
||||
/**
|
||||
* Link to a existing file or web page
|
||||
@ -209,7 +202,7 @@ public class HSSFHyperlink {
|
||||
*
|
||||
* @return the type of this hyperlink
|
||||
*/
|
||||
protected int getType(){
|
||||
public int getType(){
|
||||
return link_type;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
/* ====================================================================
|
||||
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.ss.usermodel;
|
||||
|
||||
public interface Hyperlink {
|
||||
/**
|
||||
* Link to a existing file or web page
|
||||
*/
|
||||
public static final int LINK_URL = 1;
|
||||
|
||||
/**
|
||||
* Link to a place in this document
|
||||
*/
|
||||
public static final int LINK_DOCUMENT = 2;
|
||||
|
||||
/**
|
||||
* Link to an E-mail address
|
||||
*/
|
||||
public static final int LINK_EMAIL = 3;
|
||||
|
||||
/**
|
||||
* Link to a file
|
||||
*/
|
||||
public static final int LINK_FILE = 4;
|
||||
}
|
@ -39,4 +39,10 @@ public interface CreationHelper {
|
||||
* Creates a new DataFormat instance
|
||||
*/
|
||||
DataFormat createDataFormat();
|
||||
|
||||
/**
|
||||
* Creates a new Hyperlink, of the given type,
|
||||
* for the given sheet
|
||||
*/
|
||||
Hyperlink createHyperlink(int type, Sheet sheetFor);
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
/* ====================================================================
|
||||
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.ss.usermodel;
|
||||
|
||||
/**
|
||||
* Represents an Excel hyperlink.
|
||||
*/
|
||||
public interface Hyperlink {
|
||||
/**
|
||||
* Link to a existing file or web page
|
||||
*/
|
||||
public static final int LINK_URL = 1;
|
||||
|
||||
/**
|
||||
* Link to a place in this document
|
||||
*/
|
||||
public static final int LINK_DOCUMENT = 2;
|
||||
|
||||
/**
|
||||
* Link to an E-mail address
|
||||
*/
|
||||
public static final int LINK_EMAIL = 3;
|
||||
|
||||
/**
|
||||
* Link to a file
|
||||
*/
|
||||
public static final int LINK_FILE = 4;
|
||||
|
||||
/**
|
||||
* Return the row of the first cell that contains the hyperlink
|
||||
*
|
||||
* @return the 0-based row of the cell that contains the hyperlink
|
||||
*/
|
||||
public int getFirstRow();
|
||||
|
||||
/**
|
||||
* Set the row of the first cell that contains the hyperlink
|
||||
*
|
||||
* @param row the 0-based row of the first cell that contains the hyperlink
|
||||
*/
|
||||
public void setFirstRow(int row);
|
||||
|
||||
/**
|
||||
* Return the row of the last cell that contains the hyperlink
|
||||
*
|
||||
* @return the 0-based row of the last cell that contains the hyperlink
|
||||
*/
|
||||
public int getLastRow();
|
||||
|
||||
/**
|
||||
* Set the row of the last cell that contains the hyperlink
|
||||
*
|
||||
* @param row the 0-based row of the last cell that contains the hyperlink
|
||||
*/
|
||||
public void setLastRow(int row);
|
||||
|
||||
/**
|
||||
* Return the column of the first cell that contains the hyperlink
|
||||
*
|
||||
* @return the 0-based column of the first cell that contains the hyperlink
|
||||
*/
|
||||
public short getFirstColumn();
|
||||
|
||||
/**
|
||||
* Set the column of the first cell that contains the hyperlink
|
||||
*
|
||||
* @param col the 0-based column of the first cell that contains the hyperlink
|
||||
*/
|
||||
public void setFirstColumn(short col);
|
||||
|
||||
/**
|
||||
* Return the column of the last cell that contains the hyperlink
|
||||
*
|
||||
* @return the 0-based column of the last cell that contains the hyperlink
|
||||
*/
|
||||
public short getLastColumn();
|
||||
|
||||
/**
|
||||
* Set the column of the last cell that contains the hyperlink
|
||||
*
|
||||
* @param col the 0-based column of the last cell that contains the hyperlink
|
||||
*/
|
||||
public void setLastColumn(short col);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
|
||||
*
|
||||
* @return the address of this hyperlink
|
||||
*/
|
||||
public String getAddress();
|
||||
|
||||
/**
|
||||
* Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
|
||||
*
|
||||
* @param address the address of this hyperlink
|
||||
*/
|
||||
public void setAddress(String address);
|
||||
|
||||
/**
|
||||
* Return text label for this hyperlink
|
||||
*
|
||||
* @return text to display
|
||||
*/
|
||||
public String getLabel();
|
||||
|
||||
/**
|
||||
* Sets text label for this hyperlink
|
||||
*
|
||||
* @param label text label for this hyperlink
|
||||
*/
|
||||
public void setLabel(String label);
|
||||
|
||||
/**
|
||||
* Return the type of this hyperlink
|
||||
*
|
||||
* @return the type of this hyperlink
|
||||
*/
|
||||
public int getType();
|
||||
}
|
@ -18,7 +18,9 @@ package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.CreationHelper;
|
||||
import org.apache.poi.ss.usermodel.DataFormat;
|
||||
import org.apache.poi.ss.usermodel.Hyperlink;
|
||||
import org.apache.poi.ss.usermodel.RichTextString;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
|
||||
public class XSSFCreationHelper implements CreationHelper {
|
||||
private XSSFWorkbook workbook;
|
||||
@ -40,4 +42,8 @@ public class XSSFCreationHelper implements CreationHelper {
|
||||
public DataFormat createDataFormat() {
|
||||
return dataFormat;
|
||||
}
|
||||
|
||||
public Hyperlink createHyperlink(int type, Sheet sheetFor) {
|
||||
return new XSSFHyperlink(type, (XSSFSheet)sheetFor);
|
||||
}
|
||||
}
|
||||
|
121
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java
Normal file
121
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java
Normal file
@ -0,0 +1,121 @@
|
||||
/* ====================================================================
|
||||
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;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Hyperlink;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHyperlink;
|
||||
|
||||
import org.openxml4j.opc.Package;
|
||||
import org.openxml4j.opc.PackagePart;
|
||||
|
||||
/**
|
||||
* XSSF Implementation of a Hyperlink.
|
||||
* Note - unlike with HSSF, many kinds of hyperlink
|
||||
* are largely stored as relations of the sheet
|
||||
*/
|
||||
public class XSSFHyperlink implements Hyperlink {
|
||||
private int type;
|
||||
private XSSFSheet sheet;
|
||||
private CTHyperlink ctHyperlink;
|
||||
|
||||
protected XSSFHyperlink(int type, XSSFSheet sheet) {
|
||||
this.type = type;
|
||||
this.sheet = sheet;
|
||||
this.ctHyperlink = CTHyperlink.Factory.newInstance();
|
||||
}
|
||||
protected XSSFHyperlink(CTHyperlink ctHyperlink, XSSFSheet sheet) {
|
||||
this.sheet = sheet;
|
||||
this.ctHyperlink = ctHyperlink;
|
||||
|
||||
// Figure out the Hyperlink type
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying hyperlink object
|
||||
*/
|
||||
protected CTHyperlink getCTHyperlink() {
|
||||
return ctHyperlink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we need to a relation too, to represent
|
||||
* this hyperlink?
|
||||
*/
|
||||
public boolean needsRelationToo() {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the relation if required
|
||||
*/
|
||||
protected void generateRelationIfNeeded(Package pkg, PackagePart sheetPart) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
public String getLabel() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
public void setAddress(String address) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public short getFirstColumn() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
public int getFirstRow() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
public short getLastColumn() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
public int getLastRow() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setFirstColumn(short col) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
public void setFirstRow(int row) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
public void setLastColumn(short col) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
public void setLastRow(int row) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user