~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kspread/functions/logic.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
*/
20
20
 
21
21
// built-in logical functions
 
22
#include "LogicModule.h"
22
23
 
 
24
#include "Function.h"
23
25
#include "FunctionModuleRegistry.h"
24
 
#include "Functions.h"
25
 
#include "LogicModule.h"
26
26
#include "ValueCalc.h"
27
27
#include "ValueConverter.h"
28
28
 
43
43
Value func_xor(valVector args, ValueCalc *calc, FuncExtra *);
44
44
 
45
45
 
46
 
#ifndef KSPREAD_UNIT_TEST // Do not create/export the plugin in unit tests.
47
 
K_PLUGIN_FACTORY(LogicModulePluginFactory,
48
 
                 registerPlugin<LogicModule>();
49
 
                )
50
 
K_EXPORT_PLUGIN(LogicModulePluginFactory("LogicModule"))
51
 
#endif
 
46
KSPREAD_EXPORT_FUNCTION_MODULE("logic", LogicModule)
52
47
 
53
48
 
54
49
LogicModule::LogicModule(QObject* parent, const QVariantList&)
55
 
        : FunctionModule(parent, "logic", i18n("Logic Functions"))
56
 
{
57
 
}
58
 
 
59
 
QString LogicModule::descriptionFileName() const
60
 
{
61
 
    return QString("logic.xml");
62
 
}
63
 
 
64
 
void LogicModule::registerFunctions()
65
 
{
66
 
    FunctionRepository* repo = FunctionRepository::self();
 
50
        : FunctionModule(parent)
 
51
{
67
52
    Function *f;
68
53
 
69
54
    f = new Function("FALSE", func_false);
70
55
    f->setParamCount(0);
71
 
    repo->add(f);
 
56
    add(f);
72
57
    f = new Function("TRUE", func_true);
73
58
    f->setParamCount(0);
74
 
    repo->add(f);
 
59
    add(f);
75
60
    f = new Function("NOT", func_not);
76
61
    f->setParamCount(1);
77
 
    repo->add(f);
 
62
    add(f);
78
63
    f = new Function("AND", func_and);
79
64
    f->setParamCount(1, -1);
80
65
    f->setAcceptArray();
81
 
    repo->add(f);
 
66
    add(f);
82
67
    f = new Function("NAND", func_nand);
83
68
    f->setParamCount(1, -1);
84
69
    f->setAcceptArray();
85
 
    repo->add(f);
 
70
    add(f);
86
71
    f = new Function("NOR", func_nor);
87
72
    f->setParamCount(1, -1);
88
73
    f->setAcceptArray();
89
 
    repo->add(f);
 
74
    add(f);
90
75
    f = new Function("OR", func_or);
91
76
    f->setParamCount(1, -1);
92
77
    f->setAcceptArray();
93
 
    repo->add(f);
 
78
    add(f);
94
79
    f = new Function("XOR", func_xor);
95
80
    f->setParamCount(1, -1);
96
81
    f->setAcceptArray();
97
 
    repo->add(f);
 
82
    add(f);
98
83
    f = new Function("IF", func_if);
99
84
    f->setParamCount(2, 3);
100
 
    repo->add(f);
 
85
    add(f);
101
86
}
102
87
 
103
 
void LogicModule::removeFunctions()
 
88
QString LogicModule::descriptionFileName() const
104
89
{
105
 
    // NOTE: The group name has to match the one in the xml description.
106
 
    FunctionRepository::self()->remove("Logical");
 
90
    return QString("logic.xml");
107
91
}
108
92
 
109
93
 
194
178
        return args[1];
195
179
    // evaluated to false
196
180
    if (args.count() == 3) {
197
 
        if (args[2].isEmpty()) {
 
181
        if (args[2].isNull()) {
198
182
            return Value(0);
199
183
        } else {
200
184
            return args[2];