Subversion Repositories Scribus

Rev

Rev 12337 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6443 avox 1
/*
2
 For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 to the COPYING file provided with the program. Following this notice may exist
4
 a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 for which a new license (GPL+exception) is in place.
6
 */
7
/***************************************************************************
8
*                                                                         *
9
*   This program is free software; you can redistribute it and/or modify  *
10
*   it under the terms of the GNU General Public License as published by  *
11
*   the Free Software Foundation; either version 2 of the License, or     *
12
*   (at your option) any later version.                                   *
13
*                                                                         *
14
***************************************************************************/
15
 
8337 avox 16
#ifndef PARAGRAPHSTYLE_H
17
#define PARAGRAPHSTYLE_H
6443 avox 18
 
8337 avox 19
#include "style.h"
20
#include "charstyle.h"
12340 pierre 21
// #include "styles/stylecontextproxy.h"
6443 avox 22
 
8455 avox 23
 
24
class ResourceCollection;
25
 
26
 
7005 avox 27
class SCRIBUS_API ParagraphStyle : public Style
6443 avox 28
{
29
public:
30
        enum LineSpacingMode {
31
                FixedLineSpacing        = 0,
32
                AutomaticLineSpacing    = 1,
33
                BaselineGridLineSpacing = 2
34
        };
35
        enum AlignmentType {
36
                Leftaligned  = 0,
37
                Centered     = 1,
38
                Rightaligned = 2,
39
                Justified    = 3,
40
                Extended     = 4
41
        };
7059 avox 42
        enum OpticalMarginType {
43
                OM_None  = 0,
44
                OM_LeftProtruding    = 1,
45
                OM_RightProtruding   = 2,
46
                OM_LeftHangingPunct  = 4,
47
                OM_RightHangingPunct = 8,
48
                OM_Default           = OM_RightProtruding + OM_LeftHangingPunct + OM_RightHangingPunct
49
        };
50
        enum HyphenationMode {
51
                NoHyphenation        = 0,
52
                ManualHyphenation    = 1,
53
                AutomaticHyphenation = 2
54
        };
6443 avox 55
        struct TabRecord
56
        {
57
                double tabPosition;
58
                int tabType;
59
                QChar tabFillChar;
6733 avox 60
                bool operator==(const TabRecord& other) const {
61
                        return tabPosition==other.tabPosition && tabType==other.tabType && tabFillChar == other.tabFillChar;
62
                }
63
                bool operator<(const TabRecord& other)  const { return tabPosition < other.tabPosition; }
64
                bool operator<=(const TabRecord& other) const { return tabPosition <= other.tabPosition; }
65
                bool operator>(const TabRecord& other)  const { return tabPosition > other.tabPosition; }
66
                bool operator>=(const TabRecord& other) const { return tabPosition >= other.tabPosition; }
6443 avox 67
        };
68
 
69
        ParagraphStyle();
70
        ParagraphStyle(const ParagraphStyle& other);
71
        ParagraphStyle& operator=(const ParagraphStyle& other);
6765 avox 72
        ~ParagraphStyle();
6443 avox 73
 
8266 avox 74
        static const Xml_string saxxDefaultElem;
8834 cbradney 75
        static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
8193 avox 76
 
8800 jghali 77
        virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
8266 avox 78
        virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
79
 
8455 avox 80
 
81
        void getNamedResources(ResourceCollection& lists) const;
82
        void replaceNamedResources(ResourceCollection& newNames);
83
 
12314 pierre 84
//      QString displayName() const;
6443 avox 85
 
12340 pierre 86
 
6443 avox 87
 
12340 pierre 88
        bool equiv(const QString& other) const;
6443 avox 89
 
12340 pierre 90
        void applyStyle(const QString& other);
91
        void eraseStyle(const QString& other);
92
        void setStyle(const QString& other);
93
        void erase() { eraseStyle(uuid()); }
6443 avox 94
 
95
 
12340 pierre 96
 
97
        QString charStyle(){ return cstyle;}
98
        const QString charStyle() const { return cstyle;}
99
 
6443 avox 100
        /** getter: validates and returns the attribute's value */
101
 
102
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
10508 cbradney 103
        attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
6443 avox 104
#include "paragraphstyle.attrdefs.cxx"
105
#undef ATTRDEF
106
 
107
        /** setter: sets the attribute's value and clears inherited flag */
108
 
109
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
110
        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
111
#include "paragraphstyle.attrdefs.cxx"
112
#undef ATTRDEF
8337 avox 113
        void appendTabValue(const TabRecord& tab) { validate(); m_TabValues.append(tab); inh_TabValues = false; }
6443 avox 114
 
8337 avox 115
 
6443 avox 116
        /** setter: resets the attribute's value and sets inherited flag */
117
 
118
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
119
        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
120
#include "paragraphstyle.attrdefs.cxx"
121
#undef ATTRDEF
122
 
123
        /** isInherited: returns true if the attriute is inherited */
124
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
6733 avox 125
        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
6443 avox 126
#include "paragraphstyle.attrdefs.cxx"
127
#undef ATTRDEF
128
 
129
 
6733 avox 130
        /** isDefined: returns true if the attribute is defined in this style or any parent */
131
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
132
        bool isDef##attr_NAME() const { \
6805 avox 133
                if ( !inh_##attr_NAME ) return true; \
6733 avox 134
                const ParagraphStyle * par = dynamic_cast<const ParagraphStyle*>(parentStyle()); \
135
                return par && par->isDef##attr_NAME(); \
136
        }
137
#include "paragraphstyle.attrdefs.cxx"
138
#undef ATTRDEF
139
 
140
 
6443 avox 141
private:
142
 
8058 avox 143
        // member declarations:
12337 pierre 144
        QString cstyle;
6443 avox 145
 
146
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
147
                attr_TYPE m_##attr_NAME; \
148
                        bool inh_##attr_NAME;
149
#include "paragraphstyle.attrdefs.cxx"
150
#undef ATTRDEF
151
 
152
};
8337 avox 153
 
154
#endif