File indexing completed on 2024-05-12 16:37:10
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org> 0003 Copyright (C) 2011 Boudewijn Rempt <boud@valdyas.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "KWFactory.h" 0022 #include "KWAboutData.h" 0023 #include "KWDocument.h" 0024 0025 #include <kiconloader.h> 0026 0027 #include <KWPart.h> 0028 #include <KoDockRegistry.h> 0029 #include <KoDocumentRdfBase.h> 0030 #include <KoToolRegistry.h> 0031 #include <KoMainWindow.h> 0032 #include <KoComponentData.h> 0033 0034 #ifdef SHOULD_BUILD_RDF 0035 #include <KoDocumentRdf.h> 0036 #include <KoSemanticStylesheetsEditor.h> 0037 #include "dockers/KWRdfDocker.h" 0038 #include "dockers/KWRdfDockerFactory.h" 0039 #endif 0040 0041 #include "pagetool/KWPageToolFactory.h" 0042 #include "dockers/KWStatisticsDocker.h" 0043 #include "dockers/KWNavigationDockerFactory.h" 0044 0045 #ifndef NDEBUG 0046 #include "dockers/KWDebugDockerFactory.h" 0047 #endif 0048 0049 KoComponentData *KWFactory::s_componentData = 0; 0050 0051 KWFactory::KWFactory() 0052 : KPluginFactory() 0053 { 0054 // Create our instance, so that it becomes KGlobal::instance if the 0055 // main app is Words. 0056 (void) componentData(); 0057 } 0058 0059 KWFactory::~KWFactory() 0060 { 0061 delete s_componentData; 0062 s_componentData = 0; 0063 } 0064 0065 QObject* KWFactory::create(const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent, const QVariantList& args, const QString& keyword) 0066 { 0067 Q_UNUSED(args); 0068 Q_UNUSED(keyword); 0069 0070 KWPart *part = new KWPart(parent); 0071 KWDocument *doc = new KWDocument(part); 0072 part->setDocument(doc); 0073 KoToolRegistry::instance()->add(new KWPageToolFactory()); 0074 return part; 0075 } 0076 0077 const KoComponentData &KWFactory::componentData() 0078 { 0079 if (!s_componentData) { 0080 KAboutData *aboutData = newWordsAboutData(); 0081 s_componentData = new KoComponentData(*aboutData); 0082 delete aboutData; 0083 0084 KIconLoader::global()->addAppDir("calligra"); 0085 0086 KoDockRegistry *dockRegistry = KoDockRegistry::instance(); 0087 dockRegistry->add(new KWStatisticsDockerFactory()); 0088 dockRegistry->add(new KWNavigationDockerFactory()); 0089 #ifndef NDEBUG 0090 dockRegistry->add(new KWDebugDockerFactory()); 0091 #endif 0092 0093 #ifdef SHOULD_BUILD_RDF 0094 // TODO reenable after release 0095 dockRegistry->add(new KWRdfDockerFactory()); 0096 #endif 0097 } 0098 return *s_componentData; 0099 }