WPS8Text.h
Go to the documentation of this file.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* libwps
* Version: MPL 2.0 / LGPLv2.1+
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Major Contributor(s):
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
* Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU Lesser General Public License Version 2.1 or later
* (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
* applicable instead of those above.
*/
#ifndef WPS8_TEXT_H
#define WPS8_TEXT_H
#include <vector>
#include "libwps_internal.h"
#include "WPSDebug.h"
#include "WPSTextParser.h"
class WPSEntry;
class WPSPosition;
typedef class WPSContentListener WPS8ContentListener;
typedef shared_ptr<WPS8ContentListener> WPS8ContentListenerPtr;
namespace WPS8Struct
{
struct FileData;
}
namespace WPS8TextInternal
{
struct State;
class SubDocument;
}
class WPS8Parser;
class WPS8TextStyle;
class WPS8Text : public WPSTextParser
{
friend class WPS8TextInternal::SubDocument;
friend class WPS8Parser;
friend class WPS8TextStyle;
public:
WPS8Text(WPS8Parser &parser);
~WPS8Text();
void setListener(WPS8ContentListenerPtr &listen);
int numPages() const;
void flushExtra();
bool readStructures();
int getNumTextZones() const;
int getTextZoneType(int typeId) const;
WPSEntry getHeaderEntry() const;
WPSEntry getFooterEntry() const;
WPSEntry getTextEntry() const;
WPSEntry getEntry(int strsId) const;
void readText(WPSEntry const &entry);
void readTextInCell(int strsId, int cellId);
protected:
WPS8Parser &mainParser()
{
return reinterpret_cast<WPS8Parser &> (m_mainParser);
}
WPS8Parser const &mainParser() const
{
return reinterpret_cast<WPS8Parser const &> (m_mainParser);
}
//
// interface with WPS8TextStyle
//
bool readFont(long endPos, int &id, std::string &mess);
bool readParagraph(long endPos, int &id, std::string &mess);
//
// String+text functions
//
bool readString(WPXInputStreamPtr input, long page_size,
WPXString &res);
long readUTF16LE(WPXInputStreamPtr input, long endPos, uint16_t firstC);
bool readNotes(WPSEntry const &entry);
void createNotesCorrespondance();
//----------------------------------------
// PLC parsing, setting
//----------------------------------------
typedef bool (WPS8Text::* DataParser)
(long bot, long eot, int id, WPS8Struct::FileData const &data,
std::string &mess);
typedef bool (WPS8Text::* EndDataParser)
(long endPos, std::vector<long> const &textPtrs);
bool readPLC(WPSEntry const &entry,
std::vector<long> &textPtrs, std::vector<long> &listValues,
DataParser parser = &WPS8Text::defDataParser,
EndDataParser endParser = 0L);
bool defDataParser
(long , long , int , WPS8Struct::FileData const &data, std::string &mess);
bool textZonesDataParser(long bot, long eot, int nId,
WPS8Struct::FileData const &data,
std::string &mess);
// object
bool objectDataParser(long bot, long eot, int id,
WPS8Struct::FileData const &data, std::string &mess);
// field type
bool tokenEndDataParser(long endPage, std::vector<long> const &textPtrs);
bool bmktEndDataParser(long endPage, std::vector<long> const &textPtrs);
protected:
WPS8ContentListenerPtr m_listener;
shared_ptr<WPS8TextStyle> m_styleParser;
mutable shared_ptr<WPS8TextInternal::State> m_state;
protected:
};
#endif /* WPS8_TEXT_H */
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */