Canvas5Parser.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 CANVAS5_PARSER
35 # define CANVAS5_PARSER
36 
37 #include <functional>
38 #include <map>
39 #include <string>
40 #include <utility>
41 #include <vector>
42 
43 #include <librevenge/librevenge.h>
44 
45 #include "MWAWDebug.hxx"
46 #include "MWAWInputStream.hxx"
47 #include "MWAWPosition.hxx"
48 
49 #include "MWAWParser.hxx"
50 
51 namespace Canvas5ParserInternal
52 {
53 struct Layer;
54 struct Slide;
55 
56 struct State;
57 }
58 
59 class Canvas5Graph;
60 class Canvas5Image;
62 
63 namespace Canvas5Structure
64 {
65 struct Stream;
66 }
67 
71 class Canvas5Parser final : public MWAWGraphicParser
72 {
73  friend class Canvas5Graph;
74  friend class Canvas5Image;
75  friend class Canvas5StyleManager;
76 public:
78  Canvas5Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
80  ~Canvas5Parser() final;
81 
83  bool checkHeader(MWAWHeader *header, bool strict=false) final;
84 
85  // the main parse function
86  void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
87 
88 protected:
90  void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
91 
92  //
93  // interface
94  //
95 
97  bool isWindowsFile() const;
99  librevenge::RVNGString getTextLink(int textLinkId) const;
100 
101 protected:
103  bool createZones();
105  bool readMainBlock(std::shared_ptr<Canvas5Structure::Stream> stream);
107  bool readFileRSRCs(Canvas5Structure::Stream &stream);
109  bool readSI200(Canvas5Structure::Stream &stream);
111  bool readFileDesc(Canvas5Structure::Stream &stream);
112 
113  // Intermediate level
114 
115  //
116  // first block
117  //
118 
120  bool readFileHeader(Canvas5Structure::Stream &stream);
121 
123  bool readDocumentSettings(Canvas5Structure::Stream &stream);
125  bool readLayers(Canvas5Structure::Stream &stream);
127  bool readPreview(Canvas5Structure::Stream &stream);
129  bool readSlides(Canvas5Structure::Stream &stream);
131  bool readTextLinks(Canvas5Structure::Stream &stream);
132 
133  //
134  // second block
135  //
136 
137  //
138  // third block
139  //
140 
142  bool readPrinterRsrc(Canvas5Structure::Stream &stream);
144  bool readOLnkRsrc(Canvas5Structure::Stream &stream);
146  bool readObjectDBRsrc(Canvas5Structure::Stream &stream);
147 
148  //
149  // Mac RSRC
150  //
152  bool readPnot(Canvas5Structure::Stream &stream, MWAWEntry const &entry);
154  bool readPicture(Canvas5Structure::Stream &stream, MWAWEntry const &entry);
155 
156  //
157  // Windows RSRC
158  //
159 
160  //
161  // send data to the listener
162  //
163 
165  bool send(Canvas5ParserInternal::Slide const &slide);
167  bool send(Canvas5ParserInternal::Layer const &layer);
168 
169  //
170  // low level
171  //
172 
174  bool readString(Canvas5Structure::Stream &stream, librevenge::RVNGString &string, int maxSize, bool canBeCString=false);
176  bool readDouble(Canvas5Structure::Stream &stream, double &val, bool &isNaN) const;
178  typedef std::function<void(Canvas5Structure::Stream &, int, std::string const &, long)> DataFunction;
180  static void defDataFunction(Canvas5Structure::Stream &, int, std::string const &, long) {}
182  static void stringDataFunction(Canvas5Structure::Stream &stream, int id, std::string const &what, long len);
183 
185  bool readDataHeader(Canvas5Structure::Stream &stream, int expectedSize, int &N);
190  bool readExtendedHeader(Canvas5Structure::Stream &stream, int expectedValue, std::string const &what, DataFunction const &func);
191 
193  bool readUsed(Canvas5Structure::Stream &stream, std::string const &what);
195  bool readDefined(Canvas5Structure::Stream &stream, std::vector<bool> &defined, std::string const &what);
196 
198  bool readIndexMap(Canvas5Structure::Stream &stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction);
199 
202 
203  //
204  // data
205  //
207  std::shared_ptr<Canvas5ParserInternal::State> m_state;
209  std::shared_ptr<Canvas5Graph> m_graphParser;
211  std::shared_ptr<Canvas5Image> m_imageParser;
213  std::shared_ptr<Canvas5StyleManager> m_styleManager;
214 };
215 #endif
216 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the main class to read the graphic part of Canvas5 file
Definition: Canvas5Graph.hxx:85
the main class to read/convert the image or movie inside of Canvas 5/6 file
Definition: Canvas5Image.hxx:78
the main class to read a Canvas 5/6 files
Definition: Canvas5Parser.hxx:72
bool readOLnkRsrc(Canvas5Structure::Stream &stream)
try to read the OLnk rsrc block: v6
Definition: Canvas5Parser.cxx:1905
static void defDataFunction(Canvas5Structure::Stream &, int, std::string const &, long)
the default function to parse the data of a index map/a extended header
Definition: Canvas5Parser.hxx:180
std::shared_ptr< Canvas5Graph > m_graphParser
the graph parser
Definition: Canvas5Parser.hxx:209
std::shared_ptr< Canvas5Image > m_imageParser
the image parser
Definition: Canvas5Parser.hxx:211
bool readMainBlock(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the first big block
Definition: Canvas5Parser.cxx:450
bool readSI200(Canvas5Structure::Stream &stream)
try to read the SI200 zone: v6
Definition: Canvas5Parser.cxx:1211
bool readString(Canvas5Structure::Stream &stream, librevenge::RVNGString &string, int maxSize, bool canBeCString=false)
try to read a pascal string in the data fork or a Pascal/C string depending on the file type
Definition: Canvas5Parser.cxx:2501
bool readUsed(Canvas5Structure::Stream &stream, std::string const &what)
try to read the used list
Definition: Canvas5Parser.cxx:2810
std::shared_ptr< Canvas5StyleManager > m_styleManager
the style manager
Definition: Canvas5Parser.hxx:213
std::shared_ptr< Canvas5ParserInternal::State > m_state
the state
Definition: Canvas5Parser.hxx:207
std::function< void(Canvas5Structure::Stream &, int, std::string const &, long)> DataFunction
a function used to parse the data of a index map/a extended header
Definition: Canvas5Parser.hxx:178
bool readObjectDBRsrc(Canvas5Structure::Stream &stream)
try to read the object database: XOBD v6
Definition: Canvas5Parser.cxx:1959
bool readPreview(Canvas5Structure::Stream &stream)
try to read the preview picture
Definition: Canvas5Parser.cxx:1674
bool readExtendedHeader(Canvas5Structure::Stream &stream, int expectedValue, std::string const &what, DataFunction const &func)
try to read an extended data header, ie.
Definition: Canvas5Parser.cxx:2569
librevenge::RVNGString getTextLink(int textLinkId) const
returns the link corresponding to a text id
Definition: Canvas5Parser.cxx:208
bool readDefined(Canvas5Structure::Stream &stream, std::vector< bool > &defined, std::string const &what)
try to read the defined list
Definition: Canvas5Parser.cxx:2756
bool readSlides(Canvas5Structure::Stream &stream)
try to read the list of slides
Definition: Canvas5Parser.cxx:2110
void createDocument(librevenge::RVNGDrawingInterface *documentInterface)
creates the listener which will be associated to the document
Definition: Canvas5Parser.cxx:253
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: Canvas5Parser.cxx:2310
~Canvas5Parser() final
destructor
Definition: Canvas5Parser.cxx:198
bool readFileHeader(Canvas5Structure::Stream &stream)
try to read the file header
Definition: Canvas5Parser.cxx:1346
bool readLayers(Canvas5Structure::Stream &stream)
try to read the different layers
Definition: Canvas5Parser.cxx:1569
bool readPnot(Canvas5Structure::Stream &stream, MWAWEntry const &entry)
read the RSRC 0 pnot zone
Definition: Canvas5Parser.cxx:2367
bool send(Canvas5ParserInternal::Slide const &slide)
try to send a page/slide
Definition: Canvas5Parser.cxx:2439
bool isWindowsFile() const
returns true if the file is a windows file
Definition: Canvas5Parser.cxx:202
bool readTextLinks(Canvas5Structure::Stream &stream)
try to read the text links
Definition: Canvas5Parser.cxx:2009
bool readPrinterRsrc(Canvas5Structure::Stream &stream)
try to read a printer rsrc
Definition: Canvas5Parser.cxx:1744
Canvas5Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: Canvas5Parser.cxx:179
void parse(librevenge::RVNGDrawingInterface *documentInterface) final
virtual function used to parse the input
Definition: Canvas5Parser.cxx:221
static void stringDataFunction(Canvas5Structure::Stream &stream, int id, std::string const &what, long len)
the default function to parse the data of a index map/a extended header
Definition: Canvas5Parser.cxx:2637
bool readDouble(Canvas5Structure::Stream &stream, double &val, bool &isNaN) const
try to read a double 8
Definition: Canvas5Parser.cxx:2489
bool readPicture(Canvas5Structure::Stream &stream, MWAWEntry const &entry)
read the RSRC Pict zone
Definition: Canvas5Parser.cxx:2395
bool readFileDesc(Canvas5Structure::Stream &stream)
try to read the last block: some pathes, ...
Definition: Canvas5Parser.cxx:1285
bool readIndexMap(Canvas5Structure::Stream &stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction)
try to read a index map
Definition: Canvas5Parser.cxx:2653
bool readDocumentSettings(Canvas5Structure::Stream &stream)
read the document settings
Definition: Canvas5Parser.cxx:1451
static MWAWInputStreamPtr decode(MWAWInputStreamPtr input, int version)
try to decode the input stream
Definition: Canvas5Parser.cxx:2870
bool readDataHeader(Canvas5Structure::Stream &stream, int expectedSize, int &N)
try to read a data header, ie. N fields with a given size
Definition: Canvas5Parser.cxx:2548
bool readFileRSRCs(Canvas5Structure::Stream &stream)
try to read the third big block: a list of resource?, font, ...
Definition: Canvas5Parser.cxx:483
bool createZones()
finds the different objects zones
Definition: Canvas5Parser.cxx:381
the main class to read the style part of Canvas 5 file
Definition: Canvas5StyleManager.hxx:86
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:251
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
int version() const
returns the works version
Definition: MWAWParser.hxx:108
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 Canvas5Parser.
Definition: Canvas5Parser.cxx:71
a namespace used to define basic function or structure to read a Canvas 5 file
Definition: Canvas5BMParser.hxx:64
Definition: MWAWDocument.hxx:57
a sub stream of Canvas5Structure
Definition: Canvas5Structure.hxx:49

Generated on Mon May 24 2021 16:43:56 for libmwaw by doxygen 1.9.1