HanMacWrdJParser.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 HAN_MAC_WRD_J_PARSER
# define HAN_MAC_WRD_J_PARSER
#include <iostream>
#include <string>
#include <vector>
#include <librevenge/librevenge.h>
#include "MWAWDebug.hxx"
#include "MWAWParser.hxx"
namespace HanMacWrdJParserInternal
{
struct State;
class SubDocument;
}
class HanMacWrdJGraph;
class HanMacWrdJText;
struct HanMacWrdJZoneHeader {
explicit HanMacWrdJZoneHeader(bool isMain)
: m_length(0)
, m_n(0)
, m_fieldSize(0)
, m_id(0)
, m_isMain(isMain)
{
for (auto &val : m_values) val = 0;
}
friend std::ostream &operator<<(std::ostream &o, HanMacWrdJZoneHeader 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 HanMacWrdJParser final : public MWAWTextParser
{
friend class HanMacWrdJGraph;
friend class HanMacWrdJText;
friend class HanMacWrdJParserInternal::SubDocument;
public:
HanMacWrdJParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
~HanMacWrdJParser() 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();
MWAWVec2f getPageLeftTop() const;
void newPage(int number);
// interface with the text parser
bool sendText(long id, long cPos, MWAWListenerPtr listener=MWAWListenerPtr());
bool canSendTextAsGraphic(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(HanMacWrdJZoneHeader &header, long endPos=-1);
bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &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
//
std::shared_ptr<HanMacWrdJParserInternal::State> m_state;
std::shared_ptr<HanMacWrdJGraph> m_graphParser;
std::shared_ptr<HanMacWrdJText> m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWParser.hxx
HanMacWrdJGraph
the main class to read the graphic part of a HanMac Word-J file
Definition HanMacWrdJGraph.hxx:79
HanMacWrdJParserInternal::SubDocument
Internal: the subdocument of a HanMacWrdJParser.
Definition HanMacWrdJParser.cxx:100
HanMacWrdJParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition HanMacWrdJParser.cxx:215
HanMacWrdJParser::sendText
bool sendText(long id, long cPos, MWAWListenerPtr listener=MWAWListenerPtr())
send a text zone
Definition HanMacWrdJParser.cxx:190
HanMacWrdJParser::HanMacWrdJText
friend class HanMacWrdJText
Definition HanMacWrdJParser.hxx:112
HanMacWrdJParser::m_textParser
std::shared_ptr< HanMacWrdJText > m_textParser
the text parser
Definition HanMacWrdJParser.hxx:199
HanMacWrdJParser::sendZone
bool sendZone(long zId)
send a zone
Definition HanMacWrdJParser.cxx:200
HanMacWrdJParser::readZoneA
bool readZoneA(MWAWEntry const &entry)
try to read the zone A ( a big zone containing 5 sub zone ?
Definition HanMacWrdJParser.cxx:705
HanMacWrdJParser::init
void init()
inits all internal variables
Definition HanMacWrdJParser.cxx:176
HanMacWrdJParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition HanMacWrdJParser.cxx:296
HanMacWrdJParser::decodeZone
bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &data)
try to decode a zone
Definition HanMacWrdJParser.cxx:1168
HanMacWrdJParser::HanMacWrdJParser
HanMacWrdJParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition HanMacWrdJParser.cxx:163
HanMacWrdJParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition HanMacWrdJParser.cxx:1036
HanMacWrdJParser::m_state
std::shared_ptr< HanMacWrdJParserInternal::State > m_state
the state
Definition HanMacWrdJParser.hxx:193
HanMacWrdJParser::m_graphParser
std::shared_ptr< HanMacWrdJGraph > m_graphParser
the graph parser
Definition HanMacWrdJParser.hxx:196
HanMacWrdJParser::readClassicHeader
bool readClassicHeader(HanMacWrdJZoneHeader &header, long endPos=-1)
try to read a header of classic zone
Definition HanMacWrdJParser.cxx:237
HanMacWrdJParser::readZonesList
bool readZonesList()
try to read the zones list
Definition HanMacWrdJParser.cxx:463
HanMacWrdJParser::createZones
bool createZones()
finds the different objects zones in a Hapanese File
Definition HanMacWrdJParser.cxx:339
HanMacWrdJParser::checkEntry
bool checkEntry(MWAWEntry &entry)
look in entry.begin() to see if a entry exists at this position, if so fills entry....
Definition HanMacWrdJParser.cxx:421
HanMacWrdJParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition HanMacWrdJParser.cxx:261
HanMacWrdJParser::newPage
void newPage(int number)
adds a new page
Definition HanMacWrdJParser.cxx:224
HanMacWrdJParser::readZoneB
bool readZoneB(MWAWEntry const &entry)
try to read the zone B
Definition HanMacWrdJParser.cxx:805
HanMacWrdJParser::~HanMacWrdJParser
~HanMacWrdJParser() final
destructor
Definition HanMacWrdJParser.cxx:172
HanMacWrdJParser::getColor
bool getColor(int colId, int patternId, MWAWColor &color) const
returns the color associated with a pattern
Definition HanMacWrdJParser.cxx:207
HanMacWrdJParser::readHeaderEnd
bool readHeaderEnd()
try to read a unknown zone, just after the header (simillar to HanMacWrd Zoneb)
Definition HanMacWrdJParser.cxx:885
HanMacWrdJParser::readZone
bool readZone(MWAWEntry &entry)
try to read a generic zone
Definition HanMacWrdJParser.cxx:509
HanMacWrdJParser::canSendTextAsGraphic
bool canSendTextAsGraphic(long id, long cPos)
check if we can send a textzone as graphic
Definition HanMacWrdJParser.cxx:195
HanMacWrdJParser::HanMacWrdJGraph
friend class HanMacWrdJGraph
Definition HanMacWrdJParser.hxx:111
HanMacWrdJParser::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
try to read a printinfo zone
Definition HanMacWrdJParser.cxx:602
HanMacWrdJText
the main class to read the text part of HanMac Word-J file
Definition HanMacWrdJText.hxx:63
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:307
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition libmwaw_internal.hxx:561
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition libmwaw_internal.hxx:553
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
HanMacWrdJParserInternal
Internal: the structures of a HanMacWrdJParser.
Definition HanMacWrdJParser.cxx:63
librevenge
Definition MWAWDocument.hxx:57
HanMacWrdJParserInternal::State
Internal: the state of a HanMacWrdJParser.
Definition HanMacWrdJParser.cxx:66
HanMacWrdJZoneHeader
a class use to store the classic header find before file zone
Definition HanMacWrdJParser.hxx:60
HanMacWrdJZoneHeader::m_n
int m_n
the number of item
Definition HanMacWrdJParser.hxx:93
HanMacWrdJZoneHeader::m_values
int m_values[4]
4 unknown field : freeN?, totalN?, totalN1?, ?
Definition HanMacWrdJParser.hxx:99
HanMacWrdJZoneHeader::m_fieldSize
int m_fieldSize
the field size
Definition HanMacWrdJParser.hxx:95
HanMacWrdJZoneHeader::m_length
long m_length
the zone size
Definition HanMacWrdJParser.hxx:91
HanMacWrdJZoneHeader::m_isMain
bool m_isMain
true if this is the main header
Definition HanMacWrdJParser.hxx:101
HanMacWrdJZoneHeader::operator<<
friend std::ostream & operator<<(std::ostream &o, HanMacWrdJZoneHeader const &h)
operator<<
Definition HanMacWrdJParser.hxx:73
HanMacWrdJZoneHeader::HanMacWrdJZoneHeader
HanMacWrdJZoneHeader(bool isMain)
constructor
Definition HanMacWrdJParser.hxx:62
HanMacWrdJZoneHeader::m_id
long m_id
the zone id
Definition HanMacWrdJParser.hxx:97
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192