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 _XMLOFF_ELEMENTEXPORT_HXX_
21 : : #define _XMLOFF_ELEMENTEXPORT_HXX_
22 : :
23 : : #include <com/sun/star/beans/XPropertySet.hpp>
24 : : #include <com/sun/star/container/XIndexAccess.hpp>
25 : : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
26 : : #include "propertyexport.hxx"
27 : : #include "callbacks.hxx"
28 : : #include "controlelement.hxx"
29 : : #include "valueproperties.hxx"
30 : :
31 : : class SvXMLElementExport;
32 : : //.........................................................................
33 : : namespace xmloff
34 : : {
35 : : //.........................................................................
36 : :
37 : : //=====================================================================
38 : : //= OElementExport
39 : : //=====================================================================
40 : : class OElementExport : public OPropertyExport
41 : : {
42 : : protected:
43 : : ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >
44 : : m_aEvents;
45 : :
46 : : SvXMLElementExport* m_pXMLElement; // XML element doing the concrete startElement etc.
47 : :
48 : : public:
49 : : OElementExport(IFormsExportContext& _rContext,
50 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxProps,
51 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rEvents);
52 : : virtual ~OElementExport();
53 : :
54 : : void doExport();
55 : :
56 : : protected:
57 : : /// get the name of the XML element
58 : : virtual const sal_Char* getXMLElementName() const = 0;
59 : : /// examine the element we're exporting
60 : : virtual void examine();
61 : : /// export the attributes
62 : : virtual void exportAttributes();
63 : : /// export any sub tags
64 : : virtual void exportSubTags();
65 : :
66 : : /** exports the events (as script:events tag)
67 : : */
68 : : void exportEvents();
69 : :
70 : : /** add the service-name attribute to the export context
71 : : */
72 : : virtual void exportServiceNameAttribute();
73 : :
74 : : /// start the XML element
75 : : virtual void implStartElement(const sal_Char* _pName);
76 : :
77 : : /// ends the XML element
78 : : virtual void implEndElement();
79 : : };
80 : :
81 : : //=====================================================================
82 : : //= OControlExport
83 : : //=====================================================================
84 : : /** Helper class for handling xml elements representing a form control
85 : : */
86 : : class OControlExport
87 : : :public OControlElement
88 : : ,public OValuePropertiesMetaData
89 : : ,public OElementExport
90 : : {
91 : : protected:
92 : : DECLARE_STL_STDKEY_SET(sal_Int16, Int16Set);
93 : : // used below
94 : :
95 : : ::rtl::OUString m_sControlId; // the control id to use when exporting
96 : : ::rtl::OUString m_sReferringControls; // list of referring controls (i.e. their id's)
97 : : sal_Int16 m_nClassId; // class id of the control we're representing
98 : : ElementType m_eType; // (XML) type of the control we're representing
99 : : sal_Int32 m_nIncludeCommon; // common control attributes to include
100 : : sal_Int32 m_nIncludeDatabase; // common database attributes to include
101 : : sal_Int32 m_nIncludeSpecial; // special attributes to include
102 : : sal_Int32 m_nIncludeEvents; // events to include
103 : : sal_Int32 m_nIncludeBindings; // binding attributes to include
104 : :
105 : : SvXMLElementExport* m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
106 : :
107 : : public:
108 : : /** constructs an object capable of exporting controls
109 : :
110 : : <p>You need at least two pre-requisites from outside: The control to be exported needs to have a class id
111 : : assigned, and you need the list control-ids of all the controls referring to this one as LabelControl.<br/>
112 : : This information can't be collected when known only the control itself and not it's complete context.</p>
113 : :
114 : : @param _rControlId
115 : : the control id to use when exporting the control
116 : : @param _rReferringControls
117 : : the comma-separated list of control-ids of all the controls referring to this one as LabelControl
118 : : */
119 : : OControlExport(IFormsExportContext& _rContext,
120 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
121 : : const ::rtl::OUString& _rControlId,
122 : : const ::rtl::OUString& _rReferringControls,
123 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents);
124 : : ~OControlExport();
125 : :
126 : : protected:
127 : : /// start the XML element
128 : : virtual void implStartElement(const sal_Char* _pName);
129 : :
130 : : /// ends the XML element
131 : : virtual void implEndElement();
132 : :
133 : : /// get the name of the outer XML element
134 : : virtual const sal_Char* getOuterXMLElementName() const;
135 : :
136 : : // get the name of the XML element
137 : : virtual const sal_Char* getXMLElementName() const;
138 : :
139 : : /** examine the control. Some kind of CtorImpl.
140 : : */
141 : : virtual void examine();
142 : :
143 : : /// exports the attributes for the outer element
144 : : void exportOuterAttributes();
145 : :
146 : : /// exports the attributes for the inner element
147 : : void exportInnerAttributes();
148 : :
149 : : /// export the attributes
150 : : virtual void exportAttributes();
151 : :
152 : : /** writes everything which needs to be represented as sub tag
153 : : */
154 : : void exportSubTags() throw (::com::sun::star::uno::Exception);
155 : :
156 : : /** adds the attributes which are handled via generic IPropertyHandlers
157 : :
158 : : <p>In the future, this really should be *all* attribiutes, instead of this shitload of
159 : : hand-crafted code we have currently ...</p>
160 : : */
161 : : void exportGenericHandlerAttributes();
162 : :
163 : : /** adds common control attributes to the XMLExport context given
164 : :
165 : : <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
166 : : */
167 : : void exportCommonControlAttributes();
168 : :
169 : : /** adds database attributes to the XMLExport context given
170 : :
171 : : <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
172 : : */
173 : : void exportDatabaseAttributes();
174 : :
175 : : /** adds the XML attributes which are related to binding controls to
176 : : external values and/or list sources
177 : : */
178 : : void exportBindingAtributes();
179 : :
180 : : /** adds attributes which are special to a control type to the export context's attribute list
181 : : */
182 : : void exportSpecialAttributes();
183 : :
184 : : /** exports the ListSource property of a control as attribute
185 : :
186 : : The ListSource property may be exported in different ways: For a ComboBox, it is an attribute
187 : : of the form:combobox element.
188 : :
189 : : For a ListBox, it's an attribute if the ListSourceType states that the ListBox does <em>not</em>
190 : : display a value list. In case of a value list, the ListSource is not exported, and the pairs of
191 : : StringItem/ValueItem are exported as sub-elements.
192 : :
193 : : This method does the attribute part: It exports the ListSource property as attribute, not caring
194 : : about whether the object is a ComboBox or a ListBox.
195 : : */
196 : : void exportListSourceAsAttribute();
197 : :
198 : : /** exports the ListSource property of a control as XML elements
199 : :
200 : : @see exportListSourceAsAttribute
201 : : */
202 : : void exportListSourceAsElements();
203 : :
204 : : /** get's a Sequence< sal_Int16 > property value as set of sal_Int16's
205 : : @param _rPropertyName
206 : : the property name to use
207 : : @param _rOut
208 : : out parameter. The set of integers.
209 : : */
210 : : void getSequenceInt16PropertyAsSet(const ::rtl::OUString& _rPropertyName, Int16Set& _rOut);
211 : :
212 : : /** exports the attribute which descrives a cell value binding of a control
213 : : in a spreadsheet document
214 : : */
215 : : void exportCellBindingAttributes( bool _bIncludeListLinkageType );
216 : :
217 : : /** exports the attribute(s) which bind this control to XForms */
218 : : void exportXFormsBindAttributes();
219 : :
220 : : /** exports the attribute(s) which bind the list of a list
221 : : control to XForms */
222 : : void exportXFormsListAttributes();
223 : :
224 : : /** exports the attribute(s) for an XForms submission */
225 : : void exportXFormsSubmissionAttributes();
226 : :
227 : : /** exports the attribute which descrives a cell range which acts as list source for
228 : : a list-like control
229 : : */
230 : : void exportCellListSourceRange( );
231 : :
232 : : /** exports the attribut(s) for the ImagePosition property
233 : : */
234 : : void exportImagePositionAttributes();
235 : :
236 : : /** determines whether the control we're exporting has an active data binding.
237 : :
238 : : Bindings which count here are:
239 : : <ul><li>an established connection to a database field</li>
240 : : <li>a binding to an external value supplier (<type scope="com::sun::star::form::binding">XValueBinding</type>)</li>
241 : : </ul>
242 : : */
243 : : bool controlHasActiveDataBinding() const;
244 : :
245 : : /** retrieves the string specifying the ListSource of a list or combo box
246 : : */
247 : : ::rtl::OUString getScalarListSourceValue() const;
248 : :
249 : : /** determines whether the list entries (of a combo or list box) are supplied by the user
250 : :
251 : : List entries may be
252 : : <ul><li>specified by the user</li>
253 : : <li>specified by an external list source (<type scope="com::sun::star::form::binding">XListEntrySource</type>)</li>
254 : : <li>obtained from a database query (in various ways)</li>
255 : : </ul>
256 : :
257 : : In the latter two cases, this method will return <FALSE/>
258 : : */
259 : : bool controlHasUserSuppliedListEntries() const;
260 : : };
261 : :
262 : : //=====================================================================
263 : : //= OColumnExport
264 : : //=====================================================================
265 : : /** Helper class for exporting a grid column
266 : : */
267 : : class OColumnExport : public OControlExport
268 : : {
269 : : public:
270 : : /** ctor
271 : : @see OColumnExport::OColumnExport
272 : : */
273 : : OColumnExport(IFormsExportContext& _rContext,
274 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
275 : : const ::rtl::OUString& _rControlId,
276 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents);
277 : :
278 : : ~OColumnExport();
279 : :
280 : : protected:
281 : : // OControlExport overridables
282 : : virtual const sal_Char* getOuterXMLElementName() const;
283 : : virtual void exportServiceNameAttribute();
284 : : virtual void exportAttributes();
285 : :
286 : : // OElementExport overridables
287 : : virtual void examine();
288 : : };
289 : :
290 : : //=====================================================================
291 : : //= OFormExport
292 : : //=====================================================================
293 : : /** Helper class for handling xml elements representing a form
294 : :
295 : : <p>In opposite to the class <type>OControlExport</type>, OFormExport is unable to export a <em>complete</em>
296 : : form. Instead the client has to care for sub elements of the form itself.</p>
297 : : */
298 [ # # ]: 0 : class OFormExport
299 : : :public OControlElement
300 : : ,public OElementExport
301 : : {
302 : : sal_Bool m_bCreateConnectionResourceElement;
303 : : public:
304 : : /** constructs an object capable of exporting controls
305 : : */
306 : : OFormExport(IFormsExportContext& _rContext,
307 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm,
308 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents
309 : : );
310 : :
311 : : protected:
312 : : virtual const sal_Char* getXMLElementName() const;
313 : : virtual void exportSubTags();
314 : : virtual void exportAttributes();
315 : : };
316 : : //.........................................................................
317 : : } // namespace xmloff
318 : : //.........................................................................
319 : :
320 : : #endif // _XMLOFF_ELEMENTEXPORT_HXX_
321 : :
322 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|