kword

KWFactory.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KWFactory.h"
00021 #include "KWAboutData.h"
00022 #include "KWDocument.h"
00023 
00024 #include <kstandarddirs.h>
00025 
00026 #include <kiconloader.h>
00027 
00028 KInstance* KWFactory::s_instance = 0;
00029 KAboutData* KWFactory::s_aboutData = 0;
00030 
00031 KWFactory::KWFactory( QObject* parent, const char* name )
00032     : KoFactory( parent, name )
00033 {
00034   // Create our instance, so that it becomes KGlobal::instance if the
00035   // main app is KWord.
00036   (void) instance();
00037 }
00038 
00039 KWFactory::~KWFactory()
00040 {
00041     delete s_aboutData;
00042     s_aboutData=0;
00043     delete s_instance;
00044     s_instance=0L;
00045 }
00046 
00047 KParts::Part* KWFactory::createPartObject( QWidget *parentWidget, const char *widname, QObject* parent, const char* name, const char* classname, const QStringList & )
00048 {
00049     bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00050 
00051     KWDocument *doc = new KWDocument( parentWidget, widname, parent, name, !bWantKoDocument );
00052 
00053     if ( !bWantKoDocument )
00054       doc->setReadWrite( false );
00055 
00056     return doc;
00057 }
00058 
00059 KAboutData* KWFactory::aboutData()
00060 {
00061     if(!s_aboutData) {
00062         s_aboutData = newKWordAboutData();
00063     }
00064     return s_aboutData;
00065 }
00066 
00067 KInstance* KWFactory::instance()
00068 {
00069     if ( !s_instance )
00070     {
00071       s_instance = new KInstance( aboutData() );
00072 
00073       s_instance->dirs()->addResourceType( "kword_template",
00074               KStandardDirs::kde_default("data") + "kword/templates/");
00075       s_instance->dirs()->addResourceType( "expression", KStandardDirs::kde_default("data") + "kword/expression/");
00076       s_instance->dirs()->addResourceType( "horizontalLine", KStandardDirs::kde_default("data") + "kword/horizontalline/");
00077 
00078       s_instance->dirs()->addResourceType( "toolbar",
00079               KStandardDirs::kde_default("data") + "koffice/toolbar/");
00080       s_instance->dirs()->addResourceType( "toolbar",
00081               KStandardDirs::kde_default("data") + "kformula/pics/");
00082       s_instance->iconLoader()->addAppDir("koffice");
00083     }
00084     return s_instance;
00085 }
00086 
00087 #include "KWFactory.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys