27
27
#include "WP42Listener.h"
28
#include "WP42FileStructure.h"
29
#include "libwpd_internal.h"
31
_WP42ParsingState::_WP42ParsingState()
36
_WP42ParsingState::~_WP42ParsingState()
42
WP42Listener::WP42Listener(std::vector<WPXPageSpan *> *pageList, WPXHLListenerImpl *listenerImpl) :
43
WPXListener(pageList, listenerImpl),
44
m_parseState(new WP42ParsingState)
48
WP42Listener::~WP42Listener()
54
/****************************************
55
public 'HLListenerImpl' functions
56
*****************************************/
58
void WP42Listener::insertCharacter(const uint16_t character)
60
if (m_ps->m_isSpanOpened)
62
appendUCS4(m_parseState->m_textBuffer, (uint32_t)character);
65
void WP42Listener::insertTab(const uint8_t tabType, const float tabPosition)
69
if (!m_ps->m_isSpanOpened)
74
m_listenerImpl->insertTab();
78
void WP42Listener::insertEOL()
82
if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened)
84
if (m_ps->m_isParagraphOpened)
86
if (m_ps->m_isListElementOpened)
91
void WP42Listener::endDocument()
97
m_listenerImpl->endDocument();
101
/****************************************
102
public 'parser' functions
103
*****************************************/
105
void WP42Listener::attributeChange(const bool isOn, const uint8_t attribute)
109
uint32_t textAttributeBit = 0;
111
// FIXME: handle all the possible attribute bits
114
/*case WP42_ATTRIBUTE_SUBSCRIPT:
115
textAttributeBit = WPX_SUBSCRIPT_BIT;
117
case WP42_ATTRIBUTE_SUPERSCRIPT:
118
textAttributeBit = WPX_SUPERSCRIPT_BIT;
120
case WP42_ATTRIBUTE_OUTLINE:
121
textAttributeBit = WPX_OUTLINE_BIT;
123
case WP42_ATTRIBUTE_ITALICS:
124
textAttributeBit = WPX_ITALICS_BIT;
126
case WP42_ATTRIBUTE_SHADOW:
127
textAttributeBit = WPX_SHADOW_BIT;
129
case WP42_ATTRIBUTE_REDLINE:
130
textAttributeBit = WPX_REDLINE_BIT;
132
/*case WP42_ATTRIBUTE_DOUBLE_UNDERLINE:
133
textAttributeBit = WPX_DOUBLE_UNDERLINE_BIT;
135
case WP42_ATTRIBUTE_BOLD:
136
textAttributeBit = WPX_BOLD_BIT;
138
case WP42_ATTRIBUTE_STRIKE_OUT:
139
textAttributeBit = WPX_STRIKEOUT_BIT;
141
case WP42_ATTRIBUTE_UNDERLINE:
142
textAttributeBit = WPX_UNDERLINE_BIT;
147
m_ps->m_textAttributeBits |= textAttributeBit;
149
m_ps->m_textAttributeBits ^= textAttributeBit;
152
/****************************************
154
*****************************************/
156
void WP42Listener::_flushText()
158
if (m_parseState->m_textBuffer.len())
159
m_listenerImpl->insertText(m_parseState->m_textBuffer);
160
m_parseState->m_textBuffer.clear();
29
WP42Listener::WP42Listener(std::list<WPXPageSpan> &pageList, WPXHLListenerImpl *listenerImpl)