Update ooo320-m1
[ooovba.git] / xml2cmp / source / xcd / xmlelem.hxx
blobcc74f5118573187f4b5a85954c0af8f3f6196519
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlelem.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef X2C_XMLELEM_HXX
32 #define X2C_XMLELEM_HXX
36 // USED SERVICES
37 // BASE CLASSES
38 // COMPONENTS
39 #include "../support/sistr.hxx"
40 #include "../support/list.hxx"
41 #include "../support/syshelp.hxx"
42 // PARAMETERS
45 class X2CParser;
46 class HtmlCreator;
47 class Index;
49 class XmlElement
51 public:
52 virtual ~XmlElement() {}
53 virtual void Parse(
54 X2CParser & io_rParser ) = 0;
55 virtual void Write2Html(
56 HtmlCreator & io_rHC ) const = 0;
57 virtual void Insert2Index(
58 Index & o_rIndex ) const; // Default: Does nothing, but can be overwritten.
60 // virtual void Put2Dependy() = 0;
62 const Simstr & Name() const { return sName; }
64 protected:
65 XmlElement(
66 const char * i_sName );
67 private:
68 Simstr sName;
72 class MultipleElement : public XmlElement
74 public:
75 ~MultipleElement();
77 virtual XmlElement *
78 FindChild(
79 const Simstr & i_sChildName );
82 protected:
83 typedef DynamicList<XmlElement> ChildList;
85 MultipleElement(
86 const char * i_sName );
88 void AddChild(
89 XmlElement & let_drElement );
91 const ChildList & Children() const { return aChildren; }
92 ChildList & Children() { return aChildren; }
94 private:
95 ChildList aChildren;
98 class SequenceElement : public MultipleElement
100 public:
101 virtual void Parse(
102 X2CParser & io_rParser );
103 virtual void Write2Html(
104 HtmlCreator & io_rHC ) const;
106 protected:
107 SequenceElement(
108 const char * i_sName,
109 unsigned i_nIndexNameElement = 0 );
110 private:
111 unsigned nIndexNameElement;
114 class FreeChoiceElement : public MultipleElement
116 public:
117 FreeChoiceElement();
118 using MultipleElement::AddChild;
120 virtual void Parse(
121 X2CParser & io_rParser );
122 virtual void Write2Html(
123 HtmlCreator & io_rHC ) const;
126 class ListElement : public MultipleElement
128 public:
129 typedef XmlElement * (*F_CREATE)(const Simstr &);
131 ListElement(
132 const char * i_sElementsName,
133 F_CREATE i_fCreateNewElement );
135 virtual void Parse(
136 X2CParser & io_rParser );
137 virtual void Write2Html(
138 HtmlCreator & io_rHC ) const;
139 virtual XmlElement *
140 Create_and_Add_NewElement();
141 private:
142 F_CREATE fCreateNewElement;
145 class TextElement : public XmlElement
147 public:
148 E_LinkType LinkType() const { return eLinkType; }
149 bool IsReversedName() const { return bReverseName; }
150 protected:
151 TextElement(
152 const char * i_sName,
153 E_LinkType i_eLinkType,
154 bool i_bReverseName );
155 private:
156 E_LinkType eLinkType;
157 bool bReverseName;
160 class SglTextElement : public TextElement
162 public:
163 SglTextElement(
164 const char * i_sName,
165 E_LinkType i_eLinkType,
166 bool i_bReverseName );
168 virtual void Parse(
169 X2CParser & io_rParser );
170 virtual void Write2Html(
171 HtmlCreator & io_rHC ) const;
172 virtual const Simstr &
173 Data() const { return sContent; }
174 private:
175 Simstr sContent;
178 class MultipleTextElement : public TextElement
180 public:
181 MultipleTextElement(
182 const char * i_sName,
183 E_LinkType i_eLinkType,
184 bool i_bReverseName );
186 virtual void Parse(
187 X2CParser & io_rParser );
188 virtual void Write2Html(
189 HtmlCreator & io_rHC ) const;
190 virtual const Simstr &
191 Data(
192 unsigned i_nNr ) const;
193 virtual unsigned Size() const { return aContent.size(); }
195 private:
196 List<Simstr> aContent;
199 class EmptyElement : public XmlElement
201 protected:
202 EmptyElement(
203 const char * i_sName );
206 class SglAttrElement : public EmptyElement
208 public:
209 SglAttrElement(
210 const char * i_sName,
211 const char * i_sAttrName );
213 virtual void Parse(
214 X2CParser & io_rParser );
215 virtual void Write2Html(
216 HtmlCreator & io_rHC ) const;
217 private:
218 Simstr sAttrName;
219 Simstr sAttrValue;
223 class MultipleAttrElement : public EmptyElement
225 public:
226 MultipleAttrElement(
227 const char * i_sName,
228 const char ** i_sAttrNames,
229 unsigned i_nSize );
231 virtual void Parse(
232 X2CParser & io_rParser );
233 virtual void Write2Html(
234 HtmlCreator & io_rHC ) const;
235 private:
236 List<Simstr> aAttrNames;
237 List<Simstr> aAttrValues;
240 // IMPLEMENTATION
243 #endif