ClarisWksStyleManager.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 AppleWorks/ClarisWorks parser
*
*/
#ifndef CLARIS_WKS_STYLE_MANAGER
# define CLARIS_WKS_STYLE_MANAGER
#include <iostream>
#include <string>
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWCell.hxx"
#include "MWAWDebug.hxx"
#include "MWAWGraphicStyle.hxx"
#include "MWAWInputStream.hxx"
class ClarisWksDocument;
namespace ClarisWksStyleManagerInternal
{
struct State;
}
class ClarisWksStyleManager
{
public:
struct CellFormat;
struct KSEN;
struct Style;
public:
explicit ClarisWksStyleManager(MWAWParserStatePtr const &parserState, ClarisWksDocument *document=nullptr);
~ClarisWksStyleManager();
bool readColorList(MWAWEntry const &entry);
bool readPatternList(long endPos=-1);
bool readGradientList(long endPos=-1);
bool readStyles(MWAWEntry const &entry);
bool readFontNames();
bool updateGradient(int grad, MWAWGraphicStyle &style) const;
bool updateWallPaper(int wall, MWAWGraphicStyle &style) const;
int getFontId(int localId) const;
bool getColor(int id, MWAWColor &col) const;
bool getPattern(int id, MWAWGraphicStyle::Pattern &pattern, float &percent) const;
bool getRulerName(int id, std::string &name) const;
bool get(int styleId, Style &style) const;
bool get(int fontId, MWAWFont &font) const;
bool get(int formatId, CellFormat &format) const;
bool get(int ksenId, KSEN &ksen) const;
bool get(int graphId, MWAWGraphicStyle &graph) const;
bool readFont(int id, int fontSize, MWAWFont &font);
bool readFontAndPos(int id, int &posC, MWAWFont &font);
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);
bool readStyleFonts(int N, int fSz);
protected:
ClarisWksDocument *m_document;
MWAWParserStatePtr m_parserState;
std::shared_ptr<ClarisWksStyleManagerInternal::State> m_state;
private:
ClarisWksStyleManager(ClarisWksStyleManager const &orig) = delete;
ClarisWksStyleManager &operator=(ClarisWksStyleManager const &orig) = delete;
public:
struct CellFormat final : public MWAWCell::Format {
explicit CellFormat(MWAWCell::Format const &format=MWAWCell::Format())
: MWAWCell::Format(format)
, m_hAlign(MWAWCell::HALIGN_DEFAULT)
, m_fileFormat(-1)
, m_borders(0)
, m_wrap(false)
, m_extra("")
{
}
CellFormat(CellFormat const &)=default;
CellFormat &operator=(CellFormat const &)=default;
CellFormat &operator=(CellFormat &&)=default;
~CellFormat() final;
friend std::ostream &operator<<(std::ostream &o, CellFormat const &form);
MWAWCell::HorizontalAlignment m_hAlign;
int m_fileFormat;
int m_borders;
bool m_wrap;
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_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("")
{
}
friend std::ostream &operator<<(std::ostream &o, Style const &style);
int m_fontId;
int m_cellFormatId;
int m_rulerId;
int m_rulerPId;
int m_nameId;
int m_ksenId;
int m_graphicId;
int m_localStyleId;
int m_styleId;
std::string m_extra;
};
};
#endif
operator<<
std::ostream & operator<<(std::ostream &o, ClarisWksStyleManager::KSEN const &ksen)
Definition ClarisWksStyleManager.cxx:1489
MWAWCell.hxx
Defines MWAWCell (cell content and format).
MWAWDebug.hxx
MWAWGraphicStyle.hxx
MWAWInputStream.hxx
ClarisWksDocument
main document information used to create a ClarisWorks file
Definition ClarisWksDocument.hxx:74
ClarisWksStyleManager::updateGradient
bool updateGradient(int grad, MWAWGraphicStyle &style) const
update a style using a gradiant id
Definition ClarisWksStyleManager.cxx:1715
ClarisWksStyleManager::version
int version() const
return the file version
Definition ClarisWksStyleManager.cxx:1604
ClarisWksStyleManager::ClarisWksStyleManager
ClarisWksStyleManager(ClarisWksStyleManager const &orig)=delete
ClarisWksStyleManager::readStyleNames
bool readStyleNames(int N, int fSz)
read a STYL Name sequence
Definition ClarisWksStyleManager.cxx:2513
ClarisWksStyleManager::m_state
std::shared_ptr< ClarisWksStyleManagerInternal::State > m_state
the state
Definition ClarisWksStyleManager.hxx:143
ClarisWksStyleManager::getColor
bool getColor(int id, MWAWColor &col) const
return the color which corresponds to an id (if possible)
Definition ClarisWksStyleManager.cxx:1637
ClarisWksStyleManager::m_document
ClarisWksDocument * m_document
the document
Definition ClarisWksStyleManager.hxx:139
ClarisWksStyleManager::readPatternList
bool readPatternList(long endPos=-1)
reads a pattern map zone ( v2)
Definition ClarisWksStyleManager.cxx:1758
ClarisWksStyleManager::readFont
bool readFont(int id, int fontSize, MWAWFont &font)
try to read a named font
Definition ClarisWksStyleManager.cxx:2305
ClarisWksStyleManager::readGraphStyles
bool readGraphStyles(int N, int fSz)
read a GraphicStyle sequence
Definition ClarisWksStyleManager.cxx:2638
ClarisWksStyleManager::~ClarisWksStyleManager
~ClarisWksStyleManager()
destructor
Definition ClarisWksStyleManager.cxx:1600
ClarisWksStyleManager::ClarisWksStyleManager
ClarisWksStyleManager(MWAWParserStatePtr const &parserState, ClarisWksDocument *document=nullptr)
constructor
Definition ClarisWksStyleManager.cxx:1592
ClarisWksStyleManager::readColorList
bool readColorList(MWAWEntry const &entry)
reads a color map zone ( v4-v6)
Definition ClarisWksStyleManager.cxx:1872
ClarisWksStyleManager::get
bool get(int styleId, Style &style) const
return the style corresponding to a styleId
Definition ClarisWksStyleManager.cxx:1668
ClarisWksStyleManager::getPattern
bool getPattern(int id, MWAWGraphicStyle::Pattern &pattern, float &percent) const
return the pattern which corresponds to an id.
Definition ClarisWksStyleManager.cxx:1650
ClarisWksStyleManager::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition ClarisWksStyleManager.hxx:141
ClarisWksStyleManager::getFontId
int getFontId(int localId) const
return a mac font id corresponding to a local id
Definition ClarisWksStyleManager.cxx:1663
ClarisWksStyleManager::operator=
ClarisWksStyleManager & operator=(ClarisWksStyleManager const &orig)=delete
ClarisWksStyleManager::readStyles
bool readStyles(MWAWEntry const &entry)
try to read the styles definition (in v4-6)
Definition ClarisWksStyleManager.cxx:1921
ClarisWksStyleManager::readStylesDef
bool readStylesDef(int N, int fSz)
try to read the style definition zone
Definition ClarisWksStyleManager.cxx:2073
ClarisWksStyleManager::getRulerName
bool getRulerName(int id, std::string &name) const
return the name corresponding to a styleId
Definition ClarisWksStyleManager.cxx:1610
ClarisWksStyleManager::readGenStyle
bool readGenStyle(int id)
try to read a STYL_ subzone (in v4-6)
Definition ClarisWksStyleManager.cxx:1970
ClarisWksStyleManager::updateWallPaper
bool updateWallPaper(int wall, MWAWGraphicStyle &style) const
update a style using a wall paper id
Definition ClarisWksStyleManager.cxx:1736
ClarisWksStyleManager::readLookUp
bool readLookUp(int N, int fSz)
try to read the lookup zone
Definition ClarisWksStyleManager.cxx:2134
ClarisWksStyleManager::readStyleFonts
bool readStyleFonts(int N, int fSz)
read a STYL_CHAR Font sequence
Definition ClarisWksStyleManager.cxx:2484
ClarisWksStyleManager::readFontAndPos
bool readFontAndPos(int id, int &posC, MWAWFont &font)
try to read a font
Definition ClarisWksStyleManager.cxx:2381
ClarisWksStyleManager::readKSEN
bool readKSEN(int N, int fSz)
read a KSEN sequence
Definition ClarisWksStyleManager.cxx:2731
ClarisWksStyleManager::readFontNames
bool readFontNames()
read the font name style zone (method to store font names in v2/v3 files)
Definition ClarisWksStyleManager.cxx:2175
ClarisWksStyleManager::readCellStyles
bool readCellStyles(int N, int fSz)
Definition ClarisWksStyleManager.cxx:2559
ClarisWksStyleManager::readGradientList
bool readGradientList(long endPos=-1)
reads a gradient map zone ( v2)
Definition ClarisWksStyleManager.cxx:1799
MWAWCell
a structure used to define a cell and its format
Definition MWAWCell.hxx:53
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
MWAWGraphicStyle
a structure used to define a picture style
Definition MWAWGraphicStyle.hxx:48
libmwaw_internal.hxx
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
ClarisWksStyleManagerInternal
Internal: the structures of a ClarisWksStyleManagerInternal.
Definition ClarisWksStyleManager.cxx:53
ClarisWksStyleManagerInternal::State
Internal: the state of a ClarisWksStyleManager.
Definition ClarisWksStyleManager.cxx:202
ClarisWksStyleManager::CellFormat
the CELL structure a structure related to number/date format
Definition ClarisWksStyleManager.hxx:151
ClarisWksStyleManager::CellFormat::m_fileFormat
int m_fileFormat
the field format: number, string, currency, ..
Definition ClarisWksStyleManager.hxx:172
ClarisWksStyleManager::CellFormat::CellFormat
CellFormat(MWAWCell::Format const &format=MWAWCell::Format())
constructor from cell
Definition ClarisWksStyleManager.hxx:153
ClarisWksStyleManager::CellFormat::operator=
CellFormat & operator=(CellFormat &&)=default
ClarisWksStyleManager::CellFormat::operator=
CellFormat & operator=(CellFormat const &)=default
ClarisWksStyleManager::CellFormat::m_wrap
bool m_wrap
true if the cell content is wrapped
Definition ClarisWksStyleManager.hxx:176
ClarisWksStyleManager::CellFormat::m_hAlign
MWAWCell::HorizontalAlignment m_hAlign
the cell alignment : by default nothing
Definition ClarisWksStyleManager.hxx:170
ClarisWksStyleManager::CellFormat::CellFormat
CellFormat(CellFormat const &)=default
ClarisWksStyleManager::CellFormat::m_borders
int m_borders
the borders
Definition ClarisWksStyleManager.hxx:174
ClarisWksStyleManager::CellFormat::~CellFormat
~CellFormat() final
destructor
Definition ClarisWksStyleManager.cxx:2801
ClarisWksStyleManager::CellFormat::operator<<
friend std::ostream & operator<<(std::ostream &o, CellFormat const &form)
operator<<
Definition ClarisWksStyleManager.cxx:2805
ClarisWksStyleManager::CellFormat::m_extra
std::string m_extra
extra data
Definition ClarisWksStyleManager.hxx:178
ClarisWksStyleManager::KSEN
the KSEN structure a structure related to paragraph and cell style
Definition ClarisWksStyleManager.hxx:182
ClarisWksStyleManager::KSEN::m_lineType
MWAWBorder::Style m_lineType
the line type
Definition ClarisWksStyleManager.hxx:197
ClarisWksStyleManager::KSEN::m_lineRepeat
MWAWBorder::Type m_lineRepeat
the line repetition
Definition ClarisWksStyleManager.hxx:199
ClarisWksStyleManager::KSEN::m_valign
int m_valign
the vertical alignment
Definition ClarisWksStyleManager.hxx:195
ClarisWksStyleManager::KSEN::m_lines
int m_lines
an int used to add some oblique line ( or cross )
Definition ClarisWksStyleManager.hxx:201
ClarisWksStyleManager::KSEN::KSEN
KSEN()
constructor
Definition ClarisWksStyleManager.hxx:184
ClarisWksStyleManager::KSEN::m_extra
std::string m_extra
extra data
Definition ClarisWksStyleManager.hxx:203
ClarisWksStyleManager::Style
the structure to store the style in a ClarisWksStyleManager
Definition ClarisWksStyleManager.hxx:207
ClarisWksStyleManager::Style::m_nameId
int m_nameId
the style name id
Definition ClarisWksStyleManager.hxx:234
ClarisWksStyleManager::Style::m_styleId
int m_styleId
the style id
Definition ClarisWksStyleManager.hxx:242
ClarisWksStyleManager::Style::m_rulerPId
int m_rulerPId
the ruler parent id ( or maybe the style parent)
Definition ClarisWksStyleManager.hxx:232
ClarisWksStyleManager::Style::m_ksenId
int m_ksenId
the ksen id
Definition ClarisWksStyleManager.hxx:236
ClarisWksStyleManager::Style::Style
Style()
constructor
Definition ClarisWksStyleManager.hxx:209
ClarisWksStyleManager::Style::m_rulerId
int m_rulerId
the ruler
Definition ClarisWksStyleManager.hxx:230
ClarisWksStyleManager::Style::m_extra
std::string m_extra
extra data
Definition ClarisWksStyleManager.hxx:244
ClarisWksStyleManager::Style::m_fontId
int m_fontId
the char
Definition ClarisWksStyleManager.hxx:226
ClarisWksStyleManager::Style::m_graphicId
int m_graphicId
the graphic (checkme)
Definition ClarisWksStyleManager.hxx:238
ClarisWksStyleManager::Style::m_cellFormatId
int m_cellFormatId
the formatId
Definition ClarisWksStyleManager.hxx:228
ClarisWksStyleManager::Style::m_localStyleId
int m_localStyleId
a local style id
Definition ClarisWksStyleManager.hxx:240
MWAWBorder
a border
Definition libmwaw_internal.hxx:333
MWAWBorder::Type
Type
the line repetition
Definition libmwaw_internal.hxx:337
MWAWBorder::Style
Style
the line style
Definition libmwaw_internal.hxx:335
MWAWCell::Format
a structure uses to define the format of a cell content
Definition MWAWCell.hxx:60
MWAWCell::Format::Format
Format()
constructor
Definition MWAWCell.hxx:62
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MWAWGraphicStyle::Pattern
a basic pattern used in a MWAWGraphicStyle:
Definition MWAWGraphicStyle.hxx:351