CWStyleManager.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* Class used to read main style by Claris Works parser
*
*/
#ifndef CW_STYLE_MANAGER
# define CW_STYLE_MANAGER
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWDebug.hxx"
#include "MWAWInputStream.hxx"
class CWParser;
namespace CWStyleManagerInternal
{
struct State;
}
class CWStyleManager
{
public:
struct Graphic;
struct KSEN;
struct Style;
public:
CWStyleManager(CWParser &mainParser);
~CWStyleManager();
/* try to read the styles definition (in v4-6) */
bool readStyles(MWAWEntry const &entry);
int getFontId(int localId) const;
bool get(int styleId, Style &style) const;
bool get(int ksenId, KSEN &ksen) const;
bool get(int graphId, Graphic &graph) const;
protected:
int version() const;
bool readGenStyle(int id);
bool readStylesDef(int N, int fSz);
bool readLookUp(int N, int fSz);
/* read the STYL CELL sequence */
bool readCellStyles(int N, int fSz);
bool readFontNames(int N, int fSz);
bool readGraphStyles(int N, int fSz);
bool readKSEN(int N, int fSz);
bool readStyleNames(int N, int fSz);
protected:
MWAWParserStatePtr m_parserState;
CWParser *m_mainParser;
shared_ptr<CWStyleManagerInternal::State> m_state;
private:
CWStyleManager(CWStyleManager const &orig);
CWStyleManager &operator=(CWStyleManager const &orig);
public:
struct Graphic {
Graphic() : m_lineWidth(1), m_extra("") {
for (int i = 0; i < 2; i++) {
m_pattern[i] = -1;
m_patternPercent[i] = 1;
}
m_color[0] = MWAWColor::black();
m_color[1] = MWAWColor::white();
}
MWAWColor getLineColor() const;
MWAWColor getSurfaceColor() const;
friend std::ostream &operator<<(std::ostream &o, Graphic const &graph);
int m_lineWidth;
MWAWColor m_color[2];
int m_pattern[2];
float m_patternPercent[2];
std::string m_extra;
};
struct KSEN {
KSEN() : m_valign(0), m_lineType(MWAWBorder::Simple), m_lineRepeat(MWAWBorder::Single), m_lines(0), m_extra("") {
}
friend std::ostream &operator<<(std::ostream &o, KSEN const &ksen);
int m_valign;
MWAWBorder::Style m_lineType;
MWAWBorder::Type m_lineRepeat;
int m_lines;
std::string m_extra;
};
struct Style {
Style() : m_fontId(-1), m_fontHash(-1), m_rulerId(-1), m_rulerHash(-1), m_ksenId(-1), m_graphicId(-1), m_localStyleId(-1), m_styleId(-1), m_extra("") {
}
friend std::ostream &operator<<(std::ostream &o, Style const &style);
int m_fontId;
int m_fontHash;
int m_rulerId;
int m_rulerHash;
int m_ksenId;
int m_graphicId;
int m_localStyleId;
int m_styleId;
std::string m_extra;
};
};
#endif
CWStyleManager::Style::Style
Style()
constructor
Definition: CWStyleManager.hxx:172
CWStyleManager::Style::m_extra
std::string m_extra
extra data
Definition: CWStyleManager.hxx:195
CWStyleManager::Style::m_fontHash
int m_fontHash
the fontHash id
Definition: CWStyleManager.hxx:181
CWStyleManager
a structure to store the style list and the lookup zone
Definition: CWStyleManager.hxx:60
libmwaw_internal.hxx
CWStyleManager::readStylesDef
bool readStylesDef(int N, int fSz)
try to read the style definition zone
Definition: CWStyleManager.cxx:402
MWAWColor::white
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:179
CWStyleManager::Graphic::m_pattern
int m_pattern[2]
the line an surface pattern id
Definition: CWStyleManager.hxx:143
CWStyleManager::operator=
CWStyleManager & operator=(CWStyleManager const &orig)
CWStyleManager::readStyles
bool readStyles(MWAWEntry const &entry)
Definition: CWStyleManager.cxx:269
CWStyleManager::getFontId
int getFontId(int localId) const
return a mac font id corresponding to a local id
Definition: CWStyleManager.cxx:225
CWStyleManager::m_mainParser
CWParser * m_mainParser
the main parser
Definition: CWStyleManager.hxx:112
CWStyleManager::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: CWStyleManager.hxx:110
MWAWColor::black
static MWAWColor black()
return the back color
Definition: libmwaw_internal.hxx:175
CWStyleManager::Graphic::m_color
MWAWColor m_color[2]
the line and surface color
Definition: CWStyleManager.hxx:141
CWStyleManager::Style
the structure to store the style in a CWStyleManager
Definition: CWStyleManager.hxx:170
CWStyleManager::KSEN
the KSEN structure a structure related to paragraph and cell style
Definition: CWStyleManager.hxx:151
CWStyleManager::Graphic::m_extra
std::string m_extra
extra data
Definition: CWStyleManager.hxx:147
CWStyleManager::Style::m_graphicId
int m_graphicId
the graphic (checkme)
Definition: CWStyleManager.hxx:189
CWStyleManager::Style::m_localStyleId
int m_localStyleId
a local style id
Definition: CWStyleManager.hxx:191
MWAWBorder::Type
Type
the line repetition
Definition: libmwaw_internal.hxx:236
CWStyleManager::Graphic
the Graphic structure in a CWStyleManager
Definition: CWStyleManager.hxx:122
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
CWStyleManager::KSEN::m_extra
std::string m_extra
extra data
Definition: CWStyleManager.hxx:166
MWAWBorder::Style
Style
the line style
Definition: libmwaw_internal.hxx:234
CWStyleManager::KSEN::m_lineRepeat
MWAWBorder::Type m_lineRepeat
the line repetition
Definition: CWStyleManager.hxx:162
CWStyleManager::Style::operator<<
friend std::ostream & operator<<(std::ostream &o, Style const &style)
operator<<
Definition: CWStyleManager.cxx:185
MWAWBorder
a border
Definition: libmwaw_internal.hxx:232
CWStyleManager::readGraphStyles
bool readGraphStyles(int N, int fSz)
read a Graphic sequence
Definition: CWStyleManager.cxx:649
CWStyleManager::m_state
shared_ptr< CWStyleManagerInternal::State > m_state
the state
Definition: CWStyleManager.hxx:114
CWStyleManager::Graphic::operator<<
friend std::ostream & operator<<(std::ostream &o, Graphic const &graph)
operator<<
Definition: CWStyleManager.cxx:82
CWStyleManager::Style::m_rulerId
int m_rulerId
the ruler
Definition: CWStyleManager.hxx:183
CWStyleManager::Style::m_fontId
int m_fontId
the char
Definition: CWStyleManager.hxx:179
CWStyleManager::Graphic::getLineColor
MWAWColor getLineColor() const
returns the line color
Definition: CWStyleManager.cxx:98
CWStyleManager::readStyleNames
bool readStyleNames(int N, int fSz)
read a STYL Name sequence
Definition: CWStyleManager.cxx:562
CWStyleManager::Graphic::Graphic
Graphic()
constructor
Definition: CWStyleManager.hxx:124
CWStyleManager::Graphic::getSurfaceColor
MWAWColor getSurfaceColor() const
returns the surface color
Definition: CWStyleManager.cxx:105
CWStyleManager::Style::m_rulerHash
int m_rulerHash
the rulerHash id
Definition: CWStyleManager.hxx:185
CWStyleManager::Graphic::m_lineWidth
int m_lineWidth
the line width
Definition: CWStyleManager.hxx:139
CWParser
the main class to read a Claris Works file
Definition: CWParser.hxx:73
CWStyleManager::KSEN::m_lines
int m_lines
an int used to add some oblique line ( or cross )
Definition: CWStyleManager.hxx:164
CWStyleManager::KSEN::m_lineType
MWAWBorder::Style m_lineType
the line type
Definition: CWStyleManager.hxx:160
CWStyleManager::KSEN::operator<<
friend std::ostream & operator<<(std::ostream &o, KSEN const &ksen)
operator<<
Definition: CWStyleManager.cxx:115
CWStyleManager::readGenStyle
bool readGenStyle(int id)
try to read a STYL_ subzone (in v4-6)
Definition: CWStyleManager.cxx:316
CWStyleManager::readLookUp
bool readLookUp(int N, int fSz)
try to read the lookup zone
Definition: CWStyleManager.cxx:463
CWStyleManager::~CWStyleManager
~CWStyleManager()
destructor
Definition: CWStyleManager.cxx:214
MWAWInputStream.hxx
MWAWDebug.hxx
CWStyleManager::readCellStyles
bool readCellStyles(int N, int fSz)
Definition: CWStyleManager.cxx:601
CWStyleManager::Style::m_styleId
int m_styleId
the style id
Definition: CWStyleManager.hxx:193
CWStyleManager::Style::m_ksenId
int m_ksenId
the ksen id
Definition: CWStyleManager.hxx:187
CWStyleManager::readKSEN
bool readKSEN(int N, int fSz)
read a KSEN sequence
Definition: CWStyleManager.cxx:731
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:342
CWStyleManager::KSEN::KSEN
KSEN()
constructor
Definition: CWStyleManager.hxx:153
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
CWStyleManager::version
int version() const
return the file version
Definition: CWStyleManager.cxx:218
CWStyleManager::CWStyleManager
CWStyleManager(CWParser &mainParser)
constructor
Definition: CWStyleManager.cxx:208
CWStyleManager::readFontNames
bool readFontNames(int N, int fSz)
read the font name style zone
Definition: CWStyleManager.cxx:500
CWStyleManager::KSEN::m_valign
int m_valign
the vertical alignement
Definition: CWStyleManager.hxx:158
CWStyleManager::Graphic::m_patternPercent
float m_patternPercent[2]
the line an surface pattern percent
Definition: CWStyleManager.hxx:145