kpresenter

KPrFactory.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 "KPrFactory.h"
21#include "KPrDocument.h"
22#include "KPrAboutData.h"
23
24#include <kstandarddirs.h>
25#include <tdeinstance.h>
26
27
28TDEInstance* KPrFactory::s_global = 0;
29TDEAboutData* KPrFactory::s_aboutData = 0;
30
31KPrFactory::KPrFactory( TQObject* parent, const char* name )
32 : KoFactory( parent, name )
33{
34 (void)global();
35}
36
37KPrFactory::~KPrFactory()
38{
39 delete s_aboutData;
40 s_aboutData=0;
41 delete s_global;
42 s_global=0;
43}
44
45KParts::Part* KPrFactory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject* parent,
46 const char* name, const char* classname, const TQStringList & )
47{
48 bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
49
50 KPrDocument *doc = new KPrDocument( parentWidget, widgetName, parent, name, !bWantKoDocument );
51
52 if ( !bWantKoDocument )
53 doc->setReadWrite( false );
54
55 return doc;
56}
57
58TDEAboutData* KPrFactory::aboutData()
59{
60 if( !s_aboutData )
61 s_aboutData=newKPresenterAboutData();
62 return s_aboutData;
63}
64
65TDEInstance* KPrFactory::global()
66{
67 if ( !s_global )
68 {
69 s_global = new TDEInstance(aboutData());
70
71 s_global->dirs()->addResourceType("kpresenter_template",
72 TDEStandardDirs::kde_default("data") + "kpresenter/templates/");
73 s_global->dirs()->addResourceType("autoforms",
74 TDEStandardDirs::kde_default("data") + "kpresenter/autoforms/");
75 s_global->dirs()->addResourceType("slideshow",
76 TDEStandardDirs::kde_default("data") + "kpresenter/slideshow/");
77 // Tell the iconloader about share/apps/koffice/icons
78 s_global->iconLoader()->addAppDir("koffice");
79 }
80 return s_global;
81}
82
83#include "KPrFactory.moc"