PocketWord.h Source File documentation

PocketWord.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* libwps
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) 2020 Laurent Alonso (alonso.laurent@gmail.com)
11 *
12 * For minor contributions see the git repository.
13 *
14 * Alternatively, the contents of this file may be used under the terms
15 * of the GNU Lesser General Public License Version 2.1 or later
16 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
17 * applicable instead of those above.
18 *
19 * For further information visit http://libwps.sourceforge.net
20 */
21
22#ifndef POCKET_WORD_H
23#define POCKET_WORD_H
24
25#include <memory>
26#include <vector>
27
28#include <librevenge-stream/librevenge-stream.h>
29#include "libwps_internal.h"
30#include "libwps_tools_win.h"
31
32#include "WPSParser.h"
33
34namespace PocketWordParserInternal
35{
36class SubDocument;
37
38struct State;
39}
40
45 class PocketWordParser : public WPSParser
46{
47 friend class PocketWordParserInternal::SubDocument;
48
49public:
51 PocketWordParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
52 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN);
54 ~PocketWordParser() override;
56 void parse(librevenge::RVNGTextInterface *documentInterface) override;
58 bool checkHeader(WPSHeader *header, bool strict=false);
59
60private:
61 PocketWordParser(const PocketWordParser &) = delete;
62 PocketWordParser &operator=(const PocketWordParser &) = delete;
63
65 std::shared_ptr<WPSContentListener> createListener(librevenge::RVNGTextInterface *interface);
66
67protected:
69 bool createZones();
71 bool readFontNames(WPSEntry const &entry);
73 bool readPageDims(WPSEntry const &entry);
75 bool readParagraphList(WPSEntry const &entry, std::vector<int> &paraId);
77 bool readParagraphDims(WPSEntry const &entry);
79 bool readParagraphUnkn(WPSEntry const &entry);
81 bool readSound(WPSEntry const &entry, WPSEmbeddedObject &object);
83 bool readSoundData(WPSEntry const &entry, long pictSize, WPSEmbeddedObject &object);
85 bool readUnkn8(WPSEntry const &entry);
87 bool readUnkn2021(WPSEntry const &entry, int type);
89 bool checkFilePosition(long pos) const;
91 void checkUnparsed();
92
94 void sendData();
96 bool sendParagraph(size_t paraId);
97
98 // State
99
101 std::shared_ptr<WPSContentListener> m_listener;
103 std::shared_ptr<PocketWordParserInternal::State> m_state;
104};
105
106#endif /* POCKET_WORD_H */
107/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSParser.h
PocketWordParser
This class parses some Pocket Word.
Definition: PocketWord.h:46
PocketWordParser::checkUnparsed
void checkUnparsed()
try to parse the unparsed zones
Definition: PocketWord.cpp:278
PocketWordParser::readPageDims
bool readPageDims(WPSEntry const &entry)
try to read the page dimension
Definition: PocketWord.cpp:445
PocketWordParser::readUnkn8
bool readUnkn8(WPSEntry const &entry)
try to read the unknown zone 8: one by file, maybe prefs
Definition: PocketWord.cpp:1165
PocketWordParser::~PocketWordParser
~PocketWordParser() override
destructor
Definition: PocketWord.cpp:132
PocketWordParser::readParagraphList
bool readParagraphList(WPSEntry const &entry, std::vector< int > &paraId)
try to read a paragraph list
Definition: PocketWord.cpp:966
PocketWordParser::PocketWordParser
PocketWordParser(const PocketWordParser &)=delete
PocketWordParser::readSound
bool readSound(WPSEntry const &entry, WPSEmbeddedObject &object)
try to read a sound definition (maybe a picture)
Definition: PocketWord.cpp:1016
PocketWordParser::sendData
void sendData()
try to send all the data
Definition: PocketWord.cpp:1298
PocketWordParser::m_state
std::shared_ptr< PocketWordParserInternal::State > m_state
the main state
Definition: PocketWord.h:103
PocketWordParser::sendParagraph
bool sendParagraph(size_t paraId)
try to read and send a paragraph
Definition: PocketWord.cpp:544
PocketWordParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) override
called by WPSDocument to parse the file
Definition: PocketWord.cpp:181
PocketWordParser::m_listener
std::shared_ptr< WPSContentListener > m_listener
the listener (if set)
Definition: PocketWord.h:101
PocketWordParser::createListener
std::shared_ptr< WPSContentListener > createListener(librevenge::RVNGTextInterface *interface)
creates the main listener
Definition: PocketWord.cpp:150
PocketWordParser::readParagraphDims
bool readParagraphDims(WPSEntry const &entry)
try to read a paragraph dimensions' zone which follows the paragraph zone
Definition: PocketWord.cpp:866
PocketWordParser::SubDocument
friend class PocketWordParserInternal::SubDocument
Definition: PocketWord.h:47
PocketWordParser::createZones
bool createZones()
try to read the different zones
Definition: PocketWord.cpp:221
PocketWordParser::readFontNames
bool readFontNames(WPSEntry const &entry)
try to read the font names
Definition: PocketWord.cpp:356
PocketWordParser::readUnkn2021
bool readUnkn2021(WPSEntry const &entry, int type)
try to read the unknown zone 20 and 21: one by file, find always no data, maybe style
Definition: PocketWord.cpp:1207
PocketWordParser::operator=
PocketWordParser & operator=(const PocketWordParser &)=delete
PocketWordParser::readParagraphUnkn
bool readParagraphUnkn(WPSEntry const &entry)
try to read a paragraph unknown zone: tabs, link?
Definition: PocketWord.cpp:909
PocketWordParser::checkFilePosition
bool checkFilePosition(long pos) const
check if the file position is correct or not
Definition: PocketWord.cpp:136
PocketWordParser::readSoundData
bool readSoundData(WPSEntry const &entry, long pictSize, WPSEmbeddedObject &object)
try to read a sound data (maybe a picture)
Definition: PocketWord.cpp:1124
PocketWordParser::checkHeader
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: PocketWord.cpp:1246
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:39
WPSHeader
Definition: WPSHeader.h:32
WPSParser
Definition: WPSParser.h:36
libwps_tools_win::Font::Type
Type
enum Type
Definition: libwps_tools_win.h:46
libwps_tools_win::Font::UNKNOWN
@ UNKNOWN
Definition: libwps_tools_win.h:63
libwps_internal.h
WPSHeaderPtr
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition: libwps_internal.h:109
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
libwps_tools_win.h
PocketWordParserInternal
Definition: PocketWord.cpp:47
WPSEmbeddedObject
small class use to define a embedded object
Definition: libwps_internal.h:1077