kformula

kformula_factory.cc

00001 #include "kformula_factory.h"
00002 #include "kformula_doc.h"
00003 #include "kformula_aboutdata.h"
00004 
00005 #include <kinstance.h>
00006 #include <kiconloader.h>
00007 
00008 #include <kfiledialog.h>
00009 #include <kglobal.h>
00010 #include <kstandarddirs.h>
00011 #include <klocale.h>
00012 
00013 #include <qstringlist.h>
00014 
00015 K_EXPORT_COMPONENT_FACTORY( libkformulapart, KFormulaFactory )
00016 
00017 KInstance* KFormulaFactory::s_global = 0;
00018 KAboutData* KFormulaFactory::s_aboutData = 0;
00019 
00020 KAboutData* KFormulaFactory::aboutData()
00021 {
00022     if( !s_aboutData )
00023         s_aboutData=newKFormulaAboutData();
00024     return s_aboutData;
00025 }
00026 
00027 
00028 KFormulaFactory::KFormulaFactory( QObject* parent, const char* name )
00029     : KoFactory( parent, name )
00030 {
00031     // Create our instance, so that it becomes KGlobal::instance if the
00032     // main app is KFormula.
00033     (void)global();
00034 }
00035 
00036 KFormulaFactory::~KFormulaFactory()
00037 {
00038   delete s_aboutData;
00039   s_aboutData=0;
00040   delete s_global;
00041   s_global = 0L;
00042 }
00043 
00044 KParts::Part* KFormulaFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & )
00045 {
00046   bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00047 
00048   KFormulaDoc *doc = new KFormulaDoc( parentWidget, widgetName, parent, name, !bWantKoDocument );
00049 
00050   if ( !bWantKoDocument )
00051     doc->setReadWrite( false );
00052 
00053   return doc;
00054 }
00055 
00056 KInstance* KFormulaFactory::global()
00057 {
00058     if ( !s_global )
00059     {
00060       s_global = new KInstance(aboutData());
00061       s_global->dirs()->addResourceType( "toolbar",
00062                          KStandardDirs::kde_default("data") + "koffice/toolbar/");
00063       // Tell the iconloader about share/apps/koffice/icons*/
00064       s_global->iconLoader()->addAppDir("koffice");
00065     }
00066 
00067     return s_global;
00068 }
00069 
00070 #include "kformula_factory.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys