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

« back to all changes in this revision

Viewing changes to kspread/functions/information.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:
20
20
 
21
21
// built-in information functions
22
22
 
 
23
#include "InformationModule.h"
 
24
 
23
25
#include <kofficeversion.h>
24
26
#include <sys/utsname.h>
25
27
 
29
31
#include <KLocale>
30
32
 
31
33
#include "CalculationSettings.h"
 
34
#include "Function.h"
32
35
#include "FunctionModuleRegistry.h"
33
 
#include "Functions.h"
34
 
#include "InformationModule.h"
35
36
#include "ValueCalc.h"
36
37
#include "ValueConverter.h"
37
38
#include "Sheet.h"
39
40
#include "Cell.h"
40
41
#include "Formula.h"
41
42
 
42
 
#include "part/Doc.h" // FIXME detach from part
 
43
#include <KoDocument.h>
43
44
 
44
45
using namespace KSpread;
45
46
 
67
68
Value func_version(valVector args, ValueCalc *calc, FuncExtra *);
68
69
 
69
70
 
70
 
#ifndef KSPREAD_UNIT_TEST // Do not create/export the plugin in unit tests.
71
 
K_PLUGIN_FACTORY(InformationModulePluginFactory,
72
 
                 registerPlugin<InformationModule>();
73
 
                )
74
 
K_EXPORT_PLUGIN(InformationModulePluginFactory("InformationModule"))
75
 
#endif
 
71
KSPREAD_EXPORT_FUNCTION_MODULE("information", InformationModule)
76
72
 
77
73
 
78
74
InformationModule::InformationModule(QObject* parent, const QVariantList&)
79
 
        : FunctionModule(parent, "information", i18n("Information Functions"))
80
 
{
81
 
}
82
 
 
83
 
QString InformationModule::descriptionFileName() const
84
 
{
85
 
    return QString("information.xml");
86
 
}
87
 
 
88
 
void InformationModule::registerFunctions()
89
 
{
90
 
    FunctionRepository* repo = FunctionRepository::self();
 
75
        : FunctionModule(parent)
 
76
{
91
77
    Function *f;
92
78
 
93
79
    f = new Function("ERRORTYPE", func_errortype);
94
 
    repo->add(f);
 
80
    add(f);
95
81
    f = new Function("FILENAME", func_filename);
96
82
    f->setParamCount(0);
97
 
    repo->add(f);
 
83
    add(f);
98
84
    f = new Function("FORMULA", func_formula);
99
85
    f->setParamCount(1);
100
86
    f->setNeedsExtra(true);
101
 
    repo->add(f);
 
87
    add(f);
102
88
    f = new Function("INFO", func_info);
103
 
    repo->add(f);
 
89
    add(f);
104
90
    f = new Function("ISBLANK", func_isblank);
105
 
    repo->add(f);
 
91
    add(f);
106
92
    f = new Function("ISDATE", func_isdate);
107
 
    repo->add(f);
 
93
    add(f);
108
94
    f = new Function("ISERR", func_iserr);
109
 
    repo->add(f);
 
95
    add(f);
110
96
    f = new Function("ISERROR", func_iserror);
111
 
    repo->add(f);
 
97
    add(f);
112
98
    f = new Function("ISEVEN", func_iseven);
113
 
    repo->add(f);
 
99
    f->setAlternateName("COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETISEVEN");
 
100
    add(f);
114
101
    f = new Function("ISLOGICAL", func_islogical);
115
 
    repo->add(f);
 
102
    add(f);
116
103
    f = new Function("ISNA", func_isna);
117
 
    repo->add(f);
 
104
    add(f);
118
105
    f = new Function("ISNONTEXT", func_isnottext);
119
 
    repo->add(f);
 
106
    add(f);
120
107
    f = new Function("ISNOTTEXT", func_isnottext);
121
 
    repo->add(f);
 
108
    add(f);
122
109
    f = new Function("ISNUM", func_isnum);
123
 
    repo->add(f);
 
110
    add(f);
124
111
    f = new Function("ISNUMBER", func_isnum);
125
 
    repo->add(f);
 
112
    add(f);
126
113
    f = new Function("ISODD", func_isodd);
127
 
    repo->add(f);
 
114
    f->setAlternateName("COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETISODD");
 
115
    add(f);
128
116
    f = new Function("ISREF", func_isref);
129
117
    f->setNeedsExtra(true);
130
118
    f->setAcceptArray();
131
 
    repo->add(f);
 
119
    add(f);
132
120
    f = new Function("ISTEXT", func_istext);
133
 
    repo->add(f);
 
121
    add(f);
134
122
    f = new Function("ISTIME", func_istime);
135
 
    repo->add(f);
 
123
    add(f);
136
124
    f = new Function("N", func_n);
137
 
    repo->add(f);
 
125
    add(f);
138
126
    f = new Function("NA", func_na);
139
127
    f->setParamCount(0);
140
 
    repo->add(f);
 
128
    add(f);
141
129
    f = new Function("TYPE", func_type);
142
130
    f->setAcceptArray();
143
 
    repo->add(f);
 
131
    add(f);
144
132
}
145
133
 
146
 
void InformationModule::removeFunctions()
 
134
QString InformationModule::descriptionFileName() const
147
135
{
148
 
    // NOTE: The group name has to match the one in the xml description.
149
 
    FunctionRepository::self()->remove("Information");
 
136
    return QString("information.xml");
150
137
}
151
138
 
152
139
 
199
186
        return Value(QString(KOFFICE_VERSION_STRING));
200
187
 
201
188
    if (type == "numfile")
202
 
        return Value((int) Doc::documents().count());
 
189
        return Value(KoDocument::documentList() ? KoDocument::documentList()->count() : 0);
203
190
 
204
191
    if (type == "recalc") {
205
192
        QString result;
206
 
//     if (calc->doc()) {
207
 
//       if ( calc->doc()->displaySheet() && !calc->doc()->displaySheet()->isAutoCalculationEnabled() )
208
 
//         result = i18n ("Manual");
209
 
//       else
210
 
        result = i18n("Automatic");
211
 
//     }
 
193
        if (!calc->settings()->isAutoCalculationEnabled())
 
194
            result = i18n("Manual");
 
195
        else
 
196
            result = i18n("Automatic");
212
197
        return Value(result);
213
198
    }
214
199