
/*
** Header file for inclusion with kword_xml2latex.c
**
** Copyright (C) 2000-2002 Robert JACOLIN
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library 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
** Library General Public License for more details.
**
** To receive a copy of the GNU Library General Public License, write to the
** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
**
*/

#ifndef __LATEX_XMLPARSER_H__
#define __LATEX_XMLPARSER_H__

#include "tqstring.h"
#include "tqdom.h"
#include "config.h"

class FileHeader;
class Document;
class KoStore;

/**
 * This class supply some convenients methods to access to a DOM tree.
 * TODO: implement singleton.
 * TODO: remove config in constructors, static variables.
 * @author robert jacolin
 */
class XmlParser
{
		/** The Koffice app document stored in a XML DOM Tree. */
	TQDomDocument _document;
	/** The koffice document (maindoc, picture, ...). */
	static KoStore* _in;
	/** Configuration */
	Config *_config;

	protected:
		/* All the inherit class must be have a link with
		 * the header to specify to use special package
		 */
		//static FileHeader *_fileHeader;
		static Document   *_root;
		/** Latex output file */
		static TQString _filename;

	public:
		XmlParser(Config*, TQString);
    XmlParser(Config*, TQByteArray);	/* deprecated */
		XmlParser(Config*, const KoStore*);
		XmlParser();
		virtual ~XmlParser();

		TQString     getFilename     () const { return _filename;            }
		TQString     getDocument     () const { return _document.toString(); }
		Document*   getRoot         () const { return _root;                }
		//FileHeader* getFileHeader   () const { return _fileHeader; }
		KoStore*    getStorage      () const { return _in; }
		TQString     getChildName(TQDomNode, int);
		TQDomNode    getChild(TQDomNode, TQString);
		TQDomNode    getChild(TQDomNode, TQString, int);
		TQDomNode    getChild(TQDomNode, int);
		TQString     getData(TQDomNode, int);
		int         getNbChild(TQDomNode, TQString);
		int         getNbChild(TQDomNode);
		TQString     getAttr(TQDomNode, TQString) const;
		bool        isChild(TQDomNode, TQString);

		//void setFileHeader(FileHeader* h) { _fileHeader = h; }
		void setRoot      (Document*   r) { _root       = r; }

		TQDomNode init() { return _document.documentElement(); }

};

#endif /* __LATEX_XMLPARSER_H__ */

