bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / forms / elementexport.hxx
blobd4b3e0a90476db92bac19159c95b31f85fb27599
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 _XMLOFF_ELEMENTEXPORT_HXX_
21 #define _XMLOFF_ELEMENTEXPORT_HXX_
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"
31 class SvXMLElementExport;
32 //.........................................................................
33 namespace xmloff
35 //.........................................................................
37 //=====================================================================
38 //= OElementExport
39 //=====================================================================
40 class OElementExport : public OPropertyExport
42 protected:
43 ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >
44 m_aEvents;
46 SvXMLElementExport* m_pXMLElement; // XML element doing the concrete startElement etc.
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();
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 //=====================================================================
82 //= OControlExport
83 //=====================================================================
84 /** Helper class for handling xml elements representing a form control
86 class OControlExport
87 :public OControlElement
88 ,public OValuePropertiesMetaData
89 ,public OElementExport
91 protected:
92 DECLARE_STL_STDKEY_SET(sal_Int16, Int16Set);
93 // used below
95 OUString m_sControlId; // the control id to use when exporting
96 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
105 SvXMLElementExport* m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
107 public:
108 /** constructs an object capable of exporting controls
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>
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
119 OControlExport(IFormsExportContext& _rContext,
120 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
121 const OUString& _rControlId,
122 const OUString& _rReferringControls,
123 const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents);
124 ~OControlExport();
126 protected:
127 /// start the XML element
128 virtual void implStartElement(const sal_Char* _pName);
130 /// ends the XML element
131 virtual void implEndElement();
133 /// get the name of the outer XML element
134 virtual const sal_Char* getOuterXMLElementName() const;
136 // get the name of the XML element
137 virtual const sal_Char* getXMLElementName() const;
139 /** examine the control. Some kind of CtorImpl.
141 virtual void examine();
143 /// exports the attributes for the outer element
144 void exportOuterAttributes();
146 /// exports the attributes for the inner element
147 void exportInnerAttributes();
149 /// export the attributes
150 virtual void exportAttributes();
152 /** writes everything which needs to be represented as sub tag
154 void exportSubTags() throw (::com::sun::star::uno::Exception);
156 /** adds the attributes which are handled via generic IPropertyHandlers
158 <p>In the future, this really should be *all* attribiutes, instead of this shitload of
159 hand-crafted code we have currently ...</p>
161 void exportGenericHandlerAttributes();
163 /** adds common control attributes to the XMLExport context given
165 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
167 void exportCommonControlAttributes();
169 /** adds database attributes to the XMLExport context given
171 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
173 void exportDatabaseAttributes();
175 /** adds the XML attributes which are related to binding controls to
176 external values and/or list sources
178 void exportBindingAtributes();
180 /** adds attributes which are special to a control type to the export context's attribute list
182 void exportSpecialAttributes();
184 /** exports the ListSource property of a control as attribute
186 The ListSource property may be exported in different ways: For a ComboBox, it is an attribute
187 of the form:combobox element.
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.
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.
196 void exportListSourceAsAttribute();
198 /** exports the ListSource property of a control as XML elements
200 @see exportListSourceAsAttribute
202 void exportListSourceAsElements();
204 /** get's a Sequence&lt; sal_Int16 &gt; 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.
210 void getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut);
212 /** exports the attribute which descrives a cell value binding of a control
213 in a spreadsheet document
215 void exportCellBindingAttributes( bool _bIncludeListLinkageType );
217 /** exports the attribute(s) which bind this control to XForms */
218 void exportXFormsBindAttributes();
220 /** exports the attribute(s) which bind the list of a list
221 control to XForms */
222 void exportXFormsListAttributes();
224 /** exports the attribute(s) for an XForms submission */
225 void exportXFormsSubmissionAttributes();
227 /** exports the attribute which descrives a cell range which acts as list source for
228 a list-like control
230 void exportCellListSourceRange( );
232 /** exports the attribut(s) for the ImagePosition property
234 void exportImagePositionAttributes();
236 /** determines whether the control we're exporting has an active data binding.
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>
243 bool controlHasActiveDataBinding() const;
245 /** retrieves the string specifying the ListSource of a list or combo box
247 OUString getScalarListSourceValue() const;
249 /** determines whether the list entries (of a combo or list box) are supplied by the user
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>
257 In the latter two cases, this method will return <FALSE/>
259 bool controlHasUserSuppliedListEntries() const;
262 //=====================================================================
263 //= OColumnExport
264 //=====================================================================
265 /** Helper class for exporting a grid column
267 class OColumnExport : public OControlExport
269 public:
270 /** ctor
271 @see OColumnExport::OColumnExport
273 OColumnExport(IFormsExportContext& _rContext,
274 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
275 const OUString& _rControlId,
276 const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents);
278 ~OColumnExport();
280 protected:
281 // OControlExport overridables
282 virtual const sal_Char* getOuterXMLElementName() const;
283 virtual void exportServiceNameAttribute();
284 virtual void exportAttributes();
286 // OElementExport overridables
287 virtual void examine();
290 //=====================================================================
291 //= OFormExport
292 //=====================================================================
293 /** Helper class for handling xml elements representing a form
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>
298 class OFormExport
299 :public OControlElement
300 ,public OElementExport
302 sal_Bool m_bCreateConnectionResourceElement;
303 public:
304 /** constructs an object capable of exporting controls
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
311 protected:
312 virtual const sal_Char* getXMLElementName() const;
313 virtual void exportSubTags();
314 virtual void exportAttributes();
316 //.........................................................................
317 } // namespace xmloff
318 //.........................................................................
320 #endif // _XMLOFF_ELEMENTEXPORT_HXX_
322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */