/***************************************************************************
 *   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 SVGEXPORTVISITOR_H
#define SVGEXPORTVISITOR_H

#include "visitor.h"
#include <qvaluestack.h>

class QFile;
class QTextStream;
class QString;
class Stylable;
class Transformable;
class TransformList;
class Gradient;
class Transform;
class SVGSerializer;
/**
@author Hans Oischinger
*/
class SVGExportVisitor : public Visitor
{
public:
  SVGExportVisitor(QFile& file);
  ~SVGExportVisitor();

  virtual bool visit( VectorElement& element );
  virtual bool visit( GroupElement& element );
  virtual bool visit( DefsElement& element );
  virtual bool visit( UseElement& element );
  virtual bool visit( StopElement& element );
  virtual bool visit( LinearGradient& element );
  virtual bool visit( RadialGradient& element );
  virtual bool visit( AnimateTransformElement& element );
  virtual bool visit( AnimateLengthElement& element );
  virtual bool visit( AnimateNumberElement& element );

protected:
  bool processStylable( Stylable& element );
  bool processTransformable( Transformable& element );
  bool processGradient( Gradient& element );
  bool processElementNode( ElementNode& element );
  bool processAnimateElement( AnimateElement& element );

  /**
   * Serializes a Transformlist to the SVG <transform-list> data type
   */
  const QString serializeTransformList( const TransformList& ) const;
  /**
   * Serializes a Transformattribute and returns the value needed for 
   * from or to values in the animate element
   */
  const QString serializeTransformContents( const Transform& ) const;

private:
  QTextStream* m_stream;
  QValueStack<QString> m_stack;
  unsigned int m_level;
  SVGSerializer* m_attrser;
};

#endif
