Debian Codegraph @

src/lib/ClarisDrawGraph.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 Draw document ( graphic part )
36 *
37 */
38 #ifndef CLARIS_DRAW_GRAPH
39 # define CLARIS_DRAW_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 class ClarisDrawStyleManager;
55
56 namespace ClarisDrawGraphInternal
57 {
58 struct Group;
59 struct State;
60 struct Style;
61 struct Zone;
62 struct ZoneShape;
63 struct Bitmap;
64
65 class SubDocument;
66 }
67
68 class ClarisDrawParser;
69
70 /** \brief the main class to read the graphic part of ClarisDraw file
71 *
72 *
73 *
74 */
75 class ClarisDrawGraph
76 {
77 friend class ClarisDrawGraphInternal::SubDocument;
78 friend class ClarisDrawParser;
79 friend class ClarisWksParser;
80
81 public:
82 //! constructor
83 explicit ClarisDrawGraph(ClarisDrawParser &parser);
84 //! destructor
85 virtual ~ClarisDrawGraph();
86
87 /** returns the file version */
88 int version() const;
89 /** resets the current state */
90 void resetState();
91 /** returns the number of pages */
92 int numPages() const;
93
94 //! reads the zone Group DSET
95 std::shared_ptr<ClarisWksStruct::DSET> readGroupZone
96 (ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool isLibHeader=false);
97 //! reads the zone Bitmap DSET
98 std::shared_ptr<ClarisWksStruct::DSET> readBitmapZone(ClarisWksStruct::DSET const &zone, MWAWEntry const &entry);
99 //! read the transformations
100 bool readTransformations();
101 //! update the group: ie. remove empty group child
102 void updateGroup(bool isLibrary);
103 //! returns true if a group does not exist or is empty
104 bool isEmptyGroup(int gId) const;
105
106 //! return the surface color which corresponds to some ids (if possible)
107 bool getSurfaceColor(ClarisDrawGraphInternal::Style const &style, MWAWColor &col) const;
108 protected:
109 //! sends the bitmap data to the listener (if it exists )
110 bool sendBitmap(int number, MWAWPosition const &pos=MWAWPosition());
111 //! sends the zone data to the listener (if it exists )
112 bool sendGroup(int number, MWAWPosition const &pos=MWAWPosition());
113 //! sends the ith child of the root (if it exists )
114 bool sendMainGroupChild(int childId, MWAWPosition const &pos=MWAWPosition());
115 //! sends the data which have not yet been sent to the listener
116 void flushExtra();
117
118 // interface with main parser
119
120 //! sends a text box content (via the main parser )
121 bool sendTextZone(int number, int subZone=-1);
122
123 //
124 // Intermediate level
125 //
126
127 /* read a simple group */
128 std::shared_ptr<ClarisDrawGraphInternal::Zone> readGroupDef(MWAWEntry const &entry);
129 /* read the group data.
130
131 \note \a beginGroupPos is only used to help debugging */
132 bool readGroupData(ClarisDrawGraphInternal::Group &group, long beginGroupPos, bool isLibHeader);
133
134 /* read a simple graphic zone */
135 bool readShape(MWAWEntry const &entry,
136 ClarisDrawGraphInternal::ZoneShape &zone);
137
138 /* try to read the polygon data */
139 bool readPolygonData(std::shared_ptr<ClarisDrawGraphInternal::Zone> zone);
140
141 /////////////
142 /* try to read a bitmap zone */
143 bool readBitmapColorMap(std::vector<MWAWColor> &cMap);
144
145 /* try to read the bitmap */
146 bool readBitmapData(ClarisDrawGraphInternal::Bitmap &zone);
147
148 //
149 // low level
150 //
151
152 /* read the first zone of a group type */
153 bool readGroupHeader(ClarisDrawGraphInternal::Group &group);
154
155 /* read some unknown data in first zone */
156 bool readGroupUnknown(ClarisDrawGraphInternal::Group &group, int zoneSz, int id);
157
158 //! sends a basic graphic zone
159 bool sendShape(ClarisDrawGraphInternal::ZoneShape &pict, MWAWPosition pos);
160
161 //! sends a bitmap graphic zone
162 bool sendBitmap(ClarisDrawGraphInternal::Bitmap &pict, MWAWPosition pos);
163
164 private:
165 ClarisDrawGraph(ClarisDrawGraph const &orig) = delete;
166 ClarisDrawGraph &operator=(ClarisDrawGraph const &orig) = delete;
167
168 protected:
169 //
170 // data
171 //
172 //! the parser state
173 MWAWParserStatePtr m_parserState;
174
175 //! the state
176 std::shared_ptr<ClarisDrawGraphInternal::State> m_state;
177
178 //! the main parser;
179 ClarisDrawParser *m_mainParser;
180 //! the style manager
181 std::shared_ptr<ClarisDrawStyleManager> m_styleManager;
182 };
183 #endif
184 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: