- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
48 namespace MsWksDocumentInternal
49 {
50 struct State;
51
52 class SubDocument;
53 }
54
55 class MsWksParser;
56 class MsWksDBParser;
57 class MsWksDRParser;
58 class MsWksSSParser;
59 class MsWks4Zone;
60
61 class MsWksGraph;
62 class MsWks3Text;
63 class MsWks4Text;
64
67 class MsWksDocument
68 {
69 friend class MsWksDocumentInternal::SubDocument;
70 friend class MsWksParser;
71 friend class MsWks4Zone;
72 friend class MsWksDBParser;
73 friend class MsWksDRParser;
74 friend class MsWksSSParser;
75 public:
77 enum ZoneType { Z_MAIN, Z_HEADER, Z_FOOTER, Z_NONE };
79 struct Zone {
81 Zone(ZoneType type=Z_NONE, int zoneId=-1) : m_type(type), m_zoneId(zoneId), m_textId(-1) {}
83 ZoneType m_type;
85 int m_zoneId;
87 int m_textId;
88 };
89
90 public:
91
93 MsWksDocument(MWAWInputStreamPtr input, MWAWParser &parser);
95 virtual ~MsWksDocument();
96
98 int version() const;
100 void setVersion(int vers);
102 MWAWDocument::Kind getKind() const;
104 void setKind(MWAWDocument::Kind kind);
105
107 MWAWInputStreamPtr &getInput()
108 {
109 return m_input;
110 }
112 MWAWParser &getMainParser()
113 {
114 return *m_parser;
115 }
117 shared_ptr<MsWksGraph> getGraphParser()
118 {
119 return m_graphParser;
120 }
122 shared_ptr<MsWks3Text> getTextParser3();
124 shared_ptr<MsWks4Text> getTextParser4();
126 libmwaw::DebugFile &ascii()
127 {
128 return m_asciiFile;
129 }
130
131 //
132 // read some v3 structure
133 //
134
136 bool checkHeader3(MWAWHeader *header, bool strict=false);
138 long getLengthOfFileHeader3() const;
140 bool readPrintInfo();
142 bool readDocumentInfo(long sz=-1);
144 bool readZone(Zone &zone);
146 bool readGroupHeaderFooter(bool header, int check);
147
148 //
149 // read some ole structures
150 //
151
153 bool createOLEZones(MWAWInputStreamPtr input);
155 std::vector<std::string> const &getUnparsedOLEZones() const;
156 //
157 // utilities functions
158 //
159
161 bool hasHeader() const;
163 bool hasFooter() const;
165 float getHeaderFooterHeight(bool header) const;
167 void getPageSpanList(std::vector<MWAWPageSpan> &pagesList, int &numPages);
169 static bool getColor(int id, MWAWColor &col, int vers);
171 static std::vector<MWAWColor> const &getPalette(int vers);
172
174 std::multimap<int, Zone> &getTypeZoneMap();
176 Zone getZone(ZoneType type) const;
178 int getNewZoneId() const;
180 std::multimap<std::string, MWAWEntry> &getEntryMap();
181
182 // general interface
183
185 void sendZone(int zoneType);
186
187 // interface with the text parser
188
190 void newPage(int page, bool softBreak=false);
192 void sendFootnoteContent(int noteId);
194 void sendFootnote(int id);
196 void sendText(int id);
197
198 // interface with the graph parser
199
201 void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style);
203 void sendRBIL(int id, MWAWVec2i const &sz);
205 void sendTextbox(MWAWEntry const &entry, std::string const &frame);
206
207 protected:
208 //
209 // spreadsheet/database function
210 //
211
213 bool readCellInFormula(MWAWCellContent::FormulaInstruction &instr, bool is2D);
215 bool readDBString(long endPos, std::string &res);
217 bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str);
218 /* reads a formula */
219 bool readFormula(long endPos, MWAWCellContent &content, std::string &extra);
220
221 protected:
222
223 //
224 // low level
225 //
227 void initAsciiFile(std::string const &name);
228
229 private:
230 MsWksDocument(MsWksDocument const &orig);
231 MsWksDocument &operator=(MsWksDocument const &orig);
232
233 //
234 // data
235 //
236
237 protected:
239 shared_ptr<MsWksDocumentInternal::State> m_state;
240 public:
242 shared_ptr<MWAWParserState> m_parserState;
243
244 protected:
246 MWAWParser *m_parser;
248 MsWksDocument *m_parentDocument;
250 MWAWInputStreamPtr m_input;
252 libmwaw::DebugFile m_asciiFile;
253
255 shared_ptr<MsWksGraph> m_graphParser;
257 shared_ptr<MsWks3Text> m_textParser3;
259 shared_ptr<MsWks4Text> m_textParser4;
260
262 typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
263
265 NewPage m_newPage;
266 };
267 #endif
268 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MsWksDocument::setKind
void setKind(MWAWDocument::Kind kind)
sets the document's kind
Definition: MsWksDocument.cxx:230
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition: MWAWCell.hxx:360
MsWksDocument::m_state
shared_ptr< MsWksDocumentInternal::State > m_state
the state
Definition: MsWksDocument.hxx:239
MsWksDocument::readGroupHeaderFooter
bool readGroupHeaderFooter(bool header, int check)
try to read a header/footer group
Definition: MsWksDocument.cxx:850
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:250
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:117
MsWksDocument::sendTextbox
void sendTextbox(MWAWEntry const &entry, std::string const &frame)
send a textbox
Definition: MsWksDocument.cxx:420
MsWksDocument::~MsWksDocument
virtual ~MsWksDocument()
destructor
Definition: MsWksDocument.cxx:193
MsWksDocument::Zone::m_zoneId
int m_zoneId
the parser zone id
Definition: MsWksDocument.hxx:85
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::getPalette
static std::vector< MWAWColor > const & getPalette(int vers)
returns a list of color corresponding to a version
Definition: MsWksDocument.cxx:459
MsWksDocument::getMainParser
MWAWParser & getMainParser()
returns the main parser
Definition: MsWksDocument.hxx:112
MsWksDocument::sendOLE
void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style)
send an OLE zone
Definition: MsWksDocument.cxx:394
MsWksDocument::Zone::m_type
ZoneType m_type
the zone type
Definition: MsWksDocument.hxx:83
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::version
int version() const
returns the document's version
Definition: MsWksDocument.cxx:220
MsWksDocument::Z_FOOTER
Definition: MsWksDocument.hxx:77
MsWksDocument::readFormula
bool readFormula(long endPos, MWAWCellContent &content, std::string &extra)
Definition: MsWksDocument.cxx:1227
MsWksDocument::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file of the actual input
Definition: MsWksDocument.hxx:252
MsWksDocument::NewPage
void(MWAWParser::* NewPage)(int page, bool softBreak)
callback used to send a page break
Definition: MsWksDocument.hxx:262
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:77
MsWksDocument::sendZone
void sendZone(int zoneType)
try to send a zone (v1-v3 document)
Definition: MsWksDocument.cxx:268
MsWksDocument::operator=
MsWksDocument & operator=(MsWksDocument const &orig)
MsWksDocument::Zone
a zone of a MsWksDocument ( main, header, footer )
Definition: MsWksDocument.hxx:79
MsWksDocument::sendText
void sendText(int id)
try to send a text zone (v1-v3 document)
Definition: MsWksDocument.cxx:263
MsWksDocument::m_parentDocument
MsWksDocument * m_parentDocument
the parent document (if this is not the main document)
Definition: MsWksDocument.hxx:248
MsWksDocument::sendRBIL
void sendRBIL(int id, MWAWVec2i const &sz)
send a rbil zone
Definition: MsWksDocument.cxx:410
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:177
MsWksDocument::getTextParser4
shared_ptr< MsWks4Text > getTextParser4()
returns the text parser (for v4 document)
Definition: MsWksDocument.cxx:209
MsWksDocument::Z_HEADER
Definition: MsWksDocument.hxx:77
MWAWCellContent
small class use to define a sheet cell content
Definition: MWAWCell.hxx:356
MsWksDocument::m_textParser3
shared_ptr< MsWks3Text > m_textParser3
the text document (for v1-3 document)
Definition: MsWksDocument.hxx:257
MsWksDocument::createOLEZones
bool createOLEZones(MWAWInputStreamPtr input)
finds the different OLE zones
Definition: MsWksDocument.cxx:586
MsWksDocument::readDBNumber
bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str)
try to read a number
Definition: MsWksDocument.cxx:1178
MsWksDocument::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MsWksDocument.hxx:107
MsWksDocument::readZone
bool readZone(Zone &zone)
try to read a generic zone
Definition: MsWksDocument.cxx:949
MsWksDocument::m_parser
MWAWParser * m_parser
the main parser
Definition: MsWksDocument.hxx:246
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:242
MsWks4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition: MsWks4Zone.hxx:73
MsWksDocument::newPage
void newPage(int page, bool softBreak=false)
tries to create a new page
Definition: MsWksDocument.cxx:372
MsWksDocument::getColor
static bool getColor(int id, MWAWColor &col, int vers)
returns the color which correspond to an index
Definition: MsWksDocument.cxx:556
MsWks3Text
the main class to read the text part of Microsoft Works file
Definition: MsWks3Text.hxx:69
MsWksDocument::readDocumentInfo
bool readDocumentInfo(long sz=-1)
try to read the documentinfo ( v1-v3)
Definition: MsWksDocument.cxx:736
MsWksDocument::getLengthOfFileHeader3
long getLengthOfFileHeader3() const
returns the length of the file header of a v1-v3 document (if know)
Definition: MsWksDocument.cxx:258
MsWksDocument::getEntryMap
std::multimap< std::string, MWAWEntry > & getEntryMap()
returns the document entry map of a v4 document
Definition: MsWksDocument.cxx:253
MsWksDRParser
the main class to read a Microsoft Works graphic file
Definition: MsWksDRParser.hxx:59
MsWksDocument::Z_NONE
Definition: MsWksDocument.hxx:77
MsWksDocument::getNewZoneId
int getNewZoneId() const
returns a free zone'id
Definition: MsWksDocument.cxx:235
MsWksDocument::sendFootnoteContent
void sendFootnoteContent(int noteId)
try to send a footnote content (v4 document)
Definition: MsWksDocument.cxx:276
MsWksDocument::readPrintInfo
bool readPrintInfo()
read the print info zone (v1-v3)
Definition: MsWksDocument.cxx:670
MsWksDocument::getZone
Zone getZone(ZoneType type) const
returns the zone corresponding to a zoneType (v1-v3 document)
Definition: MsWksDocument.cxx:240
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:439
MsWksDocument::getPageSpanList
void getPageSpanList(std::vector< MWAWPageSpan > &pagesList, int &numPages)
get the page span list and the number of page for a v1-v3 document
Definition: MsWksDocument.cxx:306
MsWksDocument::MsWksDocument
MsWksDocument(MWAWInputStreamPtr input, MWAWParser &parser)
constructor
Definition: MsWksDocument.cxx:185
MsWksDocument::m_newPage
NewPage m_newPage
the new page callback
Definition: MsWksDocument.hxx:265
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
MsWksDocumentInternal::SubDocument
Internal: the subdocument of a MsWksDocument.
Definition: MsWksDocument.cxx:107
MsWksDocument::getTextParser3
shared_ptr< MsWks3Text > getTextParser3()
returns the text parser (for v1-v3 document)
Definition: MsWksDocument.cxx:203
MsWksDocument::checkHeader3
bool checkHeader3(MWAWHeader *header, bool strict=false)
checks if the file header corresponds to a v1-v3 document (or not)
Definition: MsWksDocument.cxx:996
MsWksDocument::sendFootnote
void sendFootnote(int id)
tries to send a footnote
Definition: MsWksDocument.cxx:383
MsWksDocument::readDBString
bool readDBString(long endPos, std::string &res)
try to read a string
Definition: MsWksDocument.cxx:1163
MsWksDocument::Zone::m_textId
int m_textId
the text internal id
Definition: MsWksDocument.hxx:87
MWAWCell.hxx
Defines MWAWCell (cell content and format)
MsWksDocument::getTypeZoneMap
std::multimap< int, Zone > & getTypeZoneMap()
returns the document entry map of a v1-v3 document
Definition: MsWksDocument.cxx:248
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:97
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MsWksDocument::getKind
MWAWDocument::Kind getKind() const
returns the document's kind
Definition: MsWksDocument.cxx:225
MsWksDocument::initAsciiFile
void initAsciiFile(std::string const &name)
inits the ascii file
Definition: MsWksDocument.cxx:197
MsWksDocument::m_graphParser
shared_ptr< MsWksGraph > m_graphParser
the graph document
Definition: MsWksDocument.hxx:255
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:259
MsWksDocument::Zone::Zone
Zone(ZoneType type=Z_NONE, int zoneId=-1)
the constructor
Definition: MsWksDocument.hxx:81
MsWksDocument::Z_MAIN
Definition: MsWksDocument.hxx:77
MsWksDocument::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MsWksDocument.hxx:126
MsWksDocument::setVersion
void setVersion(int vers)
sets the document's version
Definition: MsWksDocument.cxx:215
MsWksDocument::getHeaderFooterHeight
float getHeaderFooterHeight(bool header) const
returns the header/footer height (found by readGroupHeaderFooter)
Definition: MsWksDocument.cxx:301
MsWksDocument::hasFooter
bool hasFooter() const
returns true if the document has some footer ( found by checkHeader3)
Definition: MsWksDocument.cxx:296
MsWksDocument::getUnparsedOLEZones
std::vector< std::string > const & getUnparsedOLEZones() const
returns the list of unparsed OLE zones
Definition: MsWksDocument.cxx:581
MsWksDocument::readCellInFormula
bool readCellInFormula(MWAWCellContent::FormulaInstruction &instr, bool is2D)
reads a cell
Definition: MsWksDocument.cxx:1188
MsWksDocument::hasHeader
bool hasHeader() const
returns true if the document has some header ( found by checkHeader3)
Definition: MsWksDocument.cxx:291
MWAWVec2< int >
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:67