Debian Codegraph @

src/lib/MacDrawProStyleManager.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 MACDRAWPRO_STYLE_MANAGER
35 # define MACDRAWPRO_STYLE_MANAGER
36
37 #include <map>
38 #include <string>
39 #include <vector>
40
41 #include <librevenge/librevenge.h>
42
43 #include "MWAWDebug.hxx"
44 #include "MWAWGraphicStyle.hxx"
45 #include "MWAWInputStream.hxx"
46
47 class MWAWFont;
48
49 namespace MacDrawProStyleManagerInternal
50 {
51 struct State;
52 }
53
54 class MacDrawProParser;
55
56 /** \brief the main class to read a MacDraw II file
57 *
58 */
59 class MacDrawProStyleManager
60 {
61 friend class MacDrawProParser;
62 public:
63 //! constructor
64 explicit MacDrawProStyleManager(MacDrawProParser &parser);
65 //! destructor
66 virtual ~MacDrawProStyleManager();
67
68 protected:
69 //! tries to read the RSRC zones
70 bool readRSRCZones();
71
72 // Intermediate level
73
74 //! tries to read the header info part which corresponds to style data
75 bool readHeaderInfoStylePart(std::string &extra);
76 //! tries to read the style zone knowings the size and the number of data in each zones
77 bool readStyles(long const(&sizeZones)[6]);
78
79 //! tries to return the color corresponding to an id
80 bool getColor(int cId, MWAWColor &color) const;
81 //! tries to return the dash definition corresponding to an id
82 bool getDash(int dId, std::vector<float> &dash) const;
83 //! tries to return the font corresponding to an id
84 bool getFont(int fId, MWAWFont &font) const;
85 //! tries to return the paragraph corresponding to an id
86 bool getParagraph(int pId, MWAWParagraph &para) const;
87 //! tries to return the pattern corresponding to an id
88 bool getPattern(int pId, MWAWGraphicStyle::Pattern &pattern) const;
89 //! tries to return the pen size corresponding to an id
90 bool getPenSize(int pId, float &penSize) const;
91 //! tries to update the style gradient
92 bool updateGradient(int gId, MWAWGraphicStyle &style) const;
93 //
94 // low level
95 //
96
97 //! tries to read the font style ( last style in v0 data fork )
98 bool readFontStyles(MWAWEntry const &entry);
99 //! tries to read the paragraph style ( last style in v1 data fork )
100 bool readParagraphStyles(MWAWEntry const &entry);
101
102 // data fork or rsrc fork
103
104 //! tries to read the Arrow styles or the resource Aset:256
105 bool readArrows(MWAWEntry const &entry, bool inRsrc=false);
106 //! tries to read the dash settings or the resource Dset:256
107 bool readDashs(MWAWEntry const &entry, bool inRsrc=false);
108 //! tries to read the Pen styles or the resource PSet:256
109 bool readPens(MWAWEntry const &entry, bool inRsrc=false);
110 //! tries to read the Ruler styles or the resource Drul:256
111 bool readRulers(MWAWEntry const &entry, bool inRsrc=false);
112
113 // rsrc
114
115 //! tries to read the Document Information resource Dinf:256
116 bool readDocumentInfo(MWAWEntry const &entry);
117 //! tries to read the main Preferences resource Pref:256
118 bool readPreferences(MWAWEntry const &entry);
119 //! tries to read the font name resources Fmtx:256 and Fnms:256
120 bool readFontNames();
121 //! tries to read colors map Ctbl:256
122 bool readColors(MWAWEntry const &entry);
123 //! tries to read the BW pattern bawP:256
124 bool readBWPatterns(MWAWEntry const &entry);
125 //! tries to read the color pattern colP:256
126 bool readColorPatterns(MWAWEntry const &entry);
127 //! tries to read the list of pattern patR:256: list of BW/Color patterns list which appear in the patterns tools
128 bool readPatternsToolList(MWAWEntry const &entry);
129 //! tries to read the Ruler settings resource Rset:256 or Rst2:256
130 bool readRulerSettings(MWAWEntry const &entry);
131 //! reads the view positions resource Dvws:256
132 bool readViews(MWAWEntry const &entry);
133
134 //! reads the Dstl:256 resource (unknown content)
135 bool readRSRCDstl(MWAWEntry const &entry);
136
137 // v1
138 //! try to read a palette definition PaDB:[0-3]
139 bool readPaletteDef(MWAWEntry const &entry);
140 //! try to read a palette map
141 bool readPaletteMap(MWAWEntry const &entry, int N, int dataSz);
142 //! try to read a palette data
143 bool readPaletteData(MWAWEntry const &entry, int dataSz);
144
145 //! try to read the display color map DPCo:0
146 bool readColorMap(MWAWEntry const &entry, int N, int fSz);
147 //! try to read the display pattern DPPa:1
148 bool readPatternMap(MWAWEntry const &entry, int N, int fSz);
149 //! try to read the gradian map DPRa:2
150 bool readGradientMap(MWAWEntry const &entry, int N, int fSz);
151 //! try to read the FA map DPFa:3
152 bool readFAMap(MWAWEntry const &entry, int N, int fSz);
153
154 //! try to read the color palette resource CoEL:128
155 bool readColorPalette(MWAWEntry const &entry, int fSz);
156 //! try to read the FA palette resource FaEL:128
157 bool readFAPalette(MWAWEntry const &entry, int fSz);
158 //! try to read the gradient palette resource RaEL:128
159 bool readGradientPalette(MWAWEntry const &entry, int fSz);
160 //! try to read the pattern palette resource PaEL:128
161 bool readPatternPalette(MWAWEntry const &entry, int fSz);
162 //! try to read a list of names : CoNa:128 color name, FaNa:128 font color name, PaNa:128...
163 bool readListNames(MWAWEntry const &entry, int N=-1);
164 //! try to read a splitted list of names
165 bool readListNames(char const *type);
166
167 //! try to read the first pref resource Prf[23459]:256
168 bool readPreferencesListBool(MWAWEntry const &entry, int num);
169 //! try to read the first pref resource Prf1:256
170 bool readPreferences1(MWAWEntry const &entry);
171 //! try to read the spelling pref resource Prf6:256
172 bool readPreferences6(MWAWEntry const &entry);
173 //! try to read the 8 pref resource Prf8:256
174 bool readPreferences8(MWAWEntry const &entry);
175 //! try to read the UPDL resource, maybe U? Palette Display Layer
176 bool readUPDL(MWAWEntry const &entry);
177 //! try to read the Grid: resource, grid of palette position
178 bool readGrid(MWAWEntry const &entry);
179
180 //
181 // data
182 //
183
184 protected:
185 //! the main parser
186 MacDrawProParser &m_parser;
187 //! the parser state
188 MWAWParserStatePtr m_parserState;
189 //! the state
190 std::shared_ptr<MacDrawProStyleManagerInternal::State> m_state;
191 };
192 #endif
193 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: