MarinerWrtParser.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
52 namespace MarinerWrtParserInternal
53 {
54 struct State;
55 class SubDocument;
56 }
57
58 class MarinerWrtGraph;
59 class MarinerWrtText;
60
62 struct MarinerWrtEntry : public MWAWEntry {
64 MarinerWrtEntry() : MWAWEntry(), m_fileType(0), m_N(0), m_value(0)
65 {
66 }
68 std::string name() const;
70 friend std::ostream &operator<< (std::ostream &o, MarinerWrtEntry const &ent)
71 {
72 if (ent.m_N || ent.m_value || ent.m_extra.length()) {
73 o << "[";
74 if (ent.m_N) o << "N=" << ent.m_N << ",";
75 if (ent.m_value) o << "unkn=" << ent.m_value << ",";
76 if (ent.m_extra.length()) o << ent.m_extra;
77 o << "],";
78 }
79 return o;
80 }
82 int m_fileType;
84 int m_N;
86 int m_value;
87 };
88
90 struct MarinerWrtStruct {
92 MarinerWrtStruct() : m_filePos(-1), m_pos(), m_type(-1), m_data()
93 {
94 }
96 friend std::ostream &operator<<(std::ostream &o, MarinerWrtStruct const &dt);
98 int numValues() const
99 {
100 return int(m_data.size());
101 }
103 bool isBasic() const
104 {
105 return (m_type==1 || m_type==2) && m_data.size()<=1;
106 }
108 long value(int i) const;
110 long m_filePos;
112 MWAWEntry m_pos;
114 int m_type;
116 std::vector<long> m_data;
117 };
118
124 class MarinerWrtParser : public MWAWTextParser
125 {
126 friend class MarinerWrtGraph;
127 friend class MarinerWrtText;
128 friend class MarinerWrtParserInternal::SubDocument;
129
130 public:
132 MarinerWrtParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
134 virtual ~MarinerWrtParser();
135
137 bool checkHeader(MWAWHeader *header, bool strict=false);
138
139 // the main parse function
140 void parse(librevenge::RVNGTextInterface *documentInterface);
141
142 protected:
144 void init();
145
147 void createDocument(librevenge::RVNGTextInterface *documentInterface);
148
150 bool createZones();
152 bool readZone(int &actZone, bool onlyTest=false);
153
155 MWAWVec2f getPageLeftTop() const;
157 MWAWSection getSection(int zoneId) const;
158
160 void newPage(int number);
161
162 // interface with the text parser
163
165 int getZoneId(uint32_t fileId, bool &endNote);
167 void sendText(int zoneId);
168
169 // interface with the graph parser
171 float getPatternPercent(int id) const;
173 void sendToken(int zoneId, long tokenId);
174
175 //
176 // low level
177 //
178
180 bool readEntryHeader(MarinerWrtEntry &entry);
182 bool decodeZone(std::vector<MarinerWrtStruct> &dataList, long numData=999999);
183
185 bool readSeparator(MarinerWrtEntry const &entry);
187 bool readZoneDim(MarinerWrtEntry const &entry, int zoneId);
189 bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest);
191 bool readZoneb(MarinerWrtEntry const &entry, int zoneId);
193 bool readZonec(MarinerWrtEntry const &entry, int zoneId);
195 bool readZone13(MarinerWrtEntry const &entry, int zoneId);
197 bool readDocInfo(MarinerWrtEntry const &entry, int zoneId);
199 bool readPrintInfo(MarinerWrtEntry const &entry);
201 bool readCPRT(MarinerWrtEntry const &entry);
202
204 bool readNumbersString(int num, std::vector<long> &res);
205
206 protected:
207 //
208 // data
209 //
211 shared_ptr<MarinerWrtParserInternal::State> m_state;
212
214 bool m_pageMarginsSpanSet;
215
217 shared_ptr<MarinerWrtGraph> m_graphParser;
218
220 shared_ptr<MarinerWrtText> m_textParser;
221 };
222 #endif
223 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MarinerWrtParser::getPatternPercent
float getPatternPercent(int id) const
return the pattern percent which corresponds to an id (or -1)
Definition: MarinerWrtParser.cxx:315
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MarinerWrtParser::readZone
bool readZone(int &actZone, bool onlyTest=false)
try to read a zone
Definition: MarinerWrtParser.cxx:466
MarinerWrtParser::m_textParser
shared_ptr< MarinerWrtText > m_textParser
the text parser
Definition: MarinerWrtParser.hxx:220
MarinerWrtParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MarinerWrtParser.cxx:366
MWAWParser.hxx
MarinerWrtParser::readZone13
bool readZone13(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone of 23 int
Definition: MarinerWrtParser.cxx:1160
MarinerWrtParser::~MarinerWrtParser
virtual ~MarinerWrtParser()
destructor
Definition: MarinerWrtParser.cxx:241
MWAWEntry.hxx
MarinerWrtParser
the main class to read a Mariner Write file
Definition: MarinerWrtParser.hxx:124
MarinerWrtParser::m_state
shared_ptr< MarinerWrtParserInternal::State > m_state
the state
Definition: MarinerWrtParser.hxx:211
MarinerWrtParser::readZoneb
bool readZoneb(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone : one by separator?, borderdim?
Definition: MarinerWrtParser.cxx:1069
MarinerWrtParser::readZoneHeader
bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest)
try to read the zone header
Definition: MarinerWrtParser.cxx:628
MarinerWrtParser::sendText
void sendText(int zoneId)
ask the text parser to send a zone
Definition: MarinerWrtParser.cxx:307
MarinerWrtText
the main class to read the text part of Mariner Write file
Definition: MarinerWrtText.hxx:60
MarinerWrtParser::getZoneId
int getZoneId(uint32_t fileId, bool &endNote)
return a zoneid corresponding to a fileId (or -1) and set the endnote flag
Definition: MarinerWrtParser.cxx:294
MarinerWrtParser::readPrintInfo
bool readPrintInfo(MarinerWrtEntry const &entry)
try to read a printinfo zone
Definition: MarinerWrtParser.cxx:1281
MarinerWrtEntry
a entry to store a zone structure
Definition: MarinerWrtParser.hxx:62
MarinerWrtParser::m_pageMarginsSpanSet
bool m_pageMarginsSpanSet
a flag to know if page margins span are set
Definition: MarinerWrtParser.hxx:214
MarinerWrtGraph
the main class to read the graphic part of a Mariner Write file
Definition: MarinerWrtGraph.hxx:68
MarinerWrtParser::getSection
MWAWSection getSection(int zoneId) const
returns the section information corresponding to a zone
Definition: MarinerWrtParser.cxx:268
MarinerWrtStruct
Internal: a struct used to read some field.
Definition: MarinerWrtParser.hxx:90
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:499
MarinerWrtEntry::m_fileType
int m_fileType
the entry type
Definition: MarinerWrtParser.hxx:82
MarinerWrtParser::readEntryHeader
bool readEntryHeader(MarinerWrtEntry &entry)
try to read an entry header
Definition: MarinerWrtParser.cxx:1340
MarinerWrtStruct::isBasic
bool isBasic() const
returns true if this corresponds to a simple container
Definition: MarinerWrtParser.hxx:103
MarinerWrtParser::init
void init()
inits all internal variables
Definition: MarinerWrtParser.cxx:245
MarinerWrtEntry::name
std::string name() const
returns the entry name;
Definition: MarinerWrtParser.cxx:1520
MarinerWrtParser::sendToken
void sendToken(int zoneId, long tokenId)
ask the graph parser to send a token
Definition: MarinerWrtParser.cxx:320
MarinerWrtStruct::m_type
int m_type
the data type
Definition: MarinerWrtParser.hxx:114
MarinerWrtParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: MarinerWrtParser.cxx:262
MarinerWrtParser::m_graphParser
shared_ptr< MarinerWrtGraph > m_graphParser
the graph parser
Definition: MarinerWrtParser.hxx:217
MWAWEntry::m_extra
std::string m_extra
an extra string
Definition: MWAWEntry.hxx:194
MarinerWrtParser::readZoneDim
bool readZoneDim(MarinerWrtEntry const &entry, int zoneId)
try to read the zone dimension ( normal and with margin )
Definition: MarinerWrtParser.cxx:835
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:284
MarinerWrtStruct::operator<<
friend std::ostream & operator<<(std::ostream &o, MarinerWrtStruct const &dt)
operator<<
Definition: MarinerWrtParser.cxx:1583
MarinerWrtEntry::m_N
int m_N
the number of value
Definition: MarinerWrtParser.hxx:84
MarinerWrtParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface)
virtual function used to parse the input
Definition: MarinerWrtParser.cxx:331
MarinerWrtParser::readNumbersString
bool readNumbersString(int num, std::vector< long > &res)
try to read a number or a list of number entries
Definition: MarinerWrtParser.cxx:1365
MarinerWrtParser::readSeparator
bool readSeparator(MarinerWrtEntry const &entry)
try to read the separator of differents part
Definition: MarinerWrtParser.cxx:599
MarinerWrtStruct::m_pos
MWAWEntry m_pos
the file data position (for type=0 data )
Definition: MarinerWrtParser.hxx:112
MarinerWrtStruct::m_filePos
long m_filePos
the file position where the field description begin
Definition: MarinerWrtParser.hxx:110
MarinerWrtParser::MarinerWrtParser
MarinerWrtParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MarinerWrtParser.cxx:235
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:489
MarinerWrtParser::readCPRT
bool readCPRT(MarinerWrtEntry const &entry)
try to read a xml printinfo zone
Definition: MarinerWrtParser.cxx:1255
MarinerWrtEntry::m_value
int m_value
a unknown value
Definition: MarinerWrtParser.hxx:86
MWAWInputStream.hxx
MWAWDebug.hxx
MarinerWrtParser::readZonec
bool readZonec(MarinerWrtEntry const &entry, int zoneId)
try to read a unknown zone of 9 int
Definition: MarinerWrtParser.cxx:1110
MarinerWrtStruct::MarinerWrtStruct
MarinerWrtStruct()
constructor
Definition: MarinerWrtParser.hxx:92
MarinerWrtStruct::m_data
std::vector< long > m_data
the data block
Definition: MarinerWrtParser.hxx:116
MarinerWrtEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MarinerWrtEntry const &ent)
operator<<
Definition: MarinerWrtParser.hxx:70
MarinerWrtStruct::numValues
int numValues() const
returns the number of values
Definition: MarinerWrtParser.hxx:98
MarinerWrtParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MarinerWrtParser.cxx:1490
MarinerWrtParser::readDocInfo
bool readDocInfo(MarinerWrtEntry const &entry, int zoneId)
try to read the doc info zone
Definition: MarinerWrtParser.cxx:919
MarinerWrtEntry::MarinerWrtEntry
MarinerWrtEntry()
constructor
Definition: MarinerWrtParser.hxx:64
MarinerWrtStruct::value
long value(int i) const
returns the ith value (or 0 if it does not exists )
Definition: MarinerWrtParser.cxx:1573
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MarinerWrtParser::createZones
bool createZones()
finds the different objects zones
Definition: MarinerWrtParser.cxx:454
MarinerWrtParser::decodeZone
bool decodeZone(std::vector< MarinerWrtStruct > &dataList, long numData=999999)
try to decode a zone
Definition: MarinerWrtParser.cxx:1423
MarinerWrtParserInternal::SubDocument
Internal: the subdocument of a MarinerWrtParser.
Definition: MarinerWrtParser.cxx:182
MWAWVec2< float >
MarinerWrtParser::newPage
void newPage(int number)
adds a new page
Definition: MarinerWrtParser.cxx:278
MarinerWrtParserInternal
Internal: the structures of a MarinerWrtParser.
Definition: MarinerWrtParser.cxx:65