00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __POLYGONUTILS_H__
00011 #define __POLYGONUTILS_H__
00012
00013 #include <vector>
00014
00015 #include <librevenge/librevenge.h>
00016 #include <boost/function.hpp>
00017 #include <boost/shared_ptr.hpp>
00018
00019 #include "ShapeType.h"
00020 #include "VectorTransformation2D.h"
00021 #include "Coordinate.h"
00022 #include "Line.h"
00023
00024 namespace libmspub
00025 {
00026 const int PROP_ADJUST_VAL_FIRST = 327;
00027 const int PROP_ADJUST_VAL_LAST = 336;
00028 const int PROP_GEO_LEFT = 320;
00029 const int PROP_GEO_TOP = 321;
00030 const int PROP_GEO_RIGHT = 322;
00031 const int PROP_GEO_BOTTOM = 323;
00032
00033 const int OTHER_CALC_VAL = 0x400;
00034 const int ASPECT_RATIO = 0x600;
00035
00036 class MSPUBCollector;
00037
00038 typedef struct
00039 {
00040 int m_x;
00041 int m_y;
00042 } Vertex;
00043
00044 typedef struct
00045 {
00046 int m_flags;
00047 int m_argOne;
00048 int m_argTwo;
00049 int m_argThree;
00050 } Calculation;
00051
00052 typedef struct
00053 {
00054 Vertex first;
00055 Vertex second;
00056 } TextRectangle;
00057
00058 struct CustomShape
00059 {
00060 const Vertex *mp_vertices;
00061 unsigned m_numVertices;
00062 const unsigned short *mp_elements;
00063 unsigned m_numElements;
00064 const Calculation *mp_calculations;
00065 unsigned m_numCalculations;
00066 const int *mp_defaultAdjustValues;
00067 unsigned m_numDefaultAdjustValues;
00068 const TextRectangle *mp_textRectangles;
00069 unsigned m_numTextRectangles;
00070 unsigned m_coordWidth;
00071 unsigned m_coordHeight;
00072 const Vertex *mp_gluePoints;
00073 unsigned m_numGluePoints;
00074 unsigned char m_adjustShiftMask;
00075
00076 Coordinate getTextRectangle(double x, double y, double width, double height, boost::function<double(unsigned index)> calculator) const;
00077
00078 CustomShape(const Vertex *p_vertices, unsigned numVertices, const unsigned short *p_elements, unsigned numElements, const Calculation *p_calculations, unsigned numCalculations, const int *p_defaultAdjustValues, unsigned numDefaultAdjustValues, const TextRectangle *p_textRectangles, unsigned numTextRectangles, unsigned coordWidth, unsigned coordHeight, const Vertex *p_gluePoints, unsigned numGluePoints, unsigned char adjustShiftMask = 0) :
00079 mp_vertices(p_vertices), m_numVertices(numVertices),
00080 mp_elements(p_elements), m_numElements(numElements),
00081 mp_calculations(p_calculations), m_numCalculations(numCalculations),
00082 mp_defaultAdjustValues(p_defaultAdjustValues), m_numDefaultAdjustValues(numDefaultAdjustValues),
00083 mp_textRectangles(p_textRectangles), m_numTextRectangles(numTextRectangles),
00084 m_coordWidth(coordWidth), m_coordHeight(coordHeight),
00085 mp_gluePoints(p_gluePoints), m_numGluePoints(numGluePoints),
00086 m_adjustShiftMask(adjustShiftMask)
00087 {
00088 }
00089 };
00090
00091 struct DynamicCustomShape
00092 {
00093 std::vector<Vertex> m_vertices;
00094 std::vector<unsigned short> m_elements;
00095 std::vector<Calculation> m_calculations;
00096 std::vector<int> m_defaultAdjustValues;
00097 std::vector<TextRectangle> m_textRectangles;
00098 std::vector<Vertex> m_gluePoints;
00099 unsigned m_coordWidth;
00100 unsigned m_coordHeight;
00101 unsigned char m_adjustShiftMask;
00102
00103 DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
00104 : m_vertices(), m_elements(),
00105 m_calculations(), m_defaultAdjustValues(),
00106 m_textRectangles(), m_gluePoints(),
00107 m_coordWidth(coordWidth), m_coordHeight(coordHeight),
00108 m_adjustShiftMask(0)
00109 {
00110 }
00111 };
00112
00113 boost::shared_ptr<const CustomShape> getFromDynamicCustomShape(const DynamicCustomShape &dcs);
00114
00115 const CustomShape *getCustomShape(ShapeType type);
00116 bool isShapeTypeRectangle(ShapeType type);
00117 librevenge::RVNGPropertyList calcClipPath(const std::vector<libmspub::Vertex> &verts, double x, double y, double height, double width, VectorTransformation2D transform, boost::shared_ptr<const CustomShape> shape);
00118 void writeCustomShape(ShapeType shapeType, librevenge::RVNGPropertyList &graphicsProps, librevenge::RVNGDrawingInterface *painter, double x, double y, double height, double width, bool closeEverything, VectorTransformation2D transform, std::vector<Line> lines, boost::function<double(unsigned index)> calculator, const std::vector<Color> &palette, boost::shared_ptr<const CustomShape> shape);
00119
00120 }
00121 #endif
00122