Coverage Report

Created: 2026-09-14 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/Quattro9Graph.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 QUATTRO9_GRAPH_H
23
#define QUATTRO9_GRAPH_H
24
25
#include <ostream>
26
#include <map>
27
#include <set>
28
#include <vector>
29
30
#include <librevenge-stream/librevenge-stream.h>
31
32
#include "libwps_internal.h"
33
34
#include "WPSDebug.h"
35
#include "WKSContentListener.h"
36
#include "WPSGraphicStyle.h"
37
38
namespace Quattro9GraphInternal
39
{
40
struct Graph;
41
struct Shape;
42
struct State;
43
44
class SubDocument;
45
}
46
47
class Quattro9Parser;
48
49
/**
50
 * This class parses Quattro9Pro graph file
51
 *
52
 */
53
class Quattro9Graph
54
{
55
public:
56
  friend class Quattro9Parser;
57
  friend class Quattro9GraphInternal::SubDocument;
58
59
  //! constructor
60
  explicit Quattro9Graph(Quattro9Parser &parser);
61
  //! destructor
62
  ~Quattro9Graph();
63
  //! sets the listener
64
  void setListener(WKSContentListenerPtr &listen)
65
7.70k
  {
66
7.70k
    m_listener = listen;
67
7.70k
  }
68
  //! clean internal state
69
  void cleanState();
70
  //! update the state (need to be called before sending data)
71
  void updateState();
72
73
  //! returns the color corresponding to an id
74
  bool getColor(int id, WPSColor &color) const;
75
  //! returns the pattern corresponding to a pattern id between 0 and 24
76
  bool getPattern(int id, WPSGraphicStyle::Pattern &pattern) const;
77
protected:
78
  //! return the file version
79
  int version() const;
80
  //! return the file sub version
81
  int subversion() const;
82
  //! stores the OLE objets
83
  void storeObjects(std::map<librevenge::RVNGString, WPSEmbeddedObject> const &nameToObjectMap);
84
85
  //! return the list of sheet which contains a graph
86
  std::set<int> getListSheets() const;
87
  //! send the page graphic corresponding to a sheet
88
  bool sendPageGraphics(int sheetId) const;
89
  //! send a shape
90
  bool sendShape(Quattro9GraphInternal::Graph const &graph, int sheetId) const;
91
  //! send a shape (recursif)
92
  bool sendShape(Quattro9GraphInternal::Shape const &shape, WPSTransformation const &transf) const;
93
  //! send a shape
94
  bool sendShape(WPSGraphicShape const &shape, WPSGraphicStyle const &style, WPSTransformation const &transf) const;
95
  //! send a OLE
96
  bool sendOLE(Quattro9GraphInternal::Graph const &graph, int sheetId) const;
97
  //! send a textbox
98
  bool sendTextbox(Quattro9GraphInternal::Graph const &graph, int sheetId) const;
99
100
  //
101
  // low level
102
  //
103
104
  //! read the begin/end graph zone: 1401/1402
105
  bool readBeginEnd(std::shared_ptr<WPSStream> stream, int sheetId);
106
  //! try to read a begin/end  zone: 2051
107
  bool readBeginEndZone(std::shared_ptr<WPSStream> const &stream);
108
  //! try to read a graph header zone: 2051
109
  bool readGraphHeader(std::shared_ptr<WPSStream> const &stream);
110
  //! try to read a frame style zone: 2131
111
  static bool readFrameStyle(std::shared_ptr<WPSStream> const &stream);
112
  //! try to read a frame style zone: 2141
113
  static bool readFramePattern(std::shared_ptr<WPSStream> const &stream);
114
  //! try to read a frame header zone: 2171
115
  static bool readFrameHeader(std::shared_ptr<WPSStream> const &stream);
116
  //! try to read the OLE name zone: 21d1
117
  bool readOLEName(std::shared_ptr<WPSStream> const &stream);
118
  //! try to read a shape zone: 2221, 23d1
119
  bool readShape(std::shared_ptr<WPSStream> const &stream);
120
  //! try to read a shape sub zone: 2221, 23d1
121
  bool readShapeRec(std::shared_ptr<WPSStream> const &stream, long endPos, Quattro9GraphInternal::Shape &shape, WPSGraphicStyle const &actStyle);
122
123
  //! try to read a textbox style zone: 2371
124
  bool readTextboxStyle(std::shared_ptr<WPSStream> const &stream);
125
  //! try to read a textbox text zone: 2372
126
  bool readTextboxText(std::shared_ptr<WPSStream> const &stream);
127
128
private:
129
  Quattro9Graph(Quattro9Graph const &orig) = delete;
130
  Quattro9Graph &operator=(Quattro9Graph const &orig) = delete;
131
  std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
132
  //! the main parser
133
  Quattro9Parser &m_mainParser;
134
  //! the internal state
135
  std::shared_ptr<Quattro9GraphInternal::State> m_state;
136
};
137
138
#endif /* QUATTRO9_GRAPH_H */
139
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */