tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / forms / elementexport.hxx
blob3cdcc880e2fa16b316023d1a90951e5bceab97b7
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 css::uno::Sequence< css::script::ScriptEventDescriptor >
43 m_aEvents;
45 std::unique_ptr<SvXMLElementExport> m_pXMLElement; // XML element doing the concrete startElement etc.
47 public:
48 OElementExport(IFormsExportContext& _rContext,
49 const css::uno::Reference< css::beans::XPropertySet >& _rxProps,
50 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents);
51 virtual ~OElementExport();
53 void doExport();
55 protected:
56 /// get the name of the XML element
57 virtual OUString getXMLElementName() const = 0;
58 /// examine the element we're exporting
59 virtual void examine();
60 /// export the attributes
61 virtual void exportAttributes();
62 /// export any sub tags
63 virtual void exportSubTags();
65 /** exports the events (as script:events tag)
67 void exportEvents();
69 /** add the service-name attribute to the export context
71 virtual void exportServiceNameAttribute();
73 /// start the XML element
74 virtual void implStartElement(const OUString& _pName);
76 /// ends the XML element
77 virtual void implEndElement();
80 //= OControlExport
81 /** Helper class for handling xml elements representing a form control
83 class OControlExport
84 :public OControlElement
85 ,public OValuePropertiesMetaData
86 ,public OElementExport
88 protected:
89 typedef o3tl::sorted_vector<sal_Int16> Int16Set;
90 // used below
92 OUString m_sControlId; // the control id to use when exporting
93 OUString m_sReferringControls; // list of referring controls (i.e. their id's)
94 sal_Int16 m_nClassId; // class id of the control we're representing
95 ElementType m_eType; // (XML) type of the control we're representing
96 CCAFlags m_nIncludeCommon; // common control attributes to include
97 DAFlags m_nIncludeDatabase; // common database attributes to include
98 SCAFlags m_nIncludeSpecial; // special attributes to include
99 EAFlags m_nIncludeEvents; // events to include
100 BAFlags m_nIncludeBindings; // binding attributes to include
102 std::unique_ptr<SvXMLElementExport> m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
104 public:
105 /** constructs an object capable of exporting controls
107 <p>You need at least two pre-requisites from outside: The control to be exported needs to have a class id
108 assigned, and you need the list control-ids of all the controls referring to this one as LabelControl.<br/>
109 This information can't be collected when known only the control itself and not it's complete context.</p>
111 @param _rControlId
112 the control id to use when exporting the control
113 @param _rReferringControls
114 the comma-separated list of control-ids of all the controls referring to this one as LabelControl
116 OControlExport(IFormsExportContext& _rContext,
117 const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
118 OUString _sControlId,
119 OUString _sReferringControls,
120 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
122 protected:
123 /// start the XML element
124 virtual void implStartElement(const OUString& _pName) override;
126 /// ends the XML element
127 virtual void implEndElement() override;
129 /// get the name of the outer XML element
130 virtual OUString getOuterXMLElementName() const;
132 // get the name of the XML element
133 virtual OUString getXMLElementName() const override;
135 /** examine the control. Some kind of CtorImpl.
137 virtual void examine() override;
139 /// exports the attributes for the outer element
140 void exportOuterAttributes();
142 /// exports the attributes for the inner element
143 void exportInnerAttributes();
145 /// export the attributes
146 virtual void exportAttributes() override;
148 /** writes everything which needs to be represented as sub tag
150 void exportSubTags() override;
152 /** adds the attributes which are handled via generic IPropertyHandlers
154 <p>In the future, this really should be *all* attributes, instead of this shitload of
155 hand-crafted code we have currently...</p>
157 void exportGenericHandlerAttributes();
159 /** adds common control attributes to the XMLExport context given
161 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
163 void exportCommonControlAttributes();
165 /** adds database attributes to the XMLExport context given
167 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
169 void exportDatabaseAttributes();
171 /** adds the XML attributes which are related to binding controls to
172 external values and/or list sources
174 void exportBindingAttributes();
176 /** adds attributes which are special to a control type to the export context's attribute list
178 void exportSpecialAttributes();
180 /** exports the ListSource property of a control as attribute
182 The ListSource property may be exported in different ways: For a ComboBox, it is an attribute
183 of the form:combobox element.
185 For a ListBox, it's an attribute if the ListSourceType states that the ListBox does <em>not</em>
186 display a value list. In case of a value list, the ListSource is not exported, and the pairs of
187 StringItem/ValueItem are exported as sub-elements.
189 This method does the attribute part: It exports the ListSource property as attribute, not caring
190 about whether the object is a ComboBox or a ListBox.
192 void exportListSourceAsAttribute();
194 /** exports the ListSource property of a control as XML elements
196 @see exportListSourceAsAttribute
198 void exportListSourceAsElements();
200 /** gets a Sequence&lt; sal_Int16 &gt; property value as set of sal_Int16's
201 @param _rPropertyName
202 the property name to use
203 @param _rOut
204 out parameter. The set of integers.
206 void getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut);
208 /** exports the attribute which descrives a cell value binding of a control
209 in a spreadsheet document
211 void exportCellBindingAttributes( bool _bIncludeListLinkageType );
213 /** exports the attribute(s) which bind this control to XForms */
214 void exportXFormsBindAttributes();
216 /** exports the attribute(s) which bind the list of a list
217 control to XForms */
218 void exportXFormsListAttributes();
220 /** exports the attribute(s) for an XForms submission */
221 void exportXFormsSubmissionAttributes();
223 /** exports the attribute which descrives a cell range which acts as list source for
224 a list-like control
226 void exportCellListSourceRange( );
228 /** exports the attribute(s) for the ImagePosition property
230 void exportImagePositionAttributes();
232 /** determines whether the control we're exporting has an active data binding.
234 Bindings which count here are:
235 <ul><li>an established connection to a database field</li>
236 <li>a binding to an external value supplier (<type scope="css::form::binding">XValueBinding</type>)</li>
237 </ul>
239 bool controlHasActiveDataBinding() const;
241 /** retrieves the string specifying the ListSource of a list or combo box
243 OUString getScalarListSourceValue() const;
245 /** determines whether the list entries (of a combo or list box) are supplied by the user
247 List entries may be
248 <ul><li>specified by the user</li>
249 <li>specified by an external list source (<type scope="css::form::binding">XListEntrySource</type>)</li>
250 <li>obtained from a database query (in various ways)</li>
251 </ul>
253 In the latter two cases, this method will return <FALSE/>
255 bool controlHasUserSuppliedListEntries() const;
258 //= OColumnExport
259 /** Helper class for exporting a grid column
261 class OColumnExport : public OControlExport
263 public:
264 /** ctor
265 @see OColumnExport::OColumnExport
267 OColumnExport(IFormsExportContext& _rContext,
268 const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
269 const OUString& _rControlId,
270 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
272 virtual ~OColumnExport() override;
274 protected:
275 // OControlExport overridables
276 virtual OUString getOuterXMLElementName() const override;
277 virtual void exportServiceNameAttribute() override;
278 virtual void exportAttributes() override;
280 // OElementExport overridables
281 virtual void examine() override;
284 //= OFormExport
285 /** Helper class for handling xml elements representing a form
287 <p>In opposite to the class <type>OControlExport</type>, OFormExport is unable to export a <em>complete</em>
288 form. Instead the client has to care for sub elements of the form itself.</p>
290 class OFormExport
291 :public OControlElement
292 ,public OElementExport
294 bool m_bCreateConnectionResourceElement;
295 public:
296 /** constructs an object capable of exporting controls
298 OFormExport(IFormsExportContext& _rContext,
299 const css::uno::Reference< css::beans::XPropertySet >& _rxForm,
300 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents
303 protected:
304 virtual OUString getXMLElementName() const override;
305 virtual void exportSubTags() override;
306 virtual void exportAttributes() override;
308 } // namespace xmloff
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */