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
50{
51struct State;
52
53class SubDocument;
54}
55
56class MsWksParser;
57class MsWksDBParser;
58class MsWksDRParser;
59class MsWksSSParser;
60class MsWks4Zone;
61
62class MsWksGraph;
63class MsWks3Text;
64class MsWks4Text;
65
69{
71 friend class MsWksParser;
72 friend class MsWks4Zone;
73 friend class MsWksDBParser;
74 friend class MsWksDRParser;
75 friend class MsWksSSParser;
76public:
80 struct Zone {
82 Zone(ZoneType type=Z_NONE, int zoneId=-1)
83 : m_type(type)
84 , m_zoneId(zoneId)
85 , m_textId(-1)
86 {
87 }
94 };
95
96public:
97
99 MsWksDocument(MWAWInputStreamPtr const &input, MWAWParser &parser);
101 virtual ~MsWksDocument();
102
104 int version() const;
106 void setVersion(int vers);
110 void setKind(MWAWDocument::Kind kind);
111
114 {
115 return m_input;
116 }
119 {
120 return *m_parser;
121 }
123 std::shared_ptr<MsWksGraph> getGraphParser()
124 {
125 return m_graphParser;
126 }
128 std::shared_ptr<MsWks3Text> getTextParser3();
130 std::shared_ptr<MsWks4Text> getTextParser4();
133 {
134 return m_asciiFile;
135 }
136
137 //
138 // read some v3 structure
139 //
140
142 bool checkHeader3(MWAWHeader *header, bool strict=false);
144 long getLengthOfFileHeader3() const;
146 bool readPrintInfo();
148 bool readDocumentInfo(long sz=-1);
150 bool readZone(Zone &zone);
152 bool readGroupHeaderFooter(bool header, int check);
153
154 //
155 // read some ole structures
156 //
157
161 std::vector<std::string> const &getUnparsedOLEZones() const;
162 //
163 // utilities functions
164 //
165
167 bool hasHeader() const;
169 bool hasFooter() const;
171 float getHeaderFooterHeight(bool header) const;
173 void getPageSpanList(std::vector<MWAWPageSpan> &pagesList, int &numPages);
175 bool getColor(int id, MWAWColor &col, int vers);
177 std::vector<MWAWColor> const &getPalette(int vers);
178
180 std::multimap<int, Zone> &getTypeZoneMap();
182 Zone getZone(ZoneType type) const;
184 int getNewZoneId() const;
186 std::multimap<std::string, MWAWEntry> &getEntryMap();
187
188 // general interface
189
191 void sendZone(int zoneType);
192
193 // interface with the text parser
194
196 void newPage(int page, bool softBreak=false);
198 void sendFootnoteContent(int noteId);
200 void sendFootnote(int id);
202 void sendText(int id);
203
204 // interface with the graph parser
205
207 void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style);
209 void sendRBIL(int id, MWAWVec2i const &sz);
211 void sendTextbox(MWAWEntry const &entry, std::string const &frame);
212
213protected:
214 //
215 // spreadsheet/database function
216 //
217
221 bool readDBString(long endPos, std::string &res);
223 bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str);
224 /* reads a formula */
225 bool readFormula(long endPos, MWAWCellContent &content, std::string &extra);
226
227protected:
228
229 //
230 // low level
231 //
233 void initAsciiFile(std::string const &name);
234
235private:
236 MsWksDocument(MsWksDocument const &orig) = delete;
237 MsWksDocument &operator=(MsWksDocument const &orig) = delete;
238
239 //
240 // data
241 //
242
243protected:
245 std::shared_ptr<MsWksDocumentInternal::State> m_state;
246public:
248 std::shared_ptr<MWAWParserState> m_parserState;
249
250protected:
259
261 std::shared_ptr<MsWksGraph> m_graphParser;
263 std::shared_ptr<MsWks3Text> m_textParser3;
265 std::shared_ptr<MsWks4Text> m_textParser4;
266
268 typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
269
272};
273#endif
274// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Defines MWAWCell (cell content and format)
small class use to define a sheet cell content
Definition: MWAWCell.hxx:394
Kind
an enum to define the kind of document
Definition: MWAWDocument.hxx:80
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:100
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
the main class to read the text part of Microsoft Works file
Definition: MsWks3Text.hxx:70
The class which parses text zones in a mac MS Works document v4.
Definition: MsWks4Text.hxx:65
The class which parses the main zones of a mac MS Works document v4.
Definition: MsWks4Zone.hxx:74
the main class to read a Microsoft Works database file and convert it in a spreadsheet file
Definition: MsWksDBParser.hxx:66
the main class to read a Microsoft Works graphic file
Definition: MsWksDRParser.hxx:60
Internal: the subdocument of a MsWksDocument.
Definition: MsWksDocument.cxx:219
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:69
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:426
MWAWParser & getMainParser()
returns the main parser
Definition: MsWksDocument.hxx:118
bool createOLEZones(MWAWInputStreamPtr input)
finds the different OLE zones
Definition: MsWksDocument.cxx:613
int getNewZoneId() const
returns a free zone'id
Definition: MsWksDocument.cxx:355
MWAWInputStreamPtr m_input
the input which can be an OLE in MSWorks 4 file
Definition: MsWksDocument.hxx:256
bool hasFooter() const
returns true if the document has some footer ( found by checkHeader3)
Definition: MsWksDocument.cxx:416
bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str)
try to read a number
Definition: MsWksDocument.cxx:1202
std::shared_ptr< MsWksGraph > getGraphParser()
returns the graph parser
Definition: MsWksDocument.hxx:123
ZoneType
the different type of zone (v1-v3)
Definition: MsWksDocument.hxx:78
@ Z_MAIN
Definition: MsWksDocument.hxx:78
@ Z_NONE
Definition: MsWksDocument.hxx:78
@ Z_HEADER
Definition: MsWksDocument.hxx:78
@ Z_FOOTER
Definition: MsWksDocument.hxx:78
void(MWAWParser::* NewPage)(int page, bool softBreak)
callback used to send a page break
Definition: MsWksDocument.hxx:268
MsWksDocument & operator=(MsWksDocument const &orig)=delete
NewPage m_newPage
the new page callback
Definition: MsWksDocument.hxx:271
void sendTextbox(MWAWEntry const &entry, std::string const &frame)
send a textbox
Definition: MsWksDocument.cxx:540
bool readCellInFormula(MWAWCellContent::FormulaInstruction &instr, bool is2D)
reads a cell
Definition: MsWksDocument.cxx:1212
std::shared_ptr< MsWksDocumentInternal::State > m_state
the state
Definition: MsWksDocument.hxx:245
long getLengthOfFileHeader3() const
returns the length of the file header of a v1-v3 document (if know)
Definition: MsWksDocument.cxx:378
void sendRBIL(int id, MWAWVec2i const &sz)
send a rbil zone
Definition: MsWksDocument.cxx:530
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MsWksDocument.hxx:113
bool readGroupHeaderFooter(bool header, int check)
try to read a header/footer group
Definition: MsWksDocument.cxx:875
std::vector< std::string > const & getUnparsedOLEZones() const
returns the list of unparsed OLE zones
Definition: MsWksDocument.cxx:608
MsWksDocument(MsWksDocument const &orig)=delete
bool hasHeader() const
returns true if the document has some header ( found by checkHeader3)
Definition: MsWksDocument.cxx:411
libmwaw::DebugFile m_asciiFile
the debug file of the actual input
Definition: MsWksDocument.hxx:258
bool checkHeader3(MWAWHeader *header, bool strict=false)
checks if the file header corresponds to a v1-v3 document (or not)
Definition: MsWksDocument.cxx:1020
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MsWksDocument.hxx:132
bool readZone(Zone &zone)
try to read a generic zone
Definition: MsWksDocument.cxx:973
std::multimap< std::string, MWAWEntry > & getEntryMap()
returns the document entry map of a v4 document
Definition: MsWksDocument.cxx:373
bool getColor(int id, MWAWColor &col, int vers)
returns the color which correspond to an index
Definition: MsWksDocument.cxx:583
void newPage(int page, bool softBreak=false)
tries to create a new page
Definition: MsWksDocument.cxx:492
MWAWParser * m_parser
the main parser
Definition: MsWksDocument.hxx:252
bool readDBString(long endPos, std::string &res)
try to read a string
Definition: MsWksDocument.cxx:1187
bool readPrintInfo()
read the print info zone (v1-v3)
Definition: MsWksDocument.cxx:695
void sendZone(int zoneType)
try to send a zone (v1-v3 document)
Definition: MsWksDocument.cxx:388
void sendFootnote(int id)
tries to send a footnote
Definition: MsWksDocument.cxx:503
bool readDocumentInfo(long sz=-1)
try to read the documentinfo ( v1-v3)
Definition: MsWksDocument.cxx:761
std::shared_ptr< MWAWParserState > m_parserState
the parser state
Definition: MsWksDocument.hxx:248
virtual ~MsWksDocument()
destructor
Definition: MsWksDocument.cxx:313
MsWksDocument * m_parentDocument
the parent document (if this is not the main document)
Definition: MsWksDocument.hxx:254
bool readFormula(long endPos, MWAWCellContent &content, std::string &extra)
Definition: MsWksDocument.cxx:1250
void setVersion(int vers)
sets the document's version
Definition: MsWksDocument.cxx:335
void initAsciiFile(std::string const &name)
inits the ascii file
Definition: MsWksDocument.cxx:317
void sendText(int id)
try to send a text zone (v1-v3 document)
Definition: MsWksDocument.cxx:383
void sendFootnoteContent(int noteId)
try to send a footnote content (v4 document)
Definition: MsWksDocument.cxx:396
std::shared_ptr< MsWks3Text > m_textParser3
the text document (for v1-3 document)
Definition: MsWksDocument.hxx:263
std::shared_ptr< MsWksGraph > m_graphParser
the graph document
Definition: MsWksDocument.hxx:261
void setKind(MWAWDocument::Kind kind)
sets the document's kind
Definition: MsWksDocument.cxx:350
float getHeaderFooterHeight(bool header) const
returns the header/footer height (found by readGroupHeaderFooter)
Definition: MsWksDocument.cxx:421
std::shared_ptr< MsWks4Text > m_textParser4
the text document (for v4 document)
Definition: MsWksDocument.hxx:265
std::shared_ptr< MsWks4Text > getTextParser4()
returns the text parser (for v4 document)
Definition: MsWksDocument.cxx:329
Zone getZone(ZoneType type) const
returns the zone corresponding to a zoneType (v1-v3 document)
Definition: MsWksDocument.cxx:360
void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style)
send an OLE zone
Definition: MsWksDocument.cxx:514
MWAWDocument::Kind getKind() const
returns the document's kind
Definition: MsWksDocument.cxx:345
int version() const
returns the document's version
Definition: MsWksDocument.cxx:340
std::shared_ptr< MsWks3Text > getTextParser3()
returns the text parser (for v1-v3 document)
Definition: MsWksDocument.cxx:323
std::multimap< int, Zone > & getTypeZoneMap()
returns the document entry map of a v1-v3 document
Definition: MsWksDocument.cxx:368
std::vector< MWAWColor > const & getPalette(int vers)
returns a list of color corresponding to a version
Definition: MsWksDocument.cxx:578
the main class to read the graphic of a Microsoft Works file
Definition: MsWksGraph.hxx:74
the main class to read a Microsoft Works file: v1-v4
Definition: MsWksParser.hxx:60
the main class to read a Microsoft Works spreadsheet file
Definition: MsWksSSParser.hxx:66
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
Internal: the structures of a MsWksDocument.
Definition: MsWksDocument.cxx:64
small class use to define a formula instruction
Definition: MWAWCell.hxx:397
the class to store a color
Definition: libmwaw_internal.hxx:192
a zone of a MsWksDocument ( main, header, footer )
Definition: MsWksDocument.hxx:80
ZoneType m_type
the zone type
Definition: MsWksDocument.hxx:89
int m_textId
the text internal id
Definition: MsWksDocument.hxx:93
int m_zoneId
the parser zone id
Definition: MsWksDocument.hxx:91
Zone(ZoneType type=Z_NONE, int zoneId=-1)
the constructor
Definition: MsWksDocument.hxx:82

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