MsWksGraph.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 * Parser to Microsoft Works text document ( graphic part )
36 *
37 */
38#ifndef MS_WKS_MWAW_GRAPH
39# define MS_WKS_MWAW_GRAPH
40
41#include <list>
42#include <string>
43#include <vector>
44
45#include "MWAWPosition.hxx"
46
47#include "MWAWEntry.hxx"
48#include "MWAWGraphicStyle.hxx"
49#include "MWAWParser.hxx"
50
51namespace MsWksGraphInternal
52{
53struct GroupZone;
54struct RBZone;
55struct TextBox;
56struct Zone;
57
58struct State;
59
60class SubDocument;
61}
62
63class MsWksTable;
64class MsWksDocument;
65
66class MsWksParser;
67class MsWks4Zone;
68class MsWksDBParser;
69class MsWksDRParser;
70class MsWksSSParser;
71
74{
75 friend class MsWksDocument;
76 friend class MsWksTable;
77
78 friend class MsWksParser;
79 friend class MsWks4Zone;
80 friend class MsWksDBParser;
81 friend class MsWksDRParser;
82 friend class MsWksSSParser;
84public:
85 struct Style;
86
88 explicit MsWksGraph(MsWksDocument &document);
90 virtual ~MsWksGraph();
91
93 void setPageLeftTop(MWAWVec2f const &leftTop);
94
96 int version() const;
98 int numPages(int zoneId) const;
99
104 void send(int id, MWAWPosition const &pos);
106 void sendAll(int zoneId, bool mainZone);
107
109 struct SendData {
112 : m_type(RBDR)
113 , m_id(-1)
114 , m_anchor(MWAWPosition::Char)
115 , m_page(-1)
116 , m_size()
117 {
118 }
120 enum Type { RBDR, RBIL, ALL } m_type;
122 int m_id;
129 };
131 void sendObjects(SendData const &what);
132
134 void computePositions(int zoneId, std::vector<int> const &linesHeight, std::vector<int> const &pagesHeight);
135
136protected:
138 void flushExtra();
139
140 //
141 // Intermediate level
142 //
143
147 bool readGradient(Style &style);
149 int getEntryPictureV1(int zoneId, MWAWEntry &zone, bool autoSend=true);
150
152 int getEntryPicture(int zoneId, MWAWEntry &zone, bool autoSend=true, int order=-1000);
153
160 bool readRB(MWAWInputStreamPtr input, MWAWEntry const &entry, int kind);
161
162 // version 4 file
163
165 bool readPictureV4(MWAWInputStreamPtr input, MWAWEntry const &entry);
166
170 void sendTextBox(int zId, MWAWListenerPtr listener);
173
174 // interface function
175
177 bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const;
179 bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const;
180
182 void sendFrameText(MWAWEntry const &entry, std::string const &frame);
183
185 void sendTable(int id);
186
188 void sendChart(int zoneId);
189
190 //
191 // low level
192 //
194 std::shared_ptr<MsWksGraphInternal::GroupZone> readGroup(MsWksGraphInternal::Zone &group);
196 void sendGroup(int zoneId, MWAWPosition const &pos);
198 void sendGroupChild(int zoneId, MWAWPosition const &pos);
200 bool canCreateGraphic(MsWksGraphInternal::GroupZone const &group) const;
202 void sendGroup(MsWksGraphInternal::GroupZone const &group, MWAWGraphicListenerPtr &listener) const;
204 bool readFont(MWAWFont &font);
205
206public:
208 struct Style final : public MWAWGraphicStyle {
212 , m_baseLineColor(MWAWColor::black())
213 , m_baseSurfaceColor(MWAWColor::white())
214 {
216 }
217 Style(Style const &)=default;
218 Style &operator=(Style const &)=default;
219 Style &operator=(Style &&)=default;
221 ~Style() final;
223 friend std::ostream &operator<<(std::ostream &o, Style const &st)
224 {
225 o << static_cast<MWAWGraphicStyle const &>(st);
226 if (st.m_baseLineColor != st.m_lineColor)
227 o << "lineColor[base]=" << st.m_baseLineColor << ",";
228 if (st.m_baseSurfaceColor != st.m_surfaceColor)
229 o << "surfaceColor[base]=" << st.m_baseSurfaceColor << ",";
230
231 return o;
232 }
233
238 };
239
240private:
241 MsWksGraph(MsWksGraph const &orig) = delete;
242 MsWksGraph &operator=(MsWksGraph const &orig) = delete;
243
244protected:
245 //
246 // data
247 //
250
252 std::shared_ptr<MsWksGraphInternal::State> m_state;
253
258
260 std::shared_ptr<MsWksTable> m_tableParser;
261};
262#endif
263// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
Class to store font.
Definition: MWAWFont.hxx:44
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
bool m_fillRuleEvenOdd
true if the fill rule is evenod
Definition: MWAWGraphicStyle.hxx:646
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:100
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
AnchorTo
a list of enum used to defined the anchor
Definition: MWAWPosition.hxx:51
The class which parses the main zones of a mac MS Works document v4.
Definition: MsWks4Zone.hxx:74
the main class to read a Microsoft Works database file and convert it in a spreadsheet file
Definition: MsWksDBParser.hxx:66
the main class to read a Microsoft Works graphic file
Definition: MsWksDRParser.hxx:60
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:69
Internal: the subdocument of a MsWksGraph.
Definition: MsWksGraph.cxx:956
the main class to read the graphic of a Microsoft Works file
Definition: MsWksGraph.hxx:74
bool readGradient(Style &style)
read the gradient structure ( v4)
Definition: MsWksGraph.cxx:1356
void sendObjects(SendData const &what)
sends all the object of a page, frame, ...
Definition: MsWksGraph.cxx:2968
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
void send(int id, MWAWPosition const &pos)
send a zone (textbox, ...).
Definition: MsWksGraph.cxx:2829
std::shared_ptr< MsWksGraphInternal::GroupZone > readGroup(MsWksGraphInternal::Zone &group)
try to read the group data
Definition: MsWksGraph.cxx:2526
void checkTextBoxLinks(MsWksGraphInternal::RBZone &rbZone)
check the text box link v4
Definition: MsWksGraph.cxx:2228
void sendTextBox(int zId, MWAWListenerPtr listener)
try to send a text box zone v1-3
Definition: MsWksGraph.cxx:2761
int version() const
returns the file version
Definition: MsWksGraph.cxx:1088
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: MsWksGraph.cxx:3045
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
bool readFont(MWAWFont &font)
reads the textbox font
Definition: MsWksGraph.cxx:2713
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
int numPages(int zoneId) const
returns the number of pages
Definition: MsWksGraph.cxx:1095
bool canCreateGraphic(MsWksGraphInternal::GroupZone const &group) const
returns true if we can create a graphic for the whole group
Definition: MsWksGraph.cxx:2455
bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const
returns the graphic style of the zone defined by zoneId
Definition: MsWksGraph.cxx:1130
void sendChart(int zoneId)
try to send a chart
Definition: MsWksGraph.cxx:1115
MsWksGraph(MsWksGraph const &orig)=delete
MWAWParserStatePtr m_parserState
the parser state
Definition: MsWksGraph.hxx:249
void sendTable(int id)
try to a table zone
Definition: MsWksGraph.cxx:1120
std::shared_ptr< MsWksGraphInternal::State > m_state
the state
Definition: MsWksGraph.hxx:252
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
MsWksDocument & m_document
the main document
Definition: MsWksGraph.hxx:257
bool readPictHeader(MsWksGraphInternal::Zone &pict)
read the picture header
Definition: MsWksGraph.cxx:1150
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
bool readText(MsWksGraphInternal::TextBox &textBox)
try to read a text zone
Definition: MsWksGraph.cxx:2566
void sendAll(int zoneId, bool mainZone)
send all the picture corresponding to a zone
Definition: MsWksGraph.cxx:2954
void sendFrameText(MWAWEntry const &entry, std::string const &frame)
ask m_mainParser to send a frame text(v4)
Definition: MsWksGraph.cxx:1110
virtual ~MsWksGraph()
destructor
Definition: MsWksGraph.cxx:1079
MsWksGraph & operator=(MsWksGraph const &orig)=delete
bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const
returns the position of the zone defined by zoneId
Definition: MsWksGraph.cxx:1140
MWAWParser * m_mainParser
the main parser;
Definition: MsWksGraph.hxx:255
void sendGroup(int zoneId, MWAWPosition const &pos)
try to send a group
Definition: MsWksGraph.cxx:2317
void setPageLeftTop(MWAWVec2f const &leftTop)
define the page left top dimension in point
Definition: MsWksGraph.cxx:1083
std::shared_ptr< MsWksTable > m_tableParser
the table manager
Definition: MsWksGraph.hxx:260
void sendGroupChild(int zoneId, MWAWPosition const &pos)
try to send a group elements by elemenys
Definition: MsWksGraph.cxx:2354
the main class to read a Microsoft Works file: v1-v4
Definition: MsWksParser.hxx:60
the main class to read a Microsoft Works spreadsheet file
Definition: MsWksSSParser.hxx:66
the main class to read the table ( or a chart ) of a Microsoft Works file
Definition: MsWksTable.hxx:59
std::shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:549
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
Internal: the structures of a MsWksGraph.
Definition: MsWksGraph.cxx:64
the class to store a color
Definition: libmwaw_internal.hxx:192
Internal: the group of a MsWksGraph.
Definition: MsWksGraph.cxx:315
Internal: a list of zones ( for v4)
Definition: MsWksGraph.cxx:67
Internal: the textbox of a MsWksGraph ( v2-v3)
Definition: MsWksGraph.cxx:615
Internal: the generic pict.
Definition: MsWksGraph.cxx:92
small struct used which picture need to be send
Definition: MsWksGraph.hxx:109
int m_id
the rbil id
Definition: MsWksGraph.hxx:122
int m_page
the page ( used if anchor==page)
Definition: MsWksGraph.hxx:126
MWAWVec2i m_size
the size of the data ( used by rbil )
Definition: MsWksGraph.hxx:128
SendData()
constructor
Definition: MsWksGraph.hxx:111
Type
the type
Definition: MsWksGraph.hxx:120
@ ALL
Definition: MsWksGraph.hxx:120
@ RBDR
Definition: MsWksGraph.hxx:120
@ RBIL
Definition: MsWksGraph.hxx:120
enum MsWksGraph::SendData::Type m_type
MWAWPosition::AnchorTo m_anchor
the anchor
Definition: MsWksGraph.hxx:124
Internal: the graphic style of MsWksGraph.
Definition: MsWksGraph.hxx:208
~Style() final
destructor
Definition: MsWksGraph.cxx:3059
MWAWColor m_baseLineColor
the line color
Definition: MsWksGraph.hxx:235
MWAWColor m_baseSurfaceColor
the 2D surface color
Definition: MsWksGraph.hxx:237
Style()
constructor
Definition: MsWksGraph.hxx:210
Style & operator=(Style const &)=default
Style & operator=(Style &&)=default
Style(Style const &)=default

Generated on Wed May 3 2023 07:18:29 for libmwaw by doxygen 1.9.6