kspread

kspread_factory.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <kdebug.h>
21#include <kstandarddirs.h>
22
23#include "kspread_aboutdata.h"
24#include "kspread_doc.h"
25#include "KSpreadAppIface.h"
26
27#include "kspread_factory.h"
28
29using namespace KSpread;
30
31TDEInstance* Factory::s_global = 0;
32DCOPObject* Factory::s_dcopObject = 0;
33TDEAboutData* Factory::s_aboutData = 0;
34
35Factory::Factory( TQObject* parent, const char* name )
36 : KoFactory( parent, name )
37{
38 //kdDebug(36001) << "Factory::Factory()" << endl;
39 // Create our instance, so that it becomes TDEGlobal::instance if the
40 // main app is KSpread.
41 (void)global();
42 (void)dcopObject();
43}
44
45Factory::~Factory()
46{
47 //kdDebug(36001) << "Factory::~Factory()" << endl;
48 delete s_aboutData;
49 s_aboutData=0;
50 delete s_global;
51 s_global = 0L;
52 delete s_dcopObject;
53 s_dcopObject = 0L;
54}
55
56KParts::Part* Factory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, const char* classname, const TQStringList & )
57{
58 bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
59
60 Doc *doc = new Doc( parentWidget, widgetName, parent, name, !bWantKoDocument );
61
62 if ( !bWantKoDocument )
63 doc->setReadWrite( false );
64
65 return doc;
66}
67
68TDEAboutData* Factory::aboutData()
69{
70 if( !s_aboutData )
71 s_aboutData = newAboutData();
72 return s_aboutData;
73}
74
75TDEInstance* Factory::global()
76{
77 if ( !s_global )
78 {
79 s_global = new TDEInstance(aboutData());
80
81 s_global->dirs()->addResourceType( "kspread_template",
82 TDEStandardDirs::kde_default("data") + "kspread/templates/");
83
84 s_global->dirs()->addResourceType( "toolbar",
85 TDEStandardDirs::kde_default("data") + "koffice/toolbar/");
86 s_global->dirs()->addResourceType( "extensions", TDEStandardDirs::kde_default("data") + "kspread/extensions/");
87 s_global->dirs()->addResourceType( "sheet-styles", TDEStandardDirs::kde_default("data") + "kspread/sheetstyles/");
88 // Tell the iconloader about share/apps/koffice/icons
89 s_global->iconLoader()->addAppDir("koffice");
90 }
91 return s_global;
92}
93
94DCOPObject* Factory::dcopObject()
95{
96 if ( !s_dcopObject )
97 s_dcopObject = new AppIface;
98 return s_dcopObject;
99}
100
101#include "kspread_factory.moc"
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
The KSpread namespace.
Definition commands.h:39