Debian Codegraph @

src/lib/LotusStyleManager.h

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2006, 2007 Andrew Ziem
11 * Copyright (C) 2003-2005 William Lachance ([email protected])
12 * Copyright (C) 2003 Marc Maurer ([email protected])
13 *
14 * For minor contributions see the git repository.
15 *
16 * Alternatively, the contents of this file may be used under the terms
17 * of the GNU Lesser General Public License Version 2.1 or later
18 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19 * applicable instead of those above.
20 */
21
22 #ifndef LOTUS_STYLE_MANAGER_H
23 #define LOTUS_STYLE_MANAGER_H
24
25 #include <ostream>
26 #include <set>
27 #include <vector>
28
29 #include <librevenge-stream/librevenge-stream.h>
30
31 #include "libwps_internal.h"
32 #include "libwps_tools_win.h"
33
34 #include "WPSDebug.h"
35
36 class WPSGraphicStyle;
37
38 namespace LotusStyleManagerInternal
39 {
40 struct CellStyleEntry;
41 struct State;
42 }
43
44 class LotusParser;
45
46 /**
47 * This class parses the Lotus style
48 *
49 */
50 class LotusStyleManager
51 {
52 public:
53 friend class LotusParser;
54
55 //! constructor
56 explicit LotusStyleManager(LotusParser &parser);
57 //! destructor
58 ~LotusStyleManager();
59 //! clean internal state
60 void cleanState();
61 //! update the state (need to be called before asking for style)
62 void updateState();
63
64 //! returns if possible the color(id between 0 and 7)
65 bool getColor8(int cId, WPSColor &color) const;
66 //! returns if possible the color(id between 0 and 15)
67 bool getColor16(int cId, WPSColor &color) const;
68 //! returns if possible the color(id between 0 and 255)
69 bool getColor256(int cId, WPSColor &color) const;
70
71 //! returns the pattern corresponding to a pattern id (id between 1 and 48)
72 bool getPattern48(int id, WPSGraphicStyle::Pattern &pattern) const;
73 //! returns the pattern corresponding to a pattern id (id between 1 and 64)
74 bool getPattern64(int id, WPSGraphicStyle::Pattern &pattern) const;
75
76 //! update a cell format using the cell id
77 bool updateCellStyle(int cellId, WPSCellFormat &format,
78 WPSFont &font, libwps_tools_win::Font::Type &fontType);
79 //! update a font using the font id
80 bool updateFontStyle(int fontId, WPSFont &font, libwps_tools_win::Font::Type &fontType);
81 //! update style using line id
82 bool updateLineStyle(int lineId, WPSGraphicStyle &style) const;
83 //! update style using color id
84 bool updateSurfaceStyle(int colorId, WPSGraphicStyle &style) const;
85 //! update style using graphic id
86 bool updateGraphicStyle(int graphicId, WPSGraphicStyle &style) const;
87 //! update style using front/back color and pattern id
88 bool updateSurfaceStyle(int fColorId, int bColorId, int patternId, WPSGraphicStyle &style) const;
89 protected:
90 //! return the file version
91 int version() const;
92
93 //
94 // low level
95 //
96
97 //! reads a color style
98 bool readColorStyle(std::shared_ptr<WPSStream> stream, long endPos);
99 //! reads a format style
100 bool readFormatStyle(std::shared_ptr<WPSStream> stream, long endPos);
101 //! reads a line style
102 bool readLineStyle(std::shared_ptr<WPSStream> stream, long endPos, int vers);
103 //! reads a graphic style
104 bool readGraphicStyle(std::shared_ptr<WPSStream> stream, long endPos);
105 //! reads a graphic style: fc9, lotus123
106 bool readGraphicStyleC9(std::shared_ptr<WPSStream> stream, long endPos);
107
108 // 1b style
109
110 //! reads a font style: fa0
111 bool readFontStyleA0(std::shared_ptr<WPSStream> stream, long endPos);
112 //! reads a font style: ff0 (wk4)
113 bool readFontStyleF0(std::shared_ptr<WPSStream> stream, long endPos);
114 //! reads a cell style: fd2 (mac 123 or 123)
115 bool readCellStyleD2(std::shared_ptr<WPSStream> stream, long endPos);
116 //! reads a cell style: fe6 (wk4)
117 bool readCellStyleE6(std::shared_ptr<WPSStream> stream, long endPos);
118
119 //! reads the list of style: 32e7 (wk4)
120 static bool readMenuStyleE7(std::shared_ptr<WPSStream> stream, long endPos);
121 //! reads a style: fe6 (123)
122 bool readStyleE6(std::shared_ptr<WPSStream> stream, long endPos);
123
124 // old fmt style
125
126 //! reads a format font name: zones 0xae
127 bool readFMTFontName(std::shared_ptr<WPSStream> stream);
128 //! reads a format font sizes zones 0xaf and 0xb1
129 bool readFMTFontSize(std::shared_ptr<WPSStream> stream);
130 //! reads a format font id zone: 0xb0
131 bool readFMTFontId(std::shared_ptr<WPSStream> stream);
132
133 //! update style using color id for defining shadow
134 bool updateShadowStyle(int colorId, WPSGraphicStyle &style) const;
135
136 //
137 // low level
138 //
139
140 /** really reads the cell style: fd2 (123)
141
142 \note this function normally called when all the styles are read, so it can reliably recover its data
143 */
144 bool readCellStyleD2Data(LotusStyleManagerInternal::CellStyleEntry const &entry, std::set<int> &seen);
145 private:
146 LotusStyleManager(LotusStyleManager const &orig) = delete;
147 LotusStyleManager &operator=(LotusStyleManager const &orig) = delete;
148 //! the main parser
149 LotusParser &m_mainParser;
150 //! the internal state
151 std::shared_ptr<LotusStyleManagerInternal::State> m_state;
152 };
153
154 #endif /* LOTUS_STYLE_MANAGER_H */
155 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */