Scribus
Open source desktop publishing at your fingertips
tablestyle.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 TABLESTYLE_H
19 #define TABLESTYLE_H
20 
21 #include "style.h"
22 #include "commonstrings.h"
23 #include "resourcecollection.h"
24 #include "styles/stylecontextproxy.h"
25 #include "tableborder.h"
26 
30 class SCRIBUS_API TableStyle : public Style {
31 public:
35  TableStyle() : Style(), tableStyleProxy(this) {
36 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
37  m_##attr_NAME = attr_DEFAULT; \
38  inh_##attr_NAME = true;
39 #include "tablestyle.attrdefs.cxx"
40 #undef ATTRDEF
41  };
42 
49  TableStyle(const TableStyle& other);
50 
58  TableStyle& operator=(const TableStyle& other);
59 
60  static const Xml_string saxxDefaultElem;
61  static void desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
62 
63  virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
64  virtual void saxx(SaxHandler& handler) const { saxx(handler, saxxDefaultElem); };
65 
71  QString displayName() const;
72 
79  bool equiv(const Style& other) const;
80 
84  void erase();
85 
89  void update(const StyleContext* context);
90 
94  void getNamedResources(ResourceCollection& lists) const;
95 
99  void replaceNamedResources(ResourceCollection& newNames);
100 
106 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
107  const attr_TYPE &attr_GETTER() const { validate(); return m_##attr_NAME; }
108 #include "tablestyle.attrdefs.cxx"
109 #undef ATTRDEF
110 
116 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
117  void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
118 #include "tablestyle.attrdefs.cxx"
119 #undef ATTRDEF
120 
125 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
126  void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
127 #include "tablestyle.attrdefs.cxx"
128 #undef ATTRDEF
129 
135 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
136  bool isInh##attr_NAME() const { return inh_##attr_NAME; }
137 #include "tablestyle.attrdefs.cxx"
138 #undef ATTRDEF
139 
146 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
147  bool isDef##attr_NAME() const { \
148  if (!inh_##attr_NAME) return true; \
149  const TableStyle *parent = dynamic_cast<const TableStyle*>(parentStyle()); \
150  return parent && parent->isDef##attr_NAME(); \
151  }
152 #include "tablestyle.attrdefs.cxx"
153 #undef ATTRDEF
154 
155 private:
156  StyleContextProxy tableStyleProxy;
157 
158  // Attribute related member declarations.
159 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
160  attr_TYPE m_##attr_NAME; \
161  bool inh_##attr_NAME;
162 #include "tablestyle.attrdefs.cxx"
163 #undef ATTRDEF
164 };
165 
167 {
168  static_cast<Style&>(*this) = static_cast<const Style&>(other);
169 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
170  m_##attr_NAME = other.m_##attr_NAME; \
171  inh_##attr_NAME = other.inh_##attr_NAME;
172 #include "tablestyle.attrdefs.cxx"
173 #undef ATTRDEF
174  m_contextversion = -1;
175  return *this;
176 }
177 
178 inline TableStyle::TableStyle(const TableStyle& other) : Style(other), tableStyleProxy(this)
179 {
180 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
181  m_##attr_NAME = other.m_##attr_NAME; \
182  inh_##attr_NAME = other.inh_##attr_NAME;
183 #include "tablestyle.attrdefs.cxx"
184 #undef ATTRDEF
185  m_contextversion = -1;
186 }
187 
188 #endif // TABLESTYLE_H
virtual bool equiv(const Style &other) const =0
Definition: stylecontext.h:35
Definition: tablestyle.h:30
Definition: saxhandler.h:21
Definition: stylecontextproxy.h:33
TableStyle & operator=(const TableStyle &other)
Definition: tablestyle.h:166
virtual void erase()=0
virtual void update(const StyleContext *b=NULL)
Definition: style.cpp:54
virtual void saxx(SaxHandler &handler) const
Definition: tablestyle.h:64
Definition: style.h:37
static const Xml_string saxxDefaultElem
Definition: saxio.h:40
Definition: digester.h:100
virtual void saxx(SaxHandler &, const Xml_string &) const =0
Definition: resourcecollection.h:41
TableStyle()
Definition: tablestyle.h:35