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