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
00029 #ifndef __POLYGONUTILS_H__
00030 #define __POLYGONUTILS_H__
00031
00032 #include <vector>
00033
00034 #include <libwpg/libwpg.h>
00035 #include <boost/function.hpp>
00036 #include <boost/shared_ptr.hpp>
00037
00038 #include "ShapeType.h"
00039 #include "VectorTransformation2D.h"
00040 #include "Coordinate.h"
00041 #include "Line.h"
00042
00043 namespace libmspub
00044 {
00045 const int PROP_ADJUST_VAL_FIRST = 327;
00046 const int PROP_ADJUST_VAL_LAST = 336;
00047 const int PROP_GEO_LEFT = 320;
00048 const int PROP_GEO_TOP = 321;
00049 const int PROP_GEO_RIGHT = 322;
00050 const int PROP_GEO_BOTTOM = 323;
00051
00052 const int OTHER_CALC_VAL = 0x400;
00053 const int ASPECT_RATIO = 0x600;
00054
00055 class MSPUBCollector;
00056
00057 typedef struct
00058 {
00059 int m_x;
00060 int m_y;
00061 } Vertex;
00062
00063 typedef struct
00064 {
00065 int m_flags;
00066 int m_argOne;
00067 int m_argTwo;
00068 int m_argThree;
00069 } Calculation;
00070
00071 typedef struct
00072 {
00073 Vertex first;
00074 Vertex second;
00075 } TextRectangle;
00076
00077 struct CustomShape
00078 {
00079 const Vertex *mp_vertices;
00080 unsigned m_numVertices;
00081 const unsigned short *mp_elements;
00082 unsigned m_numElements;
00083 const Calculation *mp_calculations;
00084 unsigned m_numCalculations;
00085 const int *mp_defaultAdjustValues;
00086 unsigned m_numDefaultAdjustValues;
00087 const TextRectangle *mp_textRectangles;
00088 unsigned m_numTextRectangles;
00089 unsigned m_coordWidth;
00090 unsigned m_coordHeight;
00091 const Vertex *mp_gluePoints;
00092 unsigned m_numGluePoints;
00093 unsigned char m_adjustShiftMask;
00094
00095 Coordinate getTextRectangle(double x, double y, double width, double height, boost::function<double (unsigned index)> calculator) const;
00096
00097 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) :
00098 mp_vertices(p_vertices), m_numVertices(numVertices),
00099 mp_elements(p_elements), m_numElements(numElements),
00100 mp_calculations(p_calculations), m_numCalculations(numCalculations),
00101 mp_defaultAdjustValues(p_defaultAdjustValues), m_numDefaultAdjustValues(numDefaultAdjustValues),
00102 mp_textRectangles(p_textRectangles), m_numTextRectangles(numTextRectangles),
00103 m_coordWidth(coordWidth), m_coordHeight(coordHeight),
00104 mp_gluePoints(p_gluePoints), m_numGluePoints(numGluePoints),
00105 m_adjustShiftMask(adjustShiftMask)
00106 {
00107 }
00108 };
00109
00110 struct DynamicCustomShape
00111 {
00112 std::vector<Vertex> m_vertices;
00113 std::vector<unsigned short> m_elements;
00114 std::vector<Calculation> m_calculations;
00115 std::vector<int> m_defaultAdjustValues;
00116 std::vector<TextRectangle> m_textRectangles;
00117 std::vector<Vertex> m_gluePoints;
00118 unsigned m_coordWidth;
00119 unsigned m_coordHeight;
00120 unsigned char m_adjustShiftMask;
00121
00122 DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
00123 : m_vertices(), m_elements(),
00124 m_calculations(), m_defaultAdjustValues(),
00125 m_textRectangles(), m_gluePoints(),
00126 m_coordWidth(coordWidth), m_coordHeight(coordHeight),
00127 m_adjustShiftMask(0)
00128 {
00129 }
00130 };
00131
00132 boost::shared_ptr<const CustomShape> getFromDynamicCustomShape(const DynamicCustomShape &dcs);
00133
00134 const CustomShape *getCustomShape(ShapeType type);
00135 bool isShapeTypeRectangle(ShapeType type);
00136 WPXPropertyList calcClipPath(const std::vector<libmspub::Vertex> &verts, double x, double y, double height, double width, VectorTransformation2D transform, boost::shared_ptr<const CustomShape> shape);
00137 void writeCustomShape(ShapeType shapeType, WPXPropertyList &graphicsProps, libwpg::WPGPaintInterface *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);
00138
00139 }
00140 #endif
00141