00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __SHAPES_H__
00011 #define __SHAPES_H__
00012
00013 #include <vector>
00014 #include <map>
00015
00016 #include "Coordinate.h"
00017 #include "MSPUBConstants.h"
00018 #include "ShapeType.h"
00019 #include "VectorTransformation2D.h"
00020
00021 namespace libmspub
00022 {
00023 class MSPUBCollector;
00024 struct CustomShape;
00025 struct Shape
00026 {
00027 Shape(MSPUBCollector *o) : props(), graphicsProps(), owner(o) { }
00028 virtual void output(librevenge::RVNGDrawingInterface *painter, Coordinate coord);
00029 virtual ~Shape()
00030 {
00031 }
00032 librevenge::RVNGPropertyList props;
00033 librevenge::RVNGPropertyList graphicsProps;
00034 protected:
00035 virtual void setCoordProps(Coordinate coord);
00036 virtual void write(librevenge::RVNGDrawingInterface *painter) = 0;
00037 MSPUBCollector *owner;
00038
00039 virtual librevenge::RVNGPropertyListVector updateGraphicsProps();
00040
00041 Shape();
00042 private:
00043 Shape(const Shape &);
00044 Shape &operator=(const Shape &);
00045 };
00046 struct FillableShape : public Shape
00047 {
00048 FillableShape(MSPUBCollector *o) : Shape(o), m_fill(NULL) { }
00049 Fill *m_fill;
00050 void setFill(Fill *fill);
00051 protected:
00052 virtual librevenge::RVNGPropertyListVector updateGraphicsProps();
00053 private:
00054 FillableShape(const FillableShape &);
00055 FillableShape &operator=(const FillableShape &);
00056 };
00057 struct GeometricShape : public FillableShape
00058 {
00059 void addLine(ColorReference color, unsigned widthInEmu, bool lineExists);
00060 void fillDefaultAdjustValues();
00061 void setAdjustValue(unsigned index, int adjustValue);
00062 void setText(std::vector<TextParagraph> str);
00063 double getCalculationValue(unsigned index, bool recursiveEntry = false) const;
00064 double getSpecialValue(const CustomShape &shape, int arg) const;
00065 void writeText(librevenge::RVNGDrawingInterface *painter);
00066 void setTransformation(VectorTransformation2D transform);
00067
00068 std::vector<TextParagraph> m_str;
00069 bool m_hasText;
00070 unsigned m_pageSeqNum;
00071 unsigned m_imgIndex;
00072 ShapeType m_type;
00073 double m_x, m_y, m_width, m_height;
00074 VectorTransformation2D m_transform;
00075 std::vector<int> m_adjustValues;
00076 unsigned m_left, m_top, m_right, m_bottom;
00077 GeometricShape(MSPUBCollector *o)
00078 : FillableShape(o), m_str(), m_hasText(false), m_pageSeqNum(0), m_imgIndex(0), m_type(RECTANGLE),
00079 m_x(0), m_y(0), m_width(0), m_height(0), m_transform(VectorTransformation2D()),
00080 m_adjustValues(),
00081 m_left(DEFAULT_MARGIN), m_top(DEFAULT_MARGIN), m_right(DEFAULT_MARGIN), m_bottom(DEFAULT_MARGIN),
00082 m_valuesSeen(), m_filledDefaultAdjustValues(false), m_textCoord(), m_closeEverything(false),
00083 m_lines(), m_drawStroke(false),
00084 m_borderPosition(HALF_INSIDE_SHAPE),
00085 m_coordinatesRotated90(false), m_foldedTransform(VectorTransformation2D()) { }
00086 GeometricShape(unsigned pageSeqNum, MSPUBCollector *o)
00087 : FillableShape(o), m_str(), m_hasText(false), m_pageSeqNum(pageSeqNum), m_imgIndex(0), m_type(RECTANGLE),
00088 m_x(0), m_y(0), m_width(0), m_height(0), m_transform(VectorTransformation2D()), m_adjustValues(),
00089 m_left(DEFAULT_MARGIN), m_top(DEFAULT_MARGIN), m_right(DEFAULT_MARGIN), m_bottom(DEFAULT_MARGIN),
00090 m_valuesSeen(), m_filledDefaultAdjustValues(false), m_textCoord(), m_closeEverything(false),
00091 m_lines(), m_drawStroke(false),
00092 m_borderPosition(HALF_INSIDE_SHAPE),
00093 m_coordinatesRotated90(false), m_foldedTransform(VectorTransformation2D()) { }
00094 std::vector<Color> getPaletteColors() const;
00095 void output(librevenge::RVNGDrawingInterface *painter, Coordinate coord);
00096 protected:
00097 virtual bool hasFill();
00098 void setCoordProps(Coordinate coord);
00099 virtual void write(librevenge::RVNGDrawingInterface *painter);
00100 librevenge::RVNGPropertyListVector updateGraphicsProps();
00101 GeometricShape();
00102 private:
00103 GeometricShape(const GeometricShape &);
00104 GeometricShape &operator=(const GeometricShape &);
00105 mutable std::vector<bool> m_valuesSeen;
00106 bool m_filledDefaultAdjustValues;
00107 Coordinate m_textCoord;
00108 bool m_closeEverything;
00109 public:
00110 std::vector<Line> m_lines;
00111 bool m_drawStroke;
00112 BorderPosition m_borderPosition;
00113 bool m_coordinatesRotated90;
00114 VectorTransformation2D m_foldedTransform;
00115 };
00116 }
00117 #endif // __SHAPES_H__
00118