/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef SVGPARSER_H
#define SVGPARSER_H

#include <qobject.h>
#include <qstring.h>

class ElementNode;
class QDomNode;
class QDomElement;
class DocumentElement;
class AnimatedTransformList;
class URIReference;
class AnimateElement;
class Stylable;
class GroupElement;
class FillAttribute;
class StrokeAttribute;
class StopElement;
/**
@author Hans Oischinger
*/
class SVGParser : public QObject
{
public:
  SVGParser();
  ~SVGParser();

  DocumentElement *getDocument() const { return m_rootDoc; }
  bool startDocument( QString path );

protected:
  void parseElement(QDomNode n, ElementNode* parent, GroupElement inheritedStyle) const;

  ElementNode* createRectElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createCircleElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createEllipseElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createLineElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createPathElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createPolygonElement(QDomElement e, GroupElement& inheritedStyle) const;

  ElementNode* createGroupElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createDefsElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createUseElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createAnimateElement(QDomElement e) const;

  ElementNode* createGradientElement(QDomElement e, GroupElement& inheritedStyle) const;
  ElementNode* createGradientStopElement(QDomElement e, GroupElement& inheritedStyle) const;

  AnimateElement* createAnimateTransformElement(QDomElement e) const;
  AnimateElement* createAnimateLengthElement(QDomElement e) const;

  bool setStyleAttributes(Stylable* element, QDomElement e, GroupElement& inheritedStyle) const;
  void parseFillPaint(FillAttribute& element, QString paint) const;
  void parseStrokePaint(StrokeAttribute& element, QString paint) const;
  URIReference* createRefAttribute(const QString& uri, bool referenceParentIfInvalid ) const;
  void createTransformList(QDomElement e, AnimatedTransformList& aList) const;
  void setCommonElementAttributes(QDomElement domElement, ElementNode* element) const;

private:
  DocumentElement *m_rootDoc;
};

#endif
