Coverage Report

Created: 2026-06-13 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libetonyek/src/lib/KEY2ParserState.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 "KEY2ParserState.h"
11
12
#include "IWORKText.h"
13
14
#include "KEY2Dictionary.h"
15
#include "KEY2Parser.h"
16
#include "KEYCollector.h"
17
18
namespace libetonyek
19
{
20
21
KEY2ParserState::KEY2ParserState(KEY2Parser &parser, KEYCollector &collector, KEY2Dictionary &dict)
22
0
  : IWORKXMLParserState(parser, collector, dict)
23
0
  , m_version(0)
24
0
  , m_dict(dict)
25
0
  , m_collector(collector)
26
0
  , m_isHeadlineOpened(false)
27
0
  , m_isBulletsOpened(false)
28
0
  , m_bodyText()
29
0
  , m_titleText()
30
0
{
31
0
}
32
33
void KEY2ParserState::setVersion(unsigned version)
34
0
{
35
0
  m_version=version;
36
0
}
37
38
unsigned KEY2ParserState::getVersion() const
39
0
{
40
0
  return m_version;
41
0
}
42
43
KEY2Dictionary &KEY2ParserState::getDictionary()
44
0
{
45
0
  return m_dict;
46
0
}
47
48
KEYCollector &KEY2ParserState::getCollector()
49
0
{
50
0
  return m_collector;
51
0
}
52
53
IWORKTextPtr_t KEY2ParserState::getBodyText()
54
0
{
55
0
  return m_bodyText;
56
0
}
57
58
IWORKTextPtr_t KEY2ParserState::getTitleText()
59
0
{
60
0
  return m_titleText;
61
0
}
62
63
void KEY2ParserState::openBullets()
64
0
{
65
0
  if (m_isBulletsOpened)
66
0
  {
67
0
    ETONYEK_DEBUG_MSG(("KEY2ParserState::openBullets: oops the bullets are already opened\n"));
68
0
    return;
69
0
  }
70
0
  m_isBulletsOpened=true;
71
0
  m_bodyText.reset();
72
0
  m_titleText.reset();
73
0
}
74
75
void KEY2ParserState::openHeadline(int depth)
76
0
{
77
0
  if (m_isHeadlineOpened)
78
0
  {
79
0
    ETONYEK_DEBUG_MSG(("KEY2ParserState::openHeadline: oops the headline are already opened\n"));
80
0
    return;
81
0
  }
82
0
  m_isHeadlineOpened=true;
83
0
  assert(!m_currentText);
84
0
  if (depth==0)
85
0
  {
86
0
    if (!m_titleText)
87
0
      m_titleText=m_collector.createText(m_langManager, true);
88
0
    m_currentText=m_titleText;
89
0
  }
90
0
  else
91
0
  {
92
0
    if (!m_bodyText)
93
0
      m_bodyText=m_collector.createText(m_langManager, true);
94
0
    m_currentText=m_bodyText;
95
0
  }
96
0
}
97
98
void KEY2ParserState::closeHeadline()
99
0
{
100
0
  if (!m_isHeadlineOpened)
101
0
  {
102
0
    ETONYEK_DEBUG_MSG(("KEY2ParserState::openHeadline: oops the headline are already close\n"));
103
0
    return;
104
0
  }
105
0
  m_isHeadlineOpened=false;
106
0
  if (m_currentText)
107
0
  {
108
0
    m_currentText->flushParagraph();
109
0
    m_currentText.reset();
110
0
  }
111
0
}
112
113
void KEY2ParserState::closeBullets()
114
0
{
115
0
  if (!m_isBulletsOpened)
116
0
  {
117
0
    ETONYEK_DEBUG_MSG(("KEY2ParserState::openBullets: oops the bullets are already close\n"));
118
0
    return;
119
0
  }
120
0
  m_isBulletsOpened=false;
121
0
  m_bodyText.reset();
122
0
  m_titleText.reset();
123
0
}
124
125
}
126
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */