CanvasParser.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 CANVAS_PARSER
35# define CANVAS_PARSER
36
37#include <string>
38#include <vector>
39
40#include <librevenge/librevenge.h>
41
42#include "MWAWDebug.hxx"
43#include "MWAWGraphicStyle.hxx"
44#include "MWAWInputStream.hxx"
45#include "MWAWPosition.hxx"
46
47#include "MWAWParser.hxx"
48
50{
51struct Layer;
52struct State;
53}
54
55class CanvasGraph;
57
61class CanvasParser final : public MWAWGraphicParser
62{
63 friend class CanvasGraph;
64 friend class CanvasStyleManager;
65public:
67 CanvasParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
69 ~CanvasParser() final;
70
72 bool checkHeader(MWAWHeader *header, bool strict=false) final;
73
74 // the main parse function
75 void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
76
77protected:
79 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
80
81 //
82 // interface
83 //
84
86 bool isWindowsFile() const;
87
88protected:
90 bool createZones();
93
94
95 // Intermediate level
96
98 bool readFileHeader();
100 bool readDocumentHeader();
102 bool readBrushes();
104 bool readGrids();
106 bool readLayers();
108 bool readMacroNames();
110 bool readFormats();
112 bool readSprays();
114 bool readViews();
115
116 //
117 // last v3 zones
118 //
119
121 bool readEndV3();
122
123 //
124 // Mac RSRC
125 //
126
128 bool readRSRCFileHeader(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile);
130 bool readPrintInfo(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile);
132 bool readLPOL(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile);
134 bool readUsers(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile);
136 bool readWindows(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile);
137
138 //
139 // Windows RSRC
140 //
141
143 bool readRSRCWindowsFile();
145 bool readCNam(MWAWEntry const &entry);
147 bool readCSet(MWAWEntry const &entry);
149 bool readPrinterDev(MWAWEntry const &entry);
151 bool readPage(MWAWEntry const &entry);
153 bool readPrinterSST(MWAWEntry const &entry);
154
158 bool readUnknownZone0();
160 bool readUnknownZone1();
162 bool readUnknownZone2();
164 bool readUnknownZone3();
166 bool readUnknownZone4();
167
168 //
169 // send data to the listener
170 //
171
173 bool send(CanvasParserInternal::Layer const &layer);
174
175 //
176 // low level
177 //
178
180 bool readString(librevenge::RVNGString &string, int maxSize, bool canBeCString=false);
182 bool readString(MWAWInputStreamPtr input, librevenge::RVNGString &string, int maxSize, bool canBeCString=false);
183
185 bool decode(long length);
186
187 //
188 // data
189 //
191 std::shared_ptr<CanvasParserInternal::State> m_state;
193 std::shared_ptr<CanvasGraph> m_graphParser;
196};
197#endif
198// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the main class to read the graphic part of Canvas file
Definition: CanvasGraph.hxx:71
the main class to read a Canvas 2 and 3 files
Definition: CanvasParser.hxx:62
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: CanvasParser.cxx:843
bool readPage(MWAWEntry const &entry)
read the Windows Page RSRC: v3
Definition: CanvasParser.cxx:2199
void parse(librevenge::RVNGDrawingInterface *documentInterface) final
virtual function used to parse the input
Definition: CanvasParser.cxx:582
void createDocument(librevenge::RVNGDrawingInterface *documentInterface)
creates the listener which will be associated to the document
Definition: CanvasParser.cxx:626
bool readWindows(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile)
read the RSRC Windows zone: v3
Definition: CanvasParser.cxx:1974
bool readViews()
try to read the views
Definition: CanvasParser.cxx:1559
bool readPrintInfo(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile)
read the print info zone
Definition: CanvasParser.cxx:1770
bool readRSRCFileHeader(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile)
read the RSRC HeAd(a copy of file header) zone: v3
Definition: CanvasParser.cxx:1867
bool readLayers()
try to read the layers
Definition: CanvasParser.cxx:750
bool createZones()
finds the different objects zones
Definition: CanvasParser.cxx:655
bool readPrinterSST(MWAWEntry const &entry)
read the Windows PSST RSRC: v3 (the printer, device name, ...)
Definition: CanvasParser.cxx:2318
bool readUnknownZoneHeader()
read the first unknown zone
Definition: CanvasParser.cxx:1090
bool readMacroNames()
read the macro names
Definition: CanvasParser.cxx:1057
std::shared_ptr< CanvasGraph > m_graphParser
the graph parser
Definition: CanvasParser.hxx:193
MWAWInputStreamPtr & getInput()
returns the current input
Definition: CanvasParser.cxx:555
bool readLPOL(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile)
read the RSRC LPol zone: v3
Definition: CanvasParser.cxx:1835
bool readString(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: CanvasParser.cxx:1715
bool readDocumentHeader()
read the document header
Definition: CanvasParser.cxx:968
bool readGrids()
read the grid: or a list which begins by a grid
Definition: CanvasParser.cxx:1354
bool readRSRCWindowsFile()
read the resource file which ends the file
Definition: CanvasParser.cxx:2005
bool readPrinterDev(MWAWEntry const &entry)
read the Windows DevM RSRC: v3 (main data of the printer device)
Definition: CanvasParser.cxx:2286
bool readBrushes()
try to read the brush
Definition: CanvasParser.cxx:1213
bool readUsers(MWAWInputStreamPtr input, MWAWEntry const &entry, libmwaw::DebugFile &ascFile)
read the RSRC user zone: v3
Definition: CanvasParser.cxx:1909
bool readFileHeader()
read the file header: list of unknown numbers
Definition: CanvasParser.cxx:897
std::shared_ptr< CanvasStyleManager > m_styleManager
the style manager
Definition: CanvasParser.hxx:195
bool readEndV3()
try to read the end zone: v3
Definition: CanvasParser.cxx:1609
bool isWindowsFile() const
returns true if the file is a windows file
Definition: CanvasParser.cxx:574
bool readCSet(MWAWEntry const &entry)
read the Windows CSet RSRC: v3 (contains the string Default)
Definition: CanvasParser.cxx:2174
~CanvasParser() final
destructor
Definition: CanvasParser.cxx:551
bool send(CanvasParserInternal::Layer const &layer)
tries to send a layer
Definition: CanvasParser.cxx:2360
bool readCNam(MWAWEntry const &entry)
read the Windows CNam RSRC: v3 (always 256 0's bytes)
Definition: CanvasParser.cxx:2143
bool readSprays()
try to read the spray
Definition: CanvasParser.cxx:1291
bool readFormats()
read the formats' zone, mainly an unit's conversion table
Definition: CanvasParser.cxx:1317
bool readUnknownZone2()
read an unknown zone
Definition: CanvasParser.cxx:1473
std::shared_ptr< CanvasParserInternal::State > m_state
the state
Definition: CanvasParser.hxx:191
bool readUnknownZone4()
read an unknown zone: the last zone of a v2 files
Definition: CanvasParser.cxx:1520
bool readUnknownZone0()
read an unknown zone: contains a layer name, some font id,sz, ...
Definition: CanvasParser.cxx:1107
bool readUnknownZone1()
read an unknown zone
Definition: CanvasParser.cxx:1421
bool readUnknownZone3()
read an unknown zone
Definition: CanvasParser.cxx:1494
bool decode(long length)
try to decode some data: length==-1 means decode end of input
Definition: CanvasParser.cxx:562
the main class to read the style part of Canvas file
Definition: CanvasStyleManager.hxx:67
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
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 CanvasParser.
Definition: CanvasParser.cxx:61
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:51
Definition: MWAWDocument.hxx:57

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