Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / forms / elementexport.hxx
blobf3b2f0ac03a4e32cb9795a17e5f1d21936031051
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 #ifndef INCLUDED_XMLOFF_SOURCE_FORMS_ELEMENTEXPORT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_FORMS_ELEMENTEXPORT_HXX
23 #include <sal/config.h>
25 #include <set>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/container/XIndexAccess.hpp>
29 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
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 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 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();
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 sal_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 std::set<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 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 const OUString& _rControlId,
120 const OUString& _rReferringControls,
121 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
122 virtual ~OControlExport();
124 protected:
125 /// start the XML element
126 virtual void implStartElement(const sal_Char* _pName) override;
128 /// ends the XML element
129 virtual void implEndElement() override;
131 /// get the name of the outer XML element
132 virtual const sal_Char* getOuterXMLElementName() const;
134 // get the name of the XML element
135 virtual const sal_Char* getXMLElementName() const override;
137 /** examine the control. Some kind of CtorImpl.
139 virtual void examine() override;
141 /// exports the attributes for the outer element
142 void exportOuterAttributes();
144 /// exports the attributes for the inner element
145 void exportInnerAttributes();
147 /// export the attributes
148 virtual void exportAttributes() override;
150 /** writes everything which needs to be represented as sub tag
152 void exportSubTags() throw (css::uno::Exception, std::exception) override;
154 /** adds the attributes which are handled via generic IPropertyHandlers
156 <p>In the future, this really should be *all* attributes, instead of this shitload of
157 hand-crafted code we have currently...</p>
159 void exportGenericHandlerAttributes();
161 /** adds common control attributes to the XMLExport context given
163 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
165 void exportCommonControlAttributes();
167 /** adds database attributes to the XMLExport context given
169 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
171 void exportDatabaseAttributes();
173 /** adds the XML attributes which are related to binding controls to
174 external values and/or list sources
176 void exportBindingAtributes();
178 /** adds attributes which are special to a control type to the export context's attribute list
180 void exportSpecialAttributes();
182 /** exports the ListSource property of a control as attribute
184 The ListSource property may be exported in different ways: For a ComboBox, it is an attribute
185 of the form:combobox element.
187 For a ListBox, it's an attribute if the ListSourceType states that the ListBox does <em>not</em>
188 display a value list. In case of a value list, the ListSource is not exported, and the pairs of
189 StringItem/ValueItem are exported as sub-elements.
191 This method does the attribute part: It exports the ListSource property as attribute, not caring
192 about whether the object is a ComboBox or a ListBox.
194 void exportListSourceAsAttribute();
196 /** exports the ListSource property of a control as XML elements
198 @see exportListSourceAsAttribute
200 void exportListSourceAsElements();
202 /** get's a Sequence&lt; sal_Int16 &gt; property value as set of sal_Int16's
203 @param _rPropertyName
204 the property name to use
205 @param _rOut
206 out parameter. The set of integers.
208 void getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut);
210 /** exports the attribute which descrives a cell value binding of a control
211 in a spreadsheet document
213 void exportCellBindingAttributes( bool _bIncludeListLinkageType );
215 /** exports the attribute(s) which bind this control to XForms */
216 void exportXFormsBindAttributes();
218 /** exports the attribute(s) which bind the list of a list
219 control to XForms */
220 void exportXFormsListAttributes();
222 /** exports the attribute(s) for an XForms submission */
223 void exportXFormsSubmissionAttributes();
225 /** exports the attribute which descrives a cell range which acts as list source for
226 a list-like control
228 void exportCellListSourceRange( );
230 /** exports the attribute(s) for the ImagePosition property
232 void exportImagePositionAttributes();
234 /** determines whether the control we're exporting has an active data binding.
236 Bindings which count here are:
237 <ul><li>an established connection to a database field</li>
238 <li>a binding to an external value supplier (<type scope="css::form::binding">XValueBinding</type>)</li>
239 </ul>
241 bool controlHasActiveDataBinding() const;
243 /** retrieves the string specifying the ListSource of a list or combo box
245 OUString getScalarListSourceValue() const;
247 /** determines whether the list entries (of a combo or list box) are supplied by the user
249 List entries may be
250 <ul><li>specified by the user</li>
251 <li>specified by an external list source (<type scope="css::form::binding">XListEntrySource</type>)</li>
252 <li>obtained from a database query (in various ways)</li>
253 </ul>
255 In the latter two cases, this method will return <FALSE/>
257 bool controlHasUserSuppliedListEntries() const;
260 //= OColumnExport
261 /** Helper class for exporting a grid column
263 class OColumnExport : public OControlExport
265 public:
266 /** ctor
267 @see OColumnExport::OColumnExport
269 OColumnExport(IFormsExportContext& _rContext,
270 const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
271 const OUString& _rControlId,
272 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
274 virtual ~OColumnExport();
276 protected:
277 // OControlExport overridables
278 virtual const sal_Char* getOuterXMLElementName() const override;
279 virtual void exportServiceNameAttribute() override;
280 virtual void exportAttributes() override;
282 // OElementExport overridables
283 virtual void examine() override;
286 //= OFormExport
287 /** Helper class for handling xml elements representing a form
289 <p>In opposite to the class <type>OControlExport</type>, OFormExport is unable to export a <em>complete</em>
290 form. Instead the client has to care for sub elements of the form itself.</p>
292 class OFormExport
293 :public OControlElement
294 ,public OElementExport
296 bool m_bCreateConnectionResourceElement;
297 public:
298 /** constructs an object capable of exporting controls
300 OFormExport(IFormsExportContext& _rContext,
301 const css::uno::Reference< css::beans::XPropertySet >& _rxForm,
302 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents
305 protected:
306 virtual const sal_Char* getXMLElementName() const override;
307 virtual void exportSubTags() override;
308 virtual void exportAttributes() override;
310 } // namespace xmloff
312 #endif // INCLUDED_XMLOFF_SOURCE_FORMS_ELEMENTEXPORT_HXX
314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */