MarinerWrtParser.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 Mariner Write document
36 */
37#ifndef MARINER_WRT_PARSER
38# define MARINER_WRT_PARSER
39
40#include <iostream>
41#include <string>
42#include <vector>
43
44#include <librevenge/librevenge.h>
45
46#include "MWAWDebug.hxx"
47#include "MWAWEntry.hxx"
48#include "MWAWInputStream.hxx"
49
50#include "MWAWParser.hxx"
51
53{
54struct State;
55class SubDocument;
56}
57
58class MarinerWrtGraph;
59class MarinerWrtText;
60
62struct MarinerWrtEntry final : public MWAWEntry {
65 : MWAWEntry()
66 , m_fileType(0)
67 , m_N(0)
68 , m_value(0)
69 {
70 }
72 ~MarinerWrtEntry() final;
74 std::string name() const;
76 friend std::ostream &operator<< (std::ostream &o, MarinerWrtEntry const &ent)
77 {
78 if (ent.m_N || ent.m_value || ent.m_extra.length()) {
79 o << "[";
80 if (ent.m_N) o << "N=" << ent.m_N << ",";
81 if (ent.m_value) o << "unkn=" << ent.m_value << ",";
82 if (ent.m_extra.length()) o << ent.m_extra;
83 o << "],";
84 }
85 return o;
86 }
90 int m_N;
93};
94
99 : m_filePos(-1)
100 , m_pos()
101 , m_type(-1)
102 , m_data()
103 {
104 }
106 friend std::ostream &operator<<(std::ostream &o, MarinerWrtStruct const &dt);
108 int numValues() const
109 {
110 return int(m_data.size());
111 }
113 bool isBasic() const
114 {
115 return (m_type==1 || m_type==2) && m_data.size()<=1;
116 }
118 long value(int i) const;
126 std::vector<long> m_data;
127};
128
135{
136 friend class MarinerWrtGraph;
137 friend class MarinerWrtText;
139
140public:
142 MarinerWrtParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
144 ~MarinerWrtParser() final;
145
147 bool checkHeader(MWAWHeader *header, bool strict=false) final;
148
149 // the main parse function
150 void parse(librevenge::RVNGTextInterface *documentInterface) final;
151
152protected:
154 void init();
155
157 void createDocument(librevenge::RVNGTextInterface *documentInterface);
158
160 bool createZones();
162 bool readZone(int &actZone, bool onlyTest=false);
163
167 MWAWSection getSection(int zoneId) const;
168
170 void newPage(int number);
171
172 // interface with the text parser
173
175 int getZoneId(uint32_t fileId, bool &endNote);
177 void sendText(int zoneId);
178
179 // interface with the graph parser
181 float getPatternPercent(int id) const;
183 void sendToken(int zoneId, long tokenId);
184
185 //
186 // low level
187 //
188
190 bool readEntryHeader(MarinerWrtEntry &entry);
192 bool decodeZone(std::vector<MarinerWrtStruct> &dataList, long numData=999999);
193
195 bool readSeparator(MarinerWrtEntry const &entry);
197 bool readZoneDim(MarinerWrtEntry const &entry, int zoneId);
199 bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest);
201 bool readZoneb(MarinerWrtEntry const &entry, int zoneId);
203 bool readZonec(MarinerWrtEntry const &entry, int zoneId);
205 bool readZone13(MarinerWrtEntry const &entry, int zoneId);
207 bool readDocInfo(MarinerWrtEntry const &entry, int zoneId);
209 bool readPrintInfo(MarinerWrtEntry const &entry);
211 bool readCPRT(MarinerWrtEntry const &entry);
212
214 bool readNumbersString(int num, std::vector<long> &res);
215
216protected:
217 //
218 // data
219 //
221 std::shared_ptr<MarinerWrtParserInternal::State> m_state;
222
225
228
230 std::shared_ptr<MarinerWrtText> m_textParser;
231};
232#endif
233// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
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
a class which stores section properties
Definition: MWAWSection.hxx:46
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:299
the main class to read the graphic part of a Mariner Write file
Definition: MarinerWrtGraph.hxx:69
Internal: the subdocument of a MarinerWrtParser.
Definition: MarinerWrtParser.cxx:199
the main class to read a Mariner Write file
Definition: MarinerWrtParser.hxx:135
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: MarinerWrtParser.cxx:348
bool readZoneb(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone : one by separator?, borderdim?
Definition: MarinerWrtParser.cxx:1086
void sendText(int zoneId)
ask the text parser to send a zone
Definition: MarinerWrtParser.cxx:324
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
std::shared_ptr< MarinerWrtGraph > m_graphParser
the graph parser
Definition: MarinerWrtParser.hxx:227
void sendToken(int zoneId, long tokenId)
ask the graph parser to send a token
Definition: MarinerWrtParser.cxx:337
std::shared_ptr< MarinerWrtText > m_textParser
the text parser
Definition: MarinerWrtParser.hxx:230
bool readCPRT(MarinerWrtEntry const &entry)
try to read a xml printinfo zone
Definition: MarinerWrtParser.cxx:1272
bool readZone13(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone of 23 int
Definition: MarinerWrtParser.cxx:1177
bool readZonec(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone of 9 int
Definition: MarinerWrtParser.cxx:1127
bool m_pageMarginsSpanSet
a flag to know if page margins span are set
Definition: MarinerWrtParser.hxx:224
~MarinerWrtParser() final
destructor
Definition: MarinerWrtParser.cxx:258
bool readPrintInfo(MarinerWrtEntry const &entry)
try to read a printinfo zone
Definition: MarinerWrtParser.cxx:1298
bool readSeparator(MarinerWrtEntry const &entry)
try to read the separator of differents part
Definition: MarinerWrtParser.cxx:616
bool readZoneDim(MarinerWrtEntry const &entry, int zoneId)
try to read the zone dimension ( normal and with margin )
Definition: MarinerWrtParser.cxx:852
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: MarinerWrtParser.cxx:279
void init()
inits all internal variables
Definition: MarinerWrtParser.cxx:262
float getPatternPercent(int id) const
return the pattern percent which corresponds to an id (or -1)
Definition: MarinerWrtParser.cxx:332
void newPage(int number)
adds a new page
Definition: MarinerWrtParser.cxx:295
MWAWSection getSection(int zoneId) const
returns the section information corresponding to a zone
Definition: MarinerWrtParser.cxx:285
std::shared_ptr< MarinerWrtParserInternal::State > m_state
the state
Definition: MarinerWrtParser.hxx:221
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MarinerWrtParser.cxx:383
bool decodeZone(std::vector< MarinerWrtStruct > &dataList, long numData=999999)
try to decode a zone
Definition: MarinerWrtParser.cxx:1440
bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest)
try to read the zone header
Definition: MarinerWrtParser.cxx:645
bool readZone(int &actZone, bool onlyTest=false)
try to read a zone
Definition: MarinerWrtParser.cxx:483
bool readDocInfo(MarinerWrtEntry const &entry, int zoneId)
try to read the doc info zone
Definition: MarinerWrtParser.cxx:936
bool readEntryHeader(MarinerWrtEntry &entry)
try to read an entry header
Definition: MarinerWrtParser.cxx:1357
bool readNumbersString(int num, std::vector< long > &res)
try to read a number or a list of number entries
Definition: MarinerWrtParser.cxx:1382
bool createZones()
finds the different objects zones
Definition: MarinerWrtParser.cxx:471
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MarinerWrtParser.cxx:1507
the main class to read the text part of Mariner Write file
Definition: MarinerWrtText.hxx:61
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
Internal: the structures of a MarinerWrtParser.
Definition: MarinerWrtParser.cxx:66
Definition: MWAWDocument.hxx:57
a entry to store a zone structure
Definition: MarinerWrtParser.hxx:62
int m_fileType
the entry type
Definition: MarinerWrtParser.hxx:88
MarinerWrtEntry()
constructor
Definition: MarinerWrtParser.hxx:64
int m_N
the number of value
Definition: MarinerWrtParser.hxx:90
int m_value
a unknown value
Definition: MarinerWrtParser.hxx:92
std::string name() const
returns the entry name;
Definition: MarinerWrtParser.cxx:1541
~MarinerWrtEntry() final
destructor
Definition: MarinerWrtParser.cxx:1537
Internal: a struct used to read some field.
Definition: MarinerWrtParser.hxx:96
MWAWEntry m_pos
the file data position (for type=0 data )
Definition: MarinerWrtParser.hxx:122
bool isBasic() const
returns true if this corresponds to a simple container
Definition: MarinerWrtParser.hxx:113
friend std::ostream & operator<<(std::ostream &o, MarinerWrtStruct const &dt)
operator<<
Definition: MarinerWrtParser.cxx:1604
long value(int i) const
returns the ith value (or 0 if it does not exists )
Definition: MarinerWrtParser.cxx:1594
int numValues() const
returns the number of values
Definition: MarinerWrtParser.hxx:108
std::vector< long > m_data
the data block
Definition: MarinerWrtParser.hxx:126
MarinerWrtStruct()
constructor
Definition: MarinerWrtParser.hxx:98
int m_type
the data type
Definition: MarinerWrtParser.hxx:124
long m_filePos
the file position where the field description begin
Definition: MarinerWrtParser.hxx:120

Generated on Thu Jan 19 2023 00:00:00 for libmwaw by doxygen 1.9.6