Canvas5StyleManager.hxx Source File documentation

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 Canvas5 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 "MWAWGraphicStyle.hxx"
51 #include "MWAWInputStream.hxx"
52 #include "MWAWPosition.hxx"
53
54 class MWAWFont;
55 class MWAWParagraph;
56
57 namespace Canvas5Structure
58 {
59 struct Stream;
60 }
61
62 namespace Canvas5StyleManagerInternal
63 {
64 struct ColorStyle;
65 struct State;
66 }
67
68 class Canvas5Graph;
69 class Canvas5Parser;
70
76 class Canvas5StyleManager
77 {
78 friend class Canvas5Graph;
79 friend class Canvas5Parser;
80
81 public:
83 struct StyleList {
85 StyleList()
86 : m_fonts()
87 , m_paragraphs()
88 {
89 }
91 std::vector<std::pair<MWAWFont, int> > m_fonts;
93 std::vector<std::pair<MWAWParagraph, int> > m_paragraphs;
94 };
95
97 explicit Canvas5StyleManager(Canvas5Parser &parser);
99 virtual ~Canvas5StyleManager();
100
102 int version() const;
103
104 protected:
105 // interface
106
112 bool updateLineStyle(int sId, MWAWGraphicStyle &style, int &numLines, int lineId=-1, float *offset=nullptr);
114 bool updateLineColor(int cId, MWAWGraphicStyle &style);
116 bool updateSurfaceColor(int cId, MWAWGraphicStyle &style);
117
118 //
119 // Intermediate level
120 //
121
123 bool readArrows(Canvas5Structure::Stream &stream);
125 bool readCharStyle(Canvas5Structure::Stream &stream, int id, std::pair<MWAWFont, int> &fontId);
127 bool readCharStyles(Canvas5Structure::Stream &stream);
129 bool readColors(Canvas5Structure::Stream &stream);
131 bool readDashes(Canvas5Structure::Stream &stream);
133 bool readFonts(Canvas5Structure::Stream &stream, int numFonts);
135 bool readFormats(Canvas5Structure::Stream &stream);
137 bool readPenSize(Canvas5Structure::Stream &stream);
139 bool readPenStyles(Canvas5Structure::Stream &stream);
141 bool readStrokes(Canvas5Structure::Stream &stream);
143 bool readStyle(Canvas5Structure::Stream &stream, int id, StyleList *styles=nullptr);
145 bool readStyles(Canvas5Structure::Stream &stream);
146
147 //
148 // Windows RSRC
149 //
150
151 //
152 // Low level
153 //
154
156 bool readArrow(Canvas5Structure::Stream &stream, MWAWGraphicStyle::Arrow &arrow, long len);
158 bool readColor(Canvas5Structure::Stream &stream, MWAWColor &color, std::string &extra);
160 bool readColorStyle(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &color, long len);
162 bool readSymbol(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &color, long len);
164 bool readTexture(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &color, long len);
170 bool readVKFL(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &texture, long len, std::vector<int> *typeList=nullptr);
171
172 private:
173 Canvas5StyleManager(Canvas5StyleManager const &orig) = delete;
174 Canvas5StyleManager &operator=(Canvas5StyleManager const &orig) = delete;
175
176 protected:
177 //
178 // data
179 //
181 MWAWParserStatePtr m_parserState;
182
184 std::shared_ptr<Canvas5StyleManagerInternal::State> m_state;
185
187 Canvas5Parser *m_mainParser;
188 };
189 #endif
190 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWGraphicStyle.hxx
MWAWInputStream.hxx
MWAWPosition.hxx
Canvas5Graph
the main class to read the graphic part of Canvas5 file
Definition: Canvas5Graph.hxx:83
Canvas5Parser
the main class to read a Canvas 5 files
Definition: Canvas5Parser.hxx:71
Canvas5StyleManager
the main class to read the style part of Canvas 5 file
Definition: Canvas5StyleManager.hxx:77
Canvas5StyleManager::readStrokes
bool readStrokes(Canvas5Structure::Stream &stream)
try to read the stroke styles
Definition: Canvas5StyleManager.cxx:1520
Canvas5StyleManager::readStyle
bool readStyle(Canvas5Structure::Stream &stream, int id, StyleList *styles=nullptr)
try to read a style
Definition: Canvas5StyleManager.cxx:1745
Canvas5StyleManager::Canvas5StyleManager
Canvas5StyleManager(Canvas5StyleManager const &orig)=delete
Canvas5StyleManager::readPenSize
bool readPenSize(Canvas5Structure::Stream &stream)
read the pen size (header file)
Definition: Canvas5StyleManager.cxx:1334
Canvas5StyleManager::Canvas5StyleManager
Canvas5StyleManager(Canvas5Parser &parser)
constructor
Definition: Canvas5StyleManager.cxx:223
Canvas5StyleManager::readTexture
bool readTexture(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &color, long len)
try to read a texture
Definition: Canvas5StyleManager.cxx:1119
Canvas5StyleManager::readFonts
bool readFonts(Canvas5Structure::Stream &stream, int numFonts)
try to read the fonts names
Definition: Canvas5StyleManager.cxx:1225
Canvas5StyleManager::updateSurfaceColor
bool updateSurfaceColor(int cId, MWAWGraphicStyle &style)
try to update the surface color given the color id
Definition: Canvas5StyleManager.cxx:2037
Canvas5StyleManager::~Canvas5StyleManager
virtual ~Canvas5StyleManager()
destructor
Definition: Canvas5StyleManager.cxx:230
Canvas5StyleManager::readVKFL
bool readVKFL(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &texture, long len, std::vector< int > *typeList=nullptr)
try to read an unknown vectorized graphic format used to store symbol, texture and arrow
Definition: Canvas5StyleManager.cxx:734
Canvas5StyleManager::readColorStyle
bool readColorStyle(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &color, long len)
try to read a color style
Definition: Canvas5StyleManager.cxx:485
Canvas5StyleManager::readArrow
bool readArrow(Canvas5Structure::Stream &stream, MWAWGraphicStyle::Arrow &arrow, long len)
try to read an arrow
Definition: Canvas5StyleManager.cxx:276
Canvas5StyleManager::readSymbol
bool readSymbol(Canvas5Structure::Stream &stream, Canvas5StyleManagerInternal::ColorStyle &color, long len)
try to read a symbol
Definition: Canvas5StyleManager.cxx:1046
Canvas5StyleManager::readStyles
bool readStyles(Canvas5Structure::Stream &stream)
try to read the styles
Definition: Canvas5StyleManager.cxx:1940
Canvas5StyleManager::version
int version() const
returns the file version
Definition: Canvas5StyleManager.cxx:233
Canvas5StyleManager::m_mainParser
Canvas5Parser * m_mainParser
the main parser;
Definition: Canvas5StyleManager.hxx:187
Canvas5StyleManager::readColor
bool readColor(Canvas5Structure::Stream &stream, MWAWColor &color, std::string &extra)
try to read a color: 12 unknown 4 components followed by a name
Definition: Canvas5StyleManager.cxx:341
Canvas5StyleManager::readArrows
bool readArrows(Canvas5Structure::Stream &stream)
try to read the arrows zones
Definition: Canvas5StyleManager.cxx:244
Canvas5StyleManager::updateLineColor
bool updateLineColor(int cId, MWAWGraphicStyle &style)
try to update the line color given the color id
Definition: Canvas5StyleManager.cxx:2001
Canvas5StyleManager::readDashes
bool readDashes(Canvas5Structure::Stream &stream)
try to read the dashes
Definition: Canvas5StyleManager.cxx:1177
Canvas5StyleManager::operator=
Canvas5StyleManager & operator=(Canvas5StyleManager const &orig)=delete
Canvas5StyleManager::readCharStyle
bool readCharStyle(Canvas5Structure::Stream &stream, int id, std::pair< MWAWFont, int > &fontId)
try to read a character style
Definition: Canvas5StyleManager.cxx:1558
Canvas5StyleManager::m_state
std::shared_ptr< Canvas5StyleManagerInternal::State > m_state
the state
Definition: Canvas5StyleManager.hxx:184
Canvas5StyleManager::updateLineStyle
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:2095
Canvas5StyleManager::readCharStyles
bool readCharStyles(Canvas5Structure::Stream &stream)
try to read the character styles
Definition: Canvas5StyleManager.cxx:1693
Canvas5StyleManager::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: Canvas5StyleManager.hxx:181
Canvas5StyleManager::readColors
bool readColors(Canvas5Structure::Stream &stream)
try to read the ink color zones
Definition: Canvas5StyleManager.cxx:382
Canvas5StyleManager::readFormats
bool readFormats(Canvas5Structure::Stream &stream)
read the list of formats, mainly an unit's conversion table
Definition: Canvas5StyleManager.cxx:1271
Canvas5StyleManager::readPenStyles
bool readPenStyles(Canvas5Structure::Stream &stream)
read the pen styles
Definition: Canvas5StyleManager.cxx:1354
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:85
libmwaw_internal.hxx
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
Canvas5Structure
a namespace used to define basic structure to read a Canvas 5 file
Definition: Canvas5Graph.hxx:60
Canvas5StyleManagerInternal
Internal: the structures of a Canvas5StyleManager.
Definition: Canvas5StyleManager.cxx:63
Canvas5Structure::Stream
a sub stream of Canvas5Structure
Definition: Canvas5Structure.hxx:46
Canvas5StyleManagerInternal::ColorStyle
Internal: the color style of a Canvas5StyleManager.
Definition: Canvas5StyleManager.cxx:67
Canvas5StyleManager::StyleList
a structure use to store a list of styles
Definition: Canvas5StyleManager.hxx:83
Canvas5StyleManager::StyleList::m_fonts
std::vector< std::pair< MWAWFont, int > > m_fonts
the fonts and the paragraph id
Definition: Canvas5StyleManager.hxx:91
Canvas5StyleManager::StyleList::StyleList
StyleList()
constructor
Definition: Canvas5StyleManager.hxx:85
Canvas5StyleManager::StyleList::m_paragraphs
std::vector< std::pair< MWAWParagraph, int > > m_paragraphs
the paragraph list and the tab id
Definition: Canvas5StyleManager.hxx:93
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MWAWGraphicStyle::Arrow
a structure used to define an arrow
Definition: MWAWGraphicStyle.hxx:56