ClarisWksStyleManager.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ClarisWksStyleManager.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 * Class used to read main style by Claris Works parser
36 *
37 */
38 #ifndef CLARIS_WKS_STYLE_MANAGER
39 # define CLARIS_WKS_STYLE_MANAGER
40
41 #include <iostream>
42 #include <string>
43 #include <vector>
44
45 #include "libmwaw_internal.hxx"
46
47 #include "MWAWCell.hxx"
48 #include "MWAWDebug.hxx"
49 #include "MWAWGraphicStyle.hxx"
50 #include "MWAWInputStream.hxx"
51
52 class ClarisWksDocument;
53
54 namespace ClarisWksStyleManagerInternal
55 {
56 struct State;
57 }
58
60 class ClarisWksStyleManager
61 {
62 public:
63 struct CellFormat;
64 struct KSEN;
65 struct Style;
66 public:
68 ClarisWksStyleManager(ClarisWksDocument &document);
70 ~ClarisWksStyleManager();
71
73 bool readColorList(MWAWEntry const &entry);
75 bool readPatternList(long endPos=-1);
77 bool readGradientList(long endPos=-1);
79 bool readStyles(MWAWEntry const &entry);
81 bool readFontNames();
83 bool updateGradient(int grad, MWAWGraphicStyle &style) const;
85 bool updateWallPaper(int wall, MWAWGraphicStyle &style) const;
86
88 int getFontId(int localId) const;
90 bool getColor(int id, MWAWColor &col) const;
92 bool getPattern(int id, MWAWGraphicStyle::Pattern &pattern, float &percent) const;
94 bool getRulerName(int id, std::string &name) const;
95
97 bool get(int styleId, Style &style) const;
99 bool get(int fontId, MWAWFont &font) const;
101 bool get(int formatId, CellFormat &format) const;
103 bool get(int ksenId, KSEN &ksen) const;
105 bool get(int graphId, MWAWGraphicStyle &graph) const;
106
108 bool readFont(int id, int fontSize, MWAWFont &font);
109
110 protected:
112 int version() const;
113
115 bool readGenStyle(int id);
116
118 bool readStylesDef(int N, int fSz);
120 bool readLookUp(int N, int fSz);
121
122 /* read the STYL CELL sequence */
123 bool readCellStyles(int N, int fSz);
125 bool readFontNames(int N, int fSz);
127 bool readGraphStyles(int N, int fSz);
129 bool readKSEN(int N, int fSz);
131 bool readStyleNames(int N, int fSz);
133 bool readStyleFonts(int N, int fSz);
134
135 protected:
137 ClarisWksDocument &m_document;
139 MWAWParserStatePtr m_parserState;
141 shared_ptr<ClarisWksStyleManagerInternal::State> m_state;
142
143 private:
144 ClarisWksStyleManager(ClarisWksStyleManager const &orig);
145 ClarisWksStyleManager &operator=(ClarisWksStyleManager const &orig);
146
147 public:
149 struct CellFormat : public MWAWCell::Format {
151 CellFormat(MWAWCell::Format const &format=MWAWCell::Format()) :
152 MWAWCell::Format(format), m_hAlign(MWAWCell::HALIGN_DEFAULT), m_fileFormat(-1), m_borders(0), m_wrap(false), m_extra("")
153 {
154 }
156 friend std::ostream &operator<<(std::ostream &o, CellFormat const &form);
158 MWAWCell::HorizontalAlignment m_hAlign;
160 int m_fileFormat;
162 int m_borders;
164 bool m_wrap;
166 std::string m_extra;
167 };
168
170 struct KSEN {
172 KSEN() : m_valign(0), m_lineType(MWAWBorder::Simple), m_lineRepeat(MWAWBorder::Single), m_lines(0), m_extra("")
173 {
174 }
176 friend std::ostream &operator<<(std::ostream &o, KSEN const &ksen);
178 int m_valign;
180 MWAWBorder::Style m_lineType;
182 MWAWBorder::Type m_lineRepeat;
184 int m_lines;
186 std::string m_extra;
187 };
188
190 struct Style {
192 Style() : m_fontId(-1), m_cellFormatId(-1), m_rulerId(-1), m_rulerPId(-1), m_nameId(-1), m_ksenId(-1), m_graphicId(-1), m_localStyleId(-1), m_styleId(-1), m_extra("")
193 {
194 }
195
197 friend std::ostream &operator<<(std::ostream &o, Style const &style);
198
200 int m_fontId;
202 int m_cellFormatId;
204 int m_rulerId;
206 int m_rulerPId;
208 int m_nameId;
210 int m_ksenId;
212 int m_graphicId;
214 int m_localStyleId;
216 int m_styleId;
218 std::string m_extra;
219 };
220 };
221
222 #endif
ClarisWksStyleManager::Style::m_graphicId
int m_graphicId
the graphic (checkme)
Definition: ClarisWksStyleManager.hxx:212
MWAWCell::Format::Format
Format()
constructor
Definition: MWAWCell.hxx:62
ClarisWksStyleManager::ClarisWksStyleManager
ClarisWksStyleManager(ClarisWksDocument &document)
constructor
Definition: ClarisWksStyleManager.cxx:1561
ClarisWksStyleManager::CellFormat::m_wrap
bool m_wrap
true if the cell content is wrapped
Definition: ClarisWksStyleManager.hxx:164
ClarisWksStyleManager::readColorList
bool readColorList(MWAWEntry const &entry)
reads a color map zone ( v4-v6)
Definition: ClarisWksStyleManager.cxx:1871
libmwaw_internal.hxx
ClarisWksStyleManager::readFont
bool readFont(int id, int fontSize, MWAWFont &font)
try to read a named font
Definition: ClarisWksStyleManager.cxx:2328
ClarisWksStyleManager::CellFormat::CellFormat
CellFormat(MWAWCell::Format const &format=MWAWCell::Format())
constructor from cell
Definition: ClarisWksStyleManager.hxx:151
MWAWCell::Format
a structure uses to define the format of a cell content
Definition: MWAWCell.hxx:60
ClarisWksStyleManager::Style::m_fontId
int m_fontId
the char
Definition: ClarisWksStyleManager.hxx:200
ClarisWksStyleManager::Style::m_localStyleId
int m_localStyleId
a local style id
Definition: ClarisWksStyleManager.hxx:214
ClarisWksStyleManager::KSEN
the KSEN structure a structure related to paragraph and cell style
Definition: ClarisWksStyleManager.hxx:170
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
ClarisWksStyleManager::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: ClarisWksStyleManager.hxx:139
ClarisWksStyleManager::operator=
ClarisWksStyleManager & operator=(ClarisWksStyleManager const &orig)
ClarisWksStyleManager::CellFormat::m_fileFormat
int m_fileFormat
the field format: number, string, currency, ..
Definition: ClarisWksStyleManager.hxx:160
ClarisWksStyleManager::CellFormat::operator<<
friend std::ostream & operator<<(std::ostream &o, CellFormat const &form)
operator<<
Definition: ClarisWksStyleManager.cxx:2722
ClarisWksStyleManager::readGradientList
bool readGradientList(long endPos=-1)
reads a gradient map zone ( v2)
Definition: ClarisWksStyleManager.cxx:1784
ClarisWksStyleManager::Style::m_ksenId
int m_ksenId
the ksen id
Definition: ClarisWksStyleManager.hxx:210
ClarisWksStyleManager::Style::m_rulerId
int m_rulerId
the ruler
Definition: ClarisWksStyleManager.hxx:204
ClarisWksStyleManager::Style::m_extra
std::string m_extra
extra data
Definition: ClarisWksStyleManager.hxx:218
ClarisWksStyleManager::readStylesDef
bool readStylesDef(int N, int fSz)
try to read the style definition zone
Definition: ClarisWksStyleManager.cxx:2073
ClarisWksStyleManager
a structure to store the style list and the lookup zone
Definition: ClarisWksStyleManager.hxx:60
MWAWBorder::Type
Type
the line repetition
Definition: libmwaw_internal.hxx:303
MWAWCell::HorizontalAlignment
HorizontalAlignment
the default horizontal alignment.
Definition: MWAWCell.hxx:118
ClarisWksStyleManager::KSEN::m_lineType
MWAWBorder::Style m_lineType
the line type
Definition: ClarisWksStyleManager.hxx:180
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:167
ClarisWksStyleManager::CellFormat::m_extra
std::string m_extra
extra data
Definition: ClarisWksStyleManager.hxx:166
ClarisWksStyleManager::readStyleFonts
bool readStyleFonts(int N, int fSz)
read a STYL_CHAR Font sequence
Definition: ClarisWksStyleManager.cxx:2404
MWAWBorder::Style
Style
the line style
Definition: libmwaw_internal.hxx:301
ClarisWksStyleManager::~ClarisWksStyleManager
~ClarisWksStyleManager()
destructor
Definition: ClarisWksStyleManager.cxx:1567
ClarisWksStyleManager::Style::operator<<
friend std::ostream & operator<<(std::ostream &o, Style const &style)
operator<<
Definition: ClarisWksStyleManager.cxx:1532
ClarisWksStyleManager::CellFormat::m_borders
int m_borders
the borders
Definition: ClarisWksStyleManager.hxx:162
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MWAWBorder
a border
Definition: libmwaw_internal.hxx:299
ClarisWksDocument
main document information used to create a ClarisWorks file
Definition: ClarisWksDocument.hxx:72
ClarisWksStyleManager::KSEN::m_lineRepeat
MWAWBorder::Type m_lineRepeat
the line repetition
Definition: ClarisWksStyleManager.hxx:182
ClarisWksStyleManager::readStyles
bool readStyles(MWAWEntry const &entry)
try to read the styles definition (in v4-6)
Definition: ClarisWksStyleManager.cxx:1920
ClarisWksStyleManager::readGenStyle
bool readGenStyle(int id)
try to read a STYL_ subzone (in v4-6)
Definition: ClarisWksStyleManager.cxx:1969
ClarisWksStyleManager::Style::m_styleId
int m_styleId
the style id
Definition: ClarisWksStyleManager.hxx:216
ClarisWksStyleManager::Style::m_rulerPId
int m_rulerPId
the ruler parent id ( or maybe the style parent)
Definition: ClarisWksStyleManager.hxx:206
ClarisWksStyleManager::readPatternList
bool readPatternList(long endPos=-1)
reads a pattern map zone ( v2)
Definition: ClarisWksStyleManager.cxx:1724
ClarisWksStyleManager::updateGradient
bool updateGradient(int grad, MWAWGraphicStyle &style) const
update a style using a gradiant id
Definition: ClarisWksStyleManager.cxx:1682
ClarisWksStyleManager::m_document
ClarisWksDocument & m_document
the document
Definition: ClarisWksStyleManager.hxx:137
ClarisWksStyleManager::readGraphStyles
bool readGraphStyles(int N, int fSz)
read a GraphicStyle sequence
Definition: ClarisWksStyleManager.cxx:2558
ClarisWksStyleManager::KSEN::operator<<
friend std::ostream & operator<<(std::ostream &o, KSEN const &ksen)
operator<<
Definition: ClarisWksStyleManager.cxx:1462
ClarisWksStyleManager::Style
the structure to store the style in a ClarisWksStyleManager
Definition: ClarisWksStyleManager.hxx:190
ClarisWksStyleManager::version
int version() const
return the file version
Definition: ClarisWksStyleManager.cxx:1571
ClarisWksStyleManager::getRulerName
bool getRulerName(int id, std::string &name) const
return the name corresponding to a styleId
Definition: ClarisWksStyleManager.cxx:1577
ClarisWksStyleManager::readStyleNames
bool readStyleNames(int N, int fSz)
read a STYL Name sequence
Definition: ClarisWksStyleManager.cxx:2433
ClarisWksStyleManager::updateWallPaper
bool updateWallPaper(int wall, MWAWGraphicStyle &style) const
update a style using a wall paper id
Definition: ClarisWksStyleManager.cxx:1702
ClarisWksStyleManager::Style::m_nameId
int m_nameId
the style name id
Definition: ClarisWksStyleManager.hxx:208
ClarisWksStyleManager::CellFormat
the CELL structure a structure related to number/date format
Definition: ClarisWksStyleManager.hxx:149
MWAWInputStream.hxx
MWAWDebug.hxx
ClarisWksStyleManager::getColor
bool getColor(int id, MWAWColor &col) const
return the color which corresponds to an id (if possible)
Definition: ClarisWksStyleManager.cxx:1604
ClarisWksStyleManagerInternal
Internal: the structures of a ClarisWksStyleManagerInternal.
Definition: ClarisWksStyleManager.cxx:52
ClarisWksStyleManager::m_state
shared_ptr< ClarisWksStyleManagerInternal::State > m_state
the state
Definition: ClarisWksStyleManager.hxx:141
ClarisWksStyleManager::KSEN::m_lines
int m_lines
an int used to add some oblique line ( or cross )
Definition: ClarisWksStyleManager.hxx:184
MWAWCell.hxx
Defines MWAWCell (cell content and format)
ClarisWksStyleManager::readCellStyles
bool readCellStyles(int N, int fSz)
Definition: ClarisWksStyleManager.cxx:2479
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:435
ClarisWksStyleManager::KSEN::m_valign
int m_valign
the vertical alignment
Definition: ClarisWksStyleManager.hxx:178
ClarisWksStyleManager::readKSEN
bool readKSEN(int N, int fSz)
read a KSEN sequence
Definition: ClarisWksStyleManager.cxx:2652
ClarisWksStyleManager::Style::m_cellFormatId
int m_cellFormatId
the formatId
Definition: ClarisWksStyleManager.hxx:202
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
ClarisWksStyleManager::readLookUp
bool readLookUp(int N, int fSz)
try to read the lookup zone
Definition: ClarisWksStyleManager.cxx:2134
ClarisWksStyleManager::KSEN::m_extra
std::string m_extra
extra data
Definition: ClarisWksStyleManager.hxx:186
ClarisWksStyleManager::KSEN::KSEN
KSEN()
constructor
Definition: ClarisWksStyleManager.hxx:172
ClarisWksStyleManager::readFontNames
bool readFontNames()
read the font name style zone (method to store font names in v2/v3 files)
Definition: ClarisWksStyleManager.cxx:2175
ClarisWksStyleManager::Style::Style
Style()
constructor
Definition: ClarisWksStyleManager.hxx:192
MWAWGraphicStyle::Pattern
a basic pattern used in a MWAWGraphicStyle:
Definition: MWAWGraphicStyle.hxx:95
ClarisWksStyleManager::getPattern
bool getPattern(int id, MWAWGraphicStyle::Pattern &pattern, float &percent) const
return the pattern which corresponds to an id.
Definition: ClarisWksStyleManager.cxx:1617
MWAWGraphicStyle.hxx
ClarisWksStyleManager::getFontId
int getFontId(int localId) const
return a mac font id corresponding to a local id
Definition: ClarisWksStyleManager.cxx:1630
ClarisWksStyleManager::CellFormat::m_hAlign
MWAWCell::HorizontalAlignment m_hAlign
the cell alignment : by default nothing
Definition: ClarisWksStyleManager.hxx:158