Canvas5StyleManager.hxx
Go to the documentation of this file.
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 (wrlach@gmail.com)
18* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20* Copyright (C) 2006, 2007 Andrew Ziem
21* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
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 Canvas v5-v11 text document ( style part )
36 *
37 */
38#ifndef CANVAS5_STYLE_MANAGER
39# define CANVAS5_STYLE_MANAGER
40
41#include <string>
42#include <utility>
43#include <vector>
44
45#include <librevenge/librevenge.h>
46
47#include "libmwaw_internal.hxx"
48
49#include "MWAWDebug.hxx"
50#include "MWAWFont.hxx"
51#include "MWAWGraphicStyle.hxx"
52#include "MWAWInputStream.hxx"
53#include "MWAWParagraph.hxx"
54#include "MWAWPosition.hxx"
55
56class MWAWFont;
57
58namespace Canvas5Structure
59{
60struct Stream;
61}
62
64{
65struct ColorStyle;
66struct PenStyle;
67
68struct State;
69}
70
72{
73struct VKFLImage;
74}
75
76class Canvas5Graph;
77class Canvas5Image;
78class Canvas5Parser;
79
86{
87 friend class Canvas5Graph;
88 friend class Canvas5Parser;
89
90public:
92 struct CharStyle {
95 : m_font()
96 , m_paragraphId(0)
97 , m_linkId(0)
98 {
99 }
106 };
107
109 struct StyleList {
112 : m_fonts()
113 , m_paragraphs()
114 {
115 }
117 std::vector<CharStyle> m_fonts;
119 std::vector<std::pair<MWAWParagraph, int> > m_paragraphs;
120 };
121
123 explicit Canvas5StyleManager(Canvas5Parser &parser);
125 virtual ~Canvas5StyleManager();
126
128 int version() const;
130 std::shared_ptr<Canvas5Image> getImageParser() const;
131
133 std::shared_ptr<Canvas5StyleManagerInternal::ColorStyle> readColorStyle(std::shared_ptr<Canvas5Structure::Stream> stream, unsigned type, long len);
138
140 std::shared_ptr<Canvas5StyleManagerInternal::PenStyle> readPenStyle(Canvas5Structure::Stream &stream, unsigned type, long len);
142 bool updateLine(Canvas5StyleManagerInternal::PenStyle const &pen, MWAWGraphicStyle &style, int &numLines, int lineId, float *offset);
143
145 bool readArrow(std::shared_ptr<Canvas5Structure::Stream> stream, MWAWGraphicStyle::Arrow &arrow, unsigned type, long len);
147 bool readCharStyle(Canvas5Structure::Stream &stream, int id, CharStyle &fontIds, bool useFileColors=true);
149 bool readDash(Canvas5Structure::Stream &stream, std::vector<float> &dashes, unsigned type, long len);
151 bool readStyleEnd(std::shared_ptr<Canvas5Structure::Stream> stream, MWAWFont *font=nullptr, MWAWParagraph *para=nullptr);
152
153protected:
154 // interface
155
161 bool updateLineStyle(int sId, MWAWGraphicStyle &style, int &numLines, int lineId=-1, float *offset=nullptr);
163 bool updateLineColor(int cId, MWAWGraphicStyle &style);
165 bool updateSurfaceColor(int cId, MWAWGraphicStyle &style);
166
167 //
168 // Intermediate level
169 //
170
172 bool readArrows(std::shared_ptr<Canvas5Structure::Stream> stream);
174 bool readCharStyles(std::shared_ptr<Canvas5Structure::Stream> stream);
176 bool readInks(std::shared_ptr<Canvas5Structure::Stream> stream);
178 bool readInks9(std::shared_ptr<Canvas5Structure::Stream> stream);
180 bool readColor(Canvas5Structure::Stream &stream, MWAWVariable<MWAWColor> &color, std::string &extra);
182 bool readDashes(std::shared_ptr<Canvas5Structure::Stream> stream);
184 bool readFrameStyles9(std::shared_ptr<Canvas5Structure::Stream> stream);
186 bool readFonts(std::shared_ptr<Canvas5Structure::Stream> stream, int numFonts);
188 bool readFormats(std::shared_ptr<Canvas5Structure::Stream> stream);
190 bool readPenSize(std::shared_ptr<Canvas5Structure::Stream> stream);
192 bool readPenStyles(std::shared_ptr<Canvas5Structure::Stream> stream);
194 bool readStrokes(std::shared_ptr<Canvas5Structure::Stream> stream);
196 bool readParaStyle(std::shared_ptr<Canvas5Structure::Stream> stream, int id, StyleList *styles=nullptr);
198 bool readParaStyles(std::shared_ptr<Canvas5Structure::Stream> stream);
199
200 //
201 // Windows RSRC
202 //
203
204 //
205 // Low level
206 //
207
209 bool readGradient(std::shared_ptr<Canvas5Structure::Stream> stream, long len, MWAWGraphicStyle::Gradient &gradient);
211 bool readHatch(std::shared_ptr<Canvas5Structure::Stream> stream, long len, MWAWGraphicStyle::Hatch &hatch,
212 MWAWVariable<MWAWColor> &backColor);
214 std::shared_ptr<Canvas5ImageInternal::VKFLImage> readSymbol(std::shared_ptr<Canvas5Structure::Stream> stream, long len,
215 MWAWVariable<MWAWColor> &backColor);
216
217private:
220
221protected:
222 //
223 // data
224 //
227
229 std::shared_ptr<Canvas5StyleManagerInternal::State> m_state;
230
233};
234#endif
235// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the main class to read the graphic part of Canvas v5-v11 file
Definition: Canvas5Graph.hxx:85
the main class to read/convert the image or movie inside of Canvas 5-11 files
Definition: Canvas5Image.hxx:78
the main class to read a Canvas 5-10 files (and probably some not password protected Windows 11 files...
Definition: Canvas5Parser.hxx:72
the main class to read the style part of Canvas 5 file
Definition: Canvas5StyleManager.hxx:86
Canvas5StyleManager(Canvas5StyleManager const &orig)=delete
std::shared_ptr< Canvas5StyleManagerInternal::PenStyle > readPenStyle(Canvas5Structure::Stream &stream, unsigned type, long len)
try to read a pen style
Definition: Canvas5StyleManager.cxx:1307
bool readFonts(std::shared_ptr< Canvas5Structure::Stream > stream, int numFonts)
try to read the fonts names
Definition: Canvas5StyleManager.cxx:1119
bool readParaStyles(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the paragraph styles
Definition: Canvas5StyleManager.cxx:2096
bool readCharStyle(Canvas5Structure::Stream &stream, int id, CharStyle &fontIds, bool useFileColors=true)
try to read a character style, returns a font, a paragraph id and it potential link id
Definition: Canvas5StyleManager.cxx:1574
bool readArrows(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the arrows zones
Definition: Canvas5StyleManager.cxx:585
bool readStyleEnd(std::shared_ptr< Canvas5Structure::Stream > stream, MWAWFont *font=nullptr, MWAWParagraph *para=nullptr)
try to read the second part of a style which contains minor paragraph styles, hyphen,...
Definition: Canvas5StyleManager.cxx:2002
virtual ~Canvas5StyleManager()
destructor
Definition: Canvas5StyleManager.cxx:226
std::shared_ptr< Canvas5StyleManagerInternal::ColorStyle > readColorStyle(std::shared_ptr< Canvas5Structure::Stream > stream, unsigned type, long len)
try to read a color style
Definition: Canvas5StyleManager.cxx:832
bool readArrow(std::shared_ptr< Canvas5Structure::Stream > stream, MWAWGraphicStyle::Arrow &arrow, unsigned type, long len)
try to read an arrow
Definition: Canvas5StyleManager.cxx:620
bool updateSurfaceColor(Canvas5StyleManagerInternal::ColorStyle const &color, MWAWGraphicStyle &style)
try to update the surface color given a color style
Definition: Canvas5StyleManager.cxx:2367
bool readColor(Canvas5Structure::Stream &stream, MWAWVariable< MWAWColor > &color, std::string &extra)
try to read a color: 12 unknown 4 components followed by a type
Definition: Canvas5StyleManager.cxx:245
bool readInks9(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the ink color zones: v9
Definition: Canvas5StyleManager.cxx:774
bool updateLine(Canvas5StyleManagerInternal::PenStyle const &pen, MWAWGraphicStyle &style, int &numLines, int lineId, float *offset)
try to update the line color given a color style
Definition: Canvas5StyleManager.cxx:2425
bool readCharStyles(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the character styles
Definition: Canvas5StyleManager.cxx:1762
std::shared_ptr< Canvas5Image > getImageParser() const
returns the image parser
Definition: Canvas5StyleManager.cxx:234
bool readFrameStyles9(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the frame zones: stroke, pen style, arrow, dashes: v9
Definition: Canvas5StyleManager.cxx:2202
int version() const
returns the file version
Definition: Canvas5StyleManager.cxx:229
Canvas5Parser * m_mainParser
the main parser;
Definition: Canvas5StyleManager.hxx:232
Canvas5StyleManager & operator=(Canvas5StyleManager const &orig)=delete
bool readPenSize(std::shared_ptr< Canvas5Structure::Stream > stream)
read the pen size (header file)
Definition: Canvas5StyleManager.cxx:1234
bool readFormats(std::shared_ptr< Canvas5Structure::Stream > stream)
read the list of formats, mainly an unit's conversion table
Definition: Canvas5StyleManager.cxx:1167
bool readInks(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the ink color zones
Definition: Canvas5StyleManager.cxx:665
bool readDash(Canvas5Structure::Stream &stream, std::vector< float > &dashes, unsigned type, long len)
try to read a dash's array
Definition: Canvas5StyleManager.cxx:1055
std::shared_ptr< Canvas5StyleManagerInternal::State > m_state
the state
Definition: Canvas5StyleManager.hxx:229
bool updateLineStyle(int sId, MWAWGraphicStyle &style, int &numLines, int lineId=-1, float *offset=nullptr)
try to update the line style given the stroke id and returns the number of lines(plin)
Definition: Canvas5StyleManager.cxx:2466
bool readHatch(std::shared_ptr< Canvas5Structure::Stream > stream, long len, MWAWGraphicStyle::Hatch &hatch, MWAWVariable< MWAWColor > &backColor)
try to read a hatch zone: htch
Definition: Canvas5StyleManager.cxx:468
std::shared_ptr< Canvas5ImageInternal::VKFLImage > readSymbol(std::shared_ptr< Canvas5Structure::Stream > stream, long len, MWAWVariable< MWAWColor > &backColor)
try to read a symbol zone: vkfl/TXUR
Definition: Canvas5StyleManager.cxx:947
MWAWParserStatePtr m_parserState
the parser state
Definition: Canvas5StyleManager.hxx:226
bool readStrokes(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the stroke styles
Definition: Canvas5StyleManager.cxx:1535
bool readDashes(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the dashes
Definition: Canvas5StyleManager.cxx:1024
bool readGradient(std::shared_ptr< Canvas5Structure::Stream > stream, long len, MWAWGraphicStyle::Gradient &gradient)
try to read a gradient zone: OBFL
Definition: Canvas5StyleManager.cxx:290
bool updateLineColor(Canvas5StyleManagerInternal::ColorStyle const &color, MWAWGraphicStyle &style)
try to update the line color given a color style
Definition: Canvas5StyleManager.cxx:2321
bool readParaStyle(std::shared_ptr< Canvas5Structure::Stream > stream, int id, StyleList *styles=nullptr)
try to read a paragraph style
Definition: Canvas5StyleManager.cxx:1862
bool readPenStyles(std::shared_ptr< Canvas5Structure::Stream > stream)
read the pen styles
Definition: Canvas5StyleManager.cxx:1258
Class to store font.
Definition: MWAWFont.hxx:44
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
class to store the paragraph properties
Definition: MWAWParagraph.hxx:85
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
Internal: the structures of a Canvas5Image.
Definition: Canvas5Image.cxx:70
a namespace used to define basic function or structure to read a Canvas v5-v11 file
Definition: Canvas5BMParser.hxx:64
Internal: the structures of a Canvas5StyleManager.
Definition: Canvas5StyleManager.cxx:62
a sub stream of Canvas5Structure
Definition: Canvas5Structure.hxx:49
Internal: the color style of a Canvas5StyleManager.
Definition: Canvas5StyleManager.cxx:66
Internal: the pen style of a Canvas5StyleManager.
Definition: Canvas5StyleManager.cxx:108
a structure use to store a character style
Definition: Canvas5StyleManager.hxx:92
int m_linkId
the link id
Definition: Canvas5StyleManager.hxx:105
MWAWFont m_font
the font
Definition: Canvas5StyleManager.hxx:101
CharStyle()
constructor
Definition: Canvas5StyleManager.hxx:94
int m_paragraphId
the paragraph id
Definition: Canvas5StyleManager.hxx:103
a structure use to store a list of styles
Definition: Canvas5StyleManager.hxx:109
StyleList()
constructor
Definition: Canvas5StyleManager.hxx:111
std::vector< CharStyle > m_fonts
the fonts, the paragraph id and the link id
Definition: Canvas5StyleManager.hxx:117
std::vector< std::pair< MWAWParagraph, int > > m_paragraphs
the paragraph list and the tab id
Definition: Canvas5StyleManager.hxx:119
a structure used to define an arrow
Definition: MWAWGraphicStyle.hxx:59
a basic gradient used in a MWAWGraphicStyle
Definition: MWAWGraphicStyle.hxx:142
a basic hatch used in MWAWGraphicStyle
Definition: MWAWGraphicStyle.hxx:279
a generic variable template: value + flag to know if the variable is set
Definition: libmwaw_internal.hxx:577

Generated on Thu Jan 19 2023 00:00:00 for libmwaw by doxygen 1.9.6