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 {
52 struct State;
53 class SubDocument;
54 }
55 
56 class HanMacWrdJGraph;
57 class HanMacWrdJText;
58 
62  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  }
86  long m_length;
88  int m_n;
92  long m_id;
94  int m_values[4];
96  bool m_isMain;
97 };
98 
105 {
106  friend class HanMacWrdJGraph;
107  friend class HanMacWrdJText;
109 
110 public:
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 
122 protected:
124  void init();
125 
127  void createDocument(librevenge::RVNGTextInterface *documentInterface);
128 
130  bool createZones();
131 
133  MWAWVec2f getPageLeftTop() const;
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
175 
176  bool readZoneWithHeader(MWAWEntry const &entry);
177 #endif
178 
179  bool readZoneA(MWAWEntry const &entry);
181  bool readZoneB(MWAWEntry const &entry);
182 
183 protected:
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:
shared_ptr< HanMacWrdJGraph > m_graphParser
the graph parser
Definition: HanMacWrdJParser.hxx:191
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:491
the main class to read a HanMac Word-J file
Definition: HanMacWrdJParser.hxx:104
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
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
the main class to read the graphic part of a HanMac Word-J file
Definition: HanMacWrdJGraph.hxx:78
the class to store a color
Definition: libmwaw_internal.hxx:176
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:499
bool m_isMain
true if this is the main header
Definition: HanMacWrdJParser.hxx:96
Internal: the subdocument of a HanMacWrdJParser.
Definition: HanMacWrdJParser.cxx:92
friend std::ostream & operator<<(std::ostream &o, HanMacWrdJZoneHeader const &h)
operator<<
Definition: HanMacWrdJParser.hxx:68
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:284
shared_ptr< HanMacWrdJParserInternal::State > m_state
the state
Definition: HanMacWrdJParser.hxx:188
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:489
Internal: the structures of a HanMacWrdJParser.
Definition: HanMacWrdJParser.cxx:62
long m_id
the zone id
Definition: HanMacWrdJParser.hxx:92
bool getColor(int color, MWAWColor &col)
try to convert a file data to a color
Definition: FullWrtStruct.cxx:45
int m_n
the number of item
Definition: HanMacWrdJParser.hxx:88
a class use to store the classic header find before file zone
Definition: HanMacWrdJParser.hxx:60
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type)
the parser function
Definition: HanMacWrdJParser.cxx:136
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
HanMacWrdJZoneHeader(bool isMain)
constructor
Definition: HanMacWrdJParser.hxx:62
shared_ptr< HanMacWrdJText > m_textParser
the text parser
Definition: HanMacWrdJParser.hxx:194
the main class to read the text part of HanMac Word-J file
Definition: HanMacWrdJText.hxx:62

Generated on Wed May 18 2016 13:43:39 for libmwaw by doxygen 1.8.11