• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ut_svg.h

Go to the documentation of this file.
00001 /* AbiSource Program Utilities
00002  * Copyright (C) 2000 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 
00021 
00022 #ifndef UT_SVG_H
00023 #define UT_SVG_H
00024 
00025 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00026  * so even if it's commented out in-file that's still a lot of work for
00027  * the preprocessor to do...
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     /* UT_XML::Listener implementation:
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;   // whether the current element is, or is a tspan-child of, a text element
00076     bool m_bIsTSpan;  // whether the current element is a tspan
00077     bool m_bHasTSpan; // whether the current text-element has any tspan-children
00078 
00079     UT_ByteBufPtr m_pBB;
00080 
00081     /* caller-definable call-back data-handle & functions
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   // DOM attributes:
00105   float a; // [ a c e ]
00106   float b; // [ b d f ]
00107   float c; // [ 0 0 1 ]
00108   float d;
00109   float e;
00110   float f;
00111 
00112   // DOM methods:
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); // degrees, I assume
00119   UT_SVGMatrix rotateFromVector (float x, float y);
00120   UT_SVGMatrix flipX ();
00121   UT_SVGMatrix flipY ();
00122   UT_SVGMatrix skewX (float angle); // degrees, I assume
00123   UT_SVGMatrix skewY (float angle); // degrees, I assume
00124 
00125   // Other:
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 /* UT_SVG_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1