poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r760343 - /poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
Date Tue, 31 Mar 2009 06:09:07 GMT
Author: josh
Date: Tue Mar 31 06:09:06 2009
New Revision: 760343

URL: http://svn.apache.org/viewvc?rev=760343&view=rev
Log:
Bugzilla 46818 (patch from Wayne Clingingsmith) - added implementation for HYPERLINK function

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java?rev=760343&r1=760342&r2=760343&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java Tue Mar
31 06:09:06 2009
@@ -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();
+		}
+	}
 }



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


Mime
View raw message