WPS4Text.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) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11 * Copyright (C) 2006, 2007 Andrew Ziem
12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15 *
16 * For minor contributions see the git repository.
17 *
18 * Alternatively, the contents of this file may be used under the terms
19 * of the GNU Lesser General Public License Version 2.1 or later
20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21 * applicable instead of those above.
22 *
23 * For further information visit http://libwps.sourceforge.net
24 */
25
26#ifndef WPS4_TEXT_H
27#define WPS4_TEXT_H
28
29#include <vector>
30
31#include "libwps_internal.h"
32#include "libwps_tools_win.h"
33
34#include "WPSEntry.h"
35#include "WPSDebug.h"
36#include "WPSTextParser.h"
37
38class WPS4Parser;
39namespace WPS4TextInternal
40{
41struct Font;
42struct State;
43}
44
64class WPS4Text : public WPSTextParser
65{
66 friend class WPS4Parser;
67
68public:
70 WPS4Text(WPS4Parser &parser, RVNGInputStreamPtr &input);
71
73 ~WPS4Text() override;
74
77 {
78 m_listener = listen;
79 }
80
82 int numPages() const;
83
85 void flushExtra();
86
90 void sendObjects(int page);
91protected:
94 {
95 return reinterpret_cast<WPS4Parser &>(m_mainParser);
96 }
97
98 WPS4Parser const &mainParser() const
99 {
100 return reinterpret_cast<WPS4Parser const &>(m_mainParser);
101 }
102
105
107 WPSEntry getHeaderEntry() const;
108
110 WPSEntry getFooterEntry() const;
111
114
116 bool readText(WPSEntry const &entry);
117
119 bool readEntries();
121 bool readStructures();
122
123protected:
124 //----------------------------------------
125 // FDP parsing
126 //----------------------------------------
127
130 bool findFDPStructures(int which);
133 bool findFDPStructuresByHand(int which);
134
135 //----------------------------------------
136 // PLC parsing, setting
137 //----------------------------------------
138
146 typedef bool (WPS4Text::* DataParser)
147 (long bot, long eot, int id, long endPos, std::string &mess);
148
155 bool readPLC(WPSEntry const &zone,
156 std::vector<long> &textPtrs, std::vector<long> &listValues,
157 DataParser parser = nullptr);
158
160 bool defDataParser(long bot, long eot, int id, long endPos, std::string &mess);
161
163 bool readFontNames(WPSEntry const &entry);
164
166 bool readFont(long endPos, int &id, std::string &mess);
167
169 bool readParagraph(long endPos, int &id, std::string &mess);
170
172 bool readDosLink(WPSEntry const &entry);
173
175 bool objectDataParser(long bot, long eot, int id,
176 long endPos, std::string &mess);
177
179 bool readFootNotes(WPSEntry const &ftnD, WPSEntry const &ftnP);
180
182 bool footNotesDataParser(long bot, long eot, int id, long endPos, std::string &mess);
183
185 bool bkmkDataParser(long bot, long eot, int id, long endPos, std::string &mess);
186
188 bool dttmDataParser(long bot, long eot, int id, long endPos, std::string &mess);
189
190protected:
193
195 mutable std::shared_ptr<WPS4TextInternal::State> m_state;
196};
197#endif
198/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
This class parses Works version 2 through 4.
Definition WPS4.h:49
bool readEntries()
finds all text entries (TEXT, SHdr, SFtr, BTEC, BTEP, FTNp, FTNp, BKMK, FONT, CHRT)
Definition WPS4Text.cpp:1024
bool footNotesDataParser(long bot, long eot, int id, long endPos, std::string &mess)
reads a book mark property ( string)
Definition WPS4Text.cpp:2229
void setListener(WPSContentListenerPtr &listen)
sets the listener
Definition WPS4Text.h:76
WPSEntry getFooterEntry() const
returns the footer entry (if such entry exists, if not returns an invalid entry)
Definition WPS4Text.cpp:595
void sendObjects(int page)
send all the objects with page anchor corresponding given page
Definition WPS4Text.cpp:567
bool readFontNames(WPSEntry const &entry)
reads the font names
Definition WPS4Text.cpp:1408
bool readDosLink(WPSEntry const &entry)
reads the ZZDLink ( a list of filename )
Definition WPS4Text.cpp:1624
WPS4TextInternal::Font getDefaultFont() const
returns the default font to use for the document
Definition WPS4Text.cpp:612
WPS4Parser & mainParser()
return the main parser
Definition WPS4Text.h:93
bool bkmkDataParser(long bot, long eot, int id, long endPos, std::string &mess)
reads a book mark property ( string)
Definition WPS4Text.cpp:2267
WPS4Parser const & mainParser() const
return the main parser
Definition WPS4Text.h:98
std::shared_ptr< WPS4TextInternal::State > m_state
the internal state
Definition WPS4Text.h:195
WPSEntry getMainTextEntry() const
returns the main text entry (if such entry exists, if not returns an invalid entry)
Definition WPS4Text.cpp:607
void flushExtra()
sends the data which have not yet been sent to the listener
Definition WPS4Text.cpp:620
WPSEntry getHeaderEntry() const
returns the header entry (if such entry exists, if not returns an invalid entry)
Definition WPS4Text.cpp:583
bool readFont(long endPos, int &id, std::string &mess)
reads a font properties
Definition WPS4Text.cpp:1482
WPSContentListenerPtr m_listener
the listener
Definition WPS4Text.h:192
bool readParagraph(long endPos, int &id, std::string &mess)
reads a paragraph properties
Definition WPS4Text.cpp:1712
bool objectDataParser(long bot, long eot, int id, long endPos, std::string &mess)
reads a object properties ( position in text, size and definition in file)
Definition WPS4Text.cpp:2303
bool findFDPStructures(int which)
Definition WPS4Text.cpp:1257
bool defDataParser(long bot, long eot, int id, long endPos, std::string &mess)
default plc reader
Definition WPS4Text.cpp:1373
bool dttmDataParser(long bot, long eot, int id, long endPos, std::string &mess)
reads a date time property
Definition WPS4Text.cpp:2390
WPS4Text(WPS4Parser &parser, RVNGInputStreamPtr &input)
contructor
Definition WPS4Text.cpp:532
bool readPLC(WPSEntry const &zone, std::vector< long > &textPtrs, std::vector< long > &listValues, DataParser parser=nullptr)
reads a PLC (Pointer List Composant ?) in zone entry
Definition WPS4Text.cpp:2514
bool(WPS4Text::* DataParser)(long bot, long eot, int id, long endPos, std::string &mess)
definition of the plc data parser (low level)
Definition WPS4Text.h:147
bool findFDPStructuresByHand(int which)
Definition WPS4Text.cpp:1293
~WPS4Text() override
destructor
Definition WPS4Text.cpp:540
friend class WPS4Parser
Definition WPS4Text.h:66
int numPages() const
returns the number of pages
Definition WPS4Text.cpp:545
bool readStructures()
parsed all the text entries
Definition WPS4Text.cpp:1143
bool readText(WPSEntry const &entry)
reads a text section and sends it to a listener
Definition WPS4Text.cpp:641
bool readFootNotes(WPSEntry const &ftnD, WPSEntry const &ftnP)
reads the footnotes positions and definitions ( zones FTNd and FTNp)
Definition WPS4Text.cpp:2145
basic class to store an entry in a file This contained :
Definition WPSEntry.h:39
WPSTextParser(WPSParser &parser, RVNGInputStreamPtr &input)
constructor
Definition WPSTextParser.cpp:38
WPSParser & m_mainParser
pointer to the main zone parser;
Definition WPSTextParser.h:130
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition libwps_internal.h:87
std::shared_ptr< WPSContentListener > WPSContentListenerPtr
shared pointer to WPSContentListener
Definition libwps_internal.h:107
Definition WPS4Text.cpp:87
Internal: class to store font properties.
Definition WPS4Text.cpp:149
Internal: the state of a WPS4Text.
Definition WPS4Text.cpp:466

Generated on Sat Jul 19 2025 05:24:40 for libwps by doxygen 1.14.0