MsWksGraph.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 Microsoft Works text document ( graphic part )
*
*/
#ifndef MS_WKS_MWAW_GRAPH
# define MS_WKS_MWAW_GRAPH
#include <list>
#include <string>
#include <vector>
#include "MWAWPosition.hxx"
#include "MWAWEntry.hxx"
#include "MWAWGraphicStyle.hxx"
#include "MWAWParser.hxx"
namespace MsWksGraphInternal
{
struct GroupZone;
struct RBZone;
struct TextBox;
struct Zone;
struct State;
class SubDocument;
}
class MsWksTable;
class MsWksDocument;
class MsWksParser;
class MsWks4Zone;
class MsWksDBParser;
class MsWksDRParser;
class MsWksSSParser;
class MsWksGraph
{
friend class MsWksDocument;
friend class MsWksTable;
friend class MsWksParser;
friend class MsWks4Zone;
friend class MsWksDBParser;
friend class MsWksDRParser;
friend class MsWksSSParser;
friend class MsWksGraphInternal::SubDocument;
public:
struct Style;
explicit MsWksGraph(MsWksDocument &document);
virtual ~MsWksGraph();
void setPageLeftTop(MWAWVec2f const &leftTop);
int version() const;
int numPages(int zoneId) const;
void send(int id, MWAWPosition const &pos);
void sendAll(int zoneId, bool mainZone);
struct SendData {
SendData()
: m_type(RBDR)
, m_id(-1)
, m_anchor(MWAWPosition::Char)
, m_page(-1)
, m_size()
{
}
enum Type { RBDR, RBIL, ALL } m_type;
int m_id;
MWAWPosition::AnchorTo m_anchor;
int m_page;
MWAWVec2i m_size;
};
void sendObjects(SendData const &what);
void computePositions(int zoneId, std::vector<int> const &linesHeight, std::vector<int> const &pagesHeight);
protected:
void flushExtra();
//
// Intermediate level
//
bool readPictHeader(MsWksGraphInternal::Zone &pict);
bool readGradient(Style &style);
int getEntryPictureV1(int zoneId, MWAWEntry &zone, bool autoSend=true);
int getEntryPicture(int zoneId, MWAWEntry &zone, bool autoSend=true, int order=-1000);
bool readRB(MWAWInputStreamPtr input, MWAWEntry const &entry, int kind);
// version 4 file
bool readPictureV4(MWAWInputStreamPtr input, MWAWEntry const &entry);
bool readText(MsWksGraphInternal::TextBox &textBox);
void sendTextBox(int zId, MWAWListenerPtr listener);
void checkTextBoxLinks(MsWksGraphInternal::RBZone &rbZone);
// interface function
bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const;
bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const;
void sendFrameText(MWAWEntry const &entry, std::string const &frame);
void sendTable(int id);
void sendChart(int zoneId);
//
// low level
//
std::shared_ptr<MsWksGraphInternal::GroupZone> readGroup(MsWksGraphInternal::Zone &group);
void sendGroup(int zoneId, MWAWPosition const &pos);
void sendGroupChild(int zoneId, MWAWPosition const &pos);
bool canCreateGraphic(MsWksGraphInternal::GroupZone const &group) const;
void sendGroup(MsWksGraphInternal::GroupZone const &group, MWAWGraphicListenerPtr &listener) const;
bool readFont(MWAWFont &font);
public:
struct Style final : public MWAWGraphicStyle {
Style()
: MWAWGraphicStyle()
, m_baseLineColor(MWAWColor::black())
, m_baseSurfaceColor(MWAWColor::white())
{
m_fillRuleEvenOdd=true;
}
Style(Style const &)=default;
Style &operator=(Style const &)=default;
Style &operator=(Style &&)=default;
~Style() final;
friend std::ostream &operator<<(std::ostream &o, Style const &st)
{
o << static_cast<MWAWGraphicStyle const &>(st);
if (st.m_baseLineColor != st.m_lineColor)
o << "lineColor[base]=" << st.m_baseLineColor << ",";
if (st.m_baseSurfaceColor != st.m_surfaceColor)
o << "surfaceColor[base]=" << st.m_baseSurfaceColor << ",";
return o;
}
MWAWColor m_baseLineColor;
MWAWColor m_baseSurfaceColor;
};
private:
MsWksGraph(MsWksGraph const &orig) = delete;
MsWksGraph &operator=(MsWksGraph const &orig) = delete;
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
std::shared_ptr<MsWksGraphInternal::State> m_state;
MWAWParser *m_mainParser;
MsWksDocument &m_document;
std::shared_ptr<MsWksTable> m_tableParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry.hxx
MWAWGraphicStyle.hxx
MWAWParser.hxx
MWAWPosition.hxx
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
MWAWGraphicStyle::m_fillRuleEvenOdd
bool m_fillRuleEvenOdd
true if the fill rule is evenod
Definition MWAWGraphicStyle.hxx:646
MWAWGraphicStyle::MWAWGraphicStyle
MWAWGraphicStyle()
constructor
Definition MWAWGraphicStyle.hxx:445
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition MWAWParser.hxx:100
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition MWAWPosition.hxx:48
MWAWPosition::AnchorTo
AnchorTo
a list of enum used to defined the anchor
Definition MWAWPosition.hxx:51
MsWks4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition MsWks4Zone.hxx:74
MsWksDBParser
the main class to read a Microsoft Works database file and convert it in a spreadsheet file
Definition MsWksDBParser.hxx:66
MsWksDRParser
the main class to read a Microsoft Works graphic file
Definition MsWksDRParser.hxx:60
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition MsWksDocument.hxx:69
MsWksGraphInternal::SubDocument
Internal: the subdocument of a MsWksGraph.
Definition MsWksGraph.cxx:956
MsWksGraph::readGradient
bool readGradient(Style &style)
read the gradient structure ( v4)
Definition MsWksGraph.cxx:1356
MsWksGraph::sendObjects
void sendObjects(SendData const &what)
sends all the object of a page, frame, ...
Definition MsWksGraph.cxx:2968
MsWksGraph::getEntryPicture
int getEntryPicture(int zoneId, MWAWEntry &zone, bool autoSend=true, int order=-1000)
checks if the next zone is a v2 picture and returns a zone id ( or -1)
Definition MsWksGraph.cxx:1457
MsWksGraph::send
void send(int id, MWAWPosition const &pos)
send a zone (textbox, ...).
Definition MsWksGraph.cxx:2829
MsWksGraph::readGroup
std::shared_ptr< MsWksGraphInternal::GroupZone > readGroup(MsWksGraphInternal::Zone &group)
try to read the group data
Definition MsWksGraph.cxx:2526
MsWksGraph::checkTextBoxLinks
void checkTextBoxLinks(MsWksGraphInternal::RBZone &rbZone)
check the text box link v4
Definition MsWksGraph.cxx:2228
MsWksGraph::sendTextBox
void sendTextBox(int zId, MWAWListenerPtr listener)
try to send a text box zone v1-3
Definition MsWksGraph.cxx:2761
MsWksGraph::version
int version() const
returns the file version
Definition MsWksGraph.cxx:1088
MsWksGraph::MsWksGraph
MsWksGraph(MsWksDocument &document)
constructor
Definition MsWksGraph.cxx:1068
MsWksGraph::flushExtra
void flushExtra()
sends the data which have not yet been sent to the listener
Definition MsWksGraph.cxx:3045
MsWksGraph::getEntryPictureV1
int getEntryPictureV1(int zoneId, MWAWEntry &zone, bool autoSend=true)
checks if the next zone is a v1 picture and returns a zone id ( or -1).
Definition MsWksGraph.cxx:2008
MsWksGraph::MsWksTable
friend class MsWksTable
Definition MsWksGraph.hxx:76
MsWksGraph::MsWksParser
friend class MsWksParser
Definition MsWksGraph.hxx:78
MsWksGraph::readFont
bool readFont(MWAWFont &font)
reads the textbox font
Definition MsWksGraph.cxx:2713
MsWksGraph::readRB
bool readRB(MWAWInputStreamPtr input, MWAWEntry const &entry, int kind)
reads the RBDR or a RBIL zone: a zone which seems to regroup all pages pictures in v3-v4 document
Definition MsWksGraph.cxx:2072
MsWksGraph::numPages
int numPages(int zoneId) const
returns the number of pages
Definition MsWksGraph.cxx:1095
MsWksGraph::canCreateGraphic
bool canCreateGraphic(MsWksGraphInternal::GroupZone const &group) const
returns true if we can create a graphic for the whole group
Definition MsWksGraph.cxx:2455
MsWksGraph::getZoneGraphicStyle
bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const
returns the graphic style of the zone defined by zoneId
Definition MsWksGraph.cxx:1130
MsWksGraph::MsWksSSParser
friend class MsWksSSParser
Definition MsWksGraph.hxx:82
MsWksGraph::sendChart
void sendChart(int zoneId)
try to send a chart
Definition MsWksGraph.cxx:1115
MsWksGraph::MsWksGraph
MsWksGraph(MsWksGraph const &orig)=delete
MsWksGraph::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition MsWksGraph.hxx:249
MsWksGraph::MsWks4Zone
friend class MsWks4Zone
Definition MsWksGraph.hxx:79
MsWksGraph::sendTable
void sendTable(int id)
try to a table zone
Definition MsWksGraph.cxx:1120
MsWksGraph::m_state
std::shared_ptr< MsWksGraphInternal::State > m_state
the state
Definition MsWksGraph.hxx:252
MsWksGraph::computePositions
void computePositions(int zoneId, std::vector< int > const &linesHeight, std::vector< int > const &pagesHeight)
try to update positions knowing pages and lines height
Definition MsWksGraph.cxx:1975
MsWksGraph::m_document
MsWksDocument & m_document
the main document
Definition MsWksGraph.hxx:257
MsWksGraph::readPictHeader
bool readPictHeader(MsWksGraphInternal::Zone &pict)
read the picture header
Definition MsWksGraph.cxx:1150
MsWksGraph::MsWksDBParser
friend class MsWksDBParser
Definition MsWksGraph.hxx:80
MsWksGraph::readPictureV4
bool readPictureV4(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads a Pict zone: a zone which seems to code in v4 : header/footer picture
Definition MsWksGraph.cxx:2285
MsWksGraph::readText
bool readText(MsWksGraphInternal::TextBox &textBox)
try to read a text zone
Definition MsWksGraph.cxx:2566
MsWksGraph::sendAll
void sendAll(int zoneId, bool mainZone)
send all the picture corresponding to a zone
Definition MsWksGraph.cxx:2954
MsWksGraph::sendFrameText
void sendFrameText(MWAWEntry const &entry, std::string const &frame)
ask m_mainParser to send a frame text(v4)
Definition MsWksGraph.cxx:1110
MsWksGraph::~MsWksGraph
virtual ~MsWksGraph()
destructor
Definition MsWksGraph.cxx:1079
MsWksGraph::operator=
MsWksGraph & operator=(MsWksGraph const &orig)=delete
MsWksGraph::getZonePosition
bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const
returns the position of the zone defined by zoneId
Definition MsWksGraph.cxx:1140
MsWksGraph::m_mainParser
MWAWParser * m_mainParser
the main parser;
Definition MsWksGraph.hxx:255
MsWksGraph::sendGroup
void sendGroup(int zoneId, MWAWPosition const &pos)
try to send a group
Definition MsWksGraph.cxx:2317
MsWksGraph::setPageLeftTop
void setPageLeftTop(MWAWVec2f const &leftTop)
define the page left top dimension in point
Definition MsWksGraph.cxx:1083
MsWksGraph::MsWksDocument
friend class MsWksDocument
Definition MsWksGraph.hxx:75
MsWksGraph::m_tableParser
std::shared_ptr< MsWksTable > m_tableParser
the table manager
Definition MsWksGraph.hxx:260
MsWksGraph::MsWksDRParser
friend class MsWksDRParser
Definition MsWksGraph.hxx:81
MsWksGraph::sendGroupChild
void sendGroupChild(int zoneId, MWAWPosition const &pos)
try to send a group elements by elemenys
Definition MsWksGraph.cxx:2354
MsWksParser
the main class to read a Microsoft Works file: v1-v4
Definition MsWksParser.hxx:60
MsWksSSParser
the main class to read a Microsoft Works spreadsheet file
Definition MsWksSSParser.hxx:66
MsWksTable
the main class to read the table ( or a chart ) of a Microsoft Works file
Definition MsWksTable.hxx:59
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition libmwaw_internal.hxx:838
MWAWGraphicListenerPtr
std::shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition libmwaw_internal.hxx:549
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition libmwaw_internal.hxx:553
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition libmwaw_internal.hxx:842
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MsWksGraphInternal
Internal: the structures of a MsWksGraph.
Definition MsWksGraph.cxx:64
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MsWksGraphInternal::GroupZone
Internal: the group of a MsWksGraph.
Definition MsWksGraph.cxx:315
MsWksGraphInternal::RBZone
Internal: a list of zones ( for v4).
Definition MsWksGraph.cxx:67
MsWksGraphInternal::State
Internal: the state of a MsWksGraph.
Definition MsWksGraph.cxx:825
MsWksGraphInternal::TextBox
Internal: the textbox of a MsWksGraph ( v2-v3).
Definition MsWksGraph.cxx:615
MsWksGraphInternal::Zone
Internal: the generic pict.
Definition MsWksGraph.cxx:92
MsWksGraph::SendData
small struct used which picture need to be send
Definition MsWksGraph.hxx:109
MsWksGraph::SendData::m_id
int m_id
the rbil id
Definition MsWksGraph.hxx:122
MsWksGraph::SendData::m_page
int m_page
the page ( used if anchor==page)
Definition MsWksGraph.hxx:126
MsWksGraph::SendData::m_size
MWAWVec2i m_size
the size of the data ( used by rbil )
Definition MsWksGraph.hxx:128
MsWksGraph::SendData::SendData
SendData()
constructor
Definition MsWksGraph.hxx:111
MsWksGraph::SendData::Type
Type
the type
Definition MsWksGraph.hxx:120
MsWksGraph::SendData::ALL
@ ALL
Definition MsWksGraph.hxx:120
MsWksGraph::SendData::RBDR
@ RBDR
Definition MsWksGraph.hxx:120
MsWksGraph::SendData::RBIL
@ RBIL
Definition MsWksGraph.hxx:120
MsWksGraph::SendData::m_type
enum MsWksGraph::SendData::Type m_type
MsWksGraph::SendData::m_anchor
MWAWPosition::AnchorTo m_anchor
the anchor
Definition MsWksGraph.hxx:124
MsWksGraph::Style
Internal: the graphic style of MsWksGraph.
Definition MsWksGraph.hxx:208
MsWksGraph::Style::~Style
~Style() final
destructor
Definition MsWksGraph.cxx:3059
MsWksGraph::Style::m_baseLineColor
MWAWColor m_baseLineColor
the line color
Definition MsWksGraph.hxx:235
MsWksGraph::Style::m_baseSurfaceColor
MWAWColor m_baseSurfaceColor
the 2D surface color
Definition MsWksGraph.hxx:237
MsWksGraph::Style::Style
Style()
constructor
Definition MsWksGraph.hxx:210
MsWksGraph::Style::operator=
Style & operator=(Style const &)=default
MsWksGraph::Style::operator=
Style & operator=(Style &&)=default
MsWksGraph::Style::Style
Style(Style const &)=default