aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2009-03-31 06:09:06 +0000
committerJosh Micich <josh@apache.org>2009-03-31 06:09:06 +0000
commit2d91c7b31fe70b5857abd2ce19a10974028f23a5 (patch)
treed1a5353b9fbc31d4e080ccf5d5782a0ae3c6b7ea /src/java
parentd92e7179bf59e146d7aef4e1621d72aeb0fd4556 (diff)
downloadpoi-2d91c7b31fe70b5857abd2ce19a10974028f23a5.tar.gz
poi-2d91c7b31fe70b5857abd2ce19a10974028f23a5.zip
Bugzilla 46818 (patch from Wayne Clingingsmith) - added implementation for HYPERLINK function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@760343 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java73
1 files changed, 52 insertions, 21 deletions
diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java b/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
index 020d40d87f..d729762a50 100644
--- a/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
+++ b/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
@@ -1,25 +1,56 @@
-/*
-* 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.
-*/
-/*
- * Created on May 15, 2005
- *
- */
+/* ====================================================================
+ 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.hssf.record.formula.functions;
-public class Hyperlink extends NotImplementedFunction {
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.EvaluationException;
+import org.apache.poi.hssf.record.formula.eval.OperandResolver;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+
+/**
+ * Implementation of Excel HYPERLINK function.<p/>
+ *
+ * In Excel this function has special behaviour - it causes the displayed cell value to behave like
+ * a hyperlink in the GUI. From an evaluation perspective however, it is very simple.<p/>
+ *
+ * <b>Syntax</b>:<br/>
+ * <b>HYPERLINK</b>(<b>link_location</b>, friendly_name)<p/>
+ *
+ * <b>link_location</b> The URL of the hyperlink <br/>
+ * <b>friendly_name</b> (optional) the value to display<p/>
+ *
+ * Returns last argument. Leaves type unchanged (does not convert to {@link StringEval}).
+
+ * @author Wayne Clingingsmith
+ */
+public class Hyperlink implements Function {
+
+ public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+ int lastArgIx = operands.length - 1;
+ if (lastArgIx < 0 || lastArgIx > 1) {
+ return ErrorEval.VALUE_INVALID;
+ }
+ try {
+ return OperandResolver.getSingleValue(operands[lastArgIx], srcRow, srcCol);
+ } catch (EvaluationException e) {
+ return e.getErrorEval();
+ }
+ }
}