Subversion Repositories Scribus

Rev

Rev 8193 | Rev 8337 | 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
 
16
 
17
// DONT INCLUDE this file directly, include "style.h" instead!
18
 
19
 
7456 jghali 20
enum StyleFlagValue {
6443 avox 21
        ScStyle_Default       = 0,
22
    ScStyle_Superscript   = 1,
23
    ScStyle_Subscript     = 2,
24
    ScStyle_Outline       = 4,
25
    ScStyle_Underline     = 8,
26
    ScStyle_Strikethrough = 16,
27
    ScStyle_AllCaps       = 32,
28
    ScStyle_SmallCaps     = 64,
29
    ScStyle_HyphenationPossible=128, //Hyphenation possible here (Smart Hyphen)
30
    ScStyle_Shadowed      = 256,
31
    ScStyle_UnderlineWords= 512,
32
    ScStyle_Reserved01    = 1024, //free, not used in the moment
33
    ScStyle_DropCap       = 2048,
34
    ScStyle_SuppressSpace = 4096,//internal use in PageItem (Suppresses spaces when in Block alignment)
35
    ScStyle_SmartHyphenVisible=8192, //Smart Hyphen visible at line end
36
    ScStyle_StartOfLine   = 16384,
7017 avox 37
        ScStyle_UserStyles    = 2047, // 1919, // == 1024 + 512 + 256 + 64 + 32 + 16 + 8 + 4 + 2 + 1
6443 avox 38
        ScStyle_None          = 65535
39
};
40
 
7456 jghali 41
class SCRIBUS_API StyleFlag
42
{
43
public:
6443 avox 44
 
7456 jghali 45
        StyleFlagValue value;
6443 avox 46
 
7456 jghali 47
        StyleFlag(void) { value = ScStyle_Default; }
48
        StyleFlag(StyleFlagValue val) { value = val; }
49
        StyleFlag(int val) { value = static_cast<StyleFlagValue>(val); }
6443 avox 50
 
7456 jghali 51
        operator StyleFlagValue() const { return value; }
6443 avox 52
 
7456 jghali 53
        StyleFlag& operator=  (StyleFlagValue val) { value = val; return *this;}
54
        StyleFlag& operator&= (const StyleFlag& right);
55
        StyleFlag& operator|= (const StyleFlag& right);
56
        StyleFlag  operator&  (const StyleFlag& right);
57
        StyleFlag  operator&  (int right);
58
        StyleFlag  operator|  (const StyleFlag& right);
59
        StyleFlag  operator^  (const StyleFlag& right);
60
        StyleFlag  operator^  (int right);
61
        StyleFlag  operator~  ();
6443 avox 62
 
7456 jghali 63
        bool operator== (const StyleFlag& right) const;
64
        bool operator== (const StyleFlagValue right) const;
65
        bool operator== (int right) const;
66
        bool operator!= (const StyleFlag& right) const;
67
        bool operator!= (const StyleFlagValue right) const;
68
};
6443 avox 69
 
7005 avox 70
class SCRIBUS_API CharStyle : public Style {
6443 avox 71
public:
72
 
73
 
74
    CharStyle() : Style() {
75
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
76
                m_##attr_NAME = attr_DEFAULT; \
77
                inh_##attr_NAME = true;
78
#include "charstyle.attrdefs.cxx"
79
#undef ATTRDEF
80
    };
81
 
82
    CharStyle(const ScFace& font, int size, StyleFlag style = ScStyle_Default) : Style() {
83
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
84
                m_##attr_NAME = attr_DEFAULT; \
85
                inh_##attr_NAME = true;
86
#include "charstyle.attrdefs.cxx"
87
#undef ATTRDEF
88
                m_Font = font;
89
        m_FontSize = size;
90
                m_Effects = style;
91
    };
92
 
93
        CharStyle(const CharStyle & other);
94
 
95
        CharStyle & operator=(const CharStyle & other);
96
 
8266 avox 97
        static const Xml_string saxxDefaultElem;
98
        static void  desaxeRules(Xml_string prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
8193 avox 99
 
8266 avox 100
        virtual void saxx(SaxHandler& handler, Xml_string elemtag) const;
101
        virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
102
 
6443 avox 103
        QString displayName() const;
104
 
8134 avox 105
        void update(const StyleContext * b);
6443 avox 106
 
107
        bool equiv(const Style& other) const;  
108
 
109
        void applyCharStyle(const CharStyle & other);
110
        void eraseCharStyle(const CharStyle & other);
7242 avox 111
        void setStyle(const CharStyle & other);
6443 avox 112
        void erase() { eraseCharStyle(*this); }
113
 
114
        QString asString() const;
115
 
116
        /** getter: validates and returns the attribute's value */
117
 
118
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
119
        const attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
120
#include "charstyle.attrdefs.cxx"
121
#undef ATTRDEF
122
 
123
        /** setter: sets the attribute's value and clears inherited flag */
124
 
125
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
126
        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
127
#include "charstyle.attrdefs.cxx"
128
#undef ATTRDEF
129
 
130
        /** setter: resets the attribute's value and sets inherited flag */
131
 
132
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
133
        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
134
#include "charstyle.attrdefs.cxx"
135
#undef ATTRDEF
136
 
6733 avox 137
        /** isInherited: returns true if the attribute is inherited */
6443 avox 138
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
6733 avox 139
        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
6443 avox 140
#include "charstyle.attrdefs.cxx"
141
#undef ATTRDEF
142
 
143
 
6733 avox 144
        /** isDefined: returns true if the attribute is defined in this style or any parent */
145
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
146
        bool isDef##attr_NAME() const { \
6805 avox 147
                if ( !inh_##attr_NAME ) return true; \
6733 avox 148
                const CharStyle * par = dynamic_cast<const CharStyle*>(parentStyle()); \
149
                return par && par->isDef##attr_NAME(); \
150
        }
151
#include "charstyle.attrdefs.cxx"
152
#undef ATTRDEF
153
 
154
 
6443 avox 155
private:
156
 
157
        // member declarations:
158
 
159
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
160
        attr_TYPE m_##attr_NAME; \
161
        bool inh_##attr_NAME;
162
#include "charstyle.attrdefs.cxx"
163
#undef ATTRDEF
164
};
165
 
166
 
167
inline CharStyle & CharStyle::operator=(const CharStyle & other)
168
{
169
        static_cast<Style&>(*this) = static_cast<const Style&>(other);
170
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
171
        m_##attr_NAME = other.m_##attr_NAME; \
172
        inh_##attr_NAME = other.inh_##attr_NAME;
173
#include "charstyle.attrdefs.cxx"
174
#undef ATTRDEF
8134 avox 175
//      m_context = NULL;
176
        m_contextversion = -1;
6443 avox 177
        return *this;
178
}
179
 
180
inline CharStyle::CharStyle(const CharStyle & other) : Style(other)
181
{
182
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
183
        m_##attr_NAME = other.m_##attr_NAME; \
184
        inh_##attr_NAME = other.inh_##attr_NAME;
185
#include "charstyle.attrdefs.cxx"
186
#undef ATTRDEF
8134 avox 187
//      m_context = NULL;
188
        m_contextversion = -1;
6443 avox 189
}
190