IWORKStyle.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libetonyek project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef IWORKSTYLE_H_INCLUDED
11 #define IWORKSTYLE_H_INCLUDED
12 
13 #include "IWORKStyle_fwd.h"
14 
15 #include <boost/any.hpp>
16 #include <boost/optional.hpp>
17 
18 #include "IWORKPropertyMap.h"
19 #include "IWORKStylesheet.h"
20 
21 namespace libetonyek
22 {
23 
24 class IWORKStyleStack;
25 
29 {
30 public:
31  IWORKStyle(const IWORKPropertyMap &props, const boost::optional<std::string> &ident, const boost::optional<std::string> &parentIdent);
32  IWORKStyle(const IWORKPropertyMap &props, const boost::optional<std::string> &ident, const IWORKStylePtr_t &parent);
33 
40 
45  void flatten();
46 
49  const IWORKPropertyMap &getPropertyMap() const;
50 
54 
59  template<class Property>
60  bool has() const
61  {
62  return m_props.has<Property>(true);
63  }
64 
69  template<class Property>
71  {
72  return m_props.get<Property>(true);
73  }
74 
75  const boost::optional<std::string> &getIdent() const;
76 
77  void setParent(const IWORKStylePtr_t parent);
78 
80  void createListLevelStyles();
81 
82 protected:
83  const boost::optional<std::string> &getParentIdent() const;
84  const IWORKStylePtr_t getParent() const;
85 
86 private:
88 
89  const boost::optional<std::string> m_ident;
90  const boost::optional<std::string> m_parentIdent;
92 };
93 
94 }
95 
96 #endif // IWORKSTYLE_H_INCLUDED
97 
98 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek
Definition: IWORKBezierElement.cpp:21
libetonyek::IWORKToken::stylesheet
@ stylesheet
Definition: IWORKToken.h:417
m_props
RVNGPropertyList & m_props
Definition: IWORKCollector.cpp:222
IWORKPropertyMap.h
IWORKProperties.h
libetonyek::IWORKStyle::flatten
void flatten()
Copy attributes from parent style (recursively).
Definition: IWORKStyle.cpp:62
libetonyek::IWORKPropertyMap::get
const IWORKPropertyInfo< Property >::ValueType & get(bool lookInParent=false) const
Retrieve the value of a property.
Definition: IWORKPropertyMap.h:113
ETONYEK_DEBUG_MSG
#define ETONYEK_DEBUG_MSG(M)
Definition: libetonyek_utils.h:54
libetonyek::IWORKToken::none
@ none
Definition: IWORKToken.h:666
libetonyek::IWORKStylesheetPtr_t
std::shared_ptr< IWORKStylesheet > IWORKStylesheetPtr_t
Definition: IWORKStylesheet.h:19
libetonyek::IWORKStyle::m_parent
IWORKStylePtr_t m_parent
Definition: IWORKStyle.h:91
libetonyek::IWORKPropertyMap::setParent
void setParent(const IWORKPropertyMap *parent)
Set a new parent for this map.
Definition: IWORKPropertyMap.cpp:47
libetonyek::IWORKStyle::m_props
IWORKPropertyMap m_props
Definition: IWORKStyle.h:87
libetonyek::IWORKStyle::m_parentIdent
const boost::optional< std::string > m_parentIdent
Definition: IWORKStyle.h:90
libetonyek::IWORKStyle::link
bool link(const IWORKStylesheetPtr_t &stylesheet)
Find the parent style by its ID.
Definition: IWORKStyle.cpp:38
libetonyek::IWORKStyle::getIdent
const boost::optional< std::string > & getIdent() const
Definition: IWORKStyle.cpp:77
libetonyek::IWORKStyle::createListLevelStyles
void createListLevelStyles()
Creates the list level properties of a list style if it does not exists.
Definition: IWORKStyle.cpp:99
libetonyek::IWORKPropertyInfo
Definition: IWORKPropertyInfo.h:22
IWORKStylesheet.h
m_parent
optional< ID_t > m_parent
Definition: KEY2Parser.cpp:226
libetonyek::IWORKStyle::getPropertyMap
const IWORKPropertyMap & getPropertyMap() const
Get the style's property map.
Definition: IWORKStyle.cpp:67
libetonyek::IWORKStyle::getParentIdent
const boost::optional< std::string > & getParentIdent() const
Definition: IWORKStyle.cpp:82
libetonyek::IWORKPropertyMap::put
void put(const typename IWORKPropertyInfo< Property >::ValueType &value)
Insert a new value for key key.
Definition: IWORKPropertyMap.h:134
libetonyek::IWORKStyle::getParent
const IWORKStylePtr_t getParent() const
Definition: IWORKStyle.cpp:87
libetonyek::IWORKStyle::m_ident
const boost::optional< std::string > m_ident
Definition: IWORKStyle.h:89
libetonyek_utils.h
libetonyek::IWORKPropertyMap::has
bool has(bool lookInParent=false) const
Check for the presence of a property.
Definition: IWORKPropertyMap.h:78
libetonyek::IWORKStyle::IWORKStyle
IWORKStyle(const IWORKPropertyMap &props, const boost::optional< std::string > &ident, const boost::optional< std::string > &parentIdent)
Definition: IWORKStyle.cpp:20
libetonyek::KEY2Token::i
@ i
Definition: KEY2Token.h:101
libetonyek::IWORKPropertyMap
Represents a (hierarchical) property map.
Definition: IWORKPropertyMap.h:25
IWORKStyleStack.h
libetonyek::IWORKStylePtr_t
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::IWORKListLevels_t
std::map< unsigned, IWORKStylePtr_t > IWORKListLevels_t
Definition: IWORKTypes.h:458
libetonyek::IWORKStyle::get
const IWORKPropertyInfo< Property >::ValueType & get() const
Retrieve the value of a property.
Definition: IWORKStyle.h:70
IWORKStyle_fwd.h
libetonyek::IWORKToken::ident
@ ident
Definition: IWORKToken.h:559
libetonyek::IWORKStyle
Represents a hierarchical style.
Definition: IWORKStyle.h:29
libetonyek::IWORKStyle::setParent
void setParent(const IWORKStylePtr_t parent)
Definition: IWORKStyle.cpp:92
libetonyek::IWORKStyle::has
bool has() const
Check for the presence of a property.
Definition: IWORKStyle.h:60
IWORKStyle.h

Generated for libetonyek by doxygen 1.8.20