HMWJParser.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 HanMac Word-J document
*/
#ifndef HMWJ_PARSER
# define HMWJ_PARSER
#include <iostream>
#include <string>
#include <vector>
#include <libwpd/libwpd.h>
#include "MWAWDebug.hxx"
#include "MWAWParser.hxx"
namespace HMWJParserInternal
{
struct State;
class SubDocument;
}
class HMWJGraph;
class HMWJText;
struct HMWJZoneHeader {
HMWJZoneHeader(bool isMain) : m_length(0), m_n(0), m_fieldSize(0), m_id(0), m_isMain(isMain) {
for (int i=0; i < 4; i++) m_values[i] = 0;
}
friend std::ostream &operator<<(std::ostream &o, HMWJZoneHeader const &h) {
if (h.m_n) o << "N=" << h.m_n << ",";
if (h.m_id) o << "zId=" << std::hex << h.m_id << std::dec << ",";
bool toPrint[4]= {true, true, true, true};
if (h.m_isMain) {
if (h.m_values[0]+h.m_n == h.m_values[1])
toPrint[0]=toPrint[1]=false;
else if (h.m_values[0]+h.m_n == h.m_values[2])
toPrint[0]=toPrint[2]=false;
else
o << "###N,";
}
for (int i=0; i < 4; i++)
if (toPrint[i] && h.m_values[i]) o << "h" << i << "=" << h.m_values[i] << ",";
return o;
}
long m_length;
int m_n;
int m_fieldSize;
long m_id;
int m_values[4];
bool m_isMain;
};
class HMWJParser : public MWAWParser
{
friend class HMWJGraph;
friend class HMWJText;
friend class HMWJParserInternal::SubDocument;
public:
HMWJParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
virtual ~HMWJParser();
bool checkHeader(MWAWHeader *header, bool strict=false);
// the main parse function
void parse(WPXDocumentInterface *documentInterface);
protected:
void init();
void createDocument(WPXDocumentInterface *documentInterface);
bool createZones();
Vec2f getPageLeftTop() const;
void newPage(int number);
// interface with the text parser
bool sendText(long id, long cPos);
// interface with the graph parser
bool sendZone(long zId);
bool getColor(int colId, int patternId, MWAWColor &color) const;
//
// low level
//
bool checkEntry(MWAWEntry &entry);
bool readZonesList();
bool readZone(MWAWEntry &entry);
bool readClassicHeader(HMWJZoneHeader &header, long endPos=-1);
bool decodeZone(MWAWEntry const &entry, WPXBinaryData &data);
bool readPrintInfo(MWAWEntry const &entry);
bool readHeaderEnd();
#ifdef DEBUG
bool readZoneWithHeader(MWAWEntry const &entry);
#endif
bool readZoneA(MWAWEntry const &entry);
bool readZoneB(MWAWEntry const &entry);
protected:
//
// data
//
shared_ptr<HMWJParserInternal::State> m_state;
shared_ptr<HMWJGraph> m_graphParser;
shared_ptr<HMWJText> m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
HMWJParser::m_textParser
shared_ptr< HMWJText > m_textParser
the text parser
Definition: HMWJParser.hxx:190
HMWJParser::~HMWJParser
virtual ~HMWJParser()
destructor
Definition: HMWJParser.cxx:158
HMWJZoneHeader
a class use to store the classic header find before file zone
Definition: HMWJParser.hxx:60
MWAWHeader
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
HMWJZoneHeader::m_values
int m_values[4]
4 unknown field : freeN?, totalN?, totalN1?, ?
Definition: HMWJParser.hxx:92
MWAWParser.hxx
HMWJParser::createZones
bool createZones()
finds the different objects zones in a Hapanese File
Definition: HMWJParser.cxx:320
HMWJParser::sendZone
bool sendZone(long zId)
send a zone
Definition: HMWJParser.cxx:181
HMWJZoneHeader::operator<<
friend std::ostream & operator<<(std::ostream &o, HMWJZoneHeader const &h)
operator<<
Definition: HMWJParser.hxx:67
HMWJParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: HMWJParser.cxx:1016
HMWJParser::init
void init()
inits all internal variables
Definition: HMWJParser.cxx:162
HMWJZoneHeader::m_id
long m_id
the zone id
Definition: HMWJParser.hxx:90
HMWJParser::decodeZone
bool decodeZone(MWAWEntry const &entry, WPXBinaryData &data)
try to decode a zone
Definition: HMWJParser.cxx:1149
HMWJParser::HMWJParser
HMWJParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: HMWJParser.cxx:152
HMWJParser::newPage
void newPage(int number)
adds a new page
Definition: HMWJParser.cxx:205
HMWJZoneHeader::m_fieldSize
int m_fieldSize
the field size
Definition: HMWJParser.hxx:88
HMWJParser::readZone
bool readZone(MWAWEntry &entry)
try to read a generic zone
Definition: HMWJParser.cxx:490
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
HMWJParser::readHeaderEnd
bool readHeaderEnd()
try to read a unknown zone, just after the header (simillar to HMW Zoneb)
Definition: HMWJParser.cxx:865
HMWJParser::m_state
shared_ptr< HMWJParserInternal::State > m_state
the state
Definition: HMWJParser.hxx:184
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
HMWJZoneHeader::m_isMain
bool m_isMain
true if this is the main header
Definition: HMWJParser.hxx:94
HMWJParserInternal::SubDocument
Internal: the subdocument of a MWParser.
Definition: HMWJParser.cxx:91
HMWJParser::getPageLeftTop
Vec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: HMWJParser.cxx:196
HMWJParser::sendText
bool sendText(long id, long cPos)
send a text zone
Definition: HMWJParser.cxx:176
HMWJParser::checkEntry
bool checkEntry(MWAWEntry &entry)
look in entry.begin() to see if a entry exists at this position, if so fills entry.end(), entry.id(), ...
Definition: HMWJParser.cxx:403
HMWJZoneHeader::m_length
long m_length
the zone size
Definition: HMWJParser.hxx:84
HMWJParser::m_graphParser
shared_ptr< HMWJGraph > m_graphParser
the graph parser
Definition: HMWJParser.hxx:187
HMWJParser::readZoneA
bool readZoneA(MWAWEntry const &entry)
try to read the zone A ( a big zone containing 5 sub zone ? )
Definition: HMWJParser.cxx:685
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
HMWJZoneHeader::HMWJZoneHeader
HMWJZoneHeader(bool isMain)
constructor
Definition: HMWJParser.hxx:62
HMWJParser::getColor
bool getColor(int colId, int patternId, MWAWColor &color) const
returns the color associated with a pattern
Definition: HMWJParser.cxx:188
HMWJParser
the main class to read a HanMac Word-J file
Definition: HMWJParser.hxx:102
MWAWDebug.hxx
HMWJParser::readClassicHeader
bool readClassicHeader(HMWJZoneHeader &header, long endPos=-1)
try to read a header of classic zone
Definition: HMWJParser.cxx:218
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
HMWJZoneHeader::m_n
int m_n
the number of item
Definition: HMWJParser.hxx:86
HMWJParser::createDocument
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: HMWJParser.cxx:277
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
Vec2< float >
HMWJParser::parse
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: HMWJParser.cxx:242
HMWJGraph
the main class to read the graphic part of a HanMac Word-J file
Definition: HMWJGraph.hxx:76
HMWJText
the main class to read the text part of HanMac Word-J file
Definition: HMWJText.hxx:62
HMWJParser::readZonesList
bool readZonesList()
try to read the zones list
Definition: HMWJParser.cxx:444
HMWJParser::readZoneB
bool readZoneB(MWAWEntry const &entry)
try to read the zone B
Definition: HMWJParser.cxx:785
HMWJParser::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
try to read a printinfo zone
Definition: HMWJParser.cxx:583