filters

qproformula.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Graham Short <grahshrt@netscape.net>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <qproformula.h>
21
22static QpFormulaConv gOverride[] =
23{
24 {14, QpFormula::binaryOperand, "=="}, // '=' => '=='
25 {15, QpFormula::binaryOperand, "!="}, // '<>' => '!='
26 {20, QpFormula::func2, "AND("}, // (e.g.) 2 #AND# 3 => AND(2;3)
27 {21, QpFormula::func2, "OR("}, // (e.g.) 2 #OR# 3 => OR(2;3)
28 {22, QpFormula::func1, "NOT("}, // (e.g.) #NOT# 3 => NOT(3)
29 {24, QpFormula::binaryOperand, "+"}, // string concat "&" => "+"
30 {32, QpFormula::func0, "ERR()"}, // @err => ERR()
31 {33, QpFormula::absKludge, 0}, // @abs => if( (arg)<0; -(arg); (arg))
32 {34, QpFormula::func1, "INT("}, // @int => INT
33 {38, QpFormula::func0, "PI()"}, // @pi => PI()
34 {47, QpFormula::func2, "MOD("}, // @mod => MOD
35 {51, QpFormula::func0, "(1==0)"}, // @false => (1==0)
36 {52, QpFormula::func0, "(1==1)"}, // @true => (1==1)
37 {53, QpFormula::func0, "rand()"}, // @rand => rand()
38 {68, QpFormula::func1, "ISNUM("}, // @isnumber => ISNUM
39 {69, QpFormula::func1, "ISTEXT("}, // @isstring => ISTEXT
40 {70, QpFormula::func1, "len("}, // @length => len
41 {81, QpFormula::funcV, "average("}, // @avg => average
42 {87, QpFormula::funcV, "variance("},// @var => variance
43 {88, QpFormula::funcV, "stddev("}, // @std => stddev
44 {101, QpFormula::func2, "REPT("}, // @repeat => REPT
45 {0, 0, 0}
46};
47
48KSpread::Formula::Formula(QpRecFormulaCell& pCell, QpTableNames& pTable)
49 : QpFormula(pCell, pTable)
50{
51 formulaStart("="); // quattro pro starts formulas with "+"
52 // kspread uses "="
53 dropLeadingAt(); // quattro pro starts it's functions with '@'
54 // kspread doesn't like this
55 argSeparator(";"); // quattro pro separates function arguments with ","
56 // kspread likes ";"
57
58 // override some of the default conversions
59 replaceFunc(gOverride);
60}
61
62KSpread::Formula::~Formula()
63{
64}