Coverage Report

Created: 2026-09-06 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/QuattroGraph.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* libwps
3
 * Version: MPL 2.0 / LGPLv2.1+
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * Major Contributor(s):
10
 * Copyright (C) 2006, 2007 Andrew Ziem
11
 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
12
 * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
13
 *
14
 * For minor contributions see the git repository.
15
 *
16
 * Alternatively, the contents of this file may be used under the terms
17
 * of the GNU Lesser General Public License Version 2.1 or later
18
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19
 * applicable instead of those above.
20
 */
21
22
#ifndef QUATTRO_GRAPH_H
23
#define QUATTRO_GRAPH_H
24
25
#include <ostream>
26
#include <map>
27
#include <vector>
28
29
#include <librevenge-stream/librevenge-stream.h>
30
31
#include "libwps_internal.h"
32
33
#include "WPSDebug.h"
34
#include "WKSContentListener.h"
35
36
namespace QuattroGraphInternal
37
{
38
struct Dialog;
39
struct Graph;
40
struct ShapeHeader;
41
struct Textbox;
42
43
struct State;
44
45
class SubDocument;
46
}
47
48
class QuattroParser;
49
class QuattroStyleManager;
50
51
/**
52
 * This class parses QuattroPro graph file
53
 *
54
 */
55
class QuattroGraph
56
{
57
public:
58
  friend class QuattroParser;
59
  friend class QuattroGraphInternal::SubDocument;
60
61
  //! constructor
62
  explicit QuattroGraph(QuattroParser &parser);
63
  //! destructor
64
  ~QuattroGraph();
65
  //! sets the listener
66
  void setListener(WKSContentListenerPtr &listen)
67
24.1k
  {
68
24.1k
    m_listener = listen;
69
24.1k
  }
70
  //! clean internal state
71
  void cleanState();
72
  //! update the state (need to be called before sending data)
73
  void updateState();
74
75
protected:
76
  //! return the file version
77
  int version() const;
78
79
  //! stores the OLE objets
80
  void storeObjects(std::map<librevenge::RVNGString, WPSEmbeddedObject> const &nameToObjectMap);
81
  //! return the list of cells containing some graphics in a sheet
82
  std::vector<Vec2i> getGraphicCellsInSheet(int sheetId) const;
83
  //! send the graphic corresponding to a cell
84
  bool sendGraphics(int sheetId, Vec2i const &cell) const;
85
  //! send the page graphic corresponding to a sheet
86
  bool sendPageGraphics(int sheetId) const;
87
88
  //! send a graphic
89
  bool sendGraphic(QuattroGraphInternal::Graph const &graph) const;
90
  //! send a shape
91
  bool sendShape(QuattroGraphInternal::Graph const &graph, int sheetId) const;
92
  //! send a textbox
93
  bool sendTextbox(QuattroGraphInternal::Graph const &graph, int sheetId) const;
94
  //! send the textbox content
95
  bool send(QuattroGraphInternal::Textbox const &textbox,
96
            std::shared_ptr<WPSStream> stream) const;
97
  //
98
  // low level
99
  //
100
101
  // ////////////////////// zone //////////////////////////////
102
103
  //! read the begin/end graph zone: 321/322
104
  bool readBeginEnd(std::shared_ptr<WPSStream> stream, int sheetId);
105
  //! read a new OLE frame zone: zone 381(wb2)
106
  bool readFrameOLE(std::shared_ptr<WPSStream> stream);
107
  //! read a image zone: zone 382(wb2)
108
  bool readImage(std::shared_ptr<WPSStream> stream);
109
  //! read a bitmap zone: zone 383(wb2)
110
  bool readBitmap(std::shared_ptr<WPSStream> stream);
111
  //! read a chart zone: zone 384
112
  bool readChart(std::shared_ptr<WPSStream> stream);
113
  //! read an frame: zone 385
114
  bool readFrame(std::shared_ptr<WPSStream> stream);
115
  //! read a button: zone 386
116
  bool readButton(std::shared_ptr<WPSStream> stream);
117
  //! read a OLE data: zone 38b
118
  bool readOLEData(std::shared_ptr<WPSStream> stream);
119
  //! try to read a graph header
120
  static bool readHeader(QuattroGraphInternal::Graph &header, std::shared_ptr<WPSStream> stream, long endPos);
121
122
  // ////////////////////// shape //////////////////////////////
123
124
  //! read a shape header: zone 4d3
125
  bool readShape(std::shared_ptr<WPSStream> stream);
126
  /** read a shape header
127
   \note the serie header is pretty similar */
128
  bool readShapeHeader(QuattroGraphInternal::ShapeHeader &shape, std::shared_ptr<WPSStream> stream,  long endPos);
129
  //! read a line/arrow data: zone 35a/37b
130
  bool readLine(std::shared_ptr<WPSStream> stream);
131
  //! read a oval/rect/round rect data: zone 33e/364/379
132
  bool readRect(std::shared_ptr<WPSStream> stream);
133
  //! read a polygon/polyline data: zone 35c/37c/35b/388
134
  bool readPolygon(std::shared_ptr<WPSStream> stream);
135
  //! read a textbox data: zone 36f
136
  bool readTextBox(std::shared_ptr<WPSStream> stream);
137
138
  // ////////////////////// dialog zone //////////////////////////////
139
140
  //! try to read a dialog header
141
  static bool readHeader(QuattroGraphInternal::Dialog &header, std::shared_ptr<WPSStream> stream, long endPos);
142
  //! read a dialog zone: 35e
143
  bool readDialog(std::shared_ptr<WPSStream> stream);
144
  //! read a unknown dialog zone: 335,343,345
145
  static bool readDialogUnknown(std::shared_ptr<WPSStream> stream);
146
147
  // ////////////////////// style //////////////////////////////
148
  bool readFillData(WPSGraphicStyle &style, int fillType, std::shared_ptr<WPSStream> stream, long endPos);
149
private:
150
  QuattroGraph(QuattroGraph const &orig) = delete;
151
  QuattroGraph &operator=(QuattroGraph const &orig) = delete;
152
  std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
153
  //! the main parser
154
  QuattroParser &m_mainParser;
155
  //! the internal state
156
  std::shared_ptr<QuattroGraphInternal::State> m_state;
157
};
158
159
#endif /* QUATTRO_GRAPH_H */
160
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */