1 /* This file is part of the KDE project
2  * Copyright (C) 2006 Thomas Zander <zander@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 "KoInlineObjectFactoryBase.h"
21 #include <KoProperties.h>
22 
23 #include <QStringList>
24 
25 class InlineObjectFactoryPrivate
26 {
27 public:
InlineObjectFactoryPrivate(const QString & identifier)28     InlineObjectFactoryPrivate(const QString &identifier)
29             : id(identifier) {
30     }
31 
~InlineObjectFactoryPrivate()32     ~InlineObjectFactoryPrivate() {
33         Q_FOREACH (const KoInlineObjectTemplate &t, templates)
34             delete t.properties;
35         templates.clear();
36     }
37 
38     const QString id;
39     QString iconName;
40     QString odfNameSpace;
41     QStringList odfElementNames;
42     QList<KoInlineObjectTemplate> templates;
43     KoInlineObjectFactoryBase::ObjectType type;
44 };
45 
KoInlineObjectFactoryBase(const QString & id,ObjectType type)46 KoInlineObjectFactoryBase::KoInlineObjectFactoryBase(const QString &id, ObjectType type)
47         : d(new InlineObjectFactoryPrivate(id))
48 {
49     d->type = type;
50 }
51 
~KoInlineObjectFactoryBase()52 KoInlineObjectFactoryBase::~KoInlineObjectFactoryBase()
53 {
54     delete d;
55 }
56 
id() const57 QString KoInlineObjectFactoryBase::id() const
58 {
59     return d->id;
60 }
61 
templates() const62 QList<KoInlineObjectTemplate> KoInlineObjectFactoryBase::templates() const
63 {
64     return d->templates;
65 }
66 
addTemplate(const KoInlineObjectTemplate & params)67 void KoInlineObjectFactoryBase::addTemplate(const KoInlineObjectTemplate &params)
68 {
69     d->templates.append(params);
70 }
71 
odfElementNames() const72 QStringList KoInlineObjectFactoryBase::odfElementNames() const
73 {
74     return d->odfElementNames;
75 }
76 
odfNameSpace() const77 QString KoInlineObjectFactoryBase::odfNameSpace() const
78 {
79     return d->odfNameSpace;
80 }
81 
setOdfElementNames(const QString & nameSpace,const QStringList & names)82 void KoInlineObjectFactoryBase::setOdfElementNames(const QString & nameSpace, const QStringList &names)
83 {
84     d->odfNameSpace = nameSpace;
85     d->odfElementNames = names;
86 }
87 
type() const88 KoInlineObjectFactoryBase::ObjectType KoInlineObjectFactoryBase::type() const
89 {
90     return d->type;
91 }
92