DocumentElement.h
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., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 * For further information visit http://libwpd.sourceforge.net
22 *
23 */
24
25/* "This product is not manufactured, approved, or supported by
26 * Corel Corporation or Corel Corporation Limited."
27 */
28
29#ifndef _DOCUMENTELEMENT_H
30#define _DOCUMENTELEMENT_H
31
32#include <libwpd/libwpd.h>
33#include <vector>
34#include "shared_headers.h"
35#include "DocumentHandler.h"
36
37const float fDefaultSideMargin = 1.0f; // inches
38const float fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
39const float fDefaultPageHeight = 11.0f; // inches
40
41class DocumentElement
42{
43public:
44 virtual ~DocumentElement() {}
45 virtual void write(DocumentHandler &xHandler) const = 0;
46 virtual void print() const {}
47};
48
49class TagElement : public DocumentElement
50{
51public:
52 TagElement(const char *szTagName) : msTagName(szTagName) {}
53 const _SH_String & getTagName() const { return msTagName; }
54 virtual void print() const;
55private:
56 _SH_String msTagName;
57};
58
59class TagOpenElement : public TagElement
60{
61public:
62 TagOpenElement(const char *szTagName) : TagElement(szTagName) {}
63 ~TagOpenElement() {}
64 void addAttribute(const char *szAttributeName, const _SH_String &sAttributeValue);
65 virtual void write(DocumentHandler &xHandler) const;
66 virtual void print () const;
67private:
68 _SH_PropertyList maAttrList;
69};
70
71class TagCloseElement : public TagElement
72{
73public:
74 TagCloseElement(const char *szTagName) : TagElement(szTagName) {}
75 virtual void write(DocumentHandler &xHandler) const;
76};
77
78class CharDataElement : public DocumentElement
79{
80public:
81 CharDataElement(const char *sData) : DocumentElement(), msData(sData) {}
82 virtual void write(DocumentHandler &xHandler) const;
83private:
84 _SH_String msData;
85};
86
87class TextElement : public DocumentElement
88{
89public:
90 TextElement(const _SH_String & sTextBuf);
91 virtual void write(DocumentHandler &xHandler) const;
92
93private:
94 _SH_String msTextBuf;
95};
96
97#endif