kword

KWFactory.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@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 "KWFactory.h"
21#include "KWAboutData.h"
22#include "KWDocument.h"
23
24#include <kstandarddirs.h>
25
26#include <kiconloader.h>
27
28TDEInstance* KWFactory::s_instance = 0;
29TDEAboutData* KWFactory::s_aboutData = 0;
30
31KWFactory::KWFactory( TQObject* parent, const char* name )
32 : KoFactory( parent, name )
33{
34 // Create our instance, so that it becomes TDEGlobal::instance if the
35 // main app is KWord.
36 (void) instance();
37}
38
39KWFactory::~KWFactory()
40{
41 delete s_aboutData;
42 s_aboutData=0;
43 delete s_instance;
44 s_instance=0L;
45}
46
47KParts::Part* KWFactory::createPartObject( TQWidget *parentWidget, const char *widname, TQObject* parent, const char* name, const char* classname, const TQStringList & )
48{
49 bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
50
51 KWDocument *doc = new KWDocument( parentWidget, widname, parent, name, !bWantKoDocument );
52
53 if ( !bWantKoDocument )
54 doc->setReadWrite( false );
55
56 return doc;
57}
58
59TDEAboutData* KWFactory::aboutData()
60{
61 if(!s_aboutData) {
62 s_aboutData = newKWordAboutData();
63 }
64 return s_aboutData;
65}
66
67TDEInstance* KWFactory::instance()
68{
69 if ( !s_instance )
70 {
71 s_instance = new TDEInstance( aboutData() );
72
73 s_instance->dirs()->addResourceType( "kword_template",
74 TDEStandardDirs::kde_default("data") + "kword/templates/");
75 s_instance->dirs()->addResourceType( "expression", TDEStandardDirs::kde_default("data") + "kword/expression/");
76 s_instance->dirs()->addResourceType( "horizontalLine", TDEStandardDirs::kde_default("data") + "kword/horizontalline/");
77
78 s_instance->dirs()->addResourceType( "toolbar",
79 TDEStandardDirs::kde_default("data") + "koffice/toolbar/");
80 s_instance->dirs()->addResourceType( "toolbar",
81 TDEStandardDirs::kde_default("data") + "kformula/pics/");
82 s_instance->iconLoader()->addAppDir("koffice");
83 }
84 return s_instance;
85}
86
87#include "KWFactory.moc"