MsWksDocument.hxx Source File documentation

MsWksDocument.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 #ifndef MS_WKS_DOCUMENT
35 # define MS_WKS_DOCUMENT
36
37 #include <string>
38 #include <map>
39 #include <vector>
40
41 #include <librevenge/librevenge.h>
42
43 #include "libmwaw_internal.hxx"
44
45 #include "MWAWDebug.hxx"
46 #include "MWAWCell.hxx"
47 #include "MWAWParser.hxx"
48
49 namespace MsWksDocumentInternal
50 {
51 struct State;
52
53 class SubDocument;
54 }
55
56 class MsWksParser;
57 class MsWksDBParser;
58 class MsWksDRParser;
59 class MsWksSSParser;
60 class MsWks4Zone;
61
62 class MsWksGraph;
63 class MsWks3Text;
64 class MsWks4Text;
65
68 class MsWksDocument
69 {
70 friend class MsWksDocumentInternal::SubDocument;
71 friend class MsWksParser;
72 friend class MsWks4Zone;
73 friend class MsWksDBParser;
74 friend class MsWksDRParser;
75 friend class MsWksSSParser;
76 public:
78 enum ZoneType { Z_MAIN, Z_HEADER, Z_FOOTER, Z_NONE };
80 struct Zone {
82 Zone(ZoneType type=Z_NONE, int zoneId=-1) : m_type(type), m_zoneId(zoneId), m_textId(-1) {}
84 ZoneType m_type;
86 int m_zoneId;
88 int m_textId;
89 };
90
91 public:
92
94 MsWksDocument(MWAWInputStreamPtr input, MWAWParser &parser);
96 virtual ~MsWksDocument();
97
99 int version() const;
101 void setVersion(int vers);
103 MWAWDocument::Kind getKind() const;
105 void setKind(MWAWDocument::Kind kind);
106
108 MWAWInputStreamPtr &getInput()
109 {
110 return m_input;
111 }
113 MWAWParser &getMainParser()
114 {
115 return *m_parser;
116 }
118 shared_ptr<MsWksGraph> getGraphParser()
119 {
120 return m_graphParser;
121 }
123 shared_ptr<MsWks3Text> getTextParser3();
125 shared_ptr<MsWks4Text> getTextParser4();
127 libmwaw::DebugFile &ascii()
128 {
129 return m_asciiFile;
130 }
131
132 //
133 // read some v3 structure
134 //
135
137 bool checkHeader3(MWAWHeader *header, bool strict=false);
139 long getLengthOfFileHeader3() const;
141 bool readPrintInfo();
143 bool readDocumentInfo(long sz=-1);
145 bool readZone(Zone &zone);
147 bool readGroupHeaderFooter(bool header, int check);
148
149 //
150 // read some ole structures
151 //
152
154 bool createOLEZones(MWAWInputStreamPtr input);
156 std::vector<std::string> const &getUnparsedOLEZones() const;
157 //
158 // utilities functions
159 //
160
162 bool hasHeader() const;
164 bool hasFooter() const;
166 float getHeaderFooterHeight(bool header) const;
168 void getPageSpanList(std::vector<MWAWPageSpan> &pagesList, int &numPages);
170 bool getColor(int id, MWAWColor &col, int vers);
172 std::vector<MWAWColor> const &getPalette(int vers);
173
175 std::multimap<int, Zone> &getTypeZoneMap();
177 Zone getZone(ZoneType type) const;
179 int getNewZoneId() const;
181 std::multimap<std::string, MWAWEntry> &getEntryMap();
182
183 // general interface
184
186 void sendZone(int zoneType);
187
188 // interface with the text parser
189
191 void newPage(int page, bool softBreak=false);
193 void sendFootnoteContent(int noteId);
195 void sendFootnote(int id);
197 void sendText(int id);
198
199 // interface with the graph parser
200
202 void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style);
204 void sendRBIL(int id, MWAWVec2i const &sz);
206 void sendTextbox(MWAWEntry const &entry, std::string const &frame);
207
208 protected:
209 //
210 // spreadsheet/database function
211 //
212
214 bool readCellInFormula(MWAWCellContent::FormulaInstruction &instr, bool is2D);
216 bool readDBString(long endPos, std::string &res);
218 bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str);
219 /* reads a formula */
220 bool readFormula(long endPos, MWAWCellContent &content, std::string &extra);
221
222 protected:
223
224 //
225 // low level
226 //
228 void initAsciiFile(std::string const &name);
229
230 private:
231 MsWksDocument(MsWksDocument const &orig);
232 MsWksDocument &operator=(MsWksDocument const &orig);
233
234 //
235 // data
236 //
237
238 protected:
240 shared_ptr<MsWksDocumentInternal::State> m_state;
241 public:
243 shared_ptr<MWAWParserState> m_parserState;
244
245 protected:
247 MWAWParser *m_parser;
249 MsWksDocument *m_parentDocument;
251 MWAWInputStreamPtr m_input;
253 libmwaw::DebugFile m_asciiFile;
254
256 shared_ptr<MsWksGraph> m_graphParser;
258 shared_ptr<MsWks3Text> m_textParser3;
260 shared_ptr<MsWks4Text> m_textParser4;
261
263 typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
264
266 NewPage m_newPage;
267 };
268 #endif
269 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition: MWAWCell.hxx:359
MsWksDocument::m_state
shared_ptr< MsWksDocumentInternal::State > m_state
the state
Definition: MsWksDocument.hxx:240
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MsWksDocument::m_input
MWAWInputStreamPtr m_input
the input which can be an OLE in MSWorks 4 file
Definition: MsWksDocument.hxx:251
MsWksDBParser
the main class to read a Microsoft Works database file and convert it in a spreadsheet file ...
Definition: MsWksDBParser.hxx:65
MsWksDocument::getGraphParser
shared_ptr< MsWksGraph > getGraphParser()
returns the graph parser
Definition: MsWksDocument.hxx:118
MWAWParser.hxx
MsWksDocument::Zone::m_zoneId
int m_zoneId
the parser zone id
Definition: MsWksDocument.hxx:86
MsWksParser
the main class to read a Microsoft Works file: v1-v4
Definition: MsWksParser.hxx:59
MsWks4Text
The class which parses text zones in a mac MS Works document v4.
Definition: MsWks4Text.hxx:64
libmwaw_internal.hxx
MsWksDocument::getMainParser
MWAWParser & getMainParser()
returns the main parser
Definition: MsWksDocument.hxx:113
MsWksDocument::Zone::m_type
ZoneType m_type
the zone type
Definition: MsWksDocument.hxx:84
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:65
MsWksDocument::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file of the actual input
Definition: MsWksDocument.hxx:253
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MsWksDocument::ZoneType
ZoneType
the different type of zone (v1-v3)
Definition: MsWksDocument.hxx:78
MsWksDocument::Zone
a zone of a MsWksDocument ( main, header, footer )
Definition: MsWksDocument.hxx:80
MsWksDocument::m_parentDocument
MsWksDocument * m_parentDocument
the parent document (if this is not the main document)
Definition: MsWksDocument.hxx:249
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:196
MWAWCellContent
small class use to define a sheet cell content
Definition: MWAWCell.hxx:355
MsWksDocument::m_textParser3
shared_ptr< MsWks3Text > m_textParser3
the text document (for v1-3 document)
Definition: MsWksDocument.hxx:258
MsWksDocument::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MsWksDocument.hxx:108
MsWksDocument::m_parser
MWAWParser * m_parser
the main parser
Definition: MsWksDocument.hxx:247
MsWksDocumentInternal
Internal: the structures of a MsWksDocument.
Definition: MsWksDocument.cxx:63
MsWksDocument::m_parserState
shared_ptr< MWAWParserState > m_parserState
the parser state
Definition: MsWksDocument.hxx:243
MsWks4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition: MsWks4Zone.hxx:73
MsWks3Text
the main class to read the text part of Microsoft Works file
Definition: MsWks3Text.hxx:69
MsWksDRParser
the main class to read a Microsoft Works graphic file
Definition: MsWksDRParser.hxx:59
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:517
MsWksDocument::m_newPage
NewPage m_newPage
the new page callback
Definition: MsWksDocument.hxx:266
MsWksGraph
the main class to read the graphic of a Microsoft Works file
Definition: MsWksGraph.hxx:73
MsWksSSParser
the main class to read a Microsoft Works spreadsheet file
Definition: MsWksSSParser.hxx:65
MWAWDebug.hxx
MWAWDocument::Kind
Kind
an enum to define the kind of document
Definition: MWAWDocument.hxx:80
FullWrtStruct::getColor
bool getColor(int color, MWAWColor &col)
try to convert a file data to a color
Definition: FullWrtStruct.cxx:45
MsWksDocumentInternal::SubDocument
Internal: the subdocument of a MsWksDocument.
Definition: MsWksDocument.cxx:203
MsWksDocument::Zone::m_textId
int m_textId
the text internal id
Definition: MsWksDocument.hxx:88
MWAWCell.hxx
Defines MWAWCell (cell content and format)
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:99
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MsWksDocument::m_graphParser
shared_ptr< MsWksGraph > m_graphParser
the graph document
Definition: MsWksDocument.hxx:256
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MsWksDocument::m_textParser4
shared_ptr< MsWks4Text > m_textParser4
the text document (for v4 document)
Definition: MsWksDocument.hxx:260
MsWksDocument::Zone::Zone
Zone(ZoneType type=Z_NONE, int zoneId=-1)
the constructor
Definition: MsWksDocument.hxx:82
MsWksDocument::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MsWksDocument.hxx:127
MWAWVec2< int >
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:68