xref: /aoo42x/main/xml2cmp/source/xcd/xmlelem.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef X2C_XMLELEM_HXX
29*cdf0e10cSrcweir #define X2C_XMLELEM_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // USED SERVICES
34*cdf0e10cSrcweir 	// BASE CLASSES
35*cdf0e10cSrcweir 	// COMPONENTS
36*cdf0e10cSrcweir #include "../support/sistr.hxx"
37*cdf0e10cSrcweir #include "../support/list.hxx"
38*cdf0e10cSrcweir #include "../support/syshelp.hxx"
39*cdf0e10cSrcweir 	// PARAMETERS
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir class X2CParser;
43*cdf0e10cSrcweir class HtmlCreator;
44*cdf0e10cSrcweir class Index;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir class XmlElement
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir   public:
49*cdf0e10cSrcweir 	virtual				~XmlElement() {}
50*cdf0e10cSrcweir 	virtual void        Parse(
51*cdf0e10cSrcweir 							X2CParser &			io_rParser ) = 0;
52*cdf0e10cSrcweir 	virtual void        Write2Html(
53*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const = 0;
54*cdf0e10cSrcweir 	virtual void        Insert2Index(
55*cdf0e10cSrcweir 							Index & 	        o_rIndex ) const;			// Default: Does nothing, but can be overwritten.
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir //	virtual void        Put2Dependy() = 0;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 	const Simstr &		Name() const			{ return sName; }
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir   protected:
62*cdf0e10cSrcweir 						XmlElement(
63*cdf0e10cSrcweir 							const char *		i_sName );
64*cdf0e10cSrcweir   private:
65*cdf0e10cSrcweir 	Simstr 				sName;
66*cdf0e10cSrcweir };
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir class MultipleElement : public XmlElement
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir   public:
72*cdf0e10cSrcweir 						~MultipleElement();
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	virtual XmlElement *
75*cdf0e10cSrcweir 						FindChild(
76*cdf0e10cSrcweir 							const Simstr &		i_sChildName );
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir   protected:
80*cdf0e10cSrcweir 	typedef DynamicList<XmlElement>			ChildList;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 						MultipleElement(
83*cdf0e10cSrcweir 							const char *		i_sName );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	void				AddChild(
86*cdf0e10cSrcweir 							XmlElement &		let_drElement );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	const ChildList &	Children() const		{ return aChildren; }
89*cdf0e10cSrcweir 	ChildList &			Children()				{ return aChildren; }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir   private:
92*cdf0e10cSrcweir 	ChildList			aChildren;
93*cdf0e10cSrcweir };
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir class SequenceElement : public MultipleElement
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir   public:
98*cdf0e10cSrcweir 	virtual void        Parse(
99*cdf0e10cSrcweir 							X2CParser &			io_rParser );
100*cdf0e10cSrcweir 	virtual void        Write2Html(
101*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir   protected:
104*cdf0e10cSrcweir 						SequenceElement(
105*cdf0e10cSrcweir 							const char *		i_sName,
106*cdf0e10cSrcweir 							unsigned            i_nIndexNameElement = 0 );
107*cdf0e10cSrcweir   private:
108*cdf0e10cSrcweir 	unsigned			nIndexNameElement;
109*cdf0e10cSrcweir };
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir class FreeChoiceElement : public MultipleElement
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir   public:
114*cdf0e10cSrcweir 						FreeChoiceElement();
115*cdf0e10cSrcweir 	using				MultipleElement::AddChild;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	virtual void        Parse(
118*cdf0e10cSrcweir 							X2CParser &			io_rParser );
119*cdf0e10cSrcweir 	virtual void        Write2Html(
120*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
121*cdf0e10cSrcweir };
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir class ListElement : public MultipleElement
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir   public:
126*cdf0e10cSrcweir 	typedef XmlElement * (*F_CREATE)(const Simstr &);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 						ListElement(
129*cdf0e10cSrcweir 							const char *		i_sElementsName,
130*cdf0e10cSrcweir 							F_CREATE            i_fCreateNewElement );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 	virtual void        Parse(
133*cdf0e10cSrcweir 							X2CParser &			io_rParser );
134*cdf0e10cSrcweir 	virtual void        Write2Html(
135*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
136*cdf0e10cSrcweir 	virtual XmlElement *
137*cdf0e10cSrcweir     					Create_and_Add_NewElement();
138*cdf0e10cSrcweir   private:
139*cdf0e10cSrcweir 	F_CREATE			fCreateNewElement;
140*cdf0e10cSrcweir };
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir class TextElement : public XmlElement
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir   public:
145*cdf0e10cSrcweir 	E_LinkType			LinkType() const		{ return eLinkType; }
146*cdf0e10cSrcweir 	bool			    IsReversedName() const	{ return bReverseName; }
147*cdf0e10cSrcweir   protected:
148*cdf0e10cSrcweir 						TextElement(
149*cdf0e10cSrcweir 							const char *		i_sName,
150*cdf0e10cSrcweir 							E_LinkType			i_eLinkType,
151*cdf0e10cSrcweir 							bool				i_bReverseName );
152*cdf0e10cSrcweir   private:
153*cdf0e10cSrcweir 	E_LinkType			eLinkType;
154*cdf0e10cSrcweir 	bool				bReverseName;
155*cdf0e10cSrcweir };
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir class SglTextElement : public TextElement
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir   public:
160*cdf0e10cSrcweir 						SglTextElement(
161*cdf0e10cSrcweir 							const char *		i_sName,
162*cdf0e10cSrcweir 							E_LinkType			i_eLinkType,
163*cdf0e10cSrcweir 							bool				i_bReverseName );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	virtual void        Parse(
166*cdf0e10cSrcweir 							X2CParser &			io_rParser );
167*cdf0e10cSrcweir 	virtual void        Write2Html(
168*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
169*cdf0e10cSrcweir 	virtual const Simstr &
170*cdf0e10cSrcweir 						Data() const			{ return sContent; }
171*cdf0e10cSrcweir   private:
172*cdf0e10cSrcweir 	Simstr				sContent;
173*cdf0e10cSrcweir };
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir class MultipleTextElement : public TextElement
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir   public:
178*cdf0e10cSrcweir 						MultipleTextElement(
179*cdf0e10cSrcweir 							const char *		i_sName,
180*cdf0e10cSrcweir 							E_LinkType			i_eLinkType,
181*cdf0e10cSrcweir 							bool				i_bReverseName );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	virtual void        Parse(
184*cdf0e10cSrcweir 							X2CParser &			io_rParser );
185*cdf0e10cSrcweir 	virtual void        Write2Html(
186*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
187*cdf0e10cSrcweir 	virtual const Simstr &
188*cdf0e10cSrcweir 						Data(
189*cdf0e10cSrcweir 							unsigned 			i_nNr ) const;
190*cdf0e10cSrcweir 	virtual unsigned	Size() const			{ return aContent.size(); }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir   private:
193*cdf0e10cSrcweir 	List<Simstr>		aContent;
194*cdf0e10cSrcweir };
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir class EmptyElement : public XmlElement
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir   protected:
199*cdf0e10cSrcweir 						EmptyElement(
200*cdf0e10cSrcweir 							const char *		i_sName );
201*cdf0e10cSrcweir };
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir class SglAttrElement : public EmptyElement
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir   public:
206*cdf0e10cSrcweir 						SglAttrElement(
207*cdf0e10cSrcweir 							const char *		i_sName,
208*cdf0e10cSrcweir 							const char *		i_sAttrName );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	virtual void        Parse(
211*cdf0e10cSrcweir 							X2CParser &			io_rParser );
212*cdf0e10cSrcweir 	virtual void        Write2Html(
213*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
214*cdf0e10cSrcweir   private:
215*cdf0e10cSrcweir 	Simstr				sAttrName;
216*cdf0e10cSrcweir 	Simstr				sAttrValue;
217*cdf0e10cSrcweir };
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir class MultipleAttrElement : public EmptyElement
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir   public:
223*cdf0e10cSrcweir 						MultipleAttrElement(
224*cdf0e10cSrcweir 							const char *		i_sName,
225*cdf0e10cSrcweir 							const char **		i_sAttrNames,
226*cdf0e10cSrcweir 							unsigned			i_nSize );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	virtual void        Parse(
229*cdf0e10cSrcweir 							X2CParser &			io_rParser );
230*cdf0e10cSrcweir 	virtual void        Write2Html(
231*cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
232*cdf0e10cSrcweir   private:
233*cdf0e10cSrcweir 	List<Simstr>		aAttrNames;
234*cdf0e10cSrcweir 	List<Simstr>		aAttrValues;
235*cdf0e10cSrcweir };
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir // IMPLEMENTATION
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir #endif
241*cdf0e10cSrcweir 
242