WPParser.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* 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 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* Parser to convert some WriterPlus text document ( a french text editor )
*
*/
#ifndef WP_PARSER
# define WP_PARSER
#include <list>
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWParser.hxx"
namespace WPParserInternal
{
struct State;
struct Font;
struct Line;
struct ParagraphData;
struct ParagraphInfo;
class SubDocument;
}
class WPParser : public MWAWParser
{
friend class WPParserInternal::SubDocument;
public:
WPParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
virtual ~WPParser();
bool checkHeader(MWAWHeader *header, bool strict=false);
// the main parse function
void parse(WPXDocumentInterface *documentInterface);
protected:
void init();
void createDocument(WPXDocumentInterface *documentInterface);
bool createZones();
bool readPrintInfo();
bool readWindowsInfo(int zone);
bool sendWindow(int zone, Vec2i limits = Vec2i(-1,-1));
bool readWindowsZone(int zone);
bool readPageInfo(int zone);
bool readColInfo(int zone);
bool readParagraphInfo(int zone);
bool findSection(int zone, Vec2i limits, MWAWSection &sec);
bool readSection(WPParserInternal::ParagraphInfo const &info, bool mainBlock);
bool readText(WPParserInternal::ParagraphInfo const &info);
bool readTable(WPParserInternal::ParagraphInfo const &info);
bool readGraphic(WPParserInternal::ParagraphInfo const &info);
bool readUnknown(WPParserInternal::ParagraphInfo const &info);
double getTextHeight() const;
void newPage(int number);
//
// low level
//
bool readParagraphData(WPParserInternal::ParagraphInfo const &info, bool hasFonts,
WPParserInternal::ParagraphData &data);
MWAWParagraph getParagraph(WPParserInternal::ParagraphData const &data);
bool readFonts(int nFonts, int type,
std::vector<WPParserInternal::Font> &fonts);
bool readLines(WPParserInternal::ParagraphInfo const &info,
int nLines, std::vector<WPParserInternal::Line> &lines);
protected:
//
// data
//
shared_ptr<WPParserInternal::State> m_state;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
WPParser::m_state
shared_ptr< WPParserInternal::State > m_state
the state
Definition: WPParser.hxx:160
MWAWHeader
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
MWAWParser.hxx
WPParser::readColInfo
bool readColInfo(int zone)
read the col info zone ?
Definition: WPParser.cxx:1310
MWAWEntry.hxx
WPParser::readFonts
bool readFonts(int nFonts, int type, std::vector< WPParserInternal::Font > &fonts)
reads a list of font (with position)
Definition: WPParser.cxx:1790
WPParser::createZones
bool createZones()
finds the different objects zones
Definition: WPParser.cxx:703
WPParserInternal::ParagraphInfo
Paragraph informations.
Definition: WPParser.cxx:125
WPParser::~WPParser
virtual ~WPParser()
destructor
Definition: WPParser.cxx:590
WPParser::getParagraph
MWAWParagraph getParagraph(WPParserInternal::ParagraphData const &data)
returns a paragraph corresponding to a paragraph data
Definition: WPParser.cxx:1229
WPParser::readPrintInfo
bool readPrintInfo()
read the print info zone
Definition: WPParser.cxx:1891
WPParser
the main class to read a Writerperfect file
Definition: WPParser.hxx:66
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libmwaw_internal.hxx:578
WPParser::readGraphic
bool readGraphic(WPParserInternal::ParagraphInfo const &info)
read a graphic
Definition: WPParser.cxx:1550
WPParser::readWindowsInfo
bool readWindowsInfo(int zone)
read the main info for zone ( 0: MAIN ZONE, 1 : HEADER, 2 : FOOTER )
Definition: WPParser.cxx:770
WPParser::WPParser
WPParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: WPParser.cxx:584
WPParser::readUnknown
bool readUnknown(WPParserInternal::ParagraphInfo const &info)
read a unknown section
Definition: WPParser.cxx:1672
WPParser::readWindowsZone
bool readWindowsZone(int zone)
read the page info zone
Definition: WPParser.cxx:896
WPParser::newPage
void newPage(int number)
adds a new page
Definition: WPParser.cxx:616
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
WPParserInternal::SubDocument
Internal: the subdocument of a MWParser.
Definition: WPParser.cxx:522
WPParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: WPParser.cxx:738
WPParser::readTable
bool readTable(WPParserInternal::ParagraphInfo const &info)
read a table
Definition: WPParser.cxx:1481
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
WPParser::getTextHeight
double getTextHeight() const
returns the page height, ie. paper size less margin (in inches) and header/footer ...
Definition: WPParser.cxx:608
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
WPParser::findSection
bool findSection(int zone, Vec2i limits, MWAWSection &sec)
try to find the data which correspond to a section ( mainly column )
Definition: WPParser.cxx:1123
MWAWInputStream.hxx
MWAWDebug.hxx
WPParser::sendWindow
bool sendWindow(int zone, Vec2i limits=Vec2i(-1,-1))
send a zone ( 0: MAIN ZONE, 1 : HEADER, 2 : FOOTER )
Definition: WPParser.cxx:987
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:83
WPParser::readParagraphInfo
bool readParagraphInfo(int zone)
read the paragraph info zone
Definition: WPParser.cxx:1247
WPParser::readText
bool readText(WPParserInternal::ParagraphInfo const &info)
read a text
Definition: WPParser.cxx:1345
WPParser::readParagraphData
bool readParagraphData(WPParserInternal::ParagraphInfo const &info, bool hasFonts, WPParserInternal::ParagraphData &data)
reads a paragraph data
Definition: WPParser.cxx:1713
WPParser::readLines
bool readLines(WPParserInternal::ParagraphInfo const &info, int nLines, std::vector< WPParserInternal::Line > &lines)
reads a list of line (with position)
Definition: WPParser.cxx:1860
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
WPParserInternal::ParagraphData
Internal: class to store the beginning of all paragraph data.
Definition: WPParser.cxx:438
Vec2< int >
WPParser::parse
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: WPParser.cxx:634
WPParser::readPageInfo
bool readPageInfo(int zone)
read the page info zone
Definition: WPParser.cxx:1179
WPParser::init
void init()
inits all internal variables
Definition: WPParser.cxx:594
WPParser::readSection
bool readSection(WPParserInternal::ParagraphInfo const &info, bool mainBlock)
read a section
Definition: WPParser.cxx:1424
WPParser::createDocument
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: WPParser.cxx:667