filters
qproformula.cc
00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Graham Short <grahshrt@netscape.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include <qproformula.h> 00021 00022 static QpFormulaConv gOverride[] = 00023 { 00024 {14, QpFormula::binaryOperand, "=="}, // '=' => '==' 00025 {15, QpFormula::binaryOperand, "!="}, // '<>' => '!=' 00026 {20, QpFormula::func2, "AND("}, // (e.g.) 2 #AND# 3 => AND(2;3) 00027 {21, QpFormula::func2, "OR("}, // (e.g.) 2 #OR# 3 => OR(2;3) 00028 {22, QpFormula::func1, "NOT("}, // (e.g.) #NOT# 3 => NOT(3) 00029 {24, QpFormula::binaryOperand, "+"}, // string concat "&" => "+" 00030 {32, QpFormula::func0, "ERR()"}, // @err => ERR() 00031 {33, QpFormula::absKludge, 0}, // @abs => if( (arg)<0; -(arg); (arg)) 00032 {34, QpFormula::func1, "INT("}, // @int => INT 00033 {38, QpFormula::func0, "PI()"}, // @pi => PI() 00034 {47, QpFormula::func2, "MOD("}, // @mod => MOD 00035 {51, QpFormula::func0, "(1==0)"}, // @false => (1==0) 00036 {52, QpFormula::func0, "(1==1)"}, // @true => (1==1) 00037 {53, QpFormula::func0, "rand()"}, // @rand => rand() 00038 {68, QpFormula::func1, "ISNUM("}, // @isnumber => ISNUM 00039 {69, QpFormula::func1, "ISTEXT("}, // @isstring => ISTEXT 00040 {70, QpFormula::func1, "len("}, // @length => len 00041 {81, QpFormula::funcV, "average("}, // @avg => average 00042 {87, QpFormula::funcV, "variance("},// @var => variance 00043 {88, QpFormula::funcV, "stddev("}, // @std => stddev 00044 {101, QpFormula::func2, "REPT("}, // @repeat => REPT 00045 {0, 0, 0} 00046 }; 00047 00048 KSpread::Formula::Formula(QpRecFormulaCell& pCell, QpTableNames& pTable) 00049 : QpFormula(pCell, pTable) 00050 { 00051 formulaStart("="); // quattro pro starts formulas with "+" 00052 // kspread uses "=" 00053 dropLeadingAt(); // quattro pro starts it's functions with '@' 00054 // kspread doesn't like this 00055 argSeparator(";"); // quattro pro separates function arguments with "," 00056 // kspread likes ";" 00057 00058 // override some of the default conversions 00059 replaceFunc(gOverride); 00060 } 00061 00062 KSpread::Formula::~Formula() 00063 { 00064 }