HanMacWrdJParser.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3/* libmwaw
4* Version: MPL 2.0 / LGPLv2+
5*
6* The contents of this file are subject to the Mozilla Public License Version
7* 2.0 (the "License"); you may not use this file except in compliance with
8* the License or as specified alternatively below. You may obtain a copy of
9* the License at http://www.mozilla.org/MPL/
10*
11* Software distributed under the License is distributed on an "AS IS" basis,
12* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13* for the specific language governing rights and limitations under the
14* License.
15*
16* Major Contributor(s):
17* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20* Copyright (C) 2006, 2007 Andrew Ziem
21* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22*
23*
24* All Rights Reserved.
25*
26* For minor contributions see the git repository.
27*
28* Alternatively, the contents of this file may be used under the terms of
29* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30* in which case the provisions of the LGPLv2+ are applicable
31* instead of those above.
32*/
33
34/*
35 * Parser to convert HanMac Word-J document
36 */
37#ifndef HAN_MAC_WRD_J_PARSER
38# define HAN_MAC_WRD_J_PARSER
39
40#include <iostream>
41#include <string>
42#include <vector>
43
44#include <librevenge/librevenge.h>
45
46#include "MWAWDebug.hxx"
47
48#include "MWAWParser.hxx"
49
51{
52struct State;
53class SubDocument;
54}
55
56class HanMacWrdJGraph;
57class HanMacWrdJText;
58
62 explicit HanMacWrdJZoneHeader(bool isMain) : m_length(0), m_n(0), m_fieldSize(0), m_id(0), m_isMain(isMain)
63 {
64 for (int i=0; i < 4; i++) m_values[i] = 0;
65 }
66
68 friend std::ostream &operator<<(std::ostream &o, HanMacWrdJZoneHeader const &h)
69 {
70 if (h.m_n) o << "N=" << h.m_n << ",";
71 if (h.m_id) o << "zId=" << std::hex << h.m_id << std::dec << ",";
72 bool toPrint[4]= {true, true, true, true};
73 if (h.m_isMain) {
74 if (h.m_values[0]+h.m_n == h.m_values[1])
75 toPrint[0]=toPrint[1]=false;
76 else if (h.m_values[0]+h.m_n == h.m_values[2])
77 toPrint[0]=toPrint[2]=false;
78 else
79 o << "###N,";
80 }
81 for (int i=0; i < 4; i++)
82 if (toPrint[i] && h.m_values[i]) o << "h" << i << "=" << h.m_values[i] << ",";
83 return o;
84 }
88 int m_n;
92 long m_id;
94 int m_values[4];
97};
98
105{
106 friend class HanMacWrdJGraph;
107 friend class HanMacWrdJText;
109
110public:
114 virtual ~HanMacWrdJParser();
115
117 bool checkHeader(MWAWHeader *header, bool strict=false);
118
119 // the main parse function
120 void parse(librevenge::RVNGTextInterface *documentInterface);
121
122protected:
124 void init();
125
127 void createDocument(librevenge::RVNGTextInterface *documentInterface);
128
130 bool createZones();
131
134
136 void newPage(int number);
137
138 // interface with the text parser
139
141 bool sendText(long id, long cPos, MWAWListenerPtr listener=MWAWListenerPtr());
143 bool canSendTextAsGraphic(long id, long cPos);
144
145 // interface with the graph parser
146
148 bool sendZone(long zId);
150 bool getColor(int colId, int patternId, MWAWColor &color) const;
151
152 //
153 // low level
154 //
155
158 bool checkEntry(MWAWEntry &entry);
159
161 bool readZonesList();
163 bool readZone(MWAWEntry &entry);
164
166 bool readClassicHeader(HanMacWrdJZoneHeader &header, long endPos=-1);
168 bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &data);
169
171 bool readPrintInfo(MWAWEntry const &entry);
173 bool readHeaderEnd();
174#ifdef DEBUG
176 bool readZoneWithHeader(MWAWEntry const &entry);
177#endif
179 bool readZoneA(MWAWEntry const &entry);
181 bool readZoneB(MWAWEntry const &entry);
182
183protected:
184 //
185 // data
186 //
188 shared_ptr<HanMacWrdJParserInternal::State> m_state;
189
191 shared_ptr<HanMacWrdJGraph> m_graphParser;
192
194 shared_ptr<HanMacWrdJText> m_textParser;
195};
196#endif
197// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the main class to read the graphic part of a HanMac Word-J file
Definition: HanMacWrdJGraph.hxx:79
Internal: the subdocument of a HanMacWrdJParser.
Definition: HanMacWrdJParser.cxx:93
the main class to read a HanMac Word-J file
Definition: HanMacWrdJParser.hxx:105
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: HanMacWrdJParser.cxx:210
shared_ptr< HanMacWrdJParserInternal::State > m_state
the state
Definition: HanMacWrdJParser.hxx:188
void parse(librevenge::RVNGTextInterface *documentInterface)
virtual function used to parse the input
Definition: HanMacWrdJParser.cxx:256
bool sendText(long id, long cPos, MWAWListenerPtr listener=MWAWListenerPtr())
send a text zone
Definition: HanMacWrdJParser.cxx:185
HanMacWrdJParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: HanMacWrdJParser.cxx:161
bool sendZone(long zId)
send a zone
Definition: HanMacWrdJParser.cxx:195
bool readZoneA(MWAWEntry const &entry)
try to read the zone A ( a big zone containing 5 sub zone ? )
Definition: HanMacWrdJParser.cxx:702
void init()
inits all internal variables
Definition: HanMacWrdJParser.cxx:171
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: HanMacWrdJParser.cxx:291
bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &data)
try to decode a zone
Definition: HanMacWrdJParser.cxx:1166
bool readClassicHeader(HanMacWrdJZoneHeader &header, long endPos=-1)
try to read a header of classic zone
Definition: HanMacWrdJParser.cxx:232
bool readZonesList()
try to read the zones list
Definition: HanMacWrdJParser.cxx:460
bool createZones()
finds the different objects zones in a Hapanese File
Definition: HanMacWrdJParser.cxx:334
bool checkEntry(MWAWEntry &entry)
look in entry.begin() to see if a entry exists at this position, if so fills entry....
Definition: HanMacWrdJParser.cxx:419
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: HanMacWrdJParser.cxx:1033
void newPage(int number)
adds a new page
Definition: HanMacWrdJParser.cxx:219
shared_ptr< HanMacWrdJText > m_textParser
the text parser
Definition: HanMacWrdJParser.hxx:194
virtual ~HanMacWrdJParser()
destructor
Definition: HanMacWrdJParser.cxx:167
bool readZoneB(MWAWEntry const &entry)
try to read the zone B
Definition: HanMacWrdJParser.cxx:802
bool getColor(int colId, int patternId, MWAWColor &color) const
returns the color associated with a pattern
Definition: HanMacWrdJParser.cxx:202
bool readHeaderEnd()
try to read a unknown zone, just after the header (simillar to HanMacWrd Zoneb)
Definition: HanMacWrdJParser.cxx:882
shared_ptr< HanMacWrdJGraph > m_graphParser
the graph parser
Definition: HanMacWrdJParser.hxx:191
bool readZone(MWAWEntry &entry)
try to read a generic zone
Definition: HanMacWrdJParser.cxx:506
bool canSendTextAsGraphic(long id, long cPos)
check if we can send a textzone as graphic
Definition: HanMacWrdJParser.cxx:190
bool readPrintInfo(MWAWEntry const &entry)
try to read a printinfo zone
Definition: HanMacWrdJParser.cxx:599
the main class to read the text part of HanMac Word-J file
Definition: HanMacWrdJText.hxx:63
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:296
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:505
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:513
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
Internal: the structures of a HanMacWrdJParser.
Definition: HanMacWrdJParser.cxx:63
a class use to store the classic header find before file zone
Definition: HanMacWrdJParser.hxx:60
int m_n
the number of item
Definition: HanMacWrdJParser.hxx:88
int m_values[4]
4 unknown field : freeN?, totalN?, totalN1?, ?
Definition: HanMacWrdJParser.hxx:94
int m_fieldSize
the field size
Definition: HanMacWrdJParser.hxx:90
long m_length
the zone size
Definition: HanMacWrdJParser.hxx:86
bool m_isMain
true if this is the main header
Definition: HanMacWrdJParser.hxx:96
friend std::ostream & operator<<(std::ostream &o, HanMacWrdJZoneHeader const &h)
operator<<
Definition: HanMacWrdJParser.hxx:68
HanMacWrdJZoneHeader(bool isMain)
constructor
Definition: HanMacWrdJParser.hxx:62
long m_id
the zone id
Definition: HanMacWrdJParser.hxx:92
the class to store a color
Definition: libmwaw_internal.hxx:182

Generated on Wed Jan 19 2022 22:23:13 for libmwaw by doxygen 1.9.3