Shapes.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*
3 * This file is part of the libmspub 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 INCLUDED_SHAPES_H
11#define INCLUDED_SHAPES_H
12
13#include <map>
14#include <vector>
15
16#include "Coordinate.h"
17#include "MSPUBConstants.h"
18#include "ShapeType.h"
19#include "VectorTransformation2D.h"
20
21 namespace libmspub
22{
23 class MSPUBCollector;
24 struct CustomShape;
25 struct Shape
26{
27 Shape(MSPUBCollector *o) : props(), graphicsProps(), owner(o) { }
28 virtual void output(librevenge::RVNGDrawingInterface *painter, Coordinate coord);
29 virtual ~Shape()
30 {
31 }
32 librevenge::RVNGPropertyList props;
33 librevenge::RVNGPropertyList graphicsProps;
34 protected:
35 virtual void setCoordProps(Coordinate coord);
36 virtual void write(librevenge::RVNGDrawingInterface *painter) = 0;
37 MSPUBCollector *owner;
38
39 virtual librevenge::RVNGPropertyListVector updateGraphicsProps();
40
41 Shape();
42 private:
43 Shape(const Shape &);
44 Shape &operator=(const Shape &);
45};
46 struct FillableShape : public Shape
47{
48 FillableShape(MSPUBCollector *o) : Shape(o), m_fill(NULL) { }
49 Fill *m_fill;
50 void setFill(Fill *fill);
51 protected:
52 virtual librevenge::RVNGPropertyListVector updateGraphicsProps();
53 private:
54 FillableShape(const FillableShape &);
55 FillableShape &operator=(const FillableShape &);
56};
57 struct GeometricShape : public FillableShape
58{
59 void addLine(ColorReference color, unsigned widthInEmu, bool lineExists);
60 void fillDefaultAdjustValues();
61 void setAdjustValue(unsigned index, int adjustValue);
62 void setText(std::vector<TextParagraph> str);
63 double getCalculationValue(unsigned index, bool recursiveEntry = false) const;
64 double getSpecialValue(const CustomShape &shape, int arg) const;
65 void writeText(librevenge::RVNGDrawingInterface *painter);
66 void setTransformation(VectorTransformation2D transform);
67
68 std::vector<TextParagraph> m_str;
69 bool m_hasText;
70 unsigned m_pageSeqNum;
71 unsigned m_imgIndex;
72 ShapeType m_type;
73 double m_x, m_y, m_width, m_height;
74 VectorTransformation2D m_transform;
75 std::vector<int> m_adjustValues;
76 unsigned m_left, m_top, m_right, m_bottom; //emu
77 GeometricShape(MSPUBCollector *o)
78 : FillableShape(o), m_str(), m_hasText(false), m_pageSeqNum(0), m_imgIndex(0), m_type(RECTANGLE),
79 m_x(0), m_y(0), m_width(0), m_height(0), m_transform(VectorTransformation2D()),
80 m_adjustValues(),
81 m_left(DEFAULT_MARGIN), m_top(DEFAULT_MARGIN), m_right(DEFAULT_MARGIN), m_bottom(DEFAULT_MARGIN),
82 m_valuesSeen(), m_filledDefaultAdjustValues(false), m_textCoord(), m_closeEverything(false),
83 m_lines(), m_drawStroke(false),
84 m_borderPosition(HALF_INSIDE_SHAPE),
85 m_coordinatesRotated90(false), m_foldedTransform(VectorTransformation2D()) { }
86 GeometricShape(unsigned pageSeqNum, MSPUBCollector *o)
87 : FillableShape(o), m_str(), m_hasText(false), m_pageSeqNum(pageSeqNum), m_imgIndex(0), m_type(RECTANGLE),
88 m_x(0), m_y(0), m_width(0), m_height(0), m_transform(VectorTransformation2D()), m_adjustValues(),
89 m_left(DEFAULT_MARGIN), m_top(DEFAULT_MARGIN), m_right(DEFAULT_MARGIN), m_bottom(DEFAULT_MARGIN),
90 m_valuesSeen(), m_filledDefaultAdjustValues(false), m_textCoord(), m_closeEverything(false),
91 m_lines(), m_drawStroke(false),
92 m_borderPosition(HALF_INSIDE_SHAPE),
93 m_coordinatesRotated90(false), m_foldedTransform(VectorTransformation2D()) { }
94 std::vector<Color> getPaletteColors() const;
95 void output(librevenge::RVNGDrawingInterface *painter, Coordinate coord);
96 protected:
97 virtual bool hasFill();
98 void setCoordProps(Coordinate coord);
99 virtual void write(librevenge::RVNGDrawingInterface *painter);
100 librevenge::RVNGPropertyListVector updateGraphicsProps();
101 GeometricShape();
102 private:
103 GeometricShape(const GeometricShape &);
104 GeometricShape &operator=(const GeometricShape &);
105 mutable std::vector<bool> m_valuesSeen;
106 bool m_filledDefaultAdjustValues;
107 Coordinate m_textCoord;
108 bool m_closeEverything;
109 public:
110 std::vector<Line> m_lines;
111 bool m_drawStroke;
112 BorderPosition m_borderPosition;
113 bool m_coordinatesRotated90;
114 VectorTransformation2D m_foldedTransform;
115};
116} // namespace libmspub
117#endif // INCLUDED_SHAPES_H
118/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Coordinate.h
MSPUBConstants.h
DEFAULT_MARGIN
#define DEFAULT_MARGIN
Definition MSPUBConstants.h:15
ShapeType.h
VectorTransformation2D.h
libmspub::ColorReference
Definition ColorReference.h:20
libmspub::Fill
Definition Fill.h:23
libmspub::MSPUBCollector
Definition MSPUBCollector.h:45
libmspub::VectorTransformation2D
Definition VectorTransformation2D.h:26
libmspub
Definition Arrow.h:14
libmspub::ShapeType
ShapeType
Definition ShapeType.h:16
libmspub::RECTANGLE
@ RECTANGLE
Definition ShapeType.h:19
libmspub::BorderPosition
BorderPosition
Definition MSPUBTypes.h:27
libmspub::HALF_INSIDE_SHAPE
@ HALF_INSIDE_SHAPE
Definition MSPUBTypes.h:29
libmspub::Coordinate
Definition Coordinate.h:23
libmspub::CustomShape
Definition PolygonUtils.h:60
libmspub::FillableShape::m_fill
Fill * m_fill
Definition Shapes.h:49
libmspub::FillableShape::FillableShape
FillableShape(const FillableShape &)
libmspub::FillableShape::setFill
void setFill(Fill *fill)
libmspub::FillableShape::operator=
FillableShape & operator=(const FillableShape &)
libmspub::FillableShape::updateGraphicsProps
virtual librevenge::RVNGPropertyListVector updateGraphicsProps()
libmspub::FillableShape::FillableShape
FillableShape(MSPUBCollector *o)
Definition Shapes.h:48
libmspub::GeometricShape::GeometricShape
GeometricShape(unsigned pageSeqNum, MSPUBCollector *o)
Definition Shapes.h:86
libmspub::GeometricShape::m_transform
VectorTransformation2D m_transform
Definition Shapes.h:74
libmspub::GeometricShape::getPaletteColors
std::vector< Color > getPaletteColors() const
libmspub::GeometricShape::setCoordProps
void setCoordProps(Coordinate coord)
libmspub::GeometricShape::m_height
double m_height
Definition Shapes.h:73
libmspub::GeometricShape::output
void output(librevenge::RVNGDrawingInterface *painter, Coordinate coord)
libmspub::GeometricShape::m_width
double m_width
Definition Shapes.h:73
libmspub::GeometricShape::setText
void setText(std::vector< TextParagraph > str)
libmspub::GeometricShape::GeometricShape
GeometricShape()
libmspub::GeometricShape::m_foldedTransform
VectorTransformation2D m_foldedTransform
Definition Shapes.h:114
libmspub::GeometricShape::setTransformation
void setTransformation(VectorTransformation2D transform)
libmspub::GeometricShape::updateGraphicsProps
librevenge::RVNGPropertyListVector updateGraphicsProps()
libmspub::GeometricShape::setAdjustValue
void setAdjustValue(unsigned index, int adjustValue)
libmspub::GeometricShape::m_coordinatesRotated90
bool m_coordinatesRotated90
Definition Shapes.h:113
libmspub::GeometricShape::m_valuesSeen
std::vector< bool > m_valuesSeen
Definition Shapes.h:105
libmspub::GeometricShape::m_x
double m_x
Definition Shapes.h:73
libmspub::GeometricShape::m_left
unsigned m_left
Definition Shapes.h:76
libmspub::GeometricShape::m_pageSeqNum
unsigned m_pageSeqNum
Definition Shapes.h:70
libmspub::GeometricShape::m_right
unsigned m_right
Definition Shapes.h:76
libmspub::GeometricShape::hasFill
virtual bool hasFill()
libmspub::GeometricShape::m_hasText
bool m_hasText
Definition Shapes.h:69
libmspub::GeometricShape::m_drawStroke
bool m_drawStroke
Definition Shapes.h:111
libmspub::GeometricShape::getCalculationValue
double getCalculationValue(unsigned index, bool recursiveEntry=false) const
libmspub::GeometricShape::m_lines
std::vector< Line > m_lines
Definition Shapes.h:110
libmspub::GeometricShape::m_imgIndex
unsigned m_imgIndex
Definition Shapes.h:71
libmspub::GeometricShape::addLine
void addLine(ColorReference color, unsigned widthInEmu, bool lineExists)
libmspub::GeometricShape::m_type
ShapeType m_type
Definition Shapes.h:72
libmspub::GeometricShape::m_y
double m_y
Definition Shapes.h:73
libmspub::GeometricShape::m_textCoord
Coordinate m_textCoord
Definition Shapes.h:107
libmspub::GeometricShape::m_filledDefaultAdjustValues
bool m_filledDefaultAdjustValues
Definition Shapes.h:106
libmspub::GeometricShape::m_adjustValues
std::vector< int > m_adjustValues
Definition Shapes.h:75
libmspub::GeometricShape::m_borderPosition
BorderPosition m_borderPosition
Definition Shapes.h:112
libmspub::GeometricShape::write
virtual void write(librevenge::RVNGDrawingInterface *painter)
libmspub::GeometricShape::GeometricShape
GeometricShape(const GeometricShape &)
libmspub::GeometricShape::getSpecialValue
double getSpecialValue(const CustomShape &shape, int arg) const
libmspub::GeometricShape::m_top
unsigned m_top
Definition Shapes.h:76
libmspub::GeometricShape::m_bottom
unsigned m_bottom
Definition Shapes.h:76
libmspub::GeometricShape::m_closeEverything
bool m_closeEverything
Definition Shapes.h:108
libmspub::GeometricShape::operator=
GeometricShape & operator=(const GeometricShape &)
libmspub::GeometricShape::GeometricShape
GeometricShape(MSPUBCollector *o)
Definition Shapes.h:77
libmspub::GeometricShape::m_str
std::vector< TextParagraph > m_str
Definition Shapes.h:68
libmspub::GeometricShape::fillDefaultAdjustValues
void fillDefaultAdjustValues()
libmspub::GeometricShape::writeText
void writeText(librevenge::RVNGDrawingInterface *painter)
libmspub::Shape::graphicsProps
librevenge::RVNGPropertyList graphicsProps
Definition Shapes.h:33
libmspub::Shape::updateGraphicsProps
virtual librevenge::RVNGPropertyListVector updateGraphicsProps()
libmspub::Shape::operator=
Shape & operator=(const Shape &)
libmspub::Shape::Shape
Shape()
libmspub::Shape::write
virtual void write(librevenge::RVNGDrawingInterface *painter)=0
libmspub::Shape::Shape
Shape(MSPUBCollector *o)
Definition Shapes.h:27
libmspub::Shape::setCoordProps
virtual void setCoordProps(Coordinate coord)
libmspub::Shape::props
librevenge::RVNGPropertyList props
Definition Shapes.h:32
libmspub::Shape::Shape
Shape(const Shape &)
libmspub::Shape::output
virtual void output(librevenge::RVNGDrawingInterface *painter, Coordinate coord)
libmspub::Shape::~Shape
virtual ~Shape()
Definition Shapes.h:29
libmspub::Shape::owner
MSPUBCollector * owner
Definition Shapes.h:37