File indexing completed on 2024-12-08 12:56:11

0001 /*
0002  *  Copyright (c) 2010 Carlos Licea <carlos@kdab.com>
0003  *
0004  *  This library is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU Lesser General Public License as published
0006  *  by the Free Software Foundation; either version 2.1 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This library is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU Lesser General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU Lesser General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 
0019 #ifndef KOSTYLE_H
0020 #define KOSTYLE_H
0021 
0022 #include <QString>
0023 #include <QSharedPointer>
0024 
0025 #include <KoGenStyle.h>
0026 #include <KoGenStyles.h>
0027 
0028 #include "koodf2_export.h"
0029 
0030 
0031 /**
0032  * \class KoStyle
0033  * \brief This class is the base for all of the styles used in KoOdf.
0034  * Allows to easily share the styles among different components.
0035  *
0036  * As all the styles it can be shared
0037  **/
0038 
0039 class KOODF2_EXPORT KoStyle
0040 {
0041 public:
0042     KoStyle();
0043     virtual ~KoStyle();
0044 
0045     QString saveOdf(KoGenStyles& styles) const;
0046 
0047     void setName(const QString &name);
0048     QString name() const;
0049 
0050     void setAutoStyleInStylesDotXml(bool b);
0051     bool autoStyleInStylesDotXml() const;
0052 
0053 protected:
0054     virtual void prepareStyle(KoGenStyle& style) const =0;
0055     virtual QString defaultPrefix() const =0;
0056     virtual KoGenStyle::Type styleType() const =0;
0057     virtual KoGenStyle::Type automaticstyleType() const =0;
0058     virtual const char* styleFamilyName() const =0;
0059 
0060 private:
0061     KoGenStyles::InsertionFlags insertionFlags() const;
0062 
0063     bool m_autoStyle;
0064     QString m_name;
0065     bool m_autoStyleInStylesDotXml;
0066 };
0067 
0068 #define KOSTYLE_DECLARE_SHARED_POINTER(class) \
0069     typedef QSharedPointer<class> Ptr; \
0070     static Ptr create();
0071 
0072 #define KOSTYLE_DECLARE_SHARED_POINTER_IMPL(class) \
0073     class::Ptr class::create() \
0074     { \
0075         return QSharedPointer<class>(new class); \
0076     }
0077 
0078 #endif