bump product version to 7.6.3.2-android
[LibreOffice.git] / xmloff / source / forms / elementexport.hxx
blobe13edcc8c8c218d79fb354d99e6203ae5ca2880f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <memory>
25 #include <o3tl/sorted_vector.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
29 #include <xmloff/xmlexp.hxx>
30 #include "propertyexport.hxx"
31 #include "callbacks.hxx"
32 #include "controlelement.hxx"
33 #include "valueproperties.hxx"
35 class SvXMLElementExport;
36 namespace xmloff
39 //= OElementExport
40 class OElementExport : public OPropertyExport
42 protected:
43 css::uno::Sequence< css::script::ScriptEventDescriptor >
44 m_aEvents;
46 std::unique_ptr<SvXMLElementExport> m_pXMLElement; // XML element doing the concrete startElement etc.
48 public:
49 OElementExport(IFormsExportContext& _rContext,
50 const css::uno::Reference< css::beans::XPropertySet >& _rxProps,
51 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents);
52 virtual ~OElementExport();
54 void doExport();
56 protected:
57 /// get the name of the XML element
58 virtual const 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();
66 /** exports the events (as script:events tag)
68 void exportEvents();
70 /** add the service-name attribute to the export context
72 virtual void exportServiceNameAttribute();
74 /// start the XML element
75 virtual void implStartElement(const char* _pName);
77 /// ends the XML element
78 virtual void implEndElement();
81 //= OControlExport
82 /** Helper class for handling xml elements representing a form control
84 class OControlExport
85 :public OControlElement
86 ,public OValuePropertiesMetaData
87 ,public OElementExport
89 protected:
90 typedef o3tl::sorted_vector<sal_Int16> Int16Set;
91 // used below
93 OUString m_sControlId; // the control id to use when exporting
94 OUString m_sReferringControls; // list of referring controls (i.e. their id's)
95 sal_Int16 m_nClassId; // class id of the control we're representing
96 ElementType m_eType; // (XML) type of the control we're representing
97 CCAFlags m_nIncludeCommon; // common control attributes to include
98 DAFlags m_nIncludeDatabase; // common database attributes to include
99 SCAFlags m_nIncludeSpecial; // special attributes to include
100 EAFlags m_nIncludeEvents; // events to include
101 BAFlags m_nIncludeBindings; // binding attributes to include
103 std::unique_ptr<SvXMLElementExport> m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
105 public:
106 /** constructs an object capable of exporting controls
108 <p>You need at least two pre-requisites from outside: The control to be exported needs to have a class id
109 assigned, and you need the list control-ids of all the controls referring to this one as LabelControl.<br/>
110 This information can't be collected when known only the control itself and not it's complete context.</p>
112 @param _rControlId
113 the control id to use when exporting the control
114 @param _rReferringControls
115 the comma-separated list of control-ids of all the controls referring to this one as LabelControl
117 OControlExport(IFormsExportContext& _rContext,
118 const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
119 OUString _sControlId,
120 OUString _sReferringControls,
121 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
123 protected:
124 /// start the XML element
125 virtual void implStartElement(const char* _pName) override;
127 /// ends the XML element
128 virtual void implEndElement() override;
130 /// get the name of the outer XML element
131 virtual const char* getOuterXMLElementName() const;
133 // get the name of the XML element
134 virtual const char* getXMLElementName() const override;
136 /** examine the control. Some kind of CtorImpl.
138 virtual void examine() override;
140 /// exports the attributes for the outer element
141 void exportOuterAttributes();
143 /// exports the attributes for the inner element
144 void exportInnerAttributes();
146 /// export the attributes
147 virtual void exportAttributes() override;
149 /** writes everything which needs to be represented as sub tag
151 void exportSubTags() override;
153 /** adds the attributes which are handled via generic IPropertyHandlers
155 <p>In the future, this really should be *all* attributes, instead of this shitload of
156 hand-crafted code we have currently...</p>
158 void exportGenericHandlerAttributes();
160 /** adds common control attributes to the XMLExport context given
162 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
164 void exportCommonControlAttributes();
166 /** adds database attributes to the XMLExport context given
168 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
170 void exportDatabaseAttributes();
172 /** adds the XML attributes which are related to binding controls to
173 external values and/or list sources
175 void exportBindingAttributes();
177 /** adds attributes which are special to a control type to the export context's attribute list
179 void exportSpecialAttributes();
181 /** exports the ListSource property of a control as attribute
183 The ListSource property may be exported in different ways: For a ComboBox, it is an attribute
184 of the form:combobox element.
186 For a ListBox, it's an attribute if the ListSourceType states that the ListBox does <em>not</em>
187 display a value list. In case of a value list, the ListSource is not exported, and the pairs of
188 StringItem/ValueItem are exported as sub-elements.
190 This method does the attribute part: It exports the ListSource property as attribute, not caring
191 about whether the object is a ComboBox or a ListBox.
193 void exportListSourceAsAttribute();
195 /** exports the ListSource property of a control as XML elements
197 @see exportListSourceAsAttribute
199 void exportListSourceAsElements();
201 /** gets a Sequence&lt; sal_Int16 &gt; property value as set of sal_Int16's
202 @param _rPropertyName
203 the property name to use
204 @param _rOut
205 out parameter. The set of integers.
207 void getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut);
209 /** exports the attribute which descrives a cell value binding of a control
210 in a spreadsheet document
212 void exportCellBindingAttributes( bool _bIncludeListLinkageType );
214 /** exports the attribute(s) which bind this control to XForms */
215 void exportXFormsBindAttributes();
217 /** exports the attribute(s) which bind the list of a list
218 control to XForms */
219 void exportXFormsListAttributes();
221 /** exports the attribute(s) for an XForms submission */
222 void exportXFormsSubmissionAttributes();
224 /** exports the attribute which descrives a cell range which acts as list source for
225 a list-like control
227 void exportCellListSourceRange( );
229 /** exports the attribute(s) for the ImagePosition property
231 void exportImagePositionAttributes();
233 /** determines whether the control we're exporting has an active data binding.
235 Bindings which count here are:
236 <ul><li>an established connection to a database field</li>
237 <li>a binding to an external value supplier (<type scope="css::form::binding">XValueBinding</type>)</li>
238 </ul>
240 bool controlHasActiveDataBinding() const;
242 /** retrieves the string specifying the ListSource of a list or combo box
244 OUString getScalarListSourceValue() const;
246 /** determines whether the list entries (of a combo or list box) are supplied by the user
248 List entries may be
249 <ul><li>specified by the user</li>
250 <li>specified by an external list source (<type scope="css::form::binding">XListEntrySource</type>)</li>
251 <li>obtained from a database query (in various ways)</li>
252 </ul>
254 In the latter two cases, this method will return <FALSE/>
256 bool controlHasUserSuppliedListEntries() const;
259 //= OColumnExport
260 /** Helper class for exporting a grid column
262 class OColumnExport : public OControlExport
264 public:
265 /** ctor
266 @see OColumnExport::OColumnExport
268 OColumnExport(IFormsExportContext& _rContext,
269 const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
270 const OUString& _rControlId,
271 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
273 virtual ~OColumnExport() override;
275 protected:
276 // OControlExport overridables
277 virtual const char* getOuterXMLElementName() const override;
278 virtual void exportServiceNameAttribute() override;
279 virtual void exportAttributes() override;
281 // OElementExport overridables
282 virtual void examine() override;
285 //= OFormExport
286 /** Helper class for handling xml elements representing a form
288 <p>In opposite to the class <type>OControlExport</type>, OFormExport is unable to export a <em>complete</em>
289 form. Instead the client has to care for sub elements of the form itself.</p>
291 class OFormExport
292 :public OControlElement
293 ,public OElementExport
295 bool m_bCreateConnectionResourceElement;
296 public:
297 /** constructs an object capable of exporting controls
299 OFormExport(IFormsExportContext& _rContext,
300 const css::uno::Reference< css::beans::XPropertySet >& _rxForm,
301 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents
304 protected:
305 virtual const char* getXMLElementName() const override;
306 virtual void exportSubTags() override;
307 virtual void exportAttributes() override;
309 } // namespace xmloff
311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */