MSKGraph.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 MSK_MWAW_GRAPH
39 # define MSK_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 MSKGraphInternal
52 {
53 struct GroupZone;
54 struct TextBox;
55 struct Zone;
56 
57 struct State;
58 
59 class SubDocument;
60 }
61 
62 class MSKParser;
63 class MSK3Parser;
64 class MSK4Zone;
65 class MSKTable;
66 
68 class MSKGraph
69 {
70  friend class MSK3Parser;
71  friend class MSK4Zone;
72  friend class MSKTable;
74 public:
75  struct Style;
77  MSKGraph(MSKParser &parser);
79  virtual ~MSKGraph();
80 
82  int version() const;
83 
85  int numPages(int zoneId) const;
86 
91  void send(int id, MWAWPosition const &pos);
92 
94  void sendAll(int zoneId, bool mainZone);
95 
97  struct SendData {
99  SendData() : m_type(RBDR), m_id(-1), m_anchor(MWAWPosition::Char), m_page(-1), m_size() {
100  }
102  enum Type { RBDR, RBIL, ALL } m_type;
104  int m_id;
108  int m_page;
111  };
113  void sendObjects(SendData const &what);
114 
116  void computePositions(int zoneId, std::vector<int> &linesHeight, std::vector<int> &pagesHeight);
117 
118 protected:
120  void flushExtra();
121 
122  //
123  // Intermediate level
124  //
125 
129  bool readGradient(Style &style);
131  int getEntryPictureV1(int zoneId, MWAWEntry &zone, bool autoSend=true);
132 
134  int getEntryPicture(int zoneId, MWAWEntry &zone, bool autoSend=true, int order=-1000);
135 
136  // version 4 file
137 
139  bool readRB(MWAWInputStreamPtr input, MWAWEntry const &entry);
140 
141 
143  bool readPictureV4(MWAWInputStreamPtr input, MWAWEntry const &entry);
144 
146  bool readText(MSKGraphInternal::TextBox &textBox);
148  void sendTextBox(int zId);
150  void checkTextBoxLinks(int zId);
151 
152  // interface function
153 
155  bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const;
157  bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const;
158 
160  void sendFrameText(MWAWEntry const &entry, std::string const &frame);
161 
163  void sendTable(int id);
164 
166  void sendChart(int zoneId);
167 
168  //
169  // low level
170  //
172  shared_ptr<MSKGraphInternal::GroupZone> readGroup(MSKGraphInternal::Zone &group);
174  void sendGroup(int zoneId, MWAWPosition const &pos);
176  void sendGroupChild(int zoneId, MWAWPosition const &pos);
178  bool canCreateGraphic(MSKGraphInternal::GroupZone const &group) const;
180  void sendGroup(MSKGraphInternal::GroupZone const &group, MWAWGraphicListenerPtr &listener) const;
182  bool readFont(MWAWFont &font);
183 
184 public:
186  struct Style : public MWAWGraphicStyle {
189  m_fillRuleEvenOdd=true;
190  }
192  friend std::ostream &operator<<(std::ostream &o, Style const &st) {
193  o << static_cast<MWAWGraphicStyle const &>(st);
194  if (st.m_baseLineColor != st.m_lineColor)
195  o << "lineColor[base]=" << st.m_baseLineColor << ",";
196  if (st.m_baseSurfaceColor != st.m_surfaceColor)
197  o << "surfaceColor[base]=" << st.m_baseSurfaceColor << ",";
198 
199  return o;
200  }
201 
206  };
207 
208 private:
209  MSKGraph(MSKGraph const &orig);
210  MSKGraph &operator=(MSKGraph const &orig);
211 
212 protected:
213  //
214  // data
215  //
218 
220  shared_ptr<MSKGraphInternal::State> m_state;
221 
224 
226  shared_ptr<MSKTable> m_tableParser;
227 };
228 #endif
229 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Definition: MSKGraph.hxx:102
MWAWColor m_surfaceColor
the surface color
Definition: MWAWGraphicStyle.hxx:254
bool readRB(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads the RBDR or a RBIL zone: a zone which seems to regroup all pages pictures
Definition: MSKGraph.cxx:1891
MWAWColor m_baseSurfaceColor
the 2D surface color
Definition: MSKGraph.hxx:205
Definition: MSKGraph.hxx:102
Definition: MSKGraph.hxx:102
virtual ~MSKGraph()
destructor
Definition: MSKGraph.cxx:909
bool readGradient(Style &style)
read the gradient structure ( v4)
Definition: MSKGraph.cxx:1172
Internal: the generic pict.
Definition: MSKGraph.cxx:84
the main class to read the graphic of a Microsoft Works file
Definition: MSKGraph.hxx:68
void sendTable(int id)
try to a table zone
Definition: MSKGraph.cxx:946
bool getZoneGraphicStyle(int zoneId, MWAWGraphicStyle &style) const
returns the graphic style of the zone defined by zoneId
Definition: MSKGraph.cxx:956
MWAWColor m_lineColor
the line color
Definition: MWAWGraphicStyle.hxx:250
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
shared_ptr< MSKTable > m_tableParser
the table manager
Definition: MSKGraph.hxx:226
void sendGroupChild(int zoneId, MWAWPosition const &pos)
try to send a group elements by elemenys
Definition: MSKGraph.cxx:2140
MWAWPosition::AnchorTo m_anchor
the anchor
Definition: MSKGraph.hxx:106
Internal: the subdocument of a MSKGraph.
Definition: MSKGraph.cxx:784
void checkTextBoxLinks(int zId)
check the text box link v4
Definition: MSKGraph.cxx:2002
SendData()
constructor
Definition: MSKGraph.hxx:99
the class to store a color
Definition: libmwaw_internal.hxx:166
small struct used which picture need to be send
Definition: MSKGraph.hxx:97
Internal: the graphic style of MSKGraph.
Definition: MSKGraph.hxx:186
bool readText(MSKGraphInternal::TextBox &textBox)
try to read a text zone
Definition: MSKGraph.cxx:2341
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: MSKGraph.cxx:2809
bool getZonePosition(int zoneId, MWAWPosition::AnchorTo anchor, MWAWPosition &pos) const
returns the position of the zone defined by zoneId
Definition: MSKGraph.cxx:966
Type
the type
Definition: MSKGraph.hxx:102
Style()
constructor
Definition: MSKGraph.hxx:188
void send(int id, MWAWPosition const &pos)
send a zone (textbox, ...).
Definition: MSKGraph.cxx:2604
AnchorTo
a list of enum used to defined the anchor
Definition: MWAWPosition.hxx:51
generic parser for Microsoft Works file
Definition: MSKParser.hxx:58
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: MSKGraph.cxx:1826
int m_page
the page ( used if anchor==page)
Definition: MSKGraph.hxx:108
MSKGraph(MSKParser &parser)
constructor
Definition: MSKGraph.cxx:902
the main class to read a Microsoft Works file
Definition: MSK3Parser.hxx:62
the main class to read the table ( or a chart ) of a Microsoft Works file
Definition: MSKTable.hxx:58
MSKGraph & operator=(MSKGraph const &orig)
void sendObjects(SendData const &what)
sends all the object of a page, frame, ...
Definition: MSKGraph.cxx:2735
void sendChart(int zoneId)
try to send a chart
Definition: MSKGraph.cxx:941
bool m_fillRuleEvenOdd
true if the fill rule is evenod
Definition: MWAWGraphicStyle.hxx:252
The class which parses the main zones of a mac MS Works document v4.
Definition: MSK4Zone.hxx:76
int version() const
returns the file version
Definition: MSKGraph.cxx:912
Internal: the textbox of a MSKGraph ( v2-v3)
Definition: MSKGraph.cxx:502
shared_ptr< MSKGraphInternal::State > m_state
the state
Definition: MSKGraph.hxx:220
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:346
int m_id
the rbil id
Definition: MSKGraph.hxx:104
bool readFont(MWAWFont &font)
reads the textbox font
Definition: MSKGraph.cxx:2488
bool readPictHeader(MSKGraphInternal::Zone &pict)
read the picture header
Definition: MSKGraph.cxx:976
void sendAll(int zoneId, bool mainZone)
send all the picture corresponding to a zone
Definition: MSKGraph.cxx:2721
int numPages(int zoneId) const
returns the number of pages
Definition: MSKGraph.cxx:919
bool readPictureV4(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads a Pict zone: a zone which seems to code in v4 : header/footer picture
Definition: MSKGraph.cxx:2066
friend std::ostream & operator<<(std::ostream &o, Style const &st)
operator&lt;&lt;
Definition: MSKGraph.hxx:192
bool canCreateGraphic(MSKGraphInternal::GroupZone const &group) const
returns true if we can create a graphic for the whole group
Definition: MSKGraph.cxx:2234
void sendFrameText(MWAWEntry const &entry, std::string const &frame)
ask m_mainParser to send a frame text(v4)
Definition: MSKGraph.cxx:936
MWAWParserStatePtr m_parserState
the parser state
Definition: MSKGraph.hxx:217
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:356
void computePositions(int zoneId, std::vector< int > &linesHeight, std::vector< int > &pagesHeight)
try to update positions knowing pages and lines height
Definition: MSKGraph.cxx:1793
MWAWColor m_baseLineColor
the line color
Definition: MSKGraph.hxx:203
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
enum MSKGraph::SendData::Type m_type
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: MSKGraph.cxx:1271
shared_ptr< MSKGraphInternal::GroupZone > readGroup(MSKGraphInternal::Zone &group)
try to read the group data
Definition: MSKGraph.cxx:2300
void sendTextBox(int zId)
try to send a text box zone v1-3
Definition: MSKGraph.cxx:2536
MSKParser * m_mainParser
the main parser;
Definition: MSKGraph.hxx:223
Internal: the group of a MSKGraph.
Definition: MSKGraph.cxx:282
void sendGroup(int zoneId, MWAWPosition const &pos)
try to send a group
Definition: MSKGraph.cxx:2098
Vec2i m_size
the size of the data ( used by rbil )
Definition: MSKGraph.hxx:110

Generated on Tue Mar 10 2015 17:32:08 for libmwaw by doxygen 1.8.5