Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UT_SVG_H
00023 #define UT_SVG_H
00024
00025
00026
00027
00028
00029 #ifndef UT_TYPES_H
00030 #include "ut_types.h"
00031 #endif
00032 #include "ut_bytebuf.h"
00033 #include "ut_xml.h"
00034
00035 #include "gr_Graphics.h"
00036
00037 bool UT_SVG_recognizeContent(const char* szBuf,UT_uint32 iNumbytes);
00038 bool UT_SVG_getDimensions(const UT_ConstByteBufPtr & pBB, GR_Graphics* pG,
00039 UT_sint32 & iDisplayWidth, UT_sint32 & iDisplayHeight,
00040 UT_sint32 & iLayoutWidth, UT_sint32 & iLayoutHeight);
00041
00042 class ABI_EXPORT UT_svg : public UT_XML::Listener
00043 {
00044 public:
00045
00046
00047 void startElement (const gchar * name, const gchar ** atts);
00048 void endElement (const gchar * name);
00049 void charData (const gchar * buffer, int length);
00050
00051 enum ParseMode
00052 {
00053 pm_recognizeContent,
00054 pm_getDimensions,
00055 pm_parse
00056 };
00057
00058 const ParseMode m_ePM;
00059
00060 bool m_bSVG;
00061 bool m_bContinue;
00062
00063 GR_Graphics *m_pG;
00064
00065 UT_sint32 m_iDisplayWidth;
00066 UT_sint32 m_iDisplayHeight;
00067 UT_sint32 m_iLayoutWidth;
00068 UT_sint32 m_iLayoutHeight;
00069
00070 UT_svg(GR_Graphics * pG,ParseMode ePM = pm_parse);
00071 ~UT_svg();
00072
00073 bool parse (const UT_ConstByteBufPtr & pBB);
00074
00075 bool m_bIsText;
00076 bool m_bIsTSpan;
00077 bool m_bHasTSpan;
00078
00079 UT_ByteBufPtr m_pBB;
00080
00081
00082
00083 void *cb_userdata;
00084 void (*cb_start) (void * userdata,const char * name,const char** atts);
00085 void (*cb_end) (void * userdata,const char * name);
00086 void (*cb_text) (void * userdata, const UT_ConstByteBufPtr & text);
00087
00088 const char *getAttribute (const char * name,const char ** atts);
00089 };
00090
00091 class ABI_EXPORT UT_SVGPoint
00092 {
00093 public:
00094 float x;
00095 float y;
00096
00097 UT_SVGPoint(float x = 0, float y = 0);
00098 ~UT_SVGPoint();
00099 };
00100
00101 class ABI_EXPORT UT_SVGMatrix
00102 {
00103 public:
00104
00105 float a;
00106 float b;
00107 float c;
00108 float d;
00109 float e;
00110 float f;
00111
00112
00113 UT_SVGMatrix multiply (const UT_SVGMatrix& matrix);
00114 UT_SVGMatrix inverse ();
00115 UT_SVGMatrix translate (float x, float y);
00116 UT_SVGMatrix scale (float scaleFactor);
00117 UT_SVGMatrix scaleNonUniform (float scaleFactorX, float scaleFactorY);
00118 UT_SVGMatrix rotate (float angle);
00119 UT_SVGMatrix rotateFromVector (float x, float y);
00120 UT_SVGMatrix flipX ();
00121 UT_SVGMatrix flipY ();
00122 UT_SVGMatrix skewX (float angle);
00123 UT_SVGMatrix skewY (float angle);
00124
00125
00126 UT_SVGMatrix(float a = 1, float b = 0, float c = 0, float d = 1, float e = 0, float f = 0);
00127 ~UT_SVGMatrix();
00128
00129 static bool applyTransform (UT_SVGMatrix * currentMatrix,const char * transformAttribute);
00130 };
00131
00132 #endif