Debian Codegraph @

src/lib/ClarisWksGraph.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 /*
35 * Parser to Claris Works text document ( graphic part )
36 *
37 */
38 #ifndef CLARIS_WKS_GRAPH
39 # define CLARIS_WKS_GRAPH
40
41 #include <string>
42 #include <vector>
43
44 #include <librevenge/librevenge.h>
45
46 #include "libmwaw_internal.hxx"
47
48 #include "MWAWDebug.hxx"
49 #include "MWAWInputStream.hxx"
50 #include "MWAWPosition.hxx"
51
52 #include "ClarisWksStruct.hxx"
53
54 namespace ClarisWksGraphInternal
55 {
56 struct Group;
57 struct State;
58 struct Style;
59 struct Zone;
60 struct Chart;
61 struct ZoneShape;
62 struct Bitmap;
63 struct ZonePict;
64
65 class SubDocument;
66 }
67
68 class ClarisWksDocument;
69 class ClarisWksParser;
70 class MWAWParser;
71
72 /** \brief the main class to read the graphic part of Claris Works file
73 *
74 *
75 *
76 */
77 class ClarisWksGraph
78 {
79 friend class ClarisWksGraphInternal::SubDocument;
80 friend class ClarisWksDocument;
81 friend class ClarisWksParser;
82
83 public:
84 //! constructor
85 explicit ClarisWksGraph(ClarisWksDocument &document);
86 //! destructor
87 virtual ~ClarisWksGraph();
88
89 /** returns the file version */
90 int version() const;
91
92 /** returns the number of pages */
93 int numPages() const;
94
95 //! returns the page dimension if known (in point)
96 bool getPageDimension(MWAWVec2f &dim) const;
97
98 //! compute the pages position
99 void computePositions() const;
100
101 //! find the master zone to the content zones in a graphic document
102 void findMasterPage() const;
103
104 //! reads the zone Group DSET
105 std::shared_ptr<ClarisWksStruct::DSET> readGroupZone
106 (ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
107
108 //! reads the zone Bitmap DSET
109 std::shared_ptr<ClarisWksStruct::DSET> readBitmapZone
110 (ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
111
112 //! try to read a database picture zone, v5-v6
113 bool readDatabasePictZone();
114
115 //! return the surface color which corresponds to some ids (if possible)
116 bool getSurfaceColor(ClarisWksGraphInternal::Style const &style, MWAWColor &col) const;
117 protected:
118 //! check if we can send a group as graphic
119 bool canSendGroupAsGraphic(int number) const;
120 //! sends the page element
121 bool sendPageGraphics(int groupId);
122 //! sends the master zone (ie. the background zone in a graphic document)
123 bool sendMaster(int pg);
124 //! sends the database zone if known
125 bool sendDatabasePictZone(int pictId, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
126 //! sends the zone data to the listener (if it exists )
127 bool sendGroup(int number, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
128 //! check if we can send a group as graphic
129 bool canSendBitmapAsGraphic(int number) const;
130 //! sends the bitmap data to the listener (if it exists )
131 bool sendBitmap(int number, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
132
133 //! sends the data which have not yet been sent to the listener
134 void flushExtra();
135
136 // interface with main parser
137
138 //! ask the main parser to send a zone
139 void askToSend(int number, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
140
141 //
142 // Intermediate level
143 //
144
145 //! update the group information to choose how to send the group data
146 void updateGroup(ClarisWksGraphInternal::Group &group) const;
147 //! check if we can send a group as graphic
148 bool canSendAsGraphic(ClarisWksGraphInternal::Group &group) const;
149 //! send a group
150 bool sendGroup(ClarisWksGraphInternal::Group &group, MWAWPosition const &position);
151 //! send a child group as graphic or as presentation
152 bool sendGroupChild(std::vector<std::shared_ptr<ClarisWksGraphInternal::Zone> > const &lChild, MWAWListenerPtr listener, MWAWVec2f const &leftTop);
153 //! send a group child
154 bool sendGroupChild(std::shared_ptr<ClarisWksGraphInternal::Zone> zone, MWAWPosition position);
155 //! send the child element corresponding to some page
156 bool sendPageChild(ClarisWksGraphInternal::Group &group);
157 /* read a simple group */
158 std::shared_ptr<ClarisWksGraphInternal::Zone> readGroupDef(MWAWEntry const &entry);
159 /* read the group data.
160
161 \note \a beginGroupPos is only used to help debugging */
162 bool readGroupData(ClarisWksGraphInternal::Group &group, long beginGroupPos);
163
164 /* read a simple graphic zone */
165 bool readShape(MWAWEntry const &entry,
166 ClarisWksGraphInternal::ZoneShape &zone);
167
168 /* try to read the chart data */
169 bool readChartData(std::shared_ptr<ClarisWksGraphInternal::Zone> zone);
170
171 /* try to read a pict data zone */
172 bool readPictData(std::shared_ptr<ClarisWksGraphInternal::Zone> zone);
173
174 /* try to read the polygon data */
175 bool readPolygonData(std::shared_ptr<ClarisWksGraphInternal::Zone> zone);
176
177 /* read a picture */
178 bool readPICT(ClarisWksGraphInternal::ZonePict &zone);
179
180 /* read a postcript zone */
181 bool readPS(ClarisWksGraphInternal::ZonePict &zone);
182
183 /* read a ole document zone */
184 bool readOLE(ClarisWksGraphInternal::ZonePict &zone);
185
186 /////////////
187 /* try to read the qtime data zone */
188 bool readQTimeData(std::shared_ptr<ClarisWksGraphInternal::Zone> zone);
189
190 /* read a named picture */
191 bool readNamedPict(ClarisWksGraphInternal::ZonePict &zone);
192
193 /////////////
194 /* try to read a bitmap zone */
195 bool readBitmapColorMap(std::vector<MWAWColor> &cMap);
196
197 /* try to read the bitmap */
198 bool readBitmapData(ClarisWksGraphInternal::Bitmap &zone);
199 //
200 // low level
201 //
202
203 /* read the first zone of a group type */
204 bool readGroupHeader(ClarisWksGraphInternal::Group &group);
205
206 /* read some unknown data in first zone */
207 bool readGroupUnknown(ClarisWksGraphInternal::Group &group, int zoneSz, int id);
208
209 //! sends a picture zone
210 bool sendPicture(ClarisWksGraphInternal::ZonePict &pict, MWAWPosition pos);
211
212 //! sends a basic graphic zone
213 bool sendShape(ClarisWksGraphInternal::ZoneShape const &pict, MWAWPosition pos);
214
215 //! sends a bitmap graphic zone
216 bool sendBitmap(ClarisWksGraphInternal::Bitmap &pict, MWAWListener &listener, MWAWPosition pos);
217
218 private:
219 ClarisWksGraph(ClarisWksGraph const &orig) = delete;
220 ClarisWksGraph &operator=(ClarisWksGraph const &orig) = delete;
221
222 protected:
223 //
224 // data
225 //
226 //! the document
227 ClarisWksDocument &m_document;
228
229 //! the parser state
230 MWAWParserStatePtr m_parserState;
231
232 //! the state
233 std::shared_ptr<ClarisWksGraphInternal::State> m_state;
234
235 //! the main parser;
236 MWAWParser *m_mainParser;
237 };
238 #endif
239 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: