filters

svgimport.h
1/* This file is part of the KDE project
2 Copyright (C) 2002, The Karbon Developers
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __SVGIMPORT_H__
21#define __SVGIMPORT_H__
22
23#include <KoFilter.h>
24#include <tqdom.h>
25#include <tqmap.h>
26#include <tqptrstack.h>
27#include <core/vdocument.h>
28#include <core/vgradient.h>
29#include <core/vfill.h>
30#include <core/vstroke.h>
31#include <core/vfillrule.h>
32#include "svggraphiccontext.h"
33
34#include <vobject.h>
35
36class VGroup;
37class VPath;
38
39class SvgImport : public KoFilter
40{
41 TQ_OBJECT
42
43
44public:
45 SvgImport(KoFilter *parent, const char *name, const TQStringList&);
46 virtual ~SvgImport();
47
48 virtual KoFilter::ConversionStatus convert(const TQCString& from, const TQCString& to);
49
50protected:
51 class GradientHelper
52 {
53 public:
54 GradientHelper()
55 {
56 bbox = true;
57 }
58 VGradient gradient;
59 bool bbox;
60 TQWMatrix gradientTransform;
61 };
62
63 void parseGroup( VGroup *, const TQDomElement & );
64 void parseDefs( const TQDomElement & );
65 void parseUse( VGroup *, const TQDomElement & );
66 void parseStyle( VObject *, const TQDomElement & );
67 void parsePA( VObject *, SvgGraphicsContext *, const TQString &, const TQString & );
68 void parseGradient( const TQDomElement &, const TQDomElement &referencedBy = TQDomElement() );
69 void parseColorStops( VGradient *, const TQDomElement & );
70 double parseUnit( const TQString &, bool horiz = false, bool vert = false, KoRect bbox = KoRect() );
71 void parseColor( VColor &, const TQString & );
72 TQColor parseColor( const TQString & );
73 double toPercentage( TQString );
74 double fromPercentage( TQString );
75 void setupTransform( const TQDomElement & );
76 void addGraphicContext();
77 TQDomDocument inpdoc;
78 TQDomDocument outdoc;
79 void convert();
80 void createObject( VGroup *grp, const TQDomElement &, VObject::VState state = VObject::normal, const TQDomElement &style = TQDomElement() );
81 void createText( VGroup *, const TQDomElement & );
82 void parseFont( const TQDomElement & );
83 // find object with given id in document
84 VObject* findObject( const TQString &name );
85 // find object with given id in given group
86 VObject* findObject( const TQString &name, VGroup * );
87 // find gradient with given id in gradient map
88 GradientHelper* findGradient( const TQString &id, const TQString &href = 0 );
89
90 // Determine scaling factor from given matrix
91 double getScalingFromMatrix( TQWMatrix &matrix );
92
93 TQDomElement mergeStyles( const TQDomElement &, const TQDomElement & );
94
95private:
96 VDocument m_document;
97 TQPtrStack<SvgGraphicsContext> m_gc;
98 TQMap<TQString, GradientHelper> m_gradients;
99 TQMap<TQString, TQDomElement> m_defs;
100 KoRect m_outerRect;
101};
102
103#endif