filters

xamlimport.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002, The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library 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 GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __XAMLIMPORT_H__
00021 #define __XAMLIMPORT_H__
00022 
00023 #include <KoFilter.h>
00024 #include <qdom.h>
00025 #include <qmap.h>
00026 #include <qptrstack.h>
00027 #include <core/vdocument.h>
00028 #include <core/vgradient.h>
00029 #include <core/vfill.h>
00030 #include <core/vstroke.h>
00031 #include <core/vfillrule.h>
00032 #include "xamlgraphiccontext.h"
00033 
00034 class VGroup;
00035 class VPath;
00036 
00037 class XAMLImport : public KoFilter
00038 {
00039     Q_OBJECT
00040 
00041 public:
00042     XAMLImport(KoFilter *parent, const char *name, const QStringList&);
00043     virtual ~XAMLImport();
00044 
00045     virtual KoFilter::ConversionStatus convert(const QCString& from, const QCString& to);
00046 
00047 protected:
00048     class GradientHelper
00049     {
00050     public:
00051         GradientHelper()
00052         {
00053             bbox = true;
00054         }
00055         VGradient   gradient;
00056         bool        bbox;
00057         QWMatrix    gradientTransform;
00058     };
00059 
00060     void parseGroup( VGroup *, const QDomElement & );
00061     void parseStyle( VObject *, const QDomElement & );
00062     void parsePA( VObject *, XAMLGraphicsContext *, const QString &, const QString & );
00063     void parseGradient( const QDomElement & );
00064     void parseColorStops( VGradient *, const QDomElement & );
00065     double parseUnit( const QString &, bool horiz = false, bool vert = false, KoRect bbox = KoRect() );
00066     void parseColor( VColor &, const QString & );
00067     QColor parseColor( const QString & );
00068     double toPercentage( QString );
00069     double fromPercentage( QString );
00070     void setupTransform( const QDomElement & );
00071     void addGraphicContext();
00072     QDomDocument inpdoc;
00073     QDomDocument outdoc;
00074     void convert();
00075     VObject* createObject( const QDomElement & );
00076     void createText( VGroup *, const QDomElement & );
00077     void parseFont( const QDomElement & );
00078     // find object with given id in document
00079     VObject* findObject( const QString &name );
00080     // find object with given id in given group
00081     VObject* findObject( const QString &name, VGroup * );
00082 
00083 private:
00084     VDocument                       m_document;
00085     QPtrStack<XAMLGraphicsContext>  m_gc;
00086     QMap<QString, GradientHelper>   m_gradients;
00087     QMap<QString, QDomElement>      m_paths;
00088     KoRect                          m_outerRect;
00089 };
00090 
00091 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys