Coverage Report

Created: 2026-07-20 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libetonyek/src/lib/contexts/IWORKHeaderFooterContext.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 "IWORKHeaderFooterContext.h"
11
12
#include <cassert>
13
14
#include "IWORKCollector.h"
15
#include "IWORKTextStorageElement.h"
16
#include "IWORKToken.h"
17
#include "IWORKXMLParserState.h"
18
19
namespace libetonyek
20
{
21
22
IWORKHeaderFooterContext::IWORKHeaderFooterContext(IWORKXMLParserState &state, const CollectFunction_t &collect)
23
0
  : IWORKXMLElementContextBase(state)
24
0
  , m_collect(collect)
25
0
  , m_name()
26
0
{
27
0
}
28
29
void IWORKHeaderFooterContext::startOfElement()
30
0
{
31
0
  if (isCollector())
32
0
  {
33
0
    assert(!getState().m_currentText);
34
0
    getState().m_currentText = getCollector().createText(getState().m_langManager, true);
35
0
  }
36
0
}
37
38
void IWORKHeaderFooterContext::attribute(const int name, const char *const value)
39
0
{
40
0
  if (name == (+IWORKToken::NS_URI_SF | IWORKToken::name))
41
0
    m_name = value;
42
0
  else
43
0
    IWORKXMLElementContextBase::attribute(name, value);
44
0
}
45
46
IWORKXMLContextPtr_t IWORKHeaderFooterContext::element(const int name)
47
0
{
48
0
  if (name == (+IWORKToken::NS_URI_SF | IWORKToken::text_storage))
49
0
    return std::make_shared<IWORKTextStorageElement>(getState());
50
0
  return IWORKXMLContextPtr_t();
51
0
}
52
53
void IWORKHeaderFooterContext::endOfElement()
54
0
{
55
0
  if (isCollector())
56
0
  {
57
0
    getCollector().collectText(getState().m_currentText);
58
0
    getState().m_currentText.reset();
59
0
    if (m_name)
60
0
      m_collect(get(m_name));
61
0
  }
62
0
}
63
64
}
65
66
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */