Scribus
Open source desktop publishing at your fingertips
cellstyle.h
1 /*
2  Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
3 
4  For general Scribus (>=1.3.2) copyright and licensing information please refer
5  to the COPYING file provided with the program. Following this notice may exist
6  a copyright and/or license notice that predates the release of Scribus 1.3.2
7  for which a new license (GPL+exception) is in place.
8  */
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 
18 #ifndef CELLSTYLE_H
19 #define CELLSTYLE_H
20 
21 #include <QString>
22 
23 #include "style.h"
24 #include "tableborder.h"
25 #include "commonstrings.h"
26 #include "resourcecollection.h"
27 #include "styles/stylecontextproxy.h"
28 
32 class SCRIBUS_API CellStyle : public Style {
33 public:
37  CellStyle() : Style(), cellStyleProxy(this) {
38 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
39  m_##attr_NAME = attr_DEFAULT; \
40  inh_##attr_NAME = true;
41 #include "cellstyle.attrdefs.cxx"
42 #undef ATTRDEF
43  };
44 
51  CellStyle(const CellStyle& other);
52 
60  CellStyle& operator=(const CellStyle& other);
61 
63  virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const {};
64 
66  virtual void saxx(SaxHandler& handler) const {};
67 
73  QString displayName() const;
74 
81  bool equiv(const Style& other) const;
82 
86  void erase();
87 
91  void update(const StyleContext* context);
92 
96  void getNamedResources(ResourceCollection& lists) const;
97 
101  void replaceNamedResources(ResourceCollection& newNames);
102 
108 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
109  const attr_TYPE &attr_GETTER() const { validate(); return m_##attr_NAME; }
110 #include "cellstyle.attrdefs.cxx"
111 #undef ATTRDEF
112 
118 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
119  void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
120 #include "cellstyle.attrdefs.cxx"
121 #undef ATTRDEF
122 
127 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
128  void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
129 #include "cellstyle.attrdefs.cxx"
130 #undef ATTRDEF
131 
137 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
138  bool isInh##attr_NAME() const { return inh_##attr_NAME; }
139 #include "cellstyle.attrdefs.cxx"
140 #undef ATTRDEF
141 
148 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
149  bool isDef##attr_NAME() const { \
150  if (!inh_##attr_NAME) return true; \
151  const CellStyle *parent = dynamic_cast<const CellStyle*>(parentStyle()); \
152  return parent && parent->isDef##attr_NAME(); \
153  }
154 #include "cellstyle.attrdefs.cxx"
155 #undef ATTRDEF
156 
158  QString asString() const;
159 
160 private:
161  StyleContextProxy cellStyleProxy;
162 
163  // Attribute related member declarations.
164 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
165  attr_TYPE m_##attr_NAME; \
166  bool inh_##attr_NAME;
167 #include "cellstyle.attrdefs.cxx"
168 #undef ATTRDEF
169 };
170 
172 {
173  static_cast<Style&>(*this) = static_cast<const Style&>(other);
174 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
175  m_##attr_NAME = other.m_##attr_NAME; \
176  inh_##attr_NAME = other.inh_##attr_NAME;
177 #include "cellstyle.attrdefs.cxx"
178 #undef ATTRDEF
179  m_contextversion = -1;
180  return *this;
181 }
182 
183 inline CellStyle::CellStyle(const CellStyle& other) : Style(other), cellStyleProxy(this)
184 {
185 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
186  m_##attr_NAME = other.m_##attr_NAME; \
187  inh_##attr_NAME = other.inh_##attr_NAME;
188 #include "cellstyle.attrdefs.cxx"
189 #undef ATTRDEF
190  m_contextversion = -1;
191 }
192 
193 #endif // CELLSTYLE_H
virtual bool equiv(const Style &other) const =0
Definition: stylecontext.h:35
CellStyle()
Definition: cellstyle.h:37
Definition: saxhandler.h:21
Definition: stylecontextproxy.h:33
virtual void erase()=0
virtual void update(const StyleContext *b=NULL)
Definition: style.cpp:54
Definition: cellstyle.h:32
Definition: style.h:37
virtual void saxx(SaxHandler &handler, const Xml_string &elemtag) const
Not implemented.
Definition: cellstyle.h:63
virtual void saxx(SaxHandler &handler) const
Not implemented.
Definition: cellstyle.h:66
Definition: resourcecollection.h:41
CellStyle & operator=(const CellStyle &other)
Definition: cellstyle.h:171