1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: elementexport.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_ELEMENTEXPORT_HXX_
32 #define _XMLOFF_ELEMENTEXPORT_HXX_
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/container/XIndexAccess.hpp>
36 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
37 #include "propertyexport.hxx"
38 #include "callbacks.hxx"
39 #include "controlelement.hxx"
40 #include "valueproperties.hxx"
42 class SvXMLElementExport
;
43 //.........................................................................
46 //.........................................................................
48 //=====================================================================
50 //=====================================================================
51 class OElementExport
: public OPropertyExport
54 ::com::sun::star::uno::Sequence
< ::com::sun::star::script::ScriptEventDescriptor
>
57 SvXMLElementExport
* m_pXMLElement
; // XML element doing the concrete startElement etc.
60 OElementExport(IFormsExportContext
& _rContext
,
61 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxProps
,
62 const ::com::sun::star::uno::Sequence
< ::com::sun::star::script::ScriptEventDescriptor
>& _rEvents
);
63 virtual ~OElementExport();
68 /// get the name of the XML element
69 virtual const sal_Char
* getXMLElementName() const = 0;
70 /// examine the element we're exporting
71 virtual void examine();
72 /// export the attributes
73 virtual void exportAttributes();
74 /// export any sub tags
75 virtual void exportSubTags();
77 /** exports the events (as script:events tag)
81 /** add the service-name attribute to the export context
83 virtual void exportServiceNameAttribute();
85 /// start the XML element
86 virtual void implStartElement(const sal_Char
* _pName
);
88 /// ends the XML element
89 virtual void implEndElement();
92 //=====================================================================
94 //=====================================================================
95 /** Helper class for handling xml elements representing a form control
98 :public OControlElement
99 ,public OValuePropertiesMetaData
100 ,public OElementExport
103 DECLARE_STL_STDKEY_SET(sal_Int16
, Int16Set
);
106 ::rtl::OUString m_sControlId
; // the control id to use when exporting
107 ::rtl::OUString m_sReferringControls
; // list of referring controls (i.e. their id's)
108 sal_Int16 m_nClassId
; // class id of the control we're representing
109 ElementType m_eType
; // (XML) type of the control we're representing
110 sal_Int32 m_nIncludeCommon
; // common control attributes to include
111 sal_Int32 m_nIncludeDatabase
; // common database attributes to include
112 sal_Int32 m_nIncludeSpecial
; // special attributes to include
113 sal_Int32 m_nIncludeEvents
; // events to include
114 sal_Int32 m_nIncludeBindings
; // binding attributes to include
116 SvXMLElementExport
* m_pOuterElement
; // XML element doing the concrete startElement etc. for the outer element
119 /** constructs an object capable of exporting controls
121 <p>You need at least two pre-requisites from outside: The control to be exported needs to have a class id
122 assigned, and you need the list control-ids of all the controls referring to this one as LabelControl.<br/>
123 This information can't be collected when known only the control itself and not it's complete context.</p>
126 the control id to use when exporting the control
127 @param _rReferringControls
128 the comma-separated list of control-ids of all the controls referring to this one as LabelControl
130 OControlExport(IFormsExportContext
& _rContext
,
131 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControl
,
132 const ::rtl::OUString
& _rControlId
,
133 const ::rtl::OUString
& _rReferringControls
,
134 const ::com::sun::star::uno::Sequence
< ::com::sun::star::script::ScriptEventDescriptor
>& _rxEvents
);
138 /// start the XML element
139 virtual void implStartElement(const sal_Char
* _pName
);
141 /// ends the XML element
142 virtual void implEndElement();
144 /// get the name of the outer XML element
145 virtual const sal_Char
* getOuterXMLElementName() const;
147 // get the name of the XML element
148 virtual const sal_Char
* getXMLElementName() const;
150 /** examine the control. Some kind of CtorImpl.
152 virtual void examine();
154 /// exports the attributes for the outer element
155 void exportOuterAttributes();
157 /// exports the attributes for the inner element
158 void exportInnerAttributes();
160 /// export the attributes
161 virtual void exportAttributes();
163 /** writes everything which needs to be represented as sub tag
165 void exportSubTags() throw (::com::sun::star::uno::Exception
);
167 /** adds common control 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 exportCommonControlAttributes();
173 /** adds database attributes to the XMLExport context given
175 <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p>
177 void exportDatabaseAttributes();
179 /** adds the XML attributes which are related to binding controls to
180 external values and/or list sources
182 void exportBindingAtributes();
184 /** adds attributes which are special to a control type to the export context's attribute list
186 void exportSpecialAttributes();
188 /** exports the ListSource property of a control as attribute
190 The ListSource property may be exported in different ways: For a ComboBox, it is an attribute
191 of the form:combobox element.
193 For a ListBox, it's an attribute if the ListSourceType states that the ListBox does <em>not</em>
194 display a value list. In case of a value list, the ListSource is not exported, and the pairs of
195 StringItem/ValueItem are exported as sub-elements.
197 This method does the attribute part: It exports the ListSource property as attribute, not caring
198 about whether the object is a ComboBox or a ListBox.
200 void exportListSourceAsAttribute();
202 /** exports the ListSource property of a control as XML elements
204 @see exportListSourceAsAttribute
206 void exportListSourceAsElements();
208 /** get's a Sequence< sal_Int16 > property value as set of sal_Int16's
209 @param _rPropertyName
210 the property name to use
212 out parameter. The set of integers.
214 void getSequenceInt16PropertyAsSet(const ::rtl::OUString
& _rPropertyName
, Int16Set
& _rOut
);
216 /** exports the attribute which descrives a cell value binding of a control
217 in a spreadsheet document
219 void exportCellBindingAttributes( bool _bIncludeListLinkageType
);
221 /** exports the attribute(s) which bind this control to XForms */
222 void exportXFormsBindAttributes();
224 /** exports the attribute(s) which bind the list of a list
226 void exportXFormsListAttributes();
228 /** exports the attribute(s) for an XForms submission */
229 void exportXFormsSubmissionAttributes();
231 /** exports the attribute which descrives a cell range which acts as list source for
234 void exportCellListSourceRange( );
236 /** exports the attribut(s) for the ImagePosition property
238 void exportImagePositionAttributes();
240 /** determines whether the control we're exporting has an active data binding.
242 Bindings which count here are:
243 <ul><li>an established connection to a database field</li>
244 <li>a binding to an external value supplier (<type scope="com::sun::star::form::binding">XValueBinding</type>)</li>
247 bool controlHasActiveDataBinding() const;
249 /** retrieves the string specifying the ListSource of a list or combo box
251 ::rtl::OUString
getScalarListSourceValue() const;
253 /** determines whether the list entries (of a combo or list box) are supplied by the user
256 <ul><li>specified by the user</li>
257 <li>specified by an external list source (<type scope="com::sun::star::form::binding">XListEntrySource</type>)</li>
258 <li>obtained from a database query (in various ways)</li>
261 In the latter two cases, this method will return <FALSE/>
263 bool controlHasUserSuppliedListEntries() const;
266 //=====================================================================
268 //=====================================================================
269 /** Helper class for exporting a grid column
271 class OColumnExport
: public OControlExport
275 @see OColumnExport::OColumnExport
277 OColumnExport(IFormsExportContext
& _rContext
,
278 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControl
,
279 const ::rtl::OUString
& _rControlId
,
280 const ::com::sun::star::uno::Sequence
< ::com::sun::star::script::ScriptEventDescriptor
>& _rxEvents
);
285 // OControlExport overridables
286 virtual const sal_Char
* getOuterXMLElementName() const;
287 virtual void exportServiceNameAttribute();
288 virtual void exportAttributes();
290 // OElementExport overridables
291 virtual void examine();
294 //=====================================================================
296 //=====================================================================
297 /** Helper class for handling xml elements representing a form
299 <p>In opposite to the class <type>OControlExport</type>, OFormExport is unable to export a <em>complete</em>
300 form. Instead the client has to care for sub elements of the form itself.</p>
303 :public OControlElement
304 ,public OElementExport
306 sal_Bool m_bCreateConnectionResourceElement
;
308 /** constructs an object capable of exporting controls
310 OFormExport(IFormsExportContext
& _rContext
,
311 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxForm
,
312 const ::com::sun::star::uno::Sequence
< ::com::sun::star::script::ScriptEventDescriptor
>& _rxEvents
316 virtual const sal_Char
* getXMLElementName() const;
317 virtual void exportSubTags();
318 virtual void exportAttributes();
320 //.........................................................................
321 } // namespace xmloff
322 //.........................................................................
324 #endif // _XMLOFF_ELEMENTEXPORT_HXX_