Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libmwaw/src/lib/Canvas5Graph.hxx
Line
Count
Source
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 Canvas v5-v11 text document ( graphic part )
36
 *
37
 */
38
#ifndef CANVAS5_GRAPH
39
#  define CANVAS5_GRAPH
40
41
#include <string>
42
#include <utility>
43
#include <vector>
44
45
#include <librevenge/librevenge.h>
46
47
#include "libmwaw_internal.hxx"
48
49
#include "MWAWDebug.hxx"
50
#include "MWAWGraphicStyle.hxx"
51
#include "MWAWInputStream.hxx"
52
#include "MWAWPosition.hxx"
53
54
#include "Canvas5StyleManager.hxx"
55
56
class MWAWFont;
57
class MWAWParagraph;
58
59
namespace Canvas5Structure
60
{
61
struct Stream;
62
}
63
64
namespace Canvas5GraphInternal
65
{
66
struct Shape;
67
struct ShapeData;
68
struct State;
69
70
struct PseudoShape;
71
72
class SubDocument;
73
}
74
75
class Canvas5Image;
76
77
class Canvas5Parser;
78
79
/** \brief the main class to read the graphic part of Canvas v5-v11 file
80
 *
81
 *
82
 *
83
 */
84
class Canvas5Graph
85
{
86
  friend class Canvas5GraphInternal::SubDocument;
87
  friend class Canvas5Image;
88
  friend class Canvas5Parser;
89
90
public:
91
  //! constructor
92
  explicit Canvas5Graph(Canvas5Parser &parser);
93
  //! destructor
94
  virtual ~Canvas5Graph();
95
96
  /** returns the file version */
97
  int version() const;
98
99
  //! Internal: the local state of a Canvas5Graph
100
  struct LocalState {
101
    //! default constructor
102
    explicit LocalState(MWAWPosition const &pos=MWAWPosition(), MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
103
0
      : m_position(pos)
104
0
      , m_style(style)
105
0
      , m_transform()
106
0
    {
107
0
    }
108
    //! set the matrix transform
109
    void multiplyMatrix(std::array<double,9> const &mat);
110
    //! the shape position position
111
    MWAWPosition m_position;
112
    //! the shape style
113
    MWAWGraphicStyle m_style;
114
    //! the shape transformation
115
    MWAWTransformation m_transform;
116
  };
117
118
119
protected:
120
121
  // interface with main parser
122
123
  //! try to send a shape
124
  bool sendShape(int sId);
125
126
  //
127
  // Intermediate level
128
  //
129
130
  //! try to find the list of data's shape zones
131
  bool findShapeDataZones(std::shared_ptr<Canvas5Structure::Stream> stream);
132
  //! try to read a shape data
133
  bool readShapeData(int id, Canvas5GraphInternal::Shape const &shape);
134
  //! try to read a special shape data
135
  bool readSpecialData(std::shared_ptr<Canvas5Structure::Stream> stream, long len, Canvas5GraphInternal::ShapeData &data, std::string &extra);
136
  //! try to read a special shape data (internal helper to understand vkfl structure)
137
  std::shared_ptr<Canvas5GraphInternal::PseudoShape> readSpecialData(std::shared_ptr<Canvas5Structure::Stream> stream, long len, unsigned type, MWAWBox2f const &box, std::string &extra);
138
  //! try to read the different shapes
139
  bool readShapes(Canvas5Structure::Stream &stream, int numShapes);
140
141
  //! try to read the different matrix
142
  bool readMatrices(std::shared_ptr<Canvas5Structure::Stream> stream);
143
144
  //! try to read a complementary styles zone: DeR3
145
  bool readDeR3(std::shared_ptr<Canvas5Structure::Stream> stream, Canvas5StyleManager::StyleList &styles);
146
147
  //
148
  // send data to the listener
149
  //
150
151
  //! try to send a shape with a transformation
152
  bool sendShape(int sId, LocalState const &local);
153
  //! try to send a shape with a transformation
154
  bool send(Canvas5GraphInternal::Shape const &shape, LocalState const &local);
155
  //! try to send a special shape
156
  bool sendSpecial(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
157
                   LocalState const &local);
158
  //! try to send a special shape
159
  bool sendSpecial(MWAWListenerPtr listener, Canvas5GraphInternal::PseudoShape const &pseudoShape, LocalState const &local);
160
161
  //! try to send a text zone
162
  bool sendText(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data);
163
164
  //! try to send a curve's text zone: CvTe
165
  bool sendCurveText(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
166
                     LocalState const &local);
167
  //! tries to send the dimension line's special shape: DIMN
168
  bool sendDimension(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
169
                     LocalState const &local);
170
  //! tries to send the dimension line's special shape: DIMN: v9
171
  bool sendDimension9(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
172
                      LocalState const &local);
173
  //! tries to send the effect's special shape: effe
174
  bool sendEffect(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
175
                  LocalState const &local);
176
  //! tries to send the extrude's special shape: Extr (pretty basic)
177
  bool sendExtrude(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
178
                   LocalState const &local);
179
  //! tries to send the technical shape: Tech (v7)
180
  bool sendTechnical(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
181
                     LocalState const &local);
182
  //! tries to send the gif's shape: AnGf (v7)
183
  bool sendGIF(MWAWListenerPtr listener, Canvas5GraphInternal::Shape const &shape, Canvas5GraphInternal::ShapeData const &data,
184
               LocalState const &local);
185
186
  //
187
  // Low level
188
  //
189
190
  //! tries to send a basic shape ( applying a transformation if need)
191
  void send(MWAWListenerPtr listener, MWAWGraphicShape const &shape, MWAWTransformation const &transform,
192
            MWAWGraphicStyle const &style);
193
  //! tries to send a measure ( applying a transformation if need)
194
  void send(MWAWListenerPtr listener, librevenge::RVNGString const &text, MWAWVec2f const &center,
195
            MWAWTransformation const &transform, MWAWFont const &font, bool addFrame);
196
197
private:
198
  Canvas5Graph(Canvas5Graph const &orig) = delete;
199
  Canvas5Graph &operator=(Canvas5Graph const &orig) = delete;
200
201
protected:
202
  //
203
  // data
204
  //
205
  //! the parser state
206
  MWAWParserStatePtr m_parserState;
207
208
  //! the state
209
  std::shared_ptr<Canvas5GraphInternal::State> m_state;
210
211
  //! the main parser;
212
  Canvas5Parser *m_mainParser;
213
  //! the image parser
214
  std::shared_ptr<Canvas5Image> m_imageParser;
215
  //! the style manager
216
  std::shared_ptr<Canvas5StyleManager> m_styleManager;
217
};
218
#endif
219
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: