~ubuntu-branches/ubuntu/trusty/libwpd/trusty

« back to all changes in this revision

Viewing changes to src/lib/WP42Listener.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2006-06-11 23:56:17 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060611235617-ce504k38fuqe8twa
Tags: 0.8.5-2
* dpatch'ize 
* add patch from upstream fixing WP5 font handling regression

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* libwpd
2
2
 * Copyright (C) 2003 William Lachance (william.lachance@sympatico.ca)
3
 
 * Copyright (C) 2003-2004 Marc Maurer (j.m.maurer@student.utwente.nl)
 
3
 * Copyright (C) 2003-2004 Marc Maurer (uwog@uwog.net)
4
4
 * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
5
5
 *
6
6
 * This library is free software; you can redistribute it and/or
25
25
 */
26
26
 
27
27
#include "WP42Listener.h"
28
 
#include "WP42FileStructure.h"
29
 
#include "libwpd_internal.h"
30
 
 
31
 
_WP42ParsingState::_WP42ParsingState()
32
 
{
33
 
        m_textBuffer.clear();
34
 
}
35
 
 
36
 
_WP42ParsingState::~_WP42ParsingState()
37
 
{
38
 
        m_textBuffer.clear();
39
 
}
40
 
 
41
 
 
42
 
WP42Listener::WP42Listener(std::vector<WPXPageSpan *> *pageList, WPXHLListenerImpl *listenerImpl) :
43
 
        WPXListener(pageList, listenerImpl),
44
 
        m_parseState(new WP42ParsingState)
45
 
{
46
 
}
47
 
 
48
 
WP42Listener::~WP42Listener() 
49
 
{
50
 
        delete m_parseState;
51
 
}
52
 
 
53
 
 
54
 
/****************************************
55
 
 public 'HLListenerImpl' functions
56
 
*****************************************/
57
 
 
58
 
void WP42Listener::insertCharacter(const uint16_t character)
59
 
{
60
 
        if (m_ps->m_isSpanOpened)
61
 
                _openSpan();
62
 
        appendUCS4(m_parseState->m_textBuffer, (uint32_t)character);
63
 
}
64
 
 
65
 
void WP42Listener::insertTab(const uint8_t tabType, const float tabPosition)
66
 
{
67
 
        if (!isUndoOn())
68
 
        {
69
 
                if (!m_ps->m_isSpanOpened)
70
 
                        _openSpan();
71
 
                else
72
 
                        _flushText();
73
 
 
74
 
                m_listenerImpl->insertTab();
75
 
        }
76
 
}
77
 
 
78
 
void WP42Listener::insertEOL()
79
 
{
80
 
        if (!isUndoOn())
81
 
        {
82
 
                if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened)
83
 
                        _openSpan();
84
 
                if (m_ps->m_isParagraphOpened)
85
 
                        _closeParagraph();
86
 
                if (m_ps->m_isListElementOpened)
87
 
                        _closeListElement();
88
 
        }
89
 
}
90
 
 
91
 
void WP42Listener::endDocument()
92
 
{
93
 
        _closeSpan();
94
 
        _closeParagraph();
95
 
        _closeSection();
96
 
        _closePageSpan();
97
 
        m_listenerImpl->endDocument();
98
 
}
99
 
 
100
 
 
101
 
/****************************************
102
 
 public 'parser' functions
103
 
*****************************************/
104
 
 
105
 
void WP42Listener::attributeChange(const bool isOn, const uint8_t attribute)
106
 
{
107
 
        _closeSpan();
108
 
 
109
 
        uint32_t textAttributeBit = 0;
110
 
 
111
 
        // FIXME: handle all the possible attribute bits
112
 
        switch (attribute)
113
 
        {
114
 
        /*case WP42_ATTRIBUTE_SUBSCRIPT:
115
 
                textAttributeBit = WPX_SUBSCRIPT_BIT;
116
 
                break;
117
 
        case WP42_ATTRIBUTE_SUPERSCRIPT:
118
 
                textAttributeBit = WPX_SUPERSCRIPT_BIT;
119
 
                break;
120
 
        case WP42_ATTRIBUTE_OUTLINE:
121
 
                textAttributeBit = WPX_OUTLINE_BIT;
122
 
                break;*/
123
 
        case WP42_ATTRIBUTE_ITALICS:
124
 
                textAttributeBit = WPX_ITALICS_BIT;
125
 
                break;
126
 
        case WP42_ATTRIBUTE_SHADOW:
127
 
                textAttributeBit = WPX_SHADOW_BIT;
128
 
                break;
129
 
        case WP42_ATTRIBUTE_REDLINE:
130
 
                textAttributeBit = WPX_REDLINE_BIT;
131
 
                break;
132
 
        /*case WP42_ATTRIBUTE_DOUBLE_UNDERLINE:
133
 
                textAttributeBit = WPX_DOUBLE_UNDERLINE_BIT;
134
 
                break;                  */
135
 
        case WP42_ATTRIBUTE_BOLD:
136
 
                textAttributeBit = WPX_BOLD_BIT;
137
 
                break;
138
 
        case WP42_ATTRIBUTE_STRIKE_OUT:
139
 
                textAttributeBit = WPX_STRIKEOUT_BIT;
140
 
                break;
141
 
        case WP42_ATTRIBUTE_UNDERLINE:
142
 
                textAttributeBit = WPX_UNDERLINE_BIT;
143
 
                break;
144
 
        }
145
 
 
146
 
        if (isOn)
147
 
                m_ps->m_textAttributeBits |= textAttributeBit;
148
 
        else
149
 
                m_ps->m_textAttributeBits ^= textAttributeBit;
150
 
}
151
 
 
152
 
/****************************************
153
 
 private functions
154
 
*****************************************/
155
 
 
156
 
void WP42Listener::_flushText()
157
 
{
158
 
        if (m_parseState->m_textBuffer.len())
159
 
                m_listenerImpl->insertText(m_parseState->m_textBuffer);
160
 
        m_parseState->m_textBuffer.clear();
 
28
 
 
29
WP42Listener::WP42Listener(std::list<WPXPageSpan> &pageList, WPXHLListenerImpl *listenerImpl)
 
30
{
161
31
}