Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef X2C_XMLELEM_HXX
21 : : #define X2C_XMLELEM_HXX
22 : :
23 : :
24 : :
25 : : // USED SERVICES
26 : : // BASE CLASSES
27 : : // COMPONENTS
28 : : #include "../support/sistr.hxx"
29 : : #include "../support/list.hxx"
30 : : #include "../support/syshelp.hxx"
31 : : // PARAMETERS
32 : :
33 : :
34 : : class X2CParser;
35 : : class HtmlCreator;
36 : :
37 : : class XmlElement
38 : : {
39 : : public:
40 [ - + ]: 234 : virtual ~XmlElement() {}
41 : : virtual void Parse(
42 : : X2CParser & io_rParser ) = 0;
43 : : virtual void Write2Html(
44 : : HtmlCreator & io_rHC ) const = 0;
45 : :
46 : 364 : const Simstr & Name() const { return sName; }
47 : :
48 : : protected:
49 : : XmlElement(
50 : : const char * i_sName );
51 : : private:
52 : : Simstr sName;
53 : : };
54 : :
55 : :
56 : : class MultipleElement : public XmlElement
57 : : {
58 : : public:
59 : : ~MultipleElement();
60 : :
61 : : virtual XmlElement *
62 : : FindChild(
63 : : const Simstr & i_sChildName );
64 : :
65 : :
66 : : protected:
67 : : typedef DynamicList<XmlElement> ChildList;
68 : :
69 : : MultipleElement(
70 : : const char * i_sName );
71 : :
72 : : void AddChild(
73 : : XmlElement & let_drElement );
74 : :
75 : 0 : const ChildList & Children() const { return aChildren; }
76 : 58 : ChildList & Children() { return aChildren; }
77 : :
78 : : private:
79 : : ChildList aChildren;
80 : : };
81 : :
82 [ - + ]: 20 : class SequenceElement : public MultipleElement
83 : : {
84 : : public:
85 : : virtual void Parse(
86 : : X2CParser & io_rParser );
87 : : virtual void Write2Html(
88 : : HtmlCreator & io_rHC ) const;
89 : :
90 : : protected:
91 : : SequenceElement(
92 : : const char * i_sName,
93 : : unsigned i_nIndexNameElement = 0 );
94 : : private:
95 : : unsigned nIndexNameElement;
96 : : };
97 : :
98 [ - + ]: 40 : class FreeChoiceElement : public MultipleElement
99 : : {
100 : : public:
101 : : FreeChoiceElement();
102 : : using MultipleElement::AddChild;
103 : :
104 : : virtual void Parse(
105 : : X2CParser & io_rParser );
106 : : virtual void Write2Html(
107 : : HtmlCreator & io_rHC ) const;
108 : : };
109 : :
110 [ - + ]: 2 : class ListElement : public MultipleElement
111 : : {
112 : : public:
113 : : typedef XmlElement * (*F_CREATE)(const Simstr &);
114 : :
115 : : ListElement(
116 : : const char * i_sElementsName,
117 : : F_CREATE i_fCreateNewElement );
118 : :
119 : : virtual void Parse(
120 : : X2CParser & io_rParser );
121 : : virtual void Write2Html(
122 : : HtmlCreator & io_rHC ) const;
123 : : virtual XmlElement *
124 : : Create_and_Add_NewElement();
125 : : private:
126 : : F_CREATE fCreateNewElement;
127 : : };
128 : :
129 [ - + ]: 154 : class TextElement : public XmlElement
130 : : {
131 : : public:
132 : 0 : E_LinkType LinkType() const { return eLinkType; }
133 : 142 : bool IsReversedName() const { return bReverseName; }
134 : : protected:
135 : : TextElement(
136 : : const char * i_sName,
137 : : E_LinkType i_eLinkType,
138 : : bool i_bReverseName );
139 : : private:
140 : : E_LinkType eLinkType;
141 : : bool bReverseName;
142 : : };
143 : :
144 [ + - ][ - + ]: 164 : class SglTextElement : public TextElement
145 : : {
146 : : public:
147 : : SglTextElement(
148 : : const char * i_sName,
149 : : E_LinkType i_eLinkType,
150 : : bool i_bReverseName );
151 : :
152 : : virtual void Parse(
153 : : X2CParser & io_rParser );
154 : : virtual void Write2Html(
155 : : HtmlCreator & io_rHC ) const;
156 : : virtual const Simstr &
157 : 0 : Data() const { return sContent; }
158 : : private:
159 : : Simstr sContent;
160 : : };
161 : :
162 [ + - ][ - + ]: 106 : class MultipleTextElement : public TextElement
163 : : {
164 : : public:
165 : : MultipleTextElement(
166 : : const char * i_sName,
167 : : E_LinkType i_eLinkType,
168 : : bool i_bReverseName );
169 : :
170 : : virtual void Parse(
171 : : X2CParser & io_rParser );
172 : : virtual void Write2Html(
173 : : HtmlCreator & io_rHC ) const;
174 : : virtual const Simstr &
175 : : Data(
176 : : unsigned i_nNr ) const;
177 : 20 : virtual unsigned Size() const { return aContent.size(); }
178 : :
179 : : private:
180 : : List<Simstr> aContent;
181 : : };
182 : :
183 [ - + ]: 38 : class EmptyElement : public XmlElement
184 : : {
185 : : protected:
186 : : EmptyElement(
187 : : const char * i_sName );
188 : : };
189 : :
190 [ + - ][ + - ]: 36 : class SglAttrElement : public EmptyElement
[ - + ]
191 : : {
192 : : public:
193 : : SglAttrElement(
194 : : const char * i_sName,
195 : : const char * i_sAttrName );
196 : :
197 : : virtual void Parse(
198 : : X2CParser & io_rParser );
199 : : virtual void Write2Html(
200 : : HtmlCreator & io_rHC ) const;
201 : : private:
202 : : Simstr sAttrName;
203 : : Simstr sAttrValue;
204 : : };
205 : :
206 : :
207 [ + - ][ + - ]: 40 : class MultipleAttrElement : public EmptyElement
[ - + ]
208 : : {
209 : : public:
210 : : MultipleAttrElement(
211 : : const char * i_sName,
212 : : const char ** i_sAttrNames,
213 : : unsigned i_nSize );
214 : :
215 : : virtual void Parse(
216 : : X2CParser & io_rParser );
217 : : virtual void Write2Html(
218 : : HtmlCreator & io_rHC ) const;
219 : : private:
220 : : List<Simstr> aAttrNames;
221 : : List<Simstr> aAttrValues;
222 : : };
223 : :
224 : : // IMPLEMENTATION
225 : :
226 : :
227 : : #endif
228 : :
229 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|