1 /* DocumentElement: The items we are collecting to be put into the Writer
2  * document: paragraph and spans of text, as well as section breaks.
3  *
4  * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser 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 program 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
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19  *
20  * For further information visit http://libwpd.sourceforge.net
21  *
22  */
23 
24 /* "This product is not manufactured, approved, or supported by
25  * Corel Corporation or Corel Corporation Limited."
26  */
27 
28 #ifndef _DOCUMENTELEMENT_H
29 #define _DOCUMENTELEMENT_H
30 #if defined _MSC_VER
31 #pragma warning( push, 1 )
32 #endif
33 #include <libwpd/libwpd.h>
34 #include <libwpd/WPXProperty.h>
35 #include <libwpd/WPXString.h>
36 #if defined _MSC_VER
37 #pragma warning( pop )
38 #endif
39 #include <vector>
40 
41 #include "DocumentHandler.hxx"
42 
43 class DocumentElement
44 {
45 public:
~DocumentElement()46 	virtual ~DocumentElement() {}
47 	virtual void write(DocumentHandler *pHandler) const = 0;
print() const48 	virtual void print() const {}
49 };
50 
51 class TagElement : public DocumentElement
52 {
53 public:
TagElement(const char * szTagName)54 	TagElement(const char *szTagName) : msTagName(szTagName) {}
getTagName() const55 	const WPXString & getTagName() const { return msTagName; }
56 	virtual void print() const;
57 private:
58 	WPXString msTagName;
59 };
60 
61 class TagOpenElement : public TagElement
62 {
63 public:
TagOpenElement(const char * szTagName)64 	TagOpenElement(const char *szTagName) : TagElement(szTagName) {}
~TagOpenElement()65 	~TagOpenElement() {}
66 	void addAttribute(const char *szAttributeName, const WPXString &sAttributeValue);
67 	virtual void write(DocumentHandler *pHandler) const;
68 	virtual void print () const;
69 private:
70 	WPXPropertyList maAttrList;
71 };
72 
73 class TagCloseElement : public TagElement
74 {
75 public:
TagCloseElement(const char * szTagName)76 	TagCloseElement(const char *szTagName) : TagElement(szTagName) {}
77 	virtual void write(DocumentHandler *pHandler) const;
78 };
79 
80 class CharDataElement : public DocumentElement
81 {
82 public:
CharDataElement(const char * sData)83 	CharDataElement(const char *sData) : DocumentElement(), msData(sData) {}
84 	virtual void write(DocumentHandler *pHandler) const;
85 private:
86 	WPXString msData;
87 };
88 
89 class TextElement : public DocumentElement
90 {
91 public:
92 	TextElement(const WPXString & sTextBuf);
93 	virtual void write(DocumentHandler *pHandler) const;
94 
95 private:
96 	WPXString msTextBuf;
97 };
98 
99 #endif
100