Debian Codegraph @

src/lib/CorelPainterParser.hxx

raw
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 ([email protected])
18 * Copyright (C) 2002,2004 Marc Maurer ([email protected])
19 * Copyright (C) 2004-2006 Fridrich Strba ([email protected])
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent ([email protected])
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 CORELPAINTER_PARSER
35 # define CORELPAINTER_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWDebug.hxx"
43 #include "MWAWInputStream.hxx"
44
45 #include "MWAWParser.hxx"
46
47 class MWAWPict;
48
49 namespace CorelPainterParserInternal
50 {
51 struct Node;
52 struct ZoneHeader;
53 struct State;
54
55 class SubDocument;
56 }
57
58 /** \brief the main class to read a Painter's file, actually, read
59 * Fractal Design Painter 1-4, MetaCreation v5-v6 and Corel Painter v7-v10 Mac files
60 * and Fractal Design Painter 3 Windows files.
61 */
62 class CorelPainterParser final : public MWAWGraphicParser
63 {
64 public:
65 friend class CorelPainterParserInternal::SubDocument;
66 //! constructor
67 CorelPainterParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
68 //! destructor
69 ~CorelPainterParser() final;
70
71 //! checks if the document header is correct (or not)
72 bool checkHeader(MWAWHeader *header, bool strict=false) final;
73
74 //! the main parser function
75 void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
76
77 protected:
78 //! inits all internal variables
79 void init();
80
81 //! creates the listener which will be associated to the document
82 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
83 //! try to send a bitmap zone (main bitmap or floater)
84 bool sendBitmap(CorelPainterParserInternal::ZoneHeader const &zone);
85 //! try to send a not bitmap zone
86 bool sendZone(CorelPainterParserInternal::ZoneHeader const &zone);
87 protected:
88 //! finds the different objects zones
89 bool createZones();
90 //! try to read the Hoffman tree
91 std::shared_ptr<CorelPainterParserInternal::Node> readCompressionTree(long endPos, int numNodes);
92
93 //! try to decompress a data
94 bool decompressData(CorelPainterParserInternal::ZoneHeader const &zone, long endPos, int &value, int &buffer, int &numBitsInBuffer);
95 // Intermediate level
96
97 //! try to read the header zone
98 bool readZoneHeader(CorelPainterParserInternal::ZoneHeader &zone);
99 //! try to read a bitmap
100 std::shared_ptr<MWAWPict> readBitmap(CorelPainterParserInternal::ZoneHeader const &zone);
101 //! try to read a bitmap line
102 bool readBitmapRow(CorelPainterParserInternal::ZoneHeader const &zone,
103 std::vector<MWAWColor> &colorList, std::vector<unsigned char> &previousValues);
104 //! try to read the list of resource zone (in the data fork)
105 bool readResourcesList(CorelPainterParserInternal::ZoneHeader &zone);
106 //! try to parse the resource data
107 bool readResource(MWAWEntry const &entry);
108 //! try to parse the text data
109 bool sendText(MWAWEntry const &entry, MWAWEntry const &unicodeEntry);
110 //! try to read a polygon data
111 bool readPolygon(long endPos, MWAWGraphicShape &shape, MWAWGraphicStyle &style);
112
113 //! update the position beforing sending a bitmap, shape, ...
114 MWAWPosition getZonePosition(CorelPainterParserInternal::ZoneHeader const &zone) const;
115
116 // low level
117 //! try to read a double 1 bytes exponent, 3 mantisse
118 bool readDouble(double &res);
119 //
120 // data
121 //
122 //! the state
123 std::shared_ptr<CorelPainterParserInternal::State> m_state;
124 };
125 #endif
126 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: