File indexing completed on 2025-01-19 13:27:33

0001 /* This file is part of the KDE project
0002    Copyright (C) 2001 Graham Short <grahshrt@netscape.net>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #include <qproformula.h>
0021 
0022 static QpFormulaConv gOverride[] = {
0023     {14,  QpFormula::binaryOperand, "=="},      // '=' => '=='
0024     {15,  QpFormula::binaryOperand, "!="},      // '<>' => '!='
0025     {20,  QpFormula::func2,         "AND("},    // (e.g.)  2 #AND# 3  => AND(2;3)
0026     {21,  QpFormula::func2,         "OR("},     // (e.g.)  2 #OR# 3  => OR(2;3)
0027     {22,  QpFormula::func1,         "NOT("},    // (e.g.)  #NOT# 3  => NOT(3)
0028     {24,  QpFormula::binaryOperand, "+"},       // string concat "&" => "+"
0029     {32,  QpFormula::func0,         "ERR()"},   // @err => ERR()
0030     {33,  QpFormula::absKludge,     0},         // @abs => if( (arg)<0; -(arg); (arg))
0031     {34,  QpFormula::func1,         "INT("},    // @int => INT
0032     {38,  QpFormula::func0,         "PI()"},    // @pi => PI()
0033     {47,  QpFormula::func2,         "MOD("},    // @mod => MOD
0034     {51,  QpFormula::func0,         "(1==0)"},  // @false => (1==0)
0035     {52,  QpFormula::func0,         "(1==1)"},  // @true  => (1==1)
0036     {53,  QpFormula::func0,         "rand()"},  // @rand  => rand()
0037     {68,  QpFormula::func1,         "ISNUM("},  // @isnumber => ISNUM
0038     {69,  QpFormula::func1,         "ISTEXT("}, // @isstring => ISTEXT
0039     {70,  QpFormula::func1,         "len("},    // @length   => len
0040     {81,  QpFormula::funcV,         "average("}, // @avg    => average
0041     {87,  QpFormula::funcV,         "variance("},// @var    => variance
0042     {88,  QpFormula::funcV,         "stddev("},  // @std    => stddev
0043     {101, QpFormula::func2,         "REPT("},    // @repeat => REPT
0044     {0,   0,                        0}
0045 };
0046 
0047 Calligra::Sheets::QuattroPro::Formula::Formula(QpRecFormulaCell& pCell, QpTableNames& pTable)
0048         : QpFormula(pCell, pTable)
0049 {
0050     formulaStart("=");   // quattro pro starts formulas with "+"
0051     // kspread uses "="
0052     dropLeadingAt();     // quattro pro starts it's functions with '@'
0053     // kspread doesn't like this
0054     argSeparator(";");   // quattro pro separates function arguments with ","
0055     // kspread likes ";"
0056 
0057     // override some of the default conversions
0058     replaceFunc(gOverride);
0059 }
0060 
0061 Calligra::Sheets::QuattroPro::Formula::~Formula()
0062 {
0063 }