Subversion Repositories Scribus

Rev

Rev 6805 | Rev 7017 | 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
#include <qvaluelist.h>
10
#include <qobject.h>
11
#include "sctextstruct.h"
12
#include "scfonts.h"
6733 avox 13
#include "style.h"
6443 avox 14
 
15
 
16
StyleFlag& operator&= (StyleFlag& left, StyleFlag right){        
17
        int result = static_cast<int>(left) & static_cast<int>(right);        
18
        left = static_cast<StyleFlag>(result);
19
        return left;
20
}
21
 
22
StyleFlag& operator|= (StyleFlag& left, StyleFlag right)
23
{
24
        int result = static_cast<int>(left) | static_cast<int>(right);
25
        left = static_cast<StyleFlag>(result);
26
        return left;
27
}
28
 
29
StyleFlag operator& (StyleFlag left, StyleFlag right)
30
{
31
        int result = static_cast<int>(left) & static_cast<int>(right);        
32
        return static_cast<StyleFlag>(result);
33
}
34
 
35
StyleFlag operator| (StyleFlag left, StyleFlag right)
36
{        
37
        int result = static_cast<int>(left) | static_cast<int>(right);
38
        return static_cast<StyleFlag>(result);
39
}
40
 
41
StyleFlag operator^ (StyleFlag left, StyleFlag right){
42
        int result = static_cast<int>(left) ^ static_cast<int>(right);
43
        return static_cast<StyleFlag>(result);
44
}
45
 
46
StyleFlag operator~ (StyleFlag arg)
47
{
48
        int result = ~ static_cast<int>(arg);
49
        return static_cast<StyleFlag>(result);
50
}
51
 
52
 
53
void CharStyle::applyCharStyle(const CharStyle & other)
54
{
6805 avox 55
        other.validate();
6443 avox 56
        Style::applyStyle(other);
57
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
58
        if (! other.inh_##attr_NAME) \
59
                set##attr_NAME(other.m_##attr_NAME);
60
#include "charstyle.attrdefs.cxx"
61
#undef ATTRDEF
62
}
63
 
64
 
65
void CharStyle::eraseCharStyle(const CharStyle & other)
66
{
6805 avox 67
        other.validate();
6443 avox 68
        Style::eraseStyle(other);
69
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
6936 avox 70
        if (!inh_##attr_NAME && m_##attr_NAME == other.m_##attr_NAME) \
6443 avox 71
                reset##attr_NAME();
72
#include "charstyle.attrdefs.cxx"
73
#undef ATTRDEF
74
}
75
 
76
bool CharStyle::equiv(const Style & other) const
77
{
6805 avox 78
        other.validate();
6443 avox 79
        const CharStyle * oth = dynamic_cast<const CharStyle*> ( & other );
80
        return  oth &&
6733 avox 81
                parent() == oth->parent()
6443 avox 82
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
6733 avox 83
                && (inh_##attr_NAME == oth->inh_##attr_NAME) \
84
                && (inh_##attr_NAME || m_##attr_NAME == oth->m_##attr_NAME)
6443 avox 85
#include "charstyle.attrdefs.cxx"
86
#undef ATTRDEF
87
                ;      
88
}
89
 
90
 
91
QString CharStyle::displayName() const
92
{
93
        if ( hasName() || !hasParent() || ! m_base)
94
                return name();
95
//      else if ( inheritsAll() )
96
//              return parent()->displayName();
97
        else
98
                return parentStyle()->displayName() + "+";
99
}
100
 
101
 
102
 
103
QString CharStyle::asString() const
104
{
105
        QString result;
106
        if ( !inh_Font )
107
                result += QObject::tr("font %1 ").arg(font().scName());
108
        if ( !inh_FontSize )
109
                result += QObject::tr("size %1 ").arg(fontSize());
110
        if ( !inh_Effects )
111
                result += QObject::tr("+style ");
112
        if ( !inh_StrokeColor  ||  !inh_StrokeShade  ||  !inh_FillColor || !inh_FillShade )
113
                result += QObject::tr("+color ");
114
        if ( !inh_UnderlineWidth  ||  !inh_UnderlineOffset )
115
                result += underlineWidth() > 0 ? QObject::tr("+underline ") : QObject::tr("-underline ");
6733 avox 116
        if ( !inh_StrikethruWidth || !inh_StrikethruOffset )
6443 avox 117
                result += strikethruWidth() > 0 ? QObject::tr("+strikeout ") : QObject::tr("-strikeout ");
118
        if ( !inh_ShadowXOffset || !inh_ShadowYOffset )
6733 avox 119
                result += shadowXOffset() != 0 || shadowYOffset() != 0 ? QObject::tr("+shadow ") : QObject::tr("-shadow ");
6443 avox 120
        if ( !inh_OutlineWidth )
121
                result += outlineWidth() > 0 ? QObject::tr("+outline ") : QObject::tr("-outline ");
122
        if ( !inh_Tracking )
123
                result += tracking() > 0 ? QObject::tr("+tracking %1 ").arg(tracking()) : QObject::tr("-tracking ");
124
        if ( !inh_BaselineOffset )
125
                result += QObject::tr("+baseline %1 ").arg(baselineOffset());
126
        if ( !inh_ScaleH || !inh_ScaleV )
127
                result += QObject::tr("+stretch ");
128
        if ( hasParent() )
129
                result += QObject::tr("parent= %1").arg(parent());
130
        return result.stripWhiteSpace();
131
}
132
 
133
 
6805 avox 134
void CharStyle::update(const StyleBase* base)
6443 avox 135
{
136
        Style::update(base);
137
        const CharStyle * oth = dynamic_cast<const CharStyle*> ( parentStyle() );
138
        if (oth) {
139
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
140
                if (inh_##attr_NAME) \
6733 avox 141
                        m_##attr_NAME = oth->attr_GETTER();
6443 avox 142
#include "charstyle.attrdefs.cxx"
143
#undef ATTRDEF
144
        }
145
}
146
 
147
 
148
 
149
 
150
/*
151
bool CharStyle::definesAll() const
152
{
153
        return definesLineSpacing() &&
154
        definesLeftMargin() &&
155
        definesRightMargin() &&
156
        definesFirstIndent() &&
157
        definesAlignment() &&
158
        definesGapBefore()  &&
159
        definesLineSpacingMode()  &&
160
        definesGapAfter()  &&
161
        definesHasDropCap() &&
162
        definesDropCapOffset() &&
163
        definesDropCapLines() &&
164
        definesUseBaselineGrid() &&
165
        charStyle().definesAll() ;
166
 
167
}
168
 
169
bool CharStyle::inheritsAll() const
170
{
171
        return inheritsLineSpacing() &&
172
        inheritsLeftMargin() &&
173
        inheritsRightMargin() &&
174
        inheritsFirstIndent() &&
175
        inheritsAlignment() &&
176
        inheritsGapBefore()  &&
177
        inheritsLineSpacingMode()  &&
178
        inheritsGapAfter()  &&
179
        inheritsHasDropCap() &&
180
        inheritsDropCapOffset() &&
181
        inheritsDropCapLines() &&
182
        inheritsUseBaselineGrid() &&
183
        charStyle().inheritsAll() ;
184
}
185
*/
186