File indexing completed on 2024-05-12 16:30:48

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001-2003 Lennart Kudling <kudling@kde.org>
0003  * Copyright (C) 2002-2003 Rob Buis <buis@kde.org>
0004  * Copyright (C) 2002 Tomislav Lukman <tomislav.lukman@ck.t-com.hr>
0005  * Copyright (C) 2002,2004-2005,2007 David Faure <faure@kde.org>
0006  * Copyright (C) 2002 Benoît Vautrin <benoit.vautrin@free.fr>
0007  * Copyright (C) 2003 Lukáš Tinkl <lukas@kde.org>
0008  * Copyright (C) 2004,2006 Laurent Montel <montel@kde.org>
0009  * Copyright (C) 2005-2006 Tim Beaulen <tbscope@gmail.com>
0010  * Copyright (C) 2005,2007 Thomas Zander <zander@kde.org>
0011  * Copyright (C) 2006-2007 Jan Hambrecht <jaham@gmx.net>
0012  * Copyright (C) 2007 Boudewijn Rempt <boud@valdyas.org>
0013  * Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
0014  * Copyright (C) 2007 Stephan Kulow <coolo@kde.org>
0015  *
0016  * This library is free software; you can redistribute it and/or
0017  * modify it under the terms of the GNU Library General Public
0018  * License as published by the Free Software Foundation; either
0019  * version 2 of the License, or (at your option) any later version.
0020  *
0021  * This library is distributed in the hope that it will be useful,
0022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0024  * Library General Public License for more details.
0025  *
0026  * You should have received a copy of the GNU Library General Public License
0027  * along with this library; see the file COPYING.LIB.  If not, write to
0028  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0029  * Boston, MA 02110-1301, USA.
0030  */
0031 
0032 #include "KarbonFactory.h"
0033 
0034 #include "KarbonPart.h"
0035 #include "KarbonDocument.h"
0036 #include "KarbonAboutData.h"
0037 
0038 #include <KoComponentData.h>
0039 #include <KoPluginLoader.h>
0040 
0041 #include <kiconloader.h>
0042 
0043 
0044 KoComponentData* KarbonFactory::s_global = 0;
0045 
0046 KarbonFactory::KarbonFactory()
0047     : KPluginFactory()
0048 {
0049     (void)global();
0050 }
0051 
0052 KarbonFactory::~KarbonFactory()
0053 {
0054 }
0055 
0056 QObject* KarbonFactory::create(const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent, const QVariantList& args, const QString& keyword)
0057 {
0058     Q_UNUSED(args);
0059     Q_UNUSED(keyword);
0060 
0061     KarbonPart *part = new KarbonPart(parent);
0062     KarbonDocument* doc = new KarbonDocument(part);
0063     part->setDocument(doc);
0064     return part;
0065 }
0066 
0067 const KSharedConfig::Ptr& KarbonFactory::karbonConfig()
0068 {
0069     return global().config();
0070 }
0071 
0072 const KoComponentData &KarbonFactory::global()
0073 {
0074     if (!s_global) {
0075         KAboutData *aboutData = newKarbonAboutData();
0076         s_global = new KoComponentData(*aboutData);
0077         delete aboutData;
0078 
0079         // Add any application-specific resource directories here
0080 
0081         // Tell the iconloader about share/apps/calligra/icons
0082         KIconLoader::global()->addAppDir("calligra");
0083 
0084         // Load Karbon specific dockers.
0085         KoPluginLoader::load(QStringLiteral("karbon/dockers"));
0086         KoPluginLoader::load(QStringLiteral("calligra/pageapptools"));
0087     }
0088     return *s_global;
0089 }