1 /* This file is part of the KDE project 2 * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef KOINLINEOBJECTREGISTRY_H 21 #define KOINLINEOBJECTREGISTRY_H 22 23 #include <KoGenericRegistry.h> 24 #include <KoInlineObjectFactoryBase.h> 25 #include <KoXmlReaderForward.h> 26 #include "kotext_export.h" 27 #include <QList> 28 29 class KoCanvasBase; 30 class QAction; 31 class KoShapeLoadingContext; 32 33 /** 34 * This singleton class keeps a register of all available InlineObject factories. 35 * @see KoInlineObjectFactoryBase 36 * @see KoInlineTextObjectManager 37 * @see KoInlineObject 38 * @see KoVariable 39 */ 40 class KOTEXT_EXPORT KoInlineObjectRegistry : public KoGenericRegistry<KoInlineObjectFactoryBase*> 41 { 42 public: 43 KoInlineObjectRegistry(); 44 ~KoInlineObjectRegistry() override; 45 46 /** 47 * Return an instance of the KoInlineObjectRegistry 48 * Creates an instance if that has never happened before and returns the singleton instance. 49 */ 50 static KoInlineObjectRegistry *instance(); 51 52 /** 53 * Create a list of actions that can be used to plug into a menu, for example. 54 * This method will find all the InlineObjectFactories that are installed in the system and 55 * find out which object they provide. If a factory provides a variable, then all its 56 * templates will be added to the response. 57 * Each of these actions, when executed, will insert the relevant variable in the current text-position. 58 * The actions assume that the text tool is selected, if that's not the case then they will silently fail. 59 * @param host the canvas for which these actions are created. Note that the actions will get these 60 * actions as a parent (for memory management purposes) as well. 61 * @see KoInlineTextObjectManager::createInsertVariableActions() 62 */ 63 QList<QAction*> createInsertVariableActions(KoCanvasBase *host) const; 64 65 /** 66 * Use the element to find out which variable plugin can load it, and returns the loaded 67 * variable. The element expected is one of 'text:subject', 'text:date' / etc. 68 * 69 * @returns the variable or 0 if no variable could be created 70 */ 71 KoInlineObject *createFromOdf(const KoXmlElement &element, KoShapeLoadingContext &context) const; 72 73 private: 74 KoInlineObjectRegistry(const KoInlineObjectRegistry&); 75 KoInlineObjectRegistry operator=(const KoInlineObjectRegistry&); 76 77 class Private; 78 Private * const d; 79 }; 80 81 #endif 82