xamlimport.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 __XAMLIMPORT_H__
21#define __XAMLIMPORT_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 "xamlgraphiccontext.h"
33
34class VGroup;
35class VPath;
36
37class XAMLImport : public KoFilter
38{
39 TQ_OBJECT
40
41
42public:
43 XAMLImport(KoFilter *parent, const char *name, const TQStringList&);
44 virtual ~XAMLImport();
45
46 virtual KoFilter::ConversionStatus convert(const TQCString& from, const TQCString& to);
47
48protected:
49 class GradientHelper
50 {
51 public:
52 GradientHelper()
53 {
54 bbox = true;
55 }
56 VGradient gradient;
57 bool bbox;
58 TQWMatrix gradientTransform;
59 };
60
61 void parseGroup( VGroup *, const TQDomElement & );
62 void parseStyle( VObject *, const TQDomElement & );
63 void parsePA( VObject *, XAMLGraphicsContext *, const TQString &, const TQString & );
64 void parseGradient( const TQDomElement & );
65 void parseColorStops( VGradient *, const TQDomElement & );
66 double parseUnit( const TQString &, bool horiz = false, bool vert = false, KoRect bbox = KoRect() );
67 void parseColor( VColor &, const TQString & );
68 TQColor parseColor( const TQString & );
69 double toPercentage( TQString );
70 double fromPercentage( TQString );
71 void setupTransform( const TQDomElement & );
72 void addGraphicContext();
73 TQDomDocument inpdoc;
74 TQDomDocument outdoc;
75 void convert();
76 VObject* createObject( const TQDomElement & );
77 void createText( VGroup *, const TQDomElement & );
78 void parseFont( const TQDomElement & );
79 // find object with given id in document
80 VObject* findObject( const TQString &name );
81 // find object with given id in given group
82 VObject* findObject( const TQString &name, VGroup * );
83
84private:
85 VDocument m_document;
86 TQPtrStack<XAMLGraphicsContext> m_gc;
87 TQMap<TQString, GradientHelper> m_gradients;
88 TQMap<TQString, TQDomElement> m_paths;
89 KoRect m_outerRect;
90};
91
92#endif