Coverage Report

Created: 2026-10-28 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libetonyek/src/lib/contexts/IWORKShapeContext.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 "IWORKShapeContext.h"
11
12
#include <cassert>
13
14
#include <boost/optional.hpp>
15
16
#include "libetonyek_xml.h"
17
#include "IWORKCollector.h"
18
#include "IWORKDictionary.h"
19
#include "IWORKGeometryElement.h"
20
#include "IWORKPathElement.h"
21
#include "IWORKRefContext.h"
22
#include "IWORKStyleContainer.h"
23
#include "IWORKTextElement.h"
24
#include "IWORKToken.h"
25
#include "IWORKWrapElement.h"
26
#include "IWORKXMLParserState.h"
27
28
namespace libetonyek
29
{
30
31
namespace
32
{
33
typedef IWORKStyleContainer<+IWORKToken::NS_URI_SF | IWORKToken::graphic_style, +IWORKToken::NS_URI_SF | IWORKToken::graphic_style_ref> GraphicStyleContext;
34
}
35
36
IWORKShapeContext::IWORKShapeContext(IWORKXMLParserState &state)
37
0
  : IWORKXMLElementContextBase(state)
38
0
  , m_style()
39
0
  , m_wrap()
40
0
  , m_order()
41
0
  , m_locked(false)
42
0
{
43
0
}
44
45
void IWORKShapeContext::attribute(const int name, const char *const value)
46
0
{
47
0
  switch (name)
48
0
  {
49
0
  case +IWORKToken::sfclass | IWORKToken::NS_URI_SFA : // shape
50
0
    break;
51
0
  case +IWORKToken::locked | IWORKToken::NS_URI_SF :
52
0
    m_locked=bool_cast(value);
53
0
    break;
54
0
  case +IWORKToken::ID | IWORKToken::NS_URI_SFA :
55
0
    IWORKXMLElementContextBase::attribute(name, value);
56
0
    break;
57
0
  default :
58
0
  {
59
    // find also can-autosize-h, can-autosize-v, key:inheritance, key:tag
60
0
    static bool first=true;
61
0
    if (first)
62
0
    {
63
0
      first=false;
64
0
      ETONYEK_DEBUG_MSG(("IWORKShapeContext::attribute: find some unknown attributes\n"));
65
0
    }
66
0
    IWORKXMLElementContextBase::attribute(name, value);
67
0
  }
68
0
  }
69
0
}
70
71
void IWORKShapeContext::startOfElement()
72
0
{
73
0
  if (isCollector())
74
0
  {
75
0
    getCollector().startLevel();
76
0
    assert(!getState().m_currentText);
77
0
    getState().m_currentText = getCollector().createText(getState().m_langManager);
78
0
  }
79
0
}
80
81
IWORKXMLContextPtr_t IWORKShapeContext::element(const int name)
82
0
{
83
0
  switch (name)
84
0
  {
85
0
  case +IWORKToken::NS_URI_SF | IWORKToken::geometry :
86
0
    return std::make_shared<IWORKGeometryElement>(getState());
87
0
  case +IWORKToken::NS_URI_SF | IWORKToken::path :
88
0
    return std::make_shared<IWORKPathElement>(getState());
89
0
  case +IWORKToken::NS_URI_SF | IWORKToken::style :
90
0
    return std::make_shared<GraphicStyleContext>(getState(), m_style, getState().getDictionary().m_graphicStyles);
91
0
  case +IWORKToken::NS_URI_SF | IWORKToken::text :
92
0
    return std::make_shared<IWORKTextElement>(getState());
93
0
  case +IWORKToken::NS_URI_SF | IWORKToken::wrap : // USEME
94
0
    return std::make_shared<IWORKWrapElement>(getState(), m_wrap);
95
0
  default:
96
0
    ETONYEK_DEBUG_MSG(("IWORKShapeContext::element: find some unknown element\n"));
97
0
    break;
98
0
  }
99
100
0
  return IWORKXMLContextPtr_t();
101
0
}
102
103
void IWORKShapeContext::endOfElement()
104
0
{
105
  // CHECKME: do we need to store shape with ID ?
106
0
  if (isCollector())
107
0
  {
108
0
    if (m_style)
109
0
      getCollector().setGraphicStyle(m_style);
110
0
    getCollector().collectText(getState().m_currentText);
111
0
    getState().m_currentText.reset();
112
0
    getCollector().collectShape(m_order, boost::none, m_locked);
113
0
    getCollector().endLevel();
114
0
  }
115
0
}
116
117
}
118
119
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */