kspread Library API Documentation

kspread_factory.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #include "kspread_doc.h"
00021 #include "kspread_aboutdata.h"
00022 #include "KSpreadAppIface.h"
00023 
00024 #include <kstandarddirs.h>
00025 #include <kdebug.h>
00026 
00027 K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory )
00028 
00029 KInstance* KSpreadFactory::s_global = 0;
00030 DCOPObject* KSpreadFactory::s_dcopObject = 0;
00031 KAboutData* KSpreadFactory::s_aboutData = 0;
00032 
00033 KSpreadFactory::KSpreadFactory( QObject* parent, const char* name )
00034     : KoFactory( parent, name )
00035 {
00036   //kdDebug(36001) << "KSpreadFactory::KSpreadFactory()" << endl;
00037   // Create our instance, so that it becomes KGlobal::instance if the
00038   // main app is KSpread.
00039   (void)global();
00040   (void)dcopObject();
00041 }
00042 
00043 KSpreadFactory::~KSpreadFactory()
00044 {
00045   //kdDebug(36001) << "KSpreadFactory::~KSpreadFactory()" << endl;
00046   delete s_aboutData;
00047   s_aboutData=0;
00048   delete s_global;
00049   s_global = 0L;
00050   delete s_dcopObject;
00051   s_dcopObject = 0L;
00052 }
00053 
00054 KParts::Part* KSpreadFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & )
00055 {
00056   bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00057 
00058   KSpreadDoc *doc = new KSpreadDoc( parentWidget, widgetName, parent, name, !bWantKoDocument );
00059 
00060   if ( !bWantKoDocument )
00061     doc->setReadWrite( false );
00062 
00063   return doc;
00064 }
00065 
00066 KAboutData* KSpreadFactory::aboutData()
00067 {
00068   if( !s_aboutData )
00069       s_aboutData = newKSpreadAboutData();
00070   return s_aboutData;
00071 }
00072 
00073 KInstance* KSpreadFactory::global()
00074 {
00075     if ( !s_global )
00076     {
00077       s_global = new KInstance(aboutData());
00078 
00079       s_global->dirs()->addResourceType( "kspread_template",
00080                                           KStandardDirs::kde_default("data") + "kspread/templates/");
00081 
00082       s_global->dirs()->addResourceType( "toolbar",
00083                          KStandardDirs::kde_default("data") + "koffice/toolbar/");
00084       s_global->dirs()->addResourceType( "extensions", KStandardDirs::kde_default("data") + "kspread/extensions/");
00085       s_global->dirs()->addResourceType( "table-styles", KStandardDirs::kde_default("data") + "kspread/tablestyles/");
00086       // Tell the iconloader about share/apps/koffice/icons
00087       s_global->iconLoader()->addAppDir("koffice");
00088     }
00089     return s_global;
00090 }
00091 
00092 DCOPObject* KSpreadFactory::dcopObject()
00093 {
00094     if ( !s_dcopObject )
00095         s_dcopObject = new KSpreadAppIface;
00096     return s_dcopObject;
00097 }
00098 
00099 #include "kspread_factory.moc"
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:03 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003