1 /* This file is part of the KDE project 2 * Copyright (C) 2002-2003,2005 Rob Buis <buis@kde.org> 3 * Copyright (C) 2005-2006 Tim Beaulen <tbscope@gmail.com> 4 * Copyright (C) 2005,2007-2009 Jan Hambrecht <jaham@gmx.net> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef SVGSTYLEPARSER_H 23 #define SVGSTYLEPARSER_H 24 25 #include "flake_export.h" 26 #include <QMap> 27 28 typedef QMap<QString, QString> SvgStyles; 29 30 class SvgLoadingContext; 31 class SvgGraphicsContext; 32 class KoXmlElement; 33 class QColor; 34 class QGradient; 35 36 class FLAKE_EXPORT SvgStyleParser 37 { 38 public: 39 explicit SvgStyleParser(SvgLoadingContext &context); 40 ~SvgStyleParser(); 41 42 /// Parses specified style attributes 43 void parseStyle(const SvgStyles &styles); 44 45 /// Parses font attributes 46 void parseFont(const SvgStyles &styles); 47 48 /// Parses a color attribute 49 bool parseColor(QColor &, const QString &); 50 51 /// Parses gradient color stops 52 void parseColorStops(QGradient *, const KoXmlElement &); 53 54 /// Creates style map from given xml element 55 SvgStyles collectStyles(const KoXmlElement &); 56 57 /// Merges two style elements, returning the merged style 58 SvgStyles mergeStyles(const SvgStyles &, const SvgStyles &); 59 60 /// Merges two style elements, returning the merged style 61 SvgStyles mergeStyles(const KoXmlElement &, const KoXmlElement &); 62 63 private: 64 65 /// Parses a single style attribute 66 void parsePA(SvgGraphicsContext *, const QString &, const QString &); 67 68 /// Returns inherited attribute value for specified element 69 QString inheritedAttribute(const QString &attributeName, const KoXmlElement &e); 70 71 class Private; 72 Private * const d; 73 }; 74 75 #endif // SVGSTYLEPARSER_H 76