File indexing completed on 2024-05-12 16:35:44
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998, 1999 Torben Weis <weis@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 // Local 0021 #include "Factory.h" 0022 0023 #include "SheetsDebug.h" 0024 0025 #include <KoDockRegistry.h> 0026 #include <KoComponentData.h> 0027 #include <KoResourcePaths.h> 0028 0029 #include "AboutData.h" 0030 #include "Doc.h" 0031 #include "Part.h" 0032 #include "ui/CellEditorDocker.h" 0033 0034 using namespace Calligra::Sheets; 0035 0036 KoComponentData* Factory::s_global = 0; 0037 KAboutData* Factory::s_aboutData = 0; 0038 0039 Factory::Factory() 0040 : KPluginFactory() 0041 { 0042 //debugSheets <<"Factory::Factory()"; 0043 // Create our instance, so that it becomes KGlobal::instance if the 0044 // main app is Calligra Sheets. 0045 (void)global(); 0046 } 0047 0048 Factory::~Factory() 0049 { 0050 //debugSheets <<"Factory::~Factory()"; 0051 delete s_aboutData; 0052 s_aboutData = 0; 0053 delete s_global; 0054 s_global = 0; 0055 } 0056 0057 QObject* Factory::create(const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent, const QVariantList& args, const QString& keyword) 0058 { 0059 Q_UNUSED(args); 0060 Q_UNUSED(keyword); 0061 Part *part = new Part(parent); 0062 Doc *doc = new Doc(part); 0063 part->setDocument(doc); 0064 return part; 0065 } 0066 0067 KAboutData* Factory::aboutData() 0068 { 0069 if (!s_aboutData) 0070 s_aboutData = newAboutData(); 0071 return s_aboutData; 0072 } 0073 0074 const KoComponentData &Factory::global() 0075 { 0076 if (!s_global) { 0077 s_global = new KoComponentData(*aboutData()); 0078 0079 KoResourcePaths::addResourceType("sheet-styles", "data", "calligrasheets/sheetstyles/"); 0080 0081 KoDockRegistry *dockRegistry = KoDockRegistry::instance(); 0082 dockRegistry->add(new CellEditorDockerFactory); 0083 } 0084 return *s_global; 0085 }