Subversion Repositories Scribus

Rev

Rev 12314 | Go to most recent revision | 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"
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
 
8134 avox 86
        void setContext(const StyleContext* context);
87
        void update(const StyleContext*);
6443 avox 88
 
89
        bool equiv(const Style& other) const;
90
 
12337 pierre 91
        void applyStyle(const ParagraphStyle* other);
92
        void eraseStyle(const ParagraphStyle* other);
93
        void setStyle(const ParagraphStyle* other);
94
        void erase() { eraseStyle(this); }
6443 avox 95
 
8134 avox 96
        StyleContext* charStyleContext() { return & cstyleContext; }
97
        const StyleContext* charStyleContext() const { return & cstyleContext; }
12337 pierre 98
        CharStyle * charStyle() ;
99
        const CharStyle* charStyle() const ;
8134 avox 100
        /** Normally the context for charStyle() is parentStyle()->charStyleContext()
101
                Use this method to break that relation and set charStyle()'s context manually
8058 avox 102
        */
103
        void breakImplicitCharStyleInheritance(bool val = true);
104
        /** used internally to establish the implicit relation
8134 avox 105
                charStyle().context() == parentStyle()->charStyleContext()
106
                Done implicitly in setContext(), update(), operator= and breakImplicitCharStyleInheritance()
8058 avox 107
        */
108
        void repairImplicitCharStyleInheritance();
6443 avox 109
 
110
        /** getter: validates and returns the attribute's value */
111
 
112
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
10508 cbradney 113
        attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
6443 avox 114
#include "paragraphstyle.attrdefs.cxx"
115
#undef ATTRDEF
116
 
117
        /** setter: sets the attribute's value and clears inherited flag */
118
 
119
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
120
        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
121
#include "paragraphstyle.attrdefs.cxx"
122
#undef ATTRDEF
8337 avox 123
        void appendTabValue(const TabRecord& tab) { validate(); m_TabValues.append(tab); inh_TabValues = false; }
6443 avox 124
 
8337 avox 125
 
6443 avox 126
        /** setter: resets the attribute's value and sets inherited flag */
127
 
128
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
129
        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
130
#include "paragraphstyle.attrdefs.cxx"
131
#undef ATTRDEF
132
 
133
        /** isInherited: returns true if the attriute is inherited */
134
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
6733 avox 135
        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
6443 avox 136
#include "paragraphstyle.attrdefs.cxx"
137
#undef ATTRDEF
138
 
139
 
6733 avox 140
        /** isDefined: returns true if the attribute is defined in this style or any parent */
141
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
142
        bool isDef##attr_NAME() const { \
6805 avox 143
                if ( !inh_##attr_NAME ) return true; \
6733 avox 144
                const ParagraphStyle * par = dynamic_cast<const ParagraphStyle*>(parentStyle()); \
145
                return par && par->isDef##attr_NAME(); \
146
        }
147
#include "paragraphstyle.attrdefs.cxx"
148
#undef ATTRDEF
149
 
150
 
6443 avox 151
private:
152
 
8058 avox 153
        // member declarations:
8134 avox 154
        StyleContextProxy cstyleContext;
155
        bool cstyleContextIsInh;
12337 pierre 156
        QString cstyle;
6443 avox 157
 
158
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
159
                attr_TYPE m_##attr_NAME; \
160
                        bool inh_##attr_NAME;
161
#include "paragraphstyle.attrdefs.cxx"
162
#undef ATTRDEF
163
 
164
};
8337 avox 165
 
166
#endif