Coverage Report

Created: 2026-07-20 07:04

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