Scribus
Open source desktop publishing at your fingertips
stylecontextproxy.h
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 #ifndef STYLECONTEXTPROXY_H
18 #define STYLECONTEXTPROXY_H
19 
20 #include <cassert>
21 #include <QList>
22 #include <QString>
23 #include "scfonts.h"
24 #include "scribusapi.h"
25 #include "sccolor.h"
26 #include "styles/stylecontext.h"
27 
28 
34 {
35 public:
36  const Style* resolve(const QString& name) const;
37 
38  StyleContextProxy(const Style* style)
39  : StyleContext(), m_default(style) {
40  }
41 
43  : StyleContext(other), m_default(other.m_default) {
44  }
45 
46  StyleContextProxy& operator= (const StyleContextProxy& other)
47  {
48  static_cast<StyleContext&>(*this) = static_cast<const StyleContext&>(other);
49  m_default = other.m_default;
50  return *this;
51  }
52 
53  const Style* defaultStyle() const { return m_default; }
54 
55  void setDefaultStyle(const Style* def) {
56  assert(def);
57  m_default = def;
58  invalidate();
59  }
60 
61  bool checkConsistency() const
62  {
63  const StyleContext* context = m_default->context();
64  return !context || context == this || !context->contextContained(this);
65  }
66 
67  bool contextContained(const StyleContext* context) const
68  {
69  const StyleContext* mycontext = m_default->context();
70  return context == this ||
71  (mycontext && mycontext->contextContained(context));
72  }
73 
74 private:
75  const Style* m_default;
76 };
77 
78 #endif
Definition: stylecontext.h:35
Definition: stylecontextproxy.h:33
Definition: style.h:37