kspread
kspread_factory.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <kdebug.h>
00021 #include <kstandarddirs.h>
00022
00023 #include "kspread_aboutdata.h"
00024 #include "kspread_doc.h"
00025 #include "KSpreadAppIface.h"
00026
00027 #include "kspread_factory.h"
00028
00029 using namespace KSpread;
00030
00031 KInstance* Factory::s_global = 0;
00032 DCOPObject* Factory::s_dcopObject = 0;
00033 KAboutData* Factory::s_aboutData = 0;
00034
00035 Factory::Factory( QObject* parent, const char* name )
00036 : KoFactory( parent, name )
00037 {
00038
00039
00040
00041 (void)global();
00042 (void)dcopObject();
00043 }
00044
00045 Factory::~Factory()
00046 {
00047
00048 delete s_aboutData;
00049 s_aboutData=0;
00050 delete s_global;
00051 s_global = 0L;
00052 delete s_dcopObject;
00053 s_dcopObject = 0L;
00054 }
00055
00056 KParts::Part* Factory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & )
00057 {
00058 bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00059
00060 Doc *doc = new Doc( parentWidget, widgetName, parent, name, !bWantKoDocument );
00061
00062 if ( !bWantKoDocument )
00063 doc->setReadWrite( false );
00064
00065 return doc;
00066 }
00067
00068 KAboutData* Factory::aboutData()
00069 {
00070 if( !s_aboutData )
00071 s_aboutData = newAboutData();
00072 return s_aboutData;
00073 }
00074
00075 KInstance* Factory::global()
00076 {
00077 if ( !s_global )
00078 {
00079 s_global = new KInstance(aboutData());
00080
00081 s_global->dirs()->addResourceType( "kspread_template",
00082 KStandardDirs::kde_default("data") + "kspread/templates/");
00083
00084 s_global->dirs()->addResourceType( "toolbar",
00085 KStandardDirs::kde_default("data") + "koffice/toolbar/");
00086 s_global->dirs()->addResourceType( "extensions", KStandardDirs::kde_default("data") + "kspread/extensions/");
00087 s_global->dirs()->addResourceType( "sheet-styles", KStandardDirs::kde_default("data") + "kspread/sheetstyles/");
00088
00089 s_global->iconLoader()->addAppDir("koffice");
00090 }
00091 return s_global;
00092 }
00093
00094 DCOPObject* Factory::dcopObject()
00095 {
00096 if ( !s_dcopObject )
00097 s_dcopObject = new AppIface;
00098 return s_dcopObject;
00099 }
00100
00101 #include "kspread_factory.moc"
|