MsWksGraph.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
51 namespace MsWksGraphInternal
52 {
53 struct GroupZone;
54 struct RBZone;
55 struct TextBox;
56 struct Zone;
57
58 struct State;
59
60 class SubDocument;
61 }
62
63 class MsWksTable;
64 class MsWksDocument;
65
66 class MsWksParser;
67 class MsWks4Zone;
68 class MsWksDBParser;
69 class MsWksDRParser;
70 class MsWksSSParser;
71
73 class MsWksGraph
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;
83 friend class MsWksGraphInternal::SubDocument;
84 public:
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 {
111 SendData() : m_type(RBDR), m_id(-1), m_anchor(MWAWPosition::Char), m_page(-1), m_size()
112 {
113 }
115 enum Type { RBDR, RBIL, ALL } m_type;
117 int m_id;
119 MWAWPosition::AnchorTo m_anchor;
121 int m_page;
123 MWAWVec2i m_size;
124 };
126 void sendObjects(SendData const &what);
127
129 void computePositions(int zoneId, std::vector<int> &linesHeight, std::vector<int> &pagesHeight);
130
131 protected:
133 void flushExtra();
134
135 //
136 // Intermediate level
137 //
138
140 bool readPictHeader(MsWksGraphInternal::Zone &pict);
142 bool readGradient(Style &style);
144 int getEntryPictureV1(int zoneId, MWAWEntry &zone, bool autoSend=true);
145
147 int getEntryPicture(int zoneId, MWAWEntry &zone, bool autoSend=true, int order=-1000);
148
155 bool readRB(MWAWInputStreamPtr input, MWAWEntry const &entry, int kind);
156
157 // version 4 file
158
160 bool readPictureV4(MWAWInputStreamPtr input, MWAWEntry const &entry);
161
163 bool readText(MsWksGraphInternal::TextBox &textBox);
165 void sendTextBox(int zId, MWAWListenerPtr listener);
167 void checkTextBoxLinks(MsWksGraphInternal::RBZone &rbZone);
168
169 // interface function
170
172 bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const;
174 bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const;
175
177 void sendFrameText(MWAWEntry const &entry, std::string const &frame);
178
180 void sendTable(int id);
181
183 void sendChart(int zoneId);
184
185 //
186 // low level
187 //
189 shared_ptr<MsWksGraphInternal::GroupZone> readGroup(MsWksGraphInternal::Zone &group);
191 void sendGroup(int zoneId, MWAWPosition const &pos);
193 void sendGroupChild(int zoneId, MWAWPosition const &pos);
195 bool canCreateGraphic(MsWksGraphInternal::GroupZone const &group) const;
197 void sendGroup(MsWksGraphInternal::GroupZone const &group, MWAWGraphicListenerPtr &listener) const;
199 bool readFont(MWAWFont &font);
200
201 public:
203 struct Style : public MWAWGraphicStyle {
205 Style() : MWAWGraphicStyle(), m_baseLineColor(MWAWColor::black()), m_baseSurfaceColor(MWAWColor::white())
206 {
207 m_fillRuleEvenOdd=true;
208 }
210 virtual ~Style();
212 friend std::ostream &operator<<(std::ostream &o, Style const &st)
213 {
214 o << static_cast<MWAWGraphicStyle const &>(st);
215 if (st.m_baseLineColor != st.m_lineColor)
216 o << "lineColor[base]=" << st.m_baseLineColor << ",";
217 if (st.m_baseSurfaceColor != st.m_surfaceColor)
218 o << "surfaceColor[base]=" << st.m_baseSurfaceColor << ",";
219
220 return o;
221 }
222
224 MWAWColor m_baseLineColor;
226 MWAWColor m_baseSurfaceColor;
227 };
228
229 private:
230 MsWksGraph(MsWksGraph const &orig);
231 MsWksGraph &operator=(MsWksGraph const &orig);
232
233 protected:
234 //
235 // data
236 //
238 MWAWParserStatePtr m_parserState;
239
241 shared_ptr<MsWksGraphInternal::State> m_state;
242
244 MWAWParser *m_mainParser;
246 MsWksDocument &m_document;
247
249 shared_ptr<MsWksTable> m_tableParser;
250 };
251 #endif
252 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWListenerPtr
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:502
MsWksGraph::m_document
MsWksDocument & m_document
the main document
Definition: MsWksGraph.hxx:246
MsWksDBParser
the main class to read a Microsoft Works database file and convert it in a spreadsheet file ...
Definition: MsWksDBParser.hxx:65
MsWksGraph::SendData::m_anchor
MWAWPosition::AnchorTo m_anchor
the anchor
Definition: MsWksGraph.hxx:119
MsWksGraph::SendData::m_page
int m_page
the page ( used if anchor==page)
Definition: MsWksGraph.hxx:121
MWAWGraphicStyle::m_surfaceColor
MWAWColor m_surfaceColor
the surface color
Definition: MWAWGraphicStyle.hxx:385
MsWksGraph::Style::Style
Style()
constructor
Definition: MsWksGraph.hxx:205
MsWksGraph::SendData::m_id
int m_id
the rbil id
Definition: MsWksGraph.hxx:117
MWAWParser.hxx
MsWksParser
the main class to read a Microsoft Works file: v1-v4
Definition: MsWksParser.hxx:59
MWAWEntry.hxx
MsWksGraph::Style::operator<<
friend std::ostream & operator<<(std::ostream &o, Style const &st)
operator<<
Definition: MsWksGraph.hxx:212
MWAWGraphicStyle::m_lineColor
MWAWColor m_lineColor
the line color
Definition: MWAWGraphicStyle.hxx:383
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MsWksGraphInternal::RBZone
Internal: a list of zones ( for v4)
Definition: MsWksGraph.cxx:67
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:182
MsWksGraph::m_tableParser
shared_ptr< MsWksTable > m_tableParser
the table manager
Definition: MsWksGraph.hxx:249
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MsWksGraphInternal::SubDocument
Internal: the subdocument of a MsWksGraph.
Definition: MsWksGraph.cxx:859
MsWksTable
the main class to read the table ( or a chart ) of a Microsoft Works file
Definition: MsWksTable.hxx:58
MsWksGraph::SendData::Type
Type
the type
Definition: MsWksGraph.hxx:115
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:73
MsWksGraphInternal::TextBox
Internal: the textbox of a MsWksGraph ( v2-v3)
Definition: MsWksGraph.cxx:547
MsWksGraphInternal
Internal: the structures of a MsWksGraph.
Definition: MsWksGraph.cxx:63
MsWksGraph::Style::m_baseSurfaceColor
MWAWColor m_baseSurfaceColor
the 2D surface color
Definition: MsWksGraph.hxx:226
MsWksGraph::SendData::SendData
SendData()
constructor
Definition: MsWksGraph.hxx:111
MsWksDRParser
the main class to read a Microsoft Works graphic file
Definition: MsWksDRParser.hxx:59
MsWksGraph::SendData::m_size
MWAWVec2i m_size
the size of the data ( used by rbil )
Definition: MsWksGraph.hxx:123
MsWksGraph::Style::m_baseLineColor
MWAWColor m_baseLineColor
the line color
Definition: MsWksGraph.hxx:224
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:500
MsWksGraph
the main class to read the graphic of a Microsoft Works file
Definition: MsWksGraph.hxx:73
MsWksSSParser
the main class to read a Microsoft Works spreadsheet file
Definition: MsWksSSParser.hxx:65
MWAWGraphicListenerPtr
shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:498
MsWksGraph::Style
Internal: the graphic style of MsWksGraph.
Definition: MsWksGraph.hxx:203
MsWksGraph::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MsWksGraph.hxx:238
MWAWPosition.hxx
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:506
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:97
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MsWksGraphInternal::Zone
Internal: the generic pict.
Definition: MsWksGraph.cxx:86
MsWksGraph::m_mainParser
MWAWParser * m_mainParser
the main parser;
Definition: MsWksGraph.hxx:244
MsWksGraph::SendData
small struct used which picture need to be send
Definition: MsWksGraph.hxx:109
MsWksGraph::m_state
shared_ptr< MsWksGraphInternal::State > m_state
the state
Definition: MsWksGraph.hxx:241
MsWksGraphInternal::GroupZone
Internal: the group of a MsWksGraph.
Definition: MsWksGraph.cxx:292
MWAWGraphicStyle.hxx
MWAWVec2< float >
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:68