Coverage Report

Created: 2026-06-13 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libpagemaker/src/lib/OutputShape.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/*
3
 * This file is part of the libpagemaker project.
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
10
#ifndef __LIBPAGEMAKER_OUTPUTSHAPE_H__
11
#define __LIBPAGEMAKER_OUTPUTSHAPE_H__
12
13
#include <memory>
14
#include <string>
15
#include <utility>
16
#include <vector>
17
18
#include "PMDExceptions.h"
19
#include "PMDTypes.h"
20
#include "geometry.h"
21
#include "libpagemaker_utils.h"
22
23
namespace libpagemaker
24
{
25
26
class OutputShape
27
{
28
  bool m_isClosed;
29
  uint8_t m_shapeType;
30
  std::vector<InchPoint> m_points;
31
  double m_rotation;
32
  double m_skew;
33
  double m_bboxLeft, m_bboxTop, m_bboxRight, m_bboxBot;
34
  PMDFillProperties m_fillProps;
35
  PMDStrokeProperties m_strokeProps;
36
  std::string m_text;
37
  std::vector<PMDCharProperties> m_charProps;
38
  std::vector<PMDParaProperties> m_paraProps;
39
  librevenge::RVNGBinaryData m_bitmap;
40
  double m_width,m_height;
41
42
public:
43
  OutputShape(bool isClosed, int shape, double rotation, double skew, const PMDFillProperties &fillProps, const PMDStrokeProperties &strokeProps)
44
0
    : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
45
0
      m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(), m_fillProps(fillProps), m_strokeProps(strokeProps), m_text(), m_charProps(),  m_paraProps(), m_bitmap(), m_width(), m_height()
46
0
  { }
47
48
  OutputShape(bool isClosed, int shape, double rotation, double skew, std::string text, std::vector<PMDCharProperties> charProps, std::vector<PMDParaProperties> paraProps)
49
0
    : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
50
      m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(),
51
0
      m_fillProps(),
52
0
      m_strokeProps(),
53
0
      m_text(text), m_charProps(charProps), m_paraProps(paraProps), m_bitmap(), m_width(), m_height()
54
0
  { }
55
56
  OutputShape(bool isClosed, int shape, double rotation, double skew, librevenge::RVNGBinaryData bitmap)
57
0
    : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
58
      m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(),
59
0
      m_fillProps(),
60
0
      m_strokeProps(),
61
0
      m_text(), m_charProps(), m_paraProps(), m_bitmap(bitmap), m_width(), m_height()
62
0
  { }
63
64
  unsigned numPoints() const
65
0
  {
66
0
    return m_points.size();
67
0
  }
68
69
  InchPoint getPoint(unsigned i) const
70
0
  {
71
0
    return (m_points.size() > i) ? m_points[i] : InchPoint(0, 0);
72
0
  }
73
74
  bool getIsClosed() const
75
0
  {
76
0
    return m_isClosed;
77
0
  }
78
79
  uint8_t shapeType() const
80
0
  {
81
0
    return m_shapeType;
82
0
  }
83
84
  const PMDFillProperties &getFillProperties() const
85
0
  {
86
0
    return m_fillProps;
87
0
  }
88
89
  const PMDStrokeProperties &getStrokeProperties() const
90
0
  {
91
0
    return m_strokeProps;
92
0
  }
93
94
  double getRotation() const
95
0
  {
96
0
    return m_rotation;
97
0
  }
98
99
  double getSkew() const
100
0
  {
101
0
    return m_skew;
102
0
  }
103
104
  std::string getText() const
105
0
  {
106
0
    return m_text;
107
0
  }
108
109
  std::vector<PMDCharProperties> getCharProperties() const
110
0
  {
111
0
    return m_charProps;
112
0
  }
113
114
  std::vector<PMDParaProperties> getParaProperties() const
115
0
  {
116
0
    return m_paraProps;
117
0
  }
118
119
  librevenge::RVNGBinaryData getBitmap() const
120
0
  {
121
0
    return m_bitmap;
122
0
  }
123
124
  std::pair<InchPoint, InchPoint> getBoundingBox() const
125
0
  {
126
0
    if (m_points.empty() && m_bitmap.empty())
127
0
    {
128
0
      throw EmptyLineSetException();
129
0
    }
130
0
    return std::make_pair(InchPoint(m_bboxLeft, m_bboxTop), InchPoint(m_bboxRight, m_bboxBot));
131
0
  }
132
133
  void setBoundingBox(InchPoint bboxTopLeft, InchPoint bboxBotRight)
134
0
  {
135
0
    m_bboxLeft = bboxTopLeft.m_x;
136
0
    m_bboxTop = bboxTopLeft.m_y;
137
0
    m_bboxRight = bboxBotRight.m_x;
138
0
    m_bboxBot = bboxBotRight.m_y;
139
0
  }
140
141
  void addPoint(InchPoint point)
142
0
  {
143
0
    m_points.push_back(InchPoint(point.m_x, point.m_y));
144
0
  }
145
146
  void setDimensions(double width, double height)
147
0
  {
148
0
    m_width = width,
149
0
    m_height = height;
150
0
  }
151
152
  double getWidth() const
153
0
  {
154
0
    return m_width;
155
0
  }
156
157
  double getHeight() const
158
0
  {
159
0
    return m_height;
160
0
  }
161
};
162
163
164
std::shared_ptr<OutputShape> newOutputShape(
165
  const std::shared_ptr<const PMDLineSet> &lineSet, const InchPoint &translate);
166
167
}
168
169
#endif /* __LIBPAGEMAKER_OUTPUTSHAPE_H__ */
170
171
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */