Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libetonyek/src/lib/IWORKStyle.h
Line
Count
Source
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
26
/** Represents a hierarchical style.
27
  */
28
class IWORKStyle
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
34
  /** Find the parent style by its ID.
35
    *
36
    * @arg[in] stylesheet the stylesheet to use for looking for parent.
37
    * @return @c true if the parent style has been found, @c false otherwise.
38
    */
39
  bool link(const IWORKStylesheetPtr_t &stylesheet);
40
41
  /** Copy attributes from parent style (recursively).
42
    *
43
    * @todo Will this have any effect on performance anyway?
44
    */
45
  void flatten();
46
47
  /** Get the style's property map.
48
    */
49
  const IWORKPropertyMap &getPropertyMap() const;
50
51
  /** Get the style's property map.
52
    */
53
  IWORKPropertyMap &getPropertyMap();
54
55
  /** Check for the presence of a property.
56
    *
57
    * @returns true if the property is present
58
    */
59
  template<class Property>
60
  bool has() const
61
19.9k
  {
62
19.9k
    return m_props.has<Property>(true);
63
19.9k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::Alignment>() const
Line
Count
Source
61
29
  {
62
29
    return m_props.has<Property>(true);
63
29
  }
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::DropCap>() const
bool libetonyek::IWORKStyle::has<libetonyek::property::VerticalAlignment>() const
Line
Count
Source
61
418
  {
62
418
    return m_props.has<Property>(true);
63
418
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::ListLevelStyles>() const
Line
Count
Source
61
737
  {
62
737
    return m_props.has<Property>(true);
63
737
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::SFTTableBandedCellFillProperty>() const
Line
Count
Source
61
42
  {
62
42
    return m_props.has<Property>(true);
63
42
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::SFTTableBandedRowsProperty>() const
Line
Count
Source
61
38
  {
62
38
    return m_props.has<Property>(true);
63
38
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::Opacity>() const
Line
Count
Source
61
1.96k
  {
62
1.96k
    return m_props.has<Property>(true);
63
1.96k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::Fill>() const
Line
Count
Source
61
3.36k
  {
62
3.36k
    return m_props.has<Property>(true);
63
3.36k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::Stroke>() const
Line
Count
Source
61
1.96k
  {
62
1.96k
    return m_props.has<Property>(true);
63
1.96k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::TailLineEnd>() const
Line
Count
Source
61
1.96k
  {
62
1.96k
    return m_props.has<Property>(true);
63
1.96k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::HeadLineEnd>() const
Line
Count
Source
61
1.96k
  {
62
1.96k
    return m_props.has<Property>(true);
63
1.96k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::Shadow>() const
Line
Count
Source
61
1.96k
  {
62
1.96k
    return m_props.has<Property>(true);
63
1.96k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::Padding>() const
Line
Count
Source
61
382
  {
62
382
    return m_props.has<Property>(true);
63
382
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::ExternalTextWrap>() const
Line
Count
Source
61
1.99k
  {
62
1.99k
    return m_props.has<Property>(true);
63
1.99k
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::LayoutStyle>() const
Line
Count
Source
61
78
  {
62
78
    return m_props.has<Property>(true);
63
78
  }
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::ListLabelGeometries>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::ListLabelIndents>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::ListTextIndents>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::ListLabelTypes>() const
bool libetonyek::IWORKStyle::has<libetonyek::property::SFTStrokeProperty>() const
Line
Count
Source
61
103
  {
62
103
    return m_props.has<Property>(true);
63
103
  }
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTCellStylePropertyNumberFormat>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTCellStylePropertyDateTimeFormat>() const
bool libetonyek::IWORKStyle::has<libetonyek::property::ListLabelGeometry>() const
Line
Count
Source
61
574
  {
62
574
    return m_props.has<Property>(true);
63
574
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::ListLabelIndent>() const
Line
Count
Source
61
574
  {
62
574
    return m_props.has<Property>(true);
63
574
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::ListTextIndent>() const
Line
Count
Source
61
574
  {
62
574
    return m_props.has<Property>(true);
63
574
  }
bool libetonyek::IWORKStyle::has<libetonyek::property::ListLabelTypeInfo>() const
Line
Count
Source
61
1.19k
  {
62
1.19k
    return m_props.has<Property>(true);
63
1.19k
  }
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::OddPageMaster>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::EvenPageMaster>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::FirstPageMaster>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::ListStyle>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTHeaderColumnRepeatsProperty>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTHeaderRowRepeatsProperty>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTDefaultBodyCellStyleProperty>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTDefaultHeaderRowCellStyleProperty>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTDefaultHeaderColumnCellStyleProperty>() const
Unexecuted instantiation: bool libetonyek::IWORKStyle::has<libetonyek::property::SFTDefaultFooterRowCellStyleProperty>() const
64
65
  /** Retrieve the value of a property.
66
    *
67
    * @returns the found value
68
    */
69
  template<class Property>
70
  const typename IWORKPropertyInfo<Property>::ValueType &get() const
71
12.3k
  {
72
12.3k
    return m_props.get<Property>(true);
73
12.3k
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::Alignment>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::Alignment>() const
Line
Count
Source
71
23
  {
72
23
    return m_props.get<Property>(true);
73
23
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::VerticalAlignment>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::VerticalAlignment>() const
Line
Count
Source
71
240
  {
72
240
    return m_props.get<Property>(true);
73
240
  }
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::DropCap>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::DropCap>() const
libetonyek::IWORKPropertyInfo<libetonyek::property::ListLevelStyles>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLevelStyles>() const
Line
Count
Source
71
737
  {
72
737
    return m_props.get<Property>(true);
73
737
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::SFTTableBandedCellFillProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTTableBandedCellFillProperty>() const
Line
Count
Source
71
42
  {
72
42
    return m_props.get<Property>(true);
73
42
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::SFTTableBandedRowsProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTTableBandedRowsProperty>() const
Line
Count
Source
71
35
  {
72
35
    return m_props.get<Property>(true);
73
35
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::Opacity>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::Opacity>() const
Line
Count
Source
71
1.77k
  {
72
1.77k
    return m_props.get<Property>(true);
73
1.77k
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::Fill>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::Fill>() const
Line
Count
Source
71
2.85k
  {
72
2.85k
    return m_props.get<Property>(true);
73
2.85k
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::Stroke>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::Stroke>() const
Line
Count
Source
71
1.79k
  {
72
1.79k
    return m_props.get<Property>(true);
73
1.79k
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::TailLineEnd>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::TailLineEnd>() const
Line
Count
Source
71
41
  {
72
41
    return m_props.get<Property>(true);
73
41
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::HeadLineEnd>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::HeadLineEnd>() const
Line
Count
Source
71
57
  {
72
57
    return m_props.get<Property>(true);
73
57
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::Shadow>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::Shadow>() const
Line
Count
Source
71
1.78k
  {
72
1.78k
    return m_props.get<Property>(true);
73
1.78k
  }
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::Padding>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::Padding>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::ExternalTextWrap>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ExternalTextWrap>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::LayoutStyle>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::LayoutStyle>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::ListLabelGeometries>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLabelGeometries>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::ListLabelIndents>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLabelIndents>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::ListTextIndents>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListTextIndents>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::ListLabelTypes>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLabelTypes>() const
libetonyek::IWORKPropertyInfo<libetonyek::property::SFTStrokeProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTStrokeProperty>() const
Line
Count
Source
71
103
  {
72
103
    return m_props.get<Property>(true);
73
103
  }
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTCellStylePropertyNumberFormat>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTCellStylePropertyNumberFormat>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTCellStylePropertyDateTimeFormat>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTCellStylePropertyDateTimeFormat>() const
libetonyek::IWORKPropertyInfo<libetonyek::property::ListLabelGeometry>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLabelGeometry>() const
Line
Count
Source
71
569
  {
72
569
    return m_props.get<Property>(true);
73
569
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::ListLabelIndent>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLabelIndent>() const
Line
Count
Source
71
572
  {
72
572
    return m_props.get<Property>(true);
73
572
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::ListTextIndent>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListTextIndent>() const
Line
Count
Source
71
569
  {
72
569
    return m_props.get<Property>(true);
73
569
  }
libetonyek::IWORKPropertyInfo<libetonyek::property::ListLabelTypeInfo>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListLabelTypeInfo>() const
Line
Count
Source
71
1.17k
  {
72
1.17k
    return m_props.get<Property>(true);
73
1.17k
  }
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::OddPageMaster>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::OddPageMaster>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::EvenPageMaster>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::EvenPageMaster>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::FirstPageMaster>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::FirstPageMaster>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::ListStyle>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::ListStyle>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTHeaderColumnRepeatsProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTHeaderColumnRepeatsProperty>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTHeaderRowRepeatsProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTHeaderRowRepeatsProperty>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTDefaultBodyCellStyleProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTDefaultBodyCellStyleProperty>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTDefaultHeaderRowCellStyleProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTDefaultHeaderRowCellStyleProperty>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTDefaultHeaderColumnCellStyleProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTDefaultHeaderColumnCellStyleProperty>() const
Unexecuted instantiation: libetonyek::IWORKPropertyInfo<libetonyek::property::SFTDefaultFooterRowCellStyleProperty>::ValueType const& libetonyek::IWORKStyle::get<libetonyek::property::SFTDefaultFooterRowCellStyleProperty>() const
74
75
  const boost::optional<std::string> &getIdent() const;
76
77
  void setParent(const IWORKStylePtr_t parent);
78
79
  /// Creates the list level properties of a list style if it does not exists
80
  void createListLevelStyles();
81
82
protected:
83
  const boost::optional<std::string> &getParentIdent() const;
84
  const IWORKStylePtr_t getParent() const;
85
86
private:
87
  IWORKPropertyMap m_props;
88
89
  const boost::optional<std::string> m_ident;
90
  const boost::optional<std::string> m_parentIdent;
91
  IWORKStylePtr_t m_parent;
92
};
93
94
}
95
96
#endif // IWORKSTYLE_H_INCLUDED
97
98
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */