Subversion Repositories Scribus

Rev

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