MarinerWrtParser.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 Mariner Write document
*/
#ifndef MARINER_WRT_PARSER
# define MARINER_WRT_PARSER
#include <iostream>
#include <string>
#include <vector>
#include <librevenge/librevenge.h>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWParser.hxx"
namespace MarinerWrtParserInternal
{
struct State;
class SubDocument;
}
class MarinerWrtGraph;
class MarinerWrtText;
struct MarinerWrtEntry final : public MWAWEntry {
MarinerWrtEntry()
: MWAWEntry()
, m_fileType(0)
, m_N(0)
, m_value(0)
{
}
~MarinerWrtEntry() final;
std::string name() const;
friend std::ostream &operator<< (std::ostream &o, MarinerWrtEntry const &ent)
{
if (ent.m_N || ent.m_value || ent.m_extra.length()) {
o << "[";
if (ent.m_N) o << "N=" << ent.m_N << ",";
if (ent.m_value) o << "unkn=" << ent.m_value << ",";
if (ent.m_extra.length()) o << ent.m_extra;
o << "],";
}
return o;
}
int m_fileType;
int m_N;
int m_value;
};
struct MarinerWrtStruct {
MarinerWrtStruct()
: m_filePos(-1)
, m_pos()
, m_type(-1)
, m_data()
{
}
friend std::ostream &operator<<(std::ostream &o, MarinerWrtStruct const &dt);
int numValues() const
{
return int(m_data.size());
}
bool isBasic() const
{
return (m_type==1 || m_type==2) && m_data.size()<=1;
}
long value(int i) const;
long m_filePos;
MWAWEntry m_pos;
int m_type;
std::vector<long> m_data;
};
class MarinerWrtParser final : public MWAWTextParser
{
friend class MarinerWrtGraph;
friend class MarinerWrtText;
friend class MarinerWrtParserInternal::SubDocument;
public:
MarinerWrtParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
~MarinerWrtParser() final;
bool checkHeader(MWAWHeader *header, bool strict=false) final;
// the main parse function
void parse(librevenge::RVNGTextInterface *documentInterface) final;
protected:
void init();
void createDocument(librevenge::RVNGTextInterface *documentInterface);
bool createZones();
bool readZone(int &actZone, bool onlyTest=false);
MWAWVec2f getPageLeftTop() const;
MWAWSection getSection(int zoneId) const;
void newPage(int number);
// interface with the text parser
int getZoneId(uint32_t fileId, bool &endNote);
void sendText(int zoneId);
// interface with the graph parser
float getPatternPercent(int id) const;
void sendToken(int zoneId, long tokenId);
//
// low level
//
bool readEntryHeader(MarinerWrtEntry &entry);
bool decodeZone(std::vector<MarinerWrtStruct> &dataList, long numData=999999);
bool readSeparator(MarinerWrtEntry const &entry);
bool readZoneDim(MarinerWrtEntry const &entry, int zoneId);
bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest);
bool readZoneb(MarinerWrtEntry const &entry, int zoneId);
bool readZonec(MarinerWrtEntry const &entry, int zoneId);
bool readZone13(MarinerWrtEntry const &entry, int zoneId);
bool readDocInfo(MarinerWrtEntry const &entry, int zoneId);
bool readPrintInfo(MarinerWrtEntry const &entry);
bool readCPRT(MarinerWrtEntry const &entry);
bool readNumbersString(int num, std::vector<long> &res);
protected:
//
// data
//
std::shared_ptr<MarinerWrtParserInternal::State> m_state;
bool m_pageMarginsSpanSet;
std::shared_ptr<MarinerWrtGraph> m_graphParser;
std::shared_ptr<MarinerWrtText> m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWEntry.hxx
MWAWInputStream.hxx
MWAWParser.hxx
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWEntry::MWAWEntry
MWAWEntry()
constructor
Definition MWAWEntry.hxx:50
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWSection
a class which stores section properties
Definition MWAWSection.hxx:46
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:307
MarinerWrtGraph
the main class to read the graphic part of a Mariner Write file
Definition MarinerWrtGraph.hxx:69
MarinerWrtParserInternal::SubDocument
Internal: the subdocument of a MarinerWrtParser.
Definition MarinerWrtParser.cxx:199
MarinerWrtParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition MarinerWrtParser.cxx:348
MarinerWrtParser::readZoneb
bool readZoneb(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone : one by separator?
Definition MarinerWrtParser.cxx:1086
MarinerWrtParser::MarinerWrtGraph
friend class MarinerWrtGraph
Definition MarinerWrtParser.hxx:136
MarinerWrtParser::sendText
void sendText(int zoneId)
ask the text parser to send a zone
Definition MarinerWrtParser.cxx:324
MarinerWrtParser::getZoneId
int getZoneId(uint32_t fileId, bool &endNote)
return a zoneid corresponding to a fileId (or -1) and set the endnote flag
Definition MarinerWrtParser.cxx:311
MarinerWrtParser::m_graphParser
std::shared_ptr< MarinerWrtGraph > m_graphParser
the graph parser
Definition MarinerWrtParser.hxx:227
MarinerWrtParser::sendToken
void sendToken(int zoneId, long tokenId)
ask the graph parser to send a token
Definition MarinerWrtParser.cxx:337
MarinerWrtParser::m_textParser
std::shared_ptr< MarinerWrtText > m_textParser
the text parser
Definition MarinerWrtParser.hxx:230
MarinerWrtParser::readCPRT
bool readCPRT(MarinerWrtEntry const &entry)
try to read a xml printinfo zone
Definition MarinerWrtParser.cxx:1272
MarinerWrtParser::readZone13
bool readZone13(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone of 23 int
Definition MarinerWrtParser.cxx:1177
MarinerWrtParser::readZonec
bool readZonec(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone of 9 int
Definition MarinerWrtParser.cxx:1127
MarinerWrtParser::m_pageMarginsSpanSet
bool m_pageMarginsSpanSet
a flag to know if page margins span are set
Definition MarinerWrtParser.hxx:224
MarinerWrtParser::~MarinerWrtParser
~MarinerWrtParser() final
destructor
Definition MarinerWrtParser.cxx:258
MarinerWrtParser::readPrintInfo
bool readPrintInfo(MarinerWrtEntry const &entry)
try to read a printinfo zone
Definition MarinerWrtParser.cxx:1298
MarinerWrtParser::readSeparator
bool readSeparator(MarinerWrtEntry const &entry)
try to read the separator of differents part
Definition MarinerWrtParser.cxx:616
MarinerWrtParser::readZoneDim
bool readZoneDim(MarinerWrtEntry const &entry, int zoneId)
try to read the zone dimension ( normal and with margin )
Definition MarinerWrtParser.cxx:852
MarinerWrtParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition MarinerWrtParser.cxx:279
MarinerWrtParser::init
void init()
inits all internal variables
Definition MarinerWrtParser.cxx:262
MarinerWrtParser::getPatternPercent
float getPatternPercent(int id) const
return the pattern percent which corresponds to an id (or -1)
Definition MarinerWrtParser.cxx:332
MarinerWrtParser::MarinerWrtText
friend class MarinerWrtText
Definition MarinerWrtParser.hxx:137
MarinerWrtParser::newPage
void newPage(int number)
adds a new page
Definition MarinerWrtParser.cxx:295
MarinerWrtParser::getSection
MWAWSection getSection(int zoneId) const
returns the section information corresponding to a zone
Definition MarinerWrtParser.cxx:285
MarinerWrtParser::m_state
std::shared_ptr< MarinerWrtParserInternal::State > m_state
the state
Definition MarinerWrtParser.hxx:221
MarinerWrtParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition MarinerWrtParser.cxx:383
MarinerWrtParser::decodeZone
bool decodeZone(std::vector< MarinerWrtStruct > &dataList, long numData=999999)
try to decode a zone
Definition MarinerWrtParser.cxx:1440
MarinerWrtParser::readZoneHeader
bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest)
try to read the zone header
Definition MarinerWrtParser.cxx:645
MarinerWrtParser::readZone
bool readZone(int &actZone, bool onlyTest=false)
try to read a zone
Definition MarinerWrtParser.cxx:483
MarinerWrtParser::readDocInfo
bool readDocInfo(MarinerWrtEntry const &entry, int zoneId)
try to read the doc info zone
Definition MarinerWrtParser.cxx:936
MarinerWrtParser::readEntryHeader
bool readEntryHeader(MarinerWrtEntry &entry)
try to read an entry header
Definition MarinerWrtParser.cxx:1357
MarinerWrtParser::MarinerWrtParser
MarinerWrtParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition MarinerWrtParser.cxx:248
MarinerWrtParser::readNumbersString
bool readNumbersString(int num, std::vector< long > &res)
try to read a number or a list of number entries
Definition MarinerWrtParser.cxx:1382
MarinerWrtParser::createZones
bool createZones()
finds the different objects zones
Definition MarinerWrtParser.cxx:471
MarinerWrtParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition MarinerWrtParser.cxx:1507
MarinerWrtText
the main class to read the text part of Mariner Write file
Definition MarinerWrtText.hxx:61
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition libmwaw_internal.hxx:561
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition libmwaw_internal.hxx:842
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MarinerWrtParserInternal
Internal: the structures of a MarinerWrtParser.
Definition MarinerWrtParser.cxx:66
librevenge
Definition MWAWDocument.hxx:57
MarinerWrtEntry
a entry to store a zone structure
Definition MarinerWrtParser.hxx:62
MarinerWrtEntry::m_fileType
int m_fileType
the entry type
Definition MarinerWrtParser.hxx:88
MarinerWrtEntry::MarinerWrtEntry
MarinerWrtEntry()
constructor
Definition MarinerWrtParser.hxx:64
MarinerWrtEntry::m_N
int m_N
the number of value
Definition MarinerWrtParser.hxx:90
MarinerWrtEntry::m_value
int m_value
a unknown value
Definition MarinerWrtParser.hxx:92
MarinerWrtEntry::name
std::string name() const
returns the entry name;
Definition MarinerWrtParser.cxx:1541
MarinerWrtEntry::~MarinerWrtEntry
~MarinerWrtEntry() final
destructor
Definition MarinerWrtParser.cxx:1537
MarinerWrtParserInternal::State
Internal: the state of a MarinerWrtParser.
Definition MarinerWrtParser.cxx:173
MarinerWrtStruct
Internal: a struct used to read some field.
Definition MarinerWrtParser.hxx:96
MarinerWrtStruct::m_pos
MWAWEntry m_pos
the file data position (for type=0 data )
Definition MarinerWrtParser.hxx:122
MarinerWrtStruct::isBasic
bool isBasic() const
returns true if this corresponds to a simple container
Definition MarinerWrtParser.hxx:113
MarinerWrtStruct::operator<<
friend std::ostream & operator<<(std::ostream &o, MarinerWrtStruct const &dt)
operator<<
Definition MarinerWrtParser.cxx:1604
MarinerWrtStruct::value
long value(int i) const
returns the ith value (or 0 if it does not exists )
Definition MarinerWrtParser.cxx:1594
MarinerWrtStruct::numValues
int numValues() const
returns the number of values
Definition MarinerWrtParser.hxx:108
MarinerWrtStruct::m_data
std::vector< long > m_data
the data block
Definition MarinerWrtParser.hxx:126
MarinerWrtStruct::MarinerWrtStruct
MarinerWrtStruct()
constructor
Definition MarinerWrtParser.hxx:98
MarinerWrtStruct::m_type
int m_type
the data type
Definition MarinerWrtParser.hxx:124
MarinerWrtStruct::m_filePos
long m_filePos
the file position where the field description begin
Definition MarinerWrtParser.hxx:120