Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libetonyek/src/lib/KEY1Dictionary.cpp
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
#include "KEY1Dictionary.h"
11
12
namespace libetonyek
13
{
14
15
KEY1Dictionary::KEY1Dictionary()
16
0
  : IWORKDictionary()
17
0
  , m_masterSlides()
18
0
  , m_slides()
19
0
  , m_styleContexts()
20
0
  , m_styleContextsMap()
21
0
{
22
0
  m_styleContexts.push_back(StylesContext());
23
0
}
24
25
KEY1Dictionary::StylesContext &KEY1Dictionary::getCurrentStylesContext()
26
0
{
27
0
  return m_styleContexts.back();
28
0
}
29
30
void KEY1Dictionary::pushStylesContext()
31
0
{
32
0
  m_styleContexts.push_back(StylesContext());
33
0
}
34
35
void KEY1Dictionary::popStylesContext()
36
0
{
37
0
  if (m_styleContexts.size()>1)
38
0
    m_styleContexts.pop_back();
39
0
  else
40
0
  {
41
0
    ETONYEK_DEBUG_MSG(("KEY1Dictionary::popCurrentStylesContext: oops style contexts must not be empty\n"));
42
0
  }
43
0
}
44
45
void KEY1Dictionary::collectStylesContext(const std::string &contextName)
46
0
{
47
0
  if (m_styleContexts.size()>1)
48
0
    m_styleContextsMap.insert(StylesContextMap_t::value_type(contextName,m_styleContexts.back()));
49
0
  else
50
0
  {
51
0
    ETONYEK_DEBUG_MSG(("KEY1Dictionary::popCurrentStylesContext: oops style contexts must not be empty\n"));
52
0
  }
53
0
}
54
55
void KEY1Dictionary::linkStylesContext(const boost::optional<std::string> &master)
56
0
{
57
0
  if (!master)
58
0
    getCurrentStylesContext().link(m_styleContexts.front());
59
0
  else if (m_styleContextsMap.find(get(master))!=m_styleContextsMap.end())
60
0
    getCurrentStylesContext().link(m_styleContextsMap.find(get(master))->second);
61
0
  else
62
0
  {
63
0
    ETONYEK_DEBUG_MSG(("KEY1Dictionary::linkStylesContext: oops can not find context %s\n", get(master).c_str()));
64
0
    getCurrentStylesContext().link(m_styleContexts.front());
65
0
  }
66
0
}
67
68
void KEY1Dictionary::storeImageStyle(IWORKStylePtr_t style, bool definition)
69
0
{
70
0
  getCurrentStylesContext().m_imageContext.storeStyle(style, definition);
71
0
}
72
73
void KEY1Dictionary::storeLineStyle(IWORKStylePtr_t style, bool definition)
74
0
{
75
0
  getCurrentStylesContext().m_lineContext.storeStyle(style, definition);
76
0
}
77
78
void KEY1Dictionary::storeShapeStyle(IWORKStylePtr_t style, bool definition)
79
0
{
80
0
  getCurrentStylesContext().m_shapeContext.storeStyle(style, definition);
81
0
}
82
83
void KEY1Dictionary::storeTextboxStyle(IWORKStylePtr_t style, bool definition)
84
0
{
85
0
  getCurrentStylesContext().m_textboxContext.storeStyle(style, definition);
86
0
}
87
88
KEYPlaceholderPtr_t KEY1Dictionary::getBodyPlaceholder()
89
0
{
90
0
  return getCurrentStylesContext().m_bodyPlaceholder;
91
0
}
92
93
KEYPlaceholderPtr_t KEY1Dictionary::getPageNumberPlaceholder()
94
0
{
95
0
  return getCurrentStylesContext().m_pageNumberPlaceholder;
96
0
}
97
98
KEYPlaceholderPtr_t KEY1Dictionary::getTitlePlaceholder()
99
0
{
100
0
  return getCurrentStylesContext().m_titlePlaceholder;
101
0
}
102
103
void KEY1Dictionary::storeBodyPlaceholder(KEYPlaceholderPtr_t placeHolder)
104
0
{
105
0
  getCurrentStylesContext().m_bodyPlaceholder=placeHolder;
106
0
}
107
108
void KEY1Dictionary::storePageNumberPlaceholder(KEYPlaceholderPtr_t placeHolder)
109
0
{
110
0
  getCurrentStylesContext().m_pageNumberPlaceholder=placeHolder;
111
0
}
112
113
void KEY1Dictionary::storeTitlePlaceholder(KEYPlaceholderPtr_t placeHolder)
114
0
{
115
0
  getCurrentStylesContext().m_titlePlaceholder=placeHolder;
116
0
}
117
118
KEY1Dictionary::StyleContext::StyleContext()
119
0
  : m_style()
120
0
  , m_styles()
121
0
{
122
0
}
123
124
void KEY1Dictionary::StyleContext::storeStyle(IWORKStylePtr_t style, bool definition)
125
0
{
126
0
  if (!style) return;
127
0
  if (definition)
128
0
    m_style=style;
129
0
  else
130
0
    m_styles.push_back(style);
131
0
}
132
133
void KEY1Dictionary::StyleContext::link(const KEY1Dictionary::StyleContext &parentContext)
134
0
{
135
0
  if (m_style)
136
0
    m_style->setParent(parentContext.m_style);
137
0
  else
138
0
    m_style=parentContext.m_style;
139
0
  if (m_style)
140
0
  {
141
0
    for (std::deque<IWORKStylePtr_t>::const_iterator it=m_styles.begin(); it!=m_styles.end(); ++it)
142
0
      (*it)->setParent(m_style);
143
0
  }
144
0
  m_styles.clear();
145
0
}
146
147
KEY1Dictionary::StylesContext::StylesContext()
148
0
  : m_imageContext()
149
0
  , m_lineContext()
150
0
  , m_shapeContext()
151
0
  , m_textboxContext()
152
0
  , m_bodyPlaceholder()
153
0
  , m_pageNumberPlaceholder()
154
0
  , m_titlePlaceholder()
155
0
{
156
0
}
157
158
void KEY1Dictionary::StylesContext::link(const KEY1Dictionary::StylesContext &parentContext)
159
0
{
160
0
  m_imageContext.link(parentContext.m_imageContext);
161
0
  m_lineContext.link(parentContext.m_lineContext);
162
0
  m_shapeContext.link(parentContext.m_shapeContext);
163
0
  m_textboxContext.link(parentContext.m_textboxContext);
164
165
0
  link(m_bodyPlaceholder, parentContext.m_bodyPlaceholder);
166
0
  link(m_pageNumberPlaceholder, parentContext.m_pageNumberPlaceholder);
167
0
  link(m_titlePlaceholder, parentContext.m_titlePlaceholder);
168
0
}
169
170
void KEY1Dictionary::StylesContext::link(KEYPlaceholderPtr_t &placeholder, const KEYPlaceholderPtr_t &parentHolder)
171
0
{
172
0
  if (!parentHolder)
173
0
    return;
174
0
  if (!placeholder)
175
0
  {
176
0
    placeholder=parentHolder;
177
0
    return;
178
0
  }
179
0
  if (!placeholder->m_geometry)
180
0
    placeholder->m_geometry=parentHolder->m_geometry;
181
0
  if (!placeholder->m_text)
182
0
    placeholder->m_text=parentHolder->m_text;
183
0
  if (!placeholder->m_visible)
184
0
    placeholder->m_visible=parentHolder->m_visible;
185
0
  if (placeholder->m_bulletIndentations.empty())
186
0
    placeholder->m_bulletIndentations=parentHolder->m_bulletIndentations;
187
0
  if (placeholder->m_style)
188
0
    placeholder->m_style->setParent(parentHolder->m_style);
189
0
  else
190
0
    placeholder->m_style=parentHolder->m_style;
191
0
  if (placeholder->m_paragraphStyle)
192
0
    placeholder->m_paragraphStyle->setParent(parentHolder->m_paragraphStyle);
193
0
  else
194
0
    placeholder->m_paragraphStyle=parentHolder->m_paragraphStyle;
195
0
  if (placeholder->m_spanStyle)
196
0
    placeholder->m_spanStyle->setParent(parentHolder->m_spanStyle);
197
0
  else
198
0
    placeholder->m_spanStyle=parentHolder->m_spanStyle;
199
0
}
200
}
201
202
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */