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:

Generated on Thu Apr 24 2014 14:47:42 for libmwaw by doxygen 1.8.3.1