ABWParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libabw 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 #ifndef __ABWPARSER_H__
11 #define __ABWPARSER_H__
12
13 #include <memory>
14
15 #include <librevenge/librevenge.h>
16 #include "ABWXMLHelper.h"
17
18 namespace libabw
19 {
20
21 class ABWCollector;
22 struct ABWParserState;
23
24 class ABWParser
25 {
26 public:
27 explicit ABWParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *iface);
28 virtual ~ABWParser();
29 bool parse();
30
31 private:
32 ABWParser();
33 ABWParser(const ABWParser &);
34 ABWParser &operator=(const ABWParser &);
35
36 // Helper functions
37
38 int getElementToken(xmlTextReaderPtr reader);
39
40 // Functions to read the AWML document structure
41
42 bool processXmlDocument(librevenge::RVNGInputStream *input);
43 int processXmlNode(xmlTextReaderPtr reader);
44
45 void readAbiword(xmlTextReaderPtr reader);
46 void readM(xmlTextReaderPtr reader);
47 int readHistory(xmlTextReaderPtr reader);
48 int readRevisions(xmlTextReaderPtr reader);
49 int readIgnoredWords(xmlTextReaderPtr reader);
50 void readPageSize(xmlTextReaderPtr reader);
51 void readSection(xmlTextReaderPtr reader);
52 void readA(xmlTextReaderPtr reader);
53 void readC(xmlTextReaderPtr reader);
54 int readD(xmlTextReaderPtr reader);
55 void readL(xmlTextReaderPtr reader);
56 void readP(xmlTextReaderPtr reader);
57 void readS(xmlTextReaderPtr reader);
58 void readEndnote(xmlTextReaderPtr reader);
59 void readFoot(xmlTextReaderPtr reader);
60 void readField(xmlTextReaderPtr reader);
61 void readImage(xmlTextReaderPtr reader);
62
63 void readTable(xmlTextReaderPtr reader);
64 void readCell(xmlTextReaderPtr reader);
65
66 void readFrame(xmlTextReaderPtr reader);
67 void readCloseFrame();
68
69 librevenge::RVNGInputStream *m_input;
70 librevenge::RVNGTextInterface *m_iface;
71 std::unique_ptr<ABWCollector> m_collector;
72 std::unique_ptr<ABWParserState> m_state;
73 };
74
75 } // namespace libabw
76
77 #endif // __ABWPARSER_H__
78 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libabw::ABWContentCollector
Definition: ABWContentCollector.h:119
XML_REVISIONS
const int XML_REVISIONS
Definition: tokens.h:31
libabw::ABWOutputElements
Definition: ABWOutputElements.h:25
libabw::ABWParser::readM
void readM(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:390
libabw::ABWParser::~ABWParser
virtual ~ABWParser()
Definition: ABWParser.cpp:136
libabw::ABWParserState::m_inMetadata
bool m_inMetadata
Definition: ABWParser.cpp:109
XML_L
const int XML_L
Definition: tokens.h:24
libabw::ABWParser::readAbiword
void readAbiword(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:383
libabw::ABWParserState
Definition: ABWParser.cpp:102
libabw::ABWParser::readTable
void readTable(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:636
libabw::ABWParser::getElementToken
int getElementToken(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:378
XML_CBR
const int XML_CBR
Definition: tokens.h:10
libabw::ABWParserState::m_data
std::map< std::string, ABWData > m_data
Definition: ABWParser.cpp:106
XML_BR
const int XML_BR
Definition: tokens.h:8
libabw::ABWParser::readField
void readField(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:619
libabw::xmlReaderForStream
std::unique_ptr< xmlTextReader, void(*)(xmlTextReaderPtr)> xmlReaderForStream(librevenge::RVNGInputStream *input, ABWXMLProgressWatcher *watcher)
Definition: ABWXMLHelper.cpp:131
libabw::ABWStylesCollector
Definition: ABWStylesCollector.h:44
libabw::ABWXMLString::get
const xmlChar * get() const
Definition: ABWXMLHelper.cpp:85
libabw_internal.h
libabw::ABWParser::processXmlNode
int processXmlNode(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:186
XML_A
const int XML_A
Definition: tokens.h:4
XML_IMAGE
const int XML_IMAGE
Definition: tokens.h:22
XML_M
const int XML_M
Definition: tokens.h:26
XML_IGNOREDWORDS
const int XML_IGNOREDWORDS
Definition: tokens.h:21
libabw::ABWXMLProgressWatcher
Definition: ABWXMLHelper.h:38
XML_METADATA
const int XML_METADATA
Definition: tokens.h:27
XML_PAGESIZE
const int XML_PAGESIZE
Definition: tokens.h:29
libabw::ABWParser::m_collector
std::unique_ptr< ABWCollector > m_collector
Definition: ABWParser.h:71
ABWXMLTokenMap.h
libabw::ABWXMLString
Definition: ABWXMLHelper.h:25
XML_TABLE
const int XML_TABLE
Definition: tokens.h:35
ABWParser.h
libabw::ABWParser::readPageSize
void readPageSize(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:470
libabw::ABWParser::m_state
std::unique_ptr< ABWParserState > m_state
Definition: ABWParser.h:72
libabw::ABWParser::readP
void readP(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:591
libabw
Definition: AbiDocument.cpp:17
libabw::ABWParser::readIgnoredWords
int readIgnoredWords(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:446
XML_D
const int XML_D
Definition: tokens.h:12
libabw::ABWParserState::m_listElements
std::map< int, std::shared_ptr< ABWListElement > > m_listElements
Definition: ABWParser.cpp:107
libabw::ABWParser::readImage
void readImage(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:650
libabw::ABWParser::readEndnote
void readEndnote(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:612
libabw::ABWParser::readRevisions
int readRevisions(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:421
ABWXMLHelper.h
libabw::ABWParser::readS
void readS(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:560
ABWStylesCollector.h
libabw::ABWParser::readCell
void readCell(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:643
libabw::ABWParser::readL
void readL(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:694
libabw::ABWParser::ABWParser
ABWParser(const ABWParser &)
XML_C
const int XML_C
Definition: tokens.h:9
libabw::ABWParser::readCloseFrame
void readCloseFrame()
Definition: ABWParser.cpp:674
XML_FRAME
const int XML_FRAME
Definition: tokens.h:18
libabw::ABWParser::m_input
librevenge::RVNGInputStream * m_input
Definition: ABWParser.h:69
libabw::ABWParserState::ABWParserState
ABWParserState()
Definition: ABWParser.cpp:115
XML_PBR
const int XML_PBR
Definition: tokens.h:30
XML_ENDNOTE
const int XML_ENDNOTE
Definition: tokens.h:14
libabw::ABWParser::readFrame
void readFrame(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:658
libabw::ABWParser::readSection
void readSection(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:480
libabw::ABWParser::operator=
ABWParser & operator=(const ABWParser &)
libabw::ABWParserState::m_currentMetadataKey
std::string m_currentMetadataKey
Definition: ABWParser.cpp:110
libabw::ABWParser::parse
bool parse()
Definition: ABWParser.cpp:140
XML_S
const int XML_S
Definition: tokens.h:32
libabw::ABWXMLProgressWatcher::isStuck
bool isStuck() const
Definition: ABWXMLHelper.cpp:109
libabw::call_BAD_CAST_OnConst
static xmlChar * call_BAD_CAST_OnConst(char const *str)
Definition: AbiDocument.cpp:19
libabw::ABWParser
Definition: ABWParser.h:25
libabw::ABWParserState::m_collectorStack
std::stack< std::unique_ptr< ABWCollector > > m_collectorStack
Definition: ABWParser.cpp:112
libabw::ABWParser::m_iface
librevenge::RVNGTextInterface * m_iface
Definition: ABWParser.h:70
libabw::ABWParserState::m_tableSizes
std::map< int, int > m_tableSizes
Definition: ABWParser.cpp:105
libabw::ABWParserState::~ABWParserState
~ABWParserState()
Definition: ABWParser.cpp:126
libabw::ABWParser::ABWParser
ABWParser()
XML_CELL
const int XML_CELL
Definition: tokens.h:11
libabw::ABWParser::readA
void readA(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:584
XML_FOOT
const int XML_FOOT
Definition: tokens.h:17
libabw::ABWParserState::m_inStyleParsing
bool m_inStyleParsing
Definition: ABWParser.cpp:111
XML_TOKEN_INVALID
const int XML_TOKEN_INVALID
Definition: tokens.h:40
libabw::ABWParser::readHistory
int readHistory(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:397
XML_HISTORY
const int XML_HISTORY
Definition: tokens.h:19
libabw::ABWParser::readC
void readC(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:603
libabw::ABWParser::readFoot
void readFoot(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:629
libabw::ABWXMLTokenMap::getTokenId
static int getTokenId(const xmlChar *name)
Definition: ABWXMLTokenMap.cpp:20
ABWContentCollector.h
XML_P
const int XML_P
Definition: tokens.h:28
XML_FIELD
const int XML_FIELD
Definition: tokens.h:16
ABW_DEBUG_MSG
#define ABW_DEBUG_MSG(M)
Definition: libabw_internal.h:33
libabw::ABWParser::readD
int readD(xmlTextReaderPtr reader)
Definition: ABWParser.cpp:510
XML_SECTION
const int XML_SECTION
Definition: tokens.h:33
libabw::ABWParser::processXmlDocument
bool processXmlDocument(librevenge::RVNGInputStream *input)
Definition: ABWParser.cpp:164
XML_ABIWORD
const int XML_ABIWORD
Definition: tokens.h:5