summaryrefslogtreecommitdiff
path: root/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java
diff options
context:
space:
mode:
Diffstat (limited to 'xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java')
-rw-r--r--xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java195
1 files changed, 0 insertions, 195 deletions
diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java
deleted file mode 100644
index a0cba9e566c8..000000000000
--- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * 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 .
- */
-
-package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula;
-
-import java.util.HashMap;
-
-public class FunctionLookup extends SymbolLookup {
-
- private HashMap<String, Integer> stringToArgs = null;
-
- /**
- * The default constructor - invokes {@link #initialize() initialize()}
- */
- public FunctionLookup() {
- initialize();
- }
-
- /**
- * Initialize the lookup table for functions
- */
- public void initialize() {
- if ((stringToID != null) || (idToString != null) || (stringToArgs !=null)) {
- return;
- }
- stringToID = new HashMap<String, Integer>();
- idToString = new HashMap<Integer, String>();
- stringToArgs = new HashMap<String, Integer>();
-
- // Functions with Variable number of Arguments
- // Math and Trig
- addEntry("SUM", TokenConstants.TSUM, -1);
- addEntry("MIN", TokenConstants.TMIN, -1);
- addEntry("PRODUCT", TokenConstants.TPRODUCT, -1);
- addEntry("LOG", TokenConstants.TLOG, -1);
- addEntry("SUMIF", TokenConstants.TSUMIF, -1);
- addEntry("TRUNC", TokenConstants.TRUNC, -1);
- // Financial
- addEntry("DDB", TokenConstants.TDDB, -1);
- addEntry("FV", TokenConstants.TFV, -1);
- addEntry("IRR", TokenConstants.TIRR, -1);
- addEntry("NPER", TokenConstants.TNPER, -1);
- addEntry("NPV", TokenConstants.TNPV, -1);
- addEntry("PMT", TokenConstants.TPMT, -1);
- addEntry("PV", TokenConstants.TPV, -1);
- addEntry("RATE", TokenConstants.TRATE, -1);
- // Statistical
- addEntry("AVERAGE", TokenConstants.TAVERAGE, -1);
- addEntry("COUNT", TokenConstants.TCOUNT, -1);
- addEntry("COUNTA", TokenConstants.TCOUNTA, -1);
- addEntry("MAX", TokenConstants.TMAX, -1 );
- addEntry("MIN", TokenConstants.TMIN, -1);
- addEntry("STDEV", TokenConstants.TSTDEV, -1 );
- addEntry("STDEVP", TokenConstants.TSTDEVP, -1 );
- addEntry("VAR", TokenConstants.TVAR, -1);
- addEntry("VARP", TokenConstants.TVARP, -1);
- // Lookup
- addEntry("CHOOSE", TokenConstants.TCHOOSE, -1);
- addEntry("HLOOKUP", TokenConstants.THLOOKUP, -1);
- addEntry("INDEX", TokenConstants.TINDEX, -1);
- addEntry("MATCH", TokenConstants.TMATCH, -1) ;
- addEntry("VLOOKUP", TokenConstants.TVLOOKUP, -1);
- // Text
- addEntry("RIGHT", TokenConstants.TRIGHT, -1);
- addEntry("SUBSTITUTE", TokenConstants.TSUBSTITUTE, -1);
- addEntry("FIND", TokenConstants.TFIND, -1);
- addEntry("LEFT", TokenConstants.TLEFT, -1);
- // Logical
- addEntry("AND", TokenConstants.TAND, -1 );
- addEntry("IF", TokenConstants.TIF, -1) ;
- addEntry("OR", TokenConstants.TOR, -1);
-
- // Functions with Fixed number of Arguments
- // Math and Trig
- addEntry("ABS", TokenConstants.TABS, 1);
- addEntry("ACOS", TokenConstants.TACOS, 1);
- addEntry("ASIN", TokenConstants.TASIN, 1);
- addEntry("ATAN", TokenConstants.TATAN, 1);
- addEntry("ATAN2", TokenConstants.TATAN2, 1);
- addEntry("COS", TokenConstants.TCOS, 1);
- addEntry("COUNTIF", TokenConstants.TCOUNTIF, 1);
- addEntry("DEGREES", TokenConstants.TDEGREES, 1);
- addEntry("EXP", TokenConstants.TEXP, 1);
- addEntry("FACT", TokenConstants.TFACT, 1);
- addEntry("INT", TokenConstants.TINTE, 1);
- addEntry("LN", TokenConstants.TLN, 1);
- addEntry("LOG10", TokenConstants.TLOG10, 1);
- addEntry("MOD", TokenConstants.TMOD, 1);
- addEntry("PI", TokenConstants.TPI, 0);
- addEntry("POWER", TokenConstants.TPOWERF, 2);
- addEntry("RADIANS", TokenConstants.TRADIANS, 1);
- addEntry("RAND", TokenConstants.TRAND, 1);
- addEntry("ROUND", TokenConstants.TROUND, 1);
- addEntry("SQRT", TokenConstants.TSQRT, 1);
- addEntry("TAN", TokenConstants.TTAN, 1);
- addEntry("SIN", TokenConstants.TSIN, 1);
- // Financial
- addEntry("SLN", TokenConstants.TSLN, 3);
- addEntry("SYD", TokenConstants.TSYD, 4);
- // Date and Time
- addEntry("DATE", TokenConstants.TDATE, 3);
- addEntry("DATEVALUE", TokenConstants.TDATEVALUE, 1);
- addEntry("DAY", TokenConstants.TDAY, 1);
- addEntry("HOUR", TokenConstants.THOUR, 1);
- addEntry("MINUTE", TokenConstants.TMINUTE, 1 );
- addEntry("MONTH", TokenConstants.TMONTH, 1);
- addEntry("NOW", TokenConstants.TNOW, 0);
- addEntry("SECOND", TokenConstants.TSECOND, 1);
- addEntry("TIME", TokenConstants.TTIME, 3);
- addEntry("TIMEVALUE", TokenConstants.TTIMEVALUE, 1);
- addEntry("YEAR", TokenConstants.TYEAR, 1);
- // Statistical
- addEntry("COUNTBLANK", TokenConstants.TCOUNTBLANK, 1);
- // lookup
- addEntry("COLUMNS", TokenConstants.TCOLUMNS, 1);
- addEntry("ROWS", TokenConstants.TROWS, 1);
- // Database
- addEntry("DAVERAGE", TokenConstants.TDAVAERAGE, 3);
- addEntry("DCOUNT", TokenConstants.TDCOUNT, 3);
- addEntry("DCOUNTA", TokenConstants.TDCOUNTA, 2);
- addEntry("DGET", TokenConstants.TDGET, 3);
- addEntry("DMAX", TokenConstants.TDMAX, 3);
- addEntry("DMIN", TokenConstants.TDMIN, 3);
- addEntry("DPRODUCT", TokenConstants.TDPRODUCT, 3);
- addEntry("DSTDEV", TokenConstants.TDSTDEV, 3);
- addEntry("DSTDEVP", TokenConstants.TDSTDEVP, 3) ;
- addEntry("DSUM", TokenConstants.TDSUM, 3);
- addEntry("DVAR", TokenConstants.TDVAR, 3);
- addEntry("DVARP", TokenConstants.TDVARP, 3);
- // Text
- addEntry("EXACT", TokenConstants.TEXACT, 2);
- addEntry("LEN", TokenConstants.TLEN, 1);
- addEntry("LOWER", TokenConstants.TLOWER, 1);
- addEntry("MID", TokenConstants.TMID, 3); // ??????
- addEntry("PROPER", TokenConstants.TPROPER, 1);
- addEntry("REPLACE", TokenConstants.TREPLACE, 4);
- addEntry("REPT", TokenConstants.TREPT, 2);
- addEntry("T", TokenConstants.TT, 1);
- addEntry("TRIM", TokenConstants.TRIM, 1);
- addEntry("UPPER", TokenConstants.TUPPER, 1);
- addEntry("VALUE", TokenConstants.TVALUE, 1);
- // Logical
- addEntry("FALSE", TokenConstants.TFALSE, 0);
- addEntry("NOT", TokenConstants.TNOT, 1);
- addEntry("TRUE", TokenConstants.TTRUE, 0);
- // Informational
- addEntry("ERRORTYPE", TokenConstants.TERRORTYPE, 1);
- addEntry("ISBLANK", TokenConstants.TISBLANK, 1);
- addEntry("ISERR", TokenConstants.TISERR, 1);
- addEntry("ISERROR", TokenConstants.TISERROR, 1);
- addEntry("ISLOGICAL", TokenConstants.TISLOGICAL, 1);
- addEntry("ISNA", TokenConstants.TISNA, 1);
- addEntry("ISNONTEXT", TokenConstants.TISNONTEXT, 1);
- addEntry("ISNUMBER", TokenConstants.TISNUMBER, 1);
- addEntry("ISTEXT", TokenConstants.TISTEXT, 1);
- addEntry("N", TokenConstants.TN, 1);
- addEntry("NA", TokenConstants.TNA, 0);
-
- }
-
- /**
- * Associate a function with an identifier and specifiy the number of arguments for that function
- * @param symbol The function string that will act as the key in the lookup table
- * @param id The identifier for the function
- * @param args The number of arguments this function requires
- */
- public void addEntry(String symbol, int id, int args) {
- addEntry(symbol, id);
- stringToArgs.put(symbol, new Integer(args));
- }
-
- /**
- * Retrieve the number of arguments for this function
- * @param symbol The function name
- * @return The number of arguments required by this function
- */
- public int getArgCountFromString(String symbol) {
- return stringToArgs.get(symbol).intValue();
- }
-}