~ubuntu-branches/ubuntu/utopic/writerperfect/utopic

« back to all changes in this revision

Viewing changes to src/DiskDocumentHandler.cxx

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2014-06-07 08:42:43 UTC
  • mfrom: (1.2.6) (2.1.15 sid)
  • Revision ID: package-import@ubuntu.com-20140607084243-d6zo1kx2ahp5uitb
Tags: 0.9.0-2
add missing build-dep on libboost-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
 
/* writerperfect
3
 
 * Version: MPL 2.0 / LGPLv2.1+
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
 
 * Major Contributor(s):
10
 
 * Copyright (C) 2002-2004 William Lachance (wrlach@gmail.com)
11
 
 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
12
 
 *
13
 
 * For minor contributions see the git repository.
14
 
 *
15
 
 * Alternatively, the contents of this file may be used under the terms
16
 
 * of the GNU Lesser General Public License Version 2.1 or later
17
 
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18
 
 * applicable instead of those above.
19
 
 *
20
 
 * For further information visit http://libwpd.sourceforge.net
21
 
 */
22
 
 
23
 
#include "DiskDocumentHandler.hxx"
24
 
 
25
 
#include <string.h>
26
 
 
27
 
#ifdef USE_GSF_OUTPUT
28
 
#define PUTSTRING(M) gsf_output_puts(mpOutput, M)
29
 
DiskOdfDocumentHandler::DiskOdfDocumentHandler(GsfOutput *pOutput) :
30
 
#else
31
 
#define PUTSTRING(M) mpOutput->writeString(M)
32
 
DiskOdfDocumentHandler::DiskOdfDocumentHandler(FemtoZip *pOutput) :
33
 
#endif
34
 
        mpOutput(pOutput),
35
 
        mbIsTagOpened(false),
36
 
        msOpenedTagName()
37
 
{
38
 
}
39
 
 
40
 
void DiskOdfDocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
41
 
{
42
 
        if (mbIsTagOpened)
43
 
        {
44
 
                PUTSTRING(">");
45
 
                mbIsTagOpened = false;
46
 
        }
47
 
        PUTSTRING("<");
48
 
        PUTSTRING(psName);
49
 
        WPXPropertyList::Iter i(xPropList);
50
 
        for (i.rewind(); i.next(); )
51
 
        {
52
 
                // filter out libwpd elements
53
 
                if (strncmp(i.key(), "libwpd", 6) != 0)
54
 
                {
55
 
                        PUTSTRING(" ");
56
 
                        PUTSTRING(i.key());
57
 
                        PUTSTRING("=\"");
58
 
                        PUTSTRING(i()->getStr().cstr());
59
 
                        PUTSTRING("\"");
60
 
                }
61
 
 
62
 
        }
63
 
        mbIsTagOpened = true;
64
 
        msOpenedTagName.sprintf("%s", psName);
65
 
}
66
 
 
67
 
void DiskOdfDocumentHandler::endElement(const char *psName)
68
 
{
69
 
        if (mbIsTagOpened)
70
 
        {
71
 
                if( msOpenedTagName == psName )
72
 
                {
73
 
                        PUTSTRING("/>");
74
 
                        mbIsTagOpened = false;
75
 
                }
76
 
                else // should not happen, but handle it
77
 
                {
78
 
                        PUTSTRING(">");
79
 
                        PUTSTRING("</");
80
 
                        PUTSTRING(psName);
81
 
                        PUTSTRING(">");
82
 
                        mbIsTagOpened = false;
83
 
                }
84
 
        }
85
 
        else
86
 
        {
87
 
                PUTSTRING("</");
88
 
                PUTSTRING(psName);
89
 
                PUTSTRING(">");
90
 
                mbIsTagOpened = false;
91
 
        }
92
 
}
93
 
 
94
 
void DiskOdfDocumentHandler::characters(const WPXString &sCharacters)
95
 
{
96
 
        if (mbIsTagOpened)
97
 
        {
98
 
                PUTSTRING(">");
99
 
                mbIsTagOpened = false;
100
 
        }
101
 
        WPXString sEscapedCharacters(sCharacters, true);
102
 
        if (sEscapedCharacters.len() > 0)
103
 
                PUTSTRING(sEscapedCharacters.cstr());
104
 
}
105
 
 
106
 
void DiskOdfDocumentHandler::endDocument()
107
 
{
108
 
        if (mbIsTagOpened)
109
 
        {
110
 
                PUTSTRING(">");
111
 
                mbIsTagOpened = false;
112
 
        }
113
 
}
114
 
 
115
 
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */