File indexing completed on 2024-04-28 16:21:23
0001 /* This file is part of the KDE project 0002 Copyright 2008 Stefan Nikolaus <stefan.nikolaus@kdemail.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 #ifndef CALLIGRA_SHEETS_FUNCTION_MODULE 0021 #define CALLIGRA_SHEETS_FUNCTION_MODULE 0022 0023 #include <QList> 0024 #include <QObject> 0025 #include <QSharedPointer> 0026 #include <QString> 0027 #include <kpluginfactory.h> 0028 0029 #include "sheets_odf_export.h" 0030 0031 namespace Calligra 0032 { 0033 namespace Sheets 0034 { 0035 class Function; 0036 0037 /** 0038 * \ingroup Value 0039 * A function module provides several Function objects. 0040 */ 0041 class CALLIGRA_SHEETS_ODF_EXPORT FunctionModule : public QObject 0042 { 0043 Q_OBJECT 0044 public: 0045 /** 0046 * Creates the function module. 0047 * The derived class should create here the Function objects and 0048 * should register them via \ref add. 0049 */ 0050 explicit FunctionModule(QObject *parent); 0051 0052 /** 0053 * Destroys the module and the provided Function objects. 0054 * Check, if this module isRemovable(), before you unload the plugin. 0055 */ 0056 ~FunctionModule() override; 0057 0058 /** 0059 * Returns the file name of the XML description for the functions. 0060 */ 0061 virtual QString descriptionFileName() const = 0; 0062 0063 /** 0064 * Returns a list of the provided Function objects. 0065 */ 0066 QList<QSharedPointer<Function> > functions() const; 0067 0068 /** 0069 * Checks whether this module can be removed, because none of its 0070 * Function objects is in use. 0071 * Used by the FunctionModuleRegistry to check, if the plugin can be unloaded. 0072 * \return \c true on success; \c false on failure 0073 */ 0074 bool isRemovable(); 0075 0076 /** 0077 * Returns the identifier (if defined). Function of the KoGenericRegistry 0078 * template, that has to be implemented. 0079 */ 0080 virtual QString id() const; 0081 0082 protected: 0083 /** 0084 * Adds \p function to the list of provided Function objects. 0085 */ 0086 void add(Function* function); 0087 0088 private: 0089 class Private; 0090 Private * const d; 0091 }; 0092 0093 } // namespace Sheets 0094 } // namespace Calligra 0095 0096 /** 0097 * Register a function module when it is contained in a loadable plugin 0098 */ 0099 #ifndef SHEETS_NO_PLUGINMODULES 0100 #define CALLIGRA_SHEETS_EXPORT_FUNCTION_MODULE(jsonfile, classname) \ 0101 K_PLUGIN_FACTORY_WITH_JSON(factory, jsonfile, registerPlugin<classname>();) 0102 #else 0103 #define CALLIGRA_SHEETS_EXPORT_FUNCTION_MODULE(libname, classname) 0104 #endif 0105 0106 #endif // CALLIGRA_SHEETS_FUNCTION_MODULE