Warning, file /office/calligra/libs/text/KoInlineObjectFactoryBase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2006 Thomas Zander <zander@kde.org> 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 KOINLINEOBJECTFACTORY_H 0021 #define KOINLINEOBJECTFACTORY_H 0022 0023 #include <QString> 0024 #include <QVector> 0025 0026 #include "kotext_export.h" 0027 0028 class KoInlineObject; 0029 class InlineObjectFactoryPrivate; 0030 class KoProperties; 0031 0032 /// A template used in the KoInlineObjectFactoryBase 0033 struct KOTEXT_EXPORT KoInlineObjectTemplate { 0034 QString id; ///< The id of the inlineObject 0035 QString name; ///< The name to be shown for this template 0036 /** 0037 * The properties which, when passed to the KoInlineObjectFactoryBase::createInlineObject() method 0038 * result in the object this template represents. 0039 */ 0040 const KoProperties *properties; 0041 }; 0042 0043 Q_DECLARE_TYPEINFO(KoInlineObjectTemplate, Q_MOVABLE_TYPE); 0044 0045 /** 0046 * A factory for inline text objects. There should be one for each plugin type to 0047 * allow the creation of the inlineObject from that plugin. 0048 * The factory additionally has information to allow showing a menu entry for user 0049 * access to the object-type. 0050 * @see KoInlineObjectRegistry 0051 */ 0052 class KOTEXT_EXPORT KoInlineObjectFactoryBase 0053 { 0054 public: 0055 /// The type of inlineObject this factory creates. 0056 enum ObjectType { 0057 TextVariable, ///< The factory creates KoVariable inheriting objects. 0058 Other = 0x100 ///< The factory creates objects that should not be shown in any menu 0059 }; 0060 0061 /** 0062 * Create the new factory 0063 * @param id a string that will be used internally for referencing the variable-type. 0064 * @param type the factory type. 0065 */ 0066 KoInlineObjectFactoryBase(const QString &id, ObjectType type); 0067 virtual ~KoInlineObjectFactoryBase(); 0068 0069 /** 0070 * Create a new instance of an inline object. 0071 */ 0072 virtual KoInlineObject *createInlineObject(const KoProperties *properties = 0) const = 0; 0073 0074 /** 0075 * return the id for the variable this factory creates. 0076 * @return the id for the variable this factory creates. 0077 */ 0078 QString id() const; 0079 0080 /** 0081 * Returns the type of object this factory creates. 0082 * The main purpose is to group plugins per type in, for example, a menu. 0083 */ 0084 ObjectType type() const; 0085 0086 /** 0087 * Return all the templates this factory knows about. 0088 * Each template shows a different way to create an object this factory is specialized in. 0089 */ 0090 QVector<KoInlineObjectTemplate> templates() const; 0091 0092 QStringList odfElementNames() const; 0093 0094 QString odfNameSpace() const; 0095 0096 void setOdfElementNames(const QString &nameSpace, const QStringList &names); 0097 0098 protected: 0099 /** 0100 * Add a template with the properties of a specific type of object this factory can generate 0101 * using the createInlineObject() method. 0102 * @param params The new template this factory knows to produce 0103 */ 0104 void addTemplate(const KoInlineObjectTemplate ¶ms); 0105 0106 private: 0107 InlineObjectFactoryPrivate * const d; 0108 }; 0109 0110 #endif