1 /*
2  *  Copyright (c) 2010 Carlos Licea <carlos@kdab.com>
3  *
4  *  This library is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU Lesser General Public License as published
6  *  by the Free Software Foundation; either version 2.1 of the License, or
7  *  (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
12  *  GNU Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KOSTYLE_H
20 #define KOSTYLE_H
21 
22 #include <QString>
23 #include <QSharedPointer>
24 
25 #include <KoGenStyle.h>
26 #include <KoGenStyles.h>
27 
28 #include "koodf2_export.h"
29 
30 
31 /**
32  * \class KoStyle
33  * \brief This class is the base for all of the styles used in KoOdf.
34  * Allows to easily share the styles among different components.
35  *
36  * As all the styles it can be shared
37  **/
38 
39 class KOODF2_EXPORT KoStyle
40 {
41 public:
42     KoStyle();
43     virtual ~KoStyle();
44 
45     QString saveOdf(KoGenStyles& styles) const;
46 
47     void setName(const QString &name);
48     QString name() const;
49 
50     void setAutoStyleInStylesDotXml(bool b);
51     bool autoStyleInStylesDotXml() const;
52 
53 protected:
54     virtual void prepareStyle(KoGenStyle& style) const =0;
55     virtual QString defaultPrefix() const =0;
56     virtual KoGenStyle::Type styleType() const =0;
57     virtual KoGenStyle::Type automaticstyleType() const =0;
58     virtual const char* styleFamilyName() const =0;
59 
60 private:
61     KoGenStyles::InsertionFlags insertionFlags() const;
62 
63     bool m_autoStyle;
64     QString m_name;
65     bool m_autoStyleInStylesDotXml;
66 };
67 
68 #define KOSTYLE_DECLARE_SHARED_POINTER(class) \
69     typedef QSharedPointer<class> Ptr; \
70     static Ptr create();
71 
72 #define KOSTYLE_DECLARE_SHARED_POINTER_IMPL(class) \
73     class::Ptr class::create() \
74     { \
75         return QSharedPointer<class>(new class); \
76     }
77 
78 #endif
79