Canvas5StyleManager.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.
*/
/*
* Parser to Canvas v5-v11 text document ( style part )
*
*/
#ifndef CANVAS5_STYLE_MANAGER
# define CANVAS5_STYLE_MANAGER
#include <string>
#include <utility>
#include <vector>
#include <librevenge/librevenge.h>
#include "libmwaw_internal.hxx"
#include "MWAWDebug.hxx"
#include "MWAWFont.hxx"
#include "MWAWGraphicStyle.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWParagraph.hxx"
#include "MWAWPosition.hxx"
class MWAWFont;
namespace Canvas5Structure
{
struct Stream;
}
namespace Canvas5StyleManagerInternal
{
struct ColorStyle;
struct PenStyle;
struct State;
}
namespace Canvas5ImageInternal
{
struct VKFLImage;
}
class Canvas5Graph;
class Canvas5Image;
class Canvas5Parser;
class Canvas5StyleManager
{
friend class Canvas5Graph;
friend class Canvas5Parser;
public:
struct CharStyle {
CharStyle()
: m_font()
, m_paragraphId(0)
, m_linkId(0)
{
}
MWAWFont m_font;
int m_paragraphId;
int m_linkId;
};
struct StyleList {
StyleList()
: m_fonts()
, m_paragraphs()
{
}
std::vector<CharStyle> m_fonts;
std::vector<std::pair<MWAWParagraph, int> > m_paragraphs;
};
explicit Canvas5StyleManager(Canvas5Parser &parser);
virtual ~Canvas5StyleManager();
int version() const;
std::shared_ptr<Canvas5Image> getImageParser() const;
std::shared_ptr<Canvas5StyleManagerInternal::ColorStyle> readColorStyle(std::shared_ptr<Canvas5Structure::Stream> stream, unsigned type, long len);
bool updateLineColor(Canvas5StyleManagerInternal::ColorStyle const &color, MWAWGraphicStyle &style);
bool updateSurfaceColor(Canvas5StyleManagerInternal::ColorStyle const &color, MWAWGraphicStyle &style);
std::shared_ptr<Canvas5StyleManagerInternal::PenStyle> readPenStyle(Canvas5Structure::Stream &stream, unsigned type, long len);
bool updateLine(Canvas5StyleManagerInternal::PenStyle const &pen, MWAWGraphicStyle &style, int &numLines, int lineId, float *offset);
bool readArrow(std::shared_ptr<Canvas5Structure::Stream> stream, MWAWGraphicStyle::Arrow &arrow, unsigned type, long len);
bool readCharStyle(Canvas5Structure::Stream &stream, int id, CharStyle &fontIds, bool useFileColors=true);
bool readDash(Canvas5Structure::Stream &stream, std::vector<float> &dashes, unsigned type, long len);
bool readStyleEnd(std::shared_ptr<Canvas5Structure::Stream> stream, MWAWFont *font=nullptr, MWAWParagraph *para=nullptr);
protected:
// interface
bool updateLineStyle(int sId, MWAWGraphicStyle &style, int &numLines, int lineId=-1, float *offset=nullptr);
bool updateLineColor(int cId, MWAWGraphicStyle &style);
bool updateSurfaceColor(int cId, MWAWGraphicStyle &style);
//
// Intermediate level
//
bool readArrows(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readCharStyles(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readInks(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readInks9(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readColor(Canvas5Structure::Stream &stream, MWAWVariable<MWAWColor> &color, std::string &extra);
bool readDashes(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readFrameStyles9(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readFonts(std::shared_ptr<Canvas5Structure::Stream> stream, int numFonts);
bool readFormats(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readPenSize(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readPenStyles(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readStrokes(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readParaStyle(std::shared_ptr<Canvas5Structure::Stream> stream, int id, StyleList *styles=nullptr);
bool readParaStyles(std::shared_ptr<Canvas5Structure::Stream> stream);
//
// Windows RSRC
//
//
// Low level
//
bool readGradient(std::shared_ptr<Canvas5Structure::Stream> stream, long len, MWAWGraphicStyle::Gradient &gradient);
bool readHatch(std::shared_ptr<Canvas5Structure::Stream> stream, long len, MWAWGraphicStyle::Hatch &hatch,
MWAWVariable<MWAWColor> &backColor);
std::shared_ptr<Canvas5ImageInternal::VKFLImage> readSymbol(std::shared_ptr<Canvas5Structure::Stream> stream, long len,
MWAWVariable<MWAWColor> &backColor);
private:
Canvas5StyleManager(Canvas5StyleManager const &orig) = delete;
Canvas5StyleManager &operator=(Canvas5StyleManager const &orig) = delete;
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
std::shared_ptr<Canvas5StyleManagerInternal::State> m_state;
Canvas5Parser *m_mainParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWFont.hxx
MWAWGraphicStyle.hxx
MWAWInputStream.hxx
MWAWParagraph.hxx
MWAWPosition.hxx
Canvas5Graph
the main class to read the graphic part of Canvas v5-v11 file
Definition Canvas5Graph.hxx:85
Canvas5Image
the main class to read/convert the image or movie inside of Canvas 5-11 files
Definition Canvas5Image.hxx:78
Canvas5Parser
the main class to read a Canvas 5-10 files (and probably some not password protected Windows 11 files...
Definition Canvas5Parser.hxx:72
Canvas5StyleManager::Canvas5StyleManager
Canvas5StyleManager(Canvas5StyleManager const &orig)=delete
Canvas5StyleManager::readPenStyle
std::shared_ptr< Canvas5StyleManagerInternal::PenStyle > readPenStyle(Canvas5Structure::Stream &stream, unsigned type, long len)
try to read a pen style
Definition Canvas5StyleManager.cxx:1307
Canvas5StyleManager::readFonts
bool readFonts(std::shared_ptr< Canvas5Structure::Stream > stream, int numFonts)
try to read the fonts names
Definition Canvas5StyleManager.cxx:1119
Canvas5StyleManager::readParaStyles
bool readParaStyles(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the paragraph styles
Definition Canvas5StyleManager.cxx:2096
Canvas5StyleManager::readCharStyle
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
Canvas5StyleManager::Canvas5Graph
friend class Canvas5Graph
Definition Canvas5StyleManager.hxx:87
Canvas5StyleManager::readArrows
bool readArrows(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the arrows zones
Definition Canvas5StyleManager.cxx:585
Canvas5StyleManager::Canvas5StyleManager
Canvas5StyleManager(Canvas5Parser &parser)
constructor
Definition Canvas5StyleManager.cxx:219
Canvas5StyleManager::readStyleEnd
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
Canvas5StyleManager::~Canvas5StyleManager
virtual ~Canvas5StyleManager()
destructor
Definition Canvas5StyleManager.cxx:226
Canvas5StyleManager::readColorStyle
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
Canvas5StyleManager::readArrow
bool readArrow(std::shared_ptr< Canvas5Structure::Stream > stream, MWAWGraphicStyle::Arrow &arrow, unsigned type, long len)
try to read an arrow
Definition Canvas5StyleManager.cxx:620
Canvas5StyleManager::updateSurfaceColor
bool updateSurfaceColor(Canvas5StyleManagerInternal::ColorStyle const &color, MWAWGraphicStyle &style)
try to update the surface color given a color style
Definition Canvas5StyleManager.cxx:2367
Canvas5StyleManager::readColor
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
Canvas5StyleManager::readInks9
bool readInks9(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the ink color zones: v9
Definition Canvas5StyleManager.cxx:774
Canvas5StyleManager::updateLine
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
Canvas5StyleManager::readCharStyles
bool readCharStyles(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the character styles
Definition Canvas5StyleManager.cxx:1762
Canvas5StyleManager::getImageParser
std::shared_ptr< Canvas5Image > getImageParser() const
returns the image parser
Definition Canvas5StyleManager.cxx:234
Canvas5StyleManager::readFrameStyles9
bool readFrameStyles9(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the frame zones: stroke, pen style, arrow, dashes: v9
Definition Canvas5StyleManager.cxx:2202
Canvas5StyleManager::version
int version() const
returns the file version
Definition Canvas5StyleManager.cxx:229
Canvas5StyleManager::m_mainParser
Canvas5Parser * m_mainParser
the main parser;
Definition Canvas5StyleManager.hxx:232
Canvas5StyleManager::operator=
Canvas5StyleManager & operator=(Canvas5StyleManager const &orig)=delete
Canvas5StyleManager::readPenSize
bool readPenSize(std::shared_ptr< Canvas5Structure::Stream > stream)
read the pen size (header file)
Definition Canvas5StyleManager.cxx:1234
Canvas5StyleManager::readFormats
bool readFormats(std::shared_ptr< Canvas5Structure::Stream > stream)
read the list of formats, mainly an unit's conversion table
Definition Canvas5StyleManager.cxx:1167
Canvas5StyleManager::readInks
bool readInks(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the ink color zones
Definition Canvas5StyleManager.cxx:665
Canvas5StyleManager::readDash
bool readDash(Canvas5Structure::Stream &stream, std::vector< float > &dashes, unsigned type, long len)
try to read a dash's array
Definition Canvas5StyleManager.cxx:1055
Canvas5StyleManager::m_state
std::shared_ptr< Canvas5StyleManagerInternal::State > m_state
the state
Definition Canvas5StyleManager.hxx:229
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:2466
Canvas5StyleManager::readHatch
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
Canvas5StyleManager::readSymbol
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
Canvas5StyleManager::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition Canvas5StyleManager.hxx:226
Canvas5StyleManager::readStrokes
bool readStrokes(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the stroke styles
Definition Canvas5StyleManager.cxx:1535
Canvas5StyleManager::readDashes
bool readDashes(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the dashes
Definition Canvas5StyleManager.cxx:1024
Canvas5StyleManager::readGradient
bool readGradient(std::shared_ptr< Canvas5Structure::Stream > stream, long len, MWAWGraphicStyle::Gradient &gradient)
try to read a gradient zone: OBFL
Definition Canvas5StyleManager.cxx:290
Canvas5StyleManager::updateLineColor
bool updateLineColor(Canvas5StyleManagerInternal::ColorStyle const &color, MWAWGraphicStyle &style)
try to update the line color given a color style
Definition Canvas5StyleManager.cxx:2321
Canvas5StyleManager::Canvas5Parser
friend class Canvas5Parser
Definition Canvas5StyleManager.hxx:88
Canvas5StyleManager::readParaStyle
bool readParaStyle(std::shared_ptr< Canvas5Structure::Stream > stream, int id, StyleList *styles=nullptr)
try to read a paragraph style
Definition Canvas5StyleManager.cxx:1862
Canvas5StyleManager::readPenStyles
bool readPenStyles(std::shared_ptr< Canvas5Structure::Stream > stream)
read the pen styles
Definition Canvas5StyleManager.cxx:1258
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
Canvas5ImageInternal
Internal: the structures of a Canvas5Image.
Definition Canvas5Image.cxx:70
Canvas5Structure
a namespace used to define basic function or structure to read a Canvas v5-v11 file
Definition Canvas5BMParser.hxx:64
Canvas5StyleManagerInternal
Internal: the structures of a Canvas5StyleManager.
Definition Canvas5StyleManager.cxx:62
Canvas5ImageInternal::VKFLImage
Internal: the internal image of a Canvas5Image.
Definition Canvas5Image.cxx:166
Canvas5Structure::Stream
a sub stream of Canvas5Structure
Definition Canvas5Structure.hxx:49
Canvas5StyleManagerInternal::ColorStyle
Internal: the color style of a Canvas5StyleManager.
Definition Canvas5StyleManager.cxx:66
Canvas5StyleManagerInternal::PenStyle
Internal: the pen style of a Canvas5StyleManager.
Definition Canvas5StyleManager.cxx:108
Canvas5StyleManagerInternal::State
Internal: the state of a Canvas5StyleManager.
Definition Canvas5StyleManager.cxx:191
Canvas5StyleManager::CharStyle
a structure use to store a character style
Definition Canvas5StyleManager.hxx:92
Canvas5StyleManager::CharStyle::m_linkId
int m_linkId
the link id
Definition Canvas5StyleManager.hxx:105
Canvas5StyleManager::CharStyle::m_font
MWAWFont m_font
the font
Definition Canvas5StyleManager.hxx:101
Canvas5StyleManager::CharStyle::CharStyle
CharStyle()
constructor
Definition Canvas5StyleManager.hxx:94
Canvas5StyleManager::CharStyle::m_paragraphId
int m_paragraphId
the paragraph id
Definition Canvas5StyleManager.hxx:103
Canvas5StyleManager::StyleList
a structure use to store a list of styles
Definition Canvas5StyleManager.hxx:109
Canvas5StyleManager::StyleList::StyleList
StyleList()
constructor
Definition Canvas5StyleManager.hxx:111
Canvas5StyleManager::StyleList::m_fonts
std::vector< CharStyle > m_fonts
the fonts, the paragraph id and the link id
Definition Canvas5StyleManager.hxx:117
Canvas5StyleManager::StyleList::m_paragraphs
std::vector< std::pair< MWAWParagraph, int > > m_paragraphs
the paragraph list and the tab id
Definition Canvas5StyleManager.hxx:119
MWAWGraphicStyle::Arrow
a structure used to define an arrow
Definition MWAWGraphicStyle.hxx:59
MWAWGraphicStyle::Gradient
a basic gradient used in a MWAWGraphicStyle
Definition MWAWGraphicStyle.hxx:142
MWAWGraphicStyle::Hatch
a basic hatch used in MWAWGraphicStyle
Definition MWAWGraphicStyle.hxx:279
MWAWVariable
a generic variable template: value + flag to know if the variable is set
Definition libmwaw_internal.hxx:577