File indexing completed on 2024-05-12 16:36:43
0001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- 0002 /* This file is part of the KDE project 0003 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.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 "KPrFactory.h" 0022 #include "KPrDocument.h" 0023 #include "KPrAboutData.h" 0024 #include "KPrPart.h" 0025 0026 #include <KoComponentData.h> 0027 #include <KoPluginLoader.h> 0028 #include <KoDockRegistry.h> 0029 0030 KoComponentData* KPrFactory::s_instance = 0; 0031 KAboutData* KPrFactory::s_aboutData = 0; 0032 0033 static int factoryCount = 0; 0034 0035 KPrFactory::KPrFactory() 0036 : KPluginFactory() 0037 { 0038 (void)componentData(); 0039 0040 if (factoryCount == 0) { 0041 0042 // Load the KoPA-specific tools 0043 KoPluginLoader::load(QStringLiteral("calligra/pageapptools")); 0044 0045 // Load the Stage-specific tools 0046 KoPluginLoader::load(QStringLiteral("calligrastage/tools")); 0047 } 0048 factoryCount++; 0049 } 0050 0051 KPrFactory::~KPrFactory() 0052 { 0053 delete s_aboutData; 0054 s_aboutData = 0; 0055 delete s_instance; 0056 s_instance = 0; 0057 } 0058 0059 QObject* KPrFactory::create( const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent, 0060 const QVariantList& args, const QString& keyword ) 0061 { 0062 Q_UNUSED( args ); 0063 Q_UNUSED( keyword ); 0064 KPrPart *part = new KPrPart(parent); 0065 KPrDocument *doc = new KPrDocument(part); 0066 doc->setDefaultStylesResourcePath(QLatin1String("calligrastage/styles/")); 0067 part->setDocument(doc); 0068 return part; 0069 } 0070 0071 KAboutData* KPrFactory::aboutData() 0072 { 0073 if( !s_aboutData ) 0074 s_aboutData = newKPresenterAboutData(); 0075 0076 return s_aboutData; 0077 } 0078 0079 const KoComponentData &KPrFactory::componentData() 0080 { 0081 if ( !s_instance ) 0082 { 0083 s_instance = new KoComponentData(*aboutData()); 0084 } 0085 return *s_instance; 0086 }