XYWrite.h Source File documentation

XYWrite.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 XY_WRITE_H
23#define XY_WRITE_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 XYWriteParserInternal
35{
36class SubDocument;
37
38struct Cell;
39struct Format;
40struct State;
41}
42
47 class XYWriteParser : public WPSParser
48{
49 friend struct XYWriteParserInternal::Cell;
50 friend class XYWriteParserInternal::SubDocument;
51
52public:
54 XYWriteParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
55 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN);
57 ~XYWriteParser() override;
59 void parse(librevenge::RVNGTextInterface *documentInterface) override;
61 bool checkHeader(WPSHeader *header, bool strict=false);
62
63private:
64 XYWriteParser(const XYWriteParser &) = delete;
65 XYWriteParser &operator=(const XYWriteParser &) = delete;
66
68 std::shared_ptr<WPSContentListener> createListener(librevenge::RVNGTextInterface *interface);
69
70protected:
72 bool checkFilePosition(long pos) const;
74 bool findAllZones();
76 bool parseTextZone(WPSEntry const &entry, std::string const &styleName="");
78 bool parseFrameZone(XYWriteParserInternal::Format const &frameFormat);
80 bool parsePictureZone(XYWriteParserInternal::Format const &pictureFormat);
82 bool parseMetaData(WPSEntry const &entry);
84 bool parseFormat(XYWriteParserInternal::Format &format);
86 bool createFormatChildren(XYWriteParserInternal::Format &format, size_t fPos=2);
88 bool update(XYWriteParserInternal::Format const &format, libwps_tools_win::Font::Type &fontType) const;
90 bool createTable(XYWriteParserInternal::Format const &format, long endPos);
91
92 // State
93
95 std::shared_ptr<WPSContentListener> m_listener;
97 std::shared_ptr<XYWriteParserInternal::State> m_state;
98};
99
100#endif /* MS_WRITE_H */
101/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSParser.h
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
XYWriteParserInternal::SubDocument
Internal: the subdocument of a XYWriteParser.
Definition: XYWrite.cpp:604
XYWriteParser
This class parses XYWrite Dos and Win4 files.
Definition: XYWrite.h:48
XYWriteParser::operator=
XYWriteParser & operator=(const XYWriteParser &)=delete
XYWriteParser::XYWriteParser
XYWriteParser(const XYWriteParser &)=delete
XYWriteParser::parseMetaData
bool parseMetaData(WPSEntry const &entry)
tries to parse the meta data zone
Definition: XYWrite.cpp:1572
XYWriteParser::checkHeader
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: XYWrite.cpp:1790
XYWriteParser::checkFilePosition
bool checkFilePosition(long pos) const
check if the file position is correct or not
Definition: XYWrite.cpp:677
XYWriteParser::parseFormat
bool parseFormat(XYWriteParserInternal::Format &format)
tries to parse a format: first character 0xae is read
Definition: XYWrite.cpp:1621
XYWriteParser::parsePictureZone
bool parsePictureZone(XYWriteParserInternal::Format const &pictureFormat)
tries to parse a picture
Definition: XYWrite.cpp:1375
XYWriteParser::m_state
std::shared_ptr< XYWriteParserInternal::State > m_state
the main state
Definition: XYWrite.h:97
XYWriteParser::parseFrameZone
bool parseFrameZone(XYWriteParserInternal::Format const &frameFormat)
tries to parse a frame
Definition: XYWrite.cpp:1319
XYWriteParser::m_listener
std::shared_ptr< WPSContentListener > m_listener
the listener (if set)
Definition: XYWrite.h:95
XYWriteParser::findAllZones
bool findAllZones()
tries to find the end of main zone, the meta data zones (only Win4)
Definition: XYWrite.cpp:848
XYWriteParser::createListener
std::shared_ptr< WPSContentListener > createListener(librevenge::RVNGTextInterface *interface)
creates the main listener
Definition: XYWrite.cpp:691
XYWriteParser::createFormatChildren
bool createFormatChildren(XYWriteParserInternal::Format &format, size_t fPos=2)
tries to parse again a format to create a list of child: SS, FA, FM1, ...
Definition: XYWrite.cpp:1688
XYWriteParser::parseTextZone
bool parseTextZone(WPSEntry const &entry, std::string const &styleName="")
tries to parse the main text zone
Definition: XYWrite.cpp:1033
XYWriteParser::createTable
bool createTable(XYWriteParserInternal::Format const &format, long endPos)
tries to create a table
Definition: XYWrite.cpp:1433
XYWriteParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) override
called by WPSDocument to parse the file
Definition: XYWrite.cpp:807
XYWriteParser::update
bool update(XYWriteParserInternal::Format const &format, libwps_tools_win::Font::Type &fontType) const
try to update the listener data(font,paragraph style, ...)
Definition: XYWrite.cpp:894
XYWriteParser::~XYWriteParser
~XYWriteParser() override
destructor
Definition: XYWrite.cpp:673
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
XYWriteParserInternal
Definition: XYWrite.cpp:46
XYWriteParserInternal::Cell
Internal: class to store a basic cell with borders.
Definition: XYWrite.cpp:49
XYWriteParserInternal::Format
a structure used to store a format
Definition: XYWrite.cpp:107