xref: /AOO41X/main/xmloff/source/forms/elementexport.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "elementexport.hxx"
32*cdf0e10cSrcweir #include "strings.hxx"
33*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
34*cdf0e10cSrcweir #include "eventexport.hxx"
35*cdf0e10cSrcweir #include "formenums.hxx"
36*cdf0e10cSrcweir #include "formcellbinding.hxx"
37*cdf0e10cSrcweir #include "formcellbinding.hxx"
38*cdf0e10cSrcweir #include "xmloff/xformsexport.hxx"
39*cdf0e10cSrcweir #include "property_meta_data.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /** === begin UNO includes === **/
42*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/io/XPersistObject.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/form/FormSubmitEncoding.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/form/FormSubmitMethod.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/form/NavigationBarMode.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/form/TabulatorCycle.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/form/ListSourceType.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/awt/ImagePosition.hpp>
57*cdf0e10cSrcweir /** === end UNO includes === **/
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #include <tools/wintypes.hxx>		// for check states
60*cdf0e10cSrcweir #include <xmloff/txtprmap.hxx>
61*cdf0e10cSrcweir #include <com/sun/star/form/binding/XBindableValue.hpp>
62*cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySink.hpp>
63*cdf0e10cSrcweir #include <tools/urlobj.hxx>
64*cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
65*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
66*cdf0e10cSrcweir #include <xmloff/XMLEventExport.hxx>
67*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
68*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
69*cdf0e10cSrcweir #include <tools/time.hxx>
70*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
71*cdf0e10cSrcweir #include <comphelper/extract.hxx>
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir #include <stdio.h>
74*cdf0e10cSrcweir #include <algorithm>
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir //.........................................................................
77*cdf0e10cSrcweir namespace xmloff
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir //.........................................................................
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     #if OSL_DEBUG_LEVEL > 0
82*cdf0e10cSrcweir         #define RESET_BIT( bitfield, bit ) \
83*cdf0e10cSrcweir 			bitfield = bitfield & ~bit
84*cdf0e10cSrcweir     #else
85*cdf0e10cSrcweir         #define RESET_BIT( bitfield, bit )
86*cdf0e10cSrcweir     #endif
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     using namespace ::xmloff::token;
89*cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
90*cdf0e10cSrcweir 	using namespace ::com::sun::star::sdb;
91*cdf0e10cSrcweir 	using namespace ::com::sun::star::awt;
92*cdf0e10cSrcweir 	using namespace ::com::sun::star::form;
93*cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
94*cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
95*cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
96*cdf0e10cSrcweir 	using namespace ::com::sun::star::container;
97*cdf0e10cSrcweir 	using namespace ::com::sun::star::script;
98*cdf0e10cSrcweir 	using namespace ::com::sun::star::io;
99*cdf0e10cSrcweir 	using namespace ::com::sun::star::table;
100*cdf0e10cSrcweir 	using namespace ::com::sun::star::text;
101*cdf0e10cSrcweir     using namespace ::com::sun::star::form::binding;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	//=====================================================================
104*cdf0e10cSrcweir 	//= OElementExport
105*cdf0e10cSrcweir 	//=====================================================================
106*cdf0e10cSrcweir 	OElementExport::OElementExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps,
107*cdf0e10cSrcweir 		const Sequence< ScriptEventDescriptor >& _rEvents)
108*cdf0e10cSrcweir 		:OPropertyExport(_rContext, _rxProps)
109*cdf0e10cSrcweir 		,m_aEvents(_rEvents)
110*cdf0e10cSrcweir 		,m_pXMLElement(NULL)
111*cdf0e10cSrcweir 	{
112*cdf0e10cSrcweir 	}
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	//---------------------------------------------------------------------
115*cdf0e10cSrcweir 	OElementExport::~OElementExport()
116*cdf0e10cSrcweir 	{
117*cdf0e10cSrcweir 		implEndElement();
118*cdf0e10cSrcweir 	}
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	//---------------------------------------------------------------------
121*cdf0e10cSrcweir 	void OElementExport::doExport()
122*cdf0e10cSrcweir 	{
123*cdf0e10cSrcweir 		// collect some general information about the element
124*cdf0e10cSrcweir 		examine();
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 		// first add the attributes necessary for the element
127*cdf0e10cSrcweir 		m_rContext.getGlobalContext().ClearAttrList();
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 		// add the attributes
130*cdf0e10cSrcweir 		exportAttributes();
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 		// start the XML element
133*cdf0e10cSrcweir 		implStartElement(getXMLElementName());
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 		// the sub elements (mostly control type dependent)
136*cdf0e10cSrcweir 		exportSubTags();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 		implEndElement();
139*cdf0e10cSrcweir 	}
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	//---------------------------------------------------------------------
142*cdf0e10cSrcweir 	void OElementExport::examine()
143*cdf0e10cSrcweir 	{
144*cdf0e10cSrcweir 		// nothing to do here
145*cdf0e10cSrcweir 	}
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	//---------------------------------------------------------------------
148*cdf0e10cSrcweir 	void OElementExport::exportAttributes()
149*cdf0e10cSrcweir 	{
150*cdf0e10cSrcweir 		// nothing to do here
151*cdf0e10cSrcweir 	}
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	//---------------------------------------------------------------------
154*cdf0e10cSrcweir 	void OElementExport::exportSubTags()
155*cdf0e10cSrcweir 	{
156*cdf0e10cSrcweir 		// the properties which where not exported 'til now
157*cdf0e10cSrcweir 		exportRemainingProperties();
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		// the script:events sub tags
160*cdf0e10cSrcweir 		exportEvents();
161*cdf0e10cSrcweir 	}
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	//---------------------------------------------------------------------
164*cdf0e10cSrcweir 	void OElementExport::implStartElement(const sal_Char* _pName)
165*cdf0e10cSrcweir 	{
166*cdf0e10cSrcweir 		m_pXMLElement = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, sal_True, sal_True);
167*cdf0e10cSrcweir 	}
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 	//---------------------------------------------------------------------
170*cdf0e10cSrcweir 	void OElementExport::implEndElement()
171*cdf0e10cSrcweir 	{
172*cdf0e10cSrcweir 		delete m_pXMLElement;
173*cdf0e10cSrcweir 		m_pXMLElement = NULL;
174*cdf0e10cSrcweir 	}
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	//---------------------------------------------------------------------
177*cdf0e10cSrcweir 	void OElementExport::exportServiceNameAttribute()
178*cdf0e10cSrcweir 	{
179*cdf0e10cSrcweir 		Reference< XPersistObject > xPersistence(m_xProps, UNO_QUERY);
180*cdf0e10cSrcweir 		if (!xPersistence.is())
181*cdf0e10cSrcweir 		{
182*cdf0e10cSrcweir 			OSL_ENSURE(sal_False, "OElementExport::exportServiceNameAttribute: no XPersistObject!");
183*cdf0e10cSrcweir 			return;
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 		::rtl::OUString sServiceName = xPersistence->getServiceName();
187*cdf0e10cSrcweir 		// we don't want to write the old service name directly: it's a name used for compatibility reasons, but
188*cdf0e10cSrcweir 		// as we start some kind of new file format here (with this xml export), we don't care about
189*cdf0e10cSrcweir 		// compatibility ...
190*cdf0e10cSrcweir 		// So we translate the old persistence service name into new ones, if possible
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 		::rtl::OUString sToWriteServiceName = sServiceName;
193*cdf0e10cSrcweir #define CHECK_N_TRANSLATE( name )	\
194*cdf0e10cSrcweir 		else if (0 == sServiceName.compareToAscii(SERVICE_PERSISTENT_COMPONENT_##name))	\
195*cdf0e10cSrcweir 			sToWriteServiceName = SERVICE_##name
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 		if (sal_False)
198*cdf0e10cSrcweir 			;
199*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( FORM );
200*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( FORM );
201*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( LISTBOX );
202*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( COMBOBOX );
203*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( RADIOBUTTON );
204*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( GROUPBOX );
205*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( FIXEDTEXT );
206*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( COMMANDBUTTON );
207*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( CHECKBOX );
208*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( GRID );
209*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( IMAGEBUTTON );
210*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( FILECONTROL );
211*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( TIMEFIELD );
212*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( DATEFIELD );
213*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( NUMERICFIELD );
214*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( CURRENCYFIELD );
215*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( PATTERNFIELD );
216*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( HIDDENCONTROL );
217*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( IMAGECONTROL );
218*cdf0e10cSrcweir 		CHECK_N_TRANSLATE( FORMATTEDFIELD );
219*cdf0e10cSrcweir 		else if (0 == sServiceName.compareToAscii(SERVICE_PERSISTENT_COMPONENT_EDIT))
220*cdf0e10cSrcweir 		{	// special handling for the edit field: we have two controls using this as persistence service name
221*cdf0e10cSrcweir 			sToWriteServiceName = SERVICE_EDIT;
222*cdf0e10cSrcweir 			Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
223*cdf0e10cSrcweir 			if (xSI.is() && xSI->supportsService(SERVICE_FORMATTEDFIELD))
224*cdf0e10cSrcweir 				sToWriteServiceName = SERVICE_FORMATTEDFIELD;
225*cdf0e10cSrcweir 		}
226*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
227*cdf0e10cSrcweir 		Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
228*cdf0e10cSrcweir 		OSL_ENSURE(xSI.is() && xSI->supportsService(sToWriteServiceName),
229*cdf0e10cSrcweir 			"OElementExport::exportServiceNameAttribute: wrong service name translation!");
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir #endif
232*cdf0e10cSrcweir 		sToWriteServiceName =
233*cdf0e10cSrcweir 			m_rContext.getGlobalContext().GetNamespaceMap().GetQNameByKey(
234*cdf0e10cSrcweir 				XML_NAMESPACE_OOO, sToWriteServiceName );
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 		// now write this
237*cdf0e10cSrcweir 		AddAttribute(
238*cdf0e10cSrcweir 			OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME),
239*cdf0e10cSrcweir 			OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME),
240*cdf0e10cSrcweir 			sToWriteServiceName);
241*cdf0e10cSrcweir 	}
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	//---------------------------------------------------------------------
244*cdf0e10cSrcweir 	void OElementExport::exportEvents()
245*cdf0e10cSrcweir 	{
246*cdf0e10cSrcweir 		if (!m_aEvents.getLength())
247*cdf0e10cSrcweir 			// nothing to do
248*cdf0e10cSrcweir 			return;
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 		Reference< XNameReplace > xWrapper = new OEventDescriptorMapper(m_aEvents);
251*cdf0e10cSrcweir 		m_rContext.getGlobalContext().GetEventExport().Export(xWrapper);
252*cdf0e10cSrcweir 	}
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	//=====================================================================
255*cdf0e10cSrcweir 	//= OControlExport
256*cdf0e10cSrcweir 	//=====================================================================
257*cdf0e10cSrcweir 	//---------------------------------------------------------------------
258*cdf0e10cSrcweir 	OControlExport::OControlExport(IFormsExportContext& _rContext,  const Reference< XPropertySet >& _rxControl,
259*cdf0e10cSrcweir 		const ::rtl::OUString& _rControlId, const ::rtl::OUString& _rReferringControls,
260*cdf0e10cSrcweir 		const Sequence< ScriptEventDescriptor >& _rEvents)
261*cdf0e10cSrcweir 		:OElementExport(_rContext, _rxControl, _rEvents)
262*cdf0e10cSrcweir 		,m_sControlId(_rControlId)
263*cdf0e10cSrcweir 		,m_sReferringControls(_rReferringControls)
264*cdf0e10cSrcweir         ,m_nClassId(FormComponentType::CONTROL)
265*cdf0e10cSrcweir         ,m_eType( UNKNOWN )
266*cdf0e10cSrcweir 		,m_nIncludeCommon(0)
267*cdf0e10cSrcweir 		,m_nIncludeDatabase(0)
268*cdf0e10cSrcweir 		,m_nIncludeSpecial(0)
269*cdf0e10cSrcweir 		,m_nIncludeEvents(0)
270*cdf0e10cSrcweir         ,m_nIncludeBindings(0)
271*cdf0e10cSrcweir 		,m_pOuterElement(NULL)
272*cdf0e10cSrcweir 	{
273*cdf0e10cSrcweir 		OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
274*cdf0e10cSrcweir 	}
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	//---------------------------------------------------------------------
277*cdf0e10cSrcweir 	OControlExport::~OControlExport()
278*cdf0e10cSrcweir 	{
279*cdf0e10cSrcweir 		implEndElement();
280*cdf0e10cSrcweir 	}
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 	//---------------------------------------------------------------------
283*cdf0e10cSrcweir 	void OControlExport::exportOuterAttributes()
284*cdf0e10cSrcweir 	{
285*cdf0e10cSrcweir 		// the control id
286*cdf0e10cSrcweir 		if (CCA_NAME & m_nIncludeCommon)
287*cdf0e10cSrcweir 		{
288*cdf0e10cSrcweir 			exportStringPropertyAttribute(
289*cdf0e10cSrcweir 				OAttributeMetaData::getCommonControlAttributeNamespace(CCA_NAME),
290*cdf0e10cSrcweir 				OAttributeMetaData::getCommonControlAttributeName(CCA_NAME),
291*cdf0e10cSrcweir 				PROPERTY_NAME
292*cdf0e10cSrcweir 				);
293*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 0
294*cdf0e10cSrcweir 			//  reset the bit for later checking
295*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_NAME;
296*cdf0e10cSrcweir 		#endif
297*cdf0e10cSrcweir 		}
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 		// the service name
300*cdf0e10cSrcweir 		if (m_nIncludeCommon & CCA_SERVICE_NAME)
301*cdf0e10cSrcweir 		{
302*cdf0e10cSrcweir 			exportServiceNameAttribute();
303*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
304*cdf0e10cSrcweir 			//  reset the bit for later checking
305*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_SERVICE_NAME;
306*cdf0e10cSrcweir 		#endif
307*cdf0e10cSrcweir 		}
308*cdf0e10cSrcweir 	}
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	//---------------------------------------------------------------------
311*cdf0e10cSrcweir 	void OControlExport::exportInnerAttributes()
312*cdf0e10cSrcweir 	{
313*cdf0e10cSrcweir 		// the control id
314*cdf0e10cSrcweir 		if (CCA_CONTROL_ID & m_nIncludeCommon)
315*cdf0e10cSrcweir 		{
316*cdf0e10cSrcweir 			OSL_ENSURE(m_sControlId.getLength(), "OControlExport::exportInnerAttributes: have no control id for the control!");
317*cdf0e10cSrcweir             m_rContext.getGlobalContext().AddAttributeIdLegacy(
318*cdf0e10cSrcweir                 XML_NAMESPACE_FORM, m_sControlId);
319*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
320*cdf0e10cSrcweir 			//  reset the bit for later checking
321*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_CONTROL_ID;
322*cdf0e10cSrcweir 		#endif
323*cdf0e10cSrcweir 		}
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir         // "new-style" properties ...
326*cdf0e10cSrcweir         exportGenericHandlerAttributes();
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir         // common control attributes
329*cdf0e10cSrcweir 		exportCommonControlAttributes();
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 		// common database attributes
332*cdf0e10cSrcweir 		exportDatabaseAttributes();
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir         // attributes related to external bindings
335*cdf0e10cSrcweir         exportBindingAtributes();
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 		// attributes special to the respective control type
338*cdf0e10cSrcweir 		exportSpecialAttributes();
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 		// add the style references to the attributes
341*cdf0e10cSrcweir 		flagStyleProperties();
342*cdf0e10cSrcweir 	}
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	//---------------------------------------------------------------------
345*cdf0e10cSrcweir 	void OControlExport::exportAttributes()
346*cdf0e10cSrcweir 	{
347*cdf0e10cSrcweir 		exportOuterAttributes();
348*cdf0e10cSrcweir 	}
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	//---------------------------------------------------------------------
351*cdf0e10cSrcweir 	void OControlExport::exportSubTags() throw (Exception)
352*cdf0e10cSrcweir 	{
353*cdf0e10cSrcweir 		// for the upcoming exportRemainingProperties:
354*cdf0e10cSrcweir 		// if a control has the LabelControl property, this is not stored with the control itself, but instead with
355*cdf0e10cSrcweir 		// the control which is referenced by this property. As the base class' exportRemainingProperties doesn't
356*cdf0e10cSrcweir 		// know anything about this, we need to prevent that it tries to export this property
357*cdf0e10cSrcweir 		exportedProperty(PROPERTY_CONTROLLABEL);
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         // if it's a control supporting XText, then we need to declare all text-related properties
360*cdf0e10cSrcweir         // as "already exported". This prevents them from being exported as generic "form:property"-tags.
361*cdf0e10cSrcweir         // *If* we would export them this way, they would be completely superfluous, and sometimes even
362*cdf0e10cSrcweir         // disastrous, since they may, at import time, override paragraph properties which already have
363*cdf0e10cSrcweir         // been set before
364*cdf0e10cSrcweir         Reference< XText > xControlText( m_xProps, UNO_QUERY );
365*cdf0e10cSrcweir         if ( xControlText.is() )
366*cdf0e10cSrcweir         {
367*cdf0e10cSrcweir             const XMLPropertyMapEntry* pCharAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_TEXT );
368*cdf0e10cSrcweir             while ( pCharAttributeProperties->msApiName )
369*cdf0e10cSrcweir             {
370*cdf0e10cSrcweir                 exportedProperty( ::rtl::OUString::createFromAscii( pCharAttributeProperties->msApiName ) );
371*cdf0e10cSrcweir                 ++pCharAttributeProperties;
372*cdf0e10cSrcweir             }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir             const XMLPropertyMapEntry* pParaAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_SHAPE_PARA );
375*cdf0e10cSrcweir             while ( pParaAttributeProperties->msApiName )
376*cdf0e10cSrcweir             {
377*cdf0e10cSrcweir                 exportedProperty( ::rtl::OUString::createFromAscii( pParaAttributeProperties->msApiName ) );
378*cdf0e10cSrcweir                 ++pParaAttributeProperties;
379*cdf0e10cSrcweir             }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir             // the RichText property is not exported. The presence of the text:p element
382*cdf0e10cSrcweir             // will be used - upon reading - as indicator for the value of the RichText property
383*cdf0e10cSrcweir             exportedProperty( PROPERTY_RICH_TEXT );
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir             // strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property
386*cdf0e10cSrcweir             // The former is a short/enum value, the latter a boolean. The former has a real meaning
387*cdf0e10cSrcweir             // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and
388*cdf0e10cSrcweir             // later on imported, it overwrites anything which has previously been imported for
389*cdf0e10cSrcweir             // CharStrikeout.
390*cdf0e10cSrcweir             // 2004-04-14 - #i27729# - fs@openoffice.org
391*cdf0e10cSrcweir             exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharCrossedOut" ) ) );
392*cdf0e10cSrcweir         }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir         if ( m_eType == LISTBOX )
395*cdf0e10cSrcweir         {
396*cdf0e10cSrcweir             // will be exported in exportListSourceAsElements:
397*cdf0e10cSrcweir             if ( controlHasUserSuppliedListEntries() )
398*cdf0e10cSrcweir                 exportedProperty( PROPERTY_DEFAULT_SELECT_SEQ );
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir             // will not be exported in a generic way. Either exportListSourceAsElements cares
401*cdf0e10cSrcweir             // for them, or we don't need them
402*cdf0e10cSrcweir             exportedProperty( PROPERTY_STRING_ITEM_LIST );
403*cdf0e10cSrcweir             exportedProperty( PROPERTY_VALUE_SEQ );
404*cdf0e10cSrcweir             exportedProperty( PROPERTY_SELECT_SEQ );
405*cdf0e10cSrcweir             exportedProperty( PROPERTY_LISTSOURCE );
406*cdf0e10cSrcweir         }
407*cdf0e10cSrcweir         if ( m_eType == COMBOBOX )
408*cdf0e10cSrcweir             exportedProperty( PROPERTY_STRING_ITEM_LIST );
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 		// let the base class export the remaining properties and the events
411*cdf0e10cSrcweir 		OElementExport::exportSubTags();
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir 		// special sub tags for some controls
414*cdf0e10cSrcweir 		switch (m_eType)
415*cdf0e10cSrcweir 		{
416*cdf0e10cSrcweir 			case LISTBOX:
417*cdf0e10cSrcweir                 // don't export the list entries if the are not provided by the user, but obtained implicitly
418*cdf0e10cSrcweir                 // from other sources
419*cdf0e10cSrcweir                 // #i26944# - 2004-05-17 - fs@openoffice.org
420*cdf0e10cSrcweir                 if ( controlHasUserSuppliedListEntries() )
421*cdf0e10cSrcweir 				    exportListSourceAsElements();
422*cdf0e10cSrcweir 				break;
423*cdf0e10cSrcweir 			case GRID:
424*cdf0e10cSrcweir 			{	// a grid control requires us to store all columns as sub elements
425*cdf0e10cSrcweir 				Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY);
426*cdf0e10cSrcweir 				OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!");
427*cdf0e10cSrcweir 				if (xColumnContainer.is())
428*cdf0e10cSrcweir 					m_rContext.exportCollectionElements(xColumnContainer);
429*cdf0e10cSrcweir 			}
430*cdf0e10cSrcweir 			break;
431*cdf0e10cSrcweir 			case COMBOBOX:
432*cdf0e10cSrcweir 			{	// a combox box description has sub elements: the items
433*cdf0e10cSrcweir 				DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< ::rtl::OUString > );
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir                 // don't export the list entries if the are not provided by the user, but obtained implicitly
436*cdf0e10cSrcweir                 // from other sources
437*cdf0e10cSrcweir                 // #i26944# - 2004-05-17 - fs@openoffice.org
438*cdf0e10cSrcweir                 if ( controlHasUserSuppliedListEntries() )
439*cdf0e10cSrcweir                 {
440*cdf0e10cSrcweir 				    // get the item list
441*cdf0e10cSrcweir 				    Sequence< ::rtl::OUString > aListItems;
442*cdf0e10cSrcweir 				    m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems;
443*cdf0e10cSrcweir 				    // loop through it and write the sub elements
444*cdf0e10cSrcweir 				    const ::rtl::OUString* pListItems = aListItems.getConstArray();
445*cdf0e10cSrcweir 				    for (sal_Int32 i=0; i<aListItems.getLength(); ++i, ++pListItems)
446*cdf0e10cSrcweir 				    {
447*cdf0e10cSrcweir 					    m_rContext.getGlobalContext().ClearAttrList();
448*cdf0e10cSrcweir 					    AddAttribute(
449*cdf0e10cSrcweir 						    OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
450*cdf0e10cSrcweir 						    OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
451*cdf0e10cSrcweir 						    *pListItems);
452*cdf0e10cSrcweir 					    SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "item", sal_True, sal_True);
453*cdf0e10cSrcweir 				    }
454*cdf0e10cSrcweir                 }
455*cdf0e10cSrcweir 			}
456*cdf0e10cSrcweir 			break;
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir             case TEXT_AREA:
459*cdf0e10cSrcweir             {
460*cdf0e10cSrcweir                 // if we act as rich text control, we need to export some text:p elements
461*cdf0e10cSrcweir                 if ( xControlText.is() )
462*cdf0e10cSrcweir                 {
463*cdf0e10cSrcweir                     sal_Bool bActingAsRichText = sal_False;
464*cdf0e10cSrcweir         			if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_RICH_TEXT ) )
465*cdf0e10cSrcweir                     {
466*cdf0e10cSrcweir                         OSL_VERIFY(m_xProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActingAsRichText );
467*cdf0e10cSrcweir                     }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir                     if ( bActingAsRichText )
470*cdf0e10cSrcweir                 		m_rContext.getGlobalContext().GetTextParagraphExport()->exportText( xControlText );
471*cdf0e10cSrcweir                 }
472*cdf0e10cSrcweir             }
473*cdf0e10cSrcweir             break;
474*cdf0e10cSrcweir             default:
475*cdf0e10cSrcweir                 // nothing do to
476*cdf0e10cSrcweir                 break;
477*cdf0e10cSrcweir 		}
478*cdf0e10cSrcweir 	}
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir     //---------------------------------------------------------------------
481*cdf0e10cSrcweir     void OControlExport::exportGenericHandlerAttributes()
482*cdf0e10cSrcweir     {
483*cdf0e10cSrcweir 	    const Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
484*cdf0e10cSrcweir         for (   const Property* prop = aProperties.getConstArray();
485*cdf0e10cSrcweir                 prop != aProperties.getConstArray() + aProperties.getLength();
486*cdf0e10cSrcweir                 ++prop
487*cdf0e10cSrcweir             )
488*cdf0e10cSrcweir         {
489*cdf0e10cSrcweir             try
490*cdf0e10cSrcweir             {
491*cdf0e10cSrcweir                 // see if this property can already be handled with an IPropertyHandler (which, on the long
492*cdf0e10cSrcweir                 // term, should be the case for most, if not all, properties)
493*cdf0e10cSrcweir                 const PropertyDescription* propDescription = metadata::getPropertyDescription( prop->Name );
494*cdf0e10cSrcweir                 if ( propDescription == NULL )
495*cdf0e10cSrcweir                     continue;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir                 // let the factory provide the concrete handler. Note that caching, if desired, is the task
498*cdf0e10cSrcweir                 // of the factory
499*cdf0e10cSrcweir                 PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId );
500*cdf0e10cSrcweir                 ENSURE_OR_CONTINUE( handler.get() != NULL,
501*cdf0e10cSrcweir                     "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir                 ::rtl::OUString attributeValue;
504*cdf0e10cSrcweir                 if ( propDescription->propertyGroup == NO_GROUP )
505*cdf0e10cSrcweir                 {
506*cdf0e10cSrcweir                     // that's a property which has a direct mapping to an attribute
507*cdf0e10cSrcweir                     if ( !shouldExportProperty( prop->Name ) )
508*cdf0e10cSrcweir                         // TODO: in the future, we surely need a more sophisticated approach to this, involving the property
509*cdf0e10cSrcweir                         // handler, or the property description
510*cdf0e10cSrcweir                     {
511*cdf0e10cSrcweir                         exportedProperty( prop->Name );
512*cdf0e10cSrcweir                         continue;
513*cdf0e10cSrcweir                     }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir                     const Any propValue = m_xProps->getPropertyValue( prop->Name );
516*cdf0e10cSrcweir                     attributeValue = handler->getAttributeValue( propValue );
517*cdf0e10cSrcweir                 }
518*cdf0e10cSrcweir                 else
519*cdf0e10cSrcweir                 {
520*cdf0e10cSrcweir                     // that's a property which is part of a group of properties, whose values, in their entity, comprise
521*cdf0e10cSrcweir                     // a single attribute value
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir                     // retrieve the descriptions of all other properties which add to the attribute value
524*cdf0e10cSrcweir                     PropertyDescriptionList descriptions;
525*cdf0e10cSrcweir                     metadata::getPropertyGroup( propDescription->propertyGroup, descriptions );
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir                     // retrieve the values for all those properties
528*cdf0e10cSrcweir                     PropertyValues aValues;
529*cdf0e10cSrcweir                     for (   PropertyDescriptionList::iterator desc = descriptions.begin();
530*cdf0e10cSrcweir                             desc != descriptions.end();
531*cdf0e10cSrcweir                             ++desc
532*cdf0e10cSrcweir                         )
533*cdf0e10cSrcweir                     {
534*cdf0e10cSrcweir                         // TODO: XMultiPropertySet?
535*cdf0e10cSrcweir                         const Any propValue = m_xProps->getPropertyValue( (*desc)->propertyName );
536*cdf0e10cSrcweir                         aValues[ (*desc)->propertyId ] = propValue;
537*cdf0e10cSrcweir                     }
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir                     // let the handler translate into an XML attribute value
540*cdf0e10cSrcweir                     attributeValue = handler->getAttributeValue( aValues );
541*cdf0e10cSrcweir                 }
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 			    AddAttribute(
544*cdf0e10cSrcweir 				    propDescription->attribute.namespacePrefix,
545*cdf0e10cSrcweir                     token::GetXMLToken( propDescription->attribute.attributeToken ),
546*cdf0e10cSrcweir 				    attributeValue
547*cdf0e10cSrcweir                 );
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir                 exportedProperty( prop->Name );
550*cdf0e10cSrcweir             }
551*cdf0e10cSrcweir             catch( const Exception& )
552*cdf0e10cSrcweir             {
553*cdf0e10cSrcweir         	    DBG_UNHANDLED_EXCEPTION();
554*cdf0e10cSrcweir             }
555*cdf0e10cSrcweir         }
556*cdf0e10cSrcweir     }
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir     //---------------------------------------------------------------------
559*cdf0e10cSrcweir 	void OControlExport::exportCommonControlAttributes()
560*cdf0e10cSrcweir 	{
561*cdf0e10cSrcweir 		size_t i=0;
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 		// I decided to handle all the properties here with some static arrays describing the property-attribute
564*cdf0e10cSrcweir 		// relations. This leads to somewhat ugly code :), but the only alternative I can think of right now
565*cdf0e10cSrcweir 		// would require maps and O(log n) searches, which seems somewhat expensive as this code is used
566*cdf0e10cSrcweir 		// very frequently.
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 		// the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using
569*cdf0e10cSrcweir 		// map identifiers from the wrong block
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 		// --------------------------------------------------------------------
572*cdf0e10cSrcweir 		// some string properties
573*cdf0e10cSrcweir 		{
574*cdf0e10cSrcweir 			// the attribute ids of all properties which are expected to be of type string
575*cdf0e10cSrcweir 			static sal_Int32 nStringPropertyAttributeIds[] =
576*cdf0e10cSrcweir 			{
577*cdf0e10cSrcweir 				CCA_LABEL, CCA_TITLE
578*cdf0e10cSrcweir 			};
579*cdf0e10cSrcweir 			// the names of all properties which are expected to be of type string
580*cdf0e10cSrcweir 			static ::rtl::OUString aStringPropertyNames[] =
581*cdf0e10cSrcweir 			{
582*cdf0e10cSrcweir 				PROPERTY_LABEL, PROPERTY_TITLE
583*cdf0e10cSrcweir 			};
584*cdf0e10cSrcweir 			OSL_ENSURE(	sizeof(aStringPropertyNames)/sizeof(aStringPropertyNames[0]) ==
585*cdf0e10cSrcweir 						sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]),
586*cdf0e10cSrcweir 						"OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir 			for (i=0; i<sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]); ++i)
589*cdf0e10cSrcweir 				if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
590*cdf0e10cSrcweir 				{
591*cdf0e10cSrcweir 					exportStringPropertyAttribute(
592*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds[i]),
593*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds[i]),
594*cdf0e10cSrcweir 						aStringPropertyNames[i]
595*cdf0e10cSrcweir 						);
596*cdf0e10cSrcweir 				#if OSL_DEBUG_LEVEL > 0
597*cdf0e10cSrcweir 					//  reset the bit for later checking
598*cdf0e10cSrcweir 					m_nIncludeCommon = m_nIncludeCommon & ~nStringPropertyAttributeIds[i];
599*cdf0e10cSrcweir 				#endif
600*cdf0e10cSrcweir 				}
601*cdf0e10cSrcweir 		}
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 		// --------------------------------------------------------------------
604*cdf0e10cSrcweir 		// some boolean properties
605*cdf0e10cSrcweir 		{
606*cdf0e10cSrcweir 			static sal_Int32 nBooleanPropertyAttributeIds[] =
607*cdf0e10cSrcweir 			{	// attribute flags
608*cdf0e10cSrcweir 				CCA_CURRENT_SELECTED, CCA_DISABLED, CCA_DROPDOWN, CCA_PRINTABLE, CCA_READONLY, CCA_SELECTED, CCA_TAB_STOP, CCA_ENABLEVISIBLE
609*cdf0e10cSrcweir 			};
610*cdf0e10cSrcweir 			static const ::rtl::OUString* pBooleanPropertyNames[] =
611*cdf0e10cSrcweir 			{	// property names
612*cdf0e10cSrcweir 				&PROPERTY_STATE, &PROPERTY_ENABLED, &PROPERTY_DROPDOWN, &PROPERTY_PRINTABLE, &PROPERTY_READONLY, &PROPERTY_DEFAULT_STATE, &PROPERTY_TABSTOP, &PROPERTY_ENABLEVISIBLE
613*cdf0e10cSrcweir 			};
614*cdf0e10cSrcweir 			static sal_Bool nBooleanPropertyAttrFlags[] =
615*cdf0e10cSrcweir 			{	// attribute defaults
616*cdf0e10cSrcweir 				BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE | BOOLATTR_INVERSE_SEMANTICS, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_VOID, BOOLATTR_DEFAULT_FALSE
617*cdf0e10cSrcweir 			};
618*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
619*cdf0e10cSrcweir 			sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
620*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
621*cdf0e10cSrcweir 			sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]);
622*cdf0e10cSrcweir 			OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
623*cdf0e10cSrcweir 				"OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
624*cdf0e10cSrcweir 		#endif
625*cdf0e10cSrcweir 			for (i=0; i<sizeof(nBooleanPropertyAttributeIds)/sizeof(nBooleanPropertyAttributeIds[0]); ++i)
626*cdf0e10cSrcweir 				if (nBooleanPropertyAttributeIds[i] & m_nIncludeCommon)
627*cdf0e10cSrcweir 				{
628*cdf0e10cSrcweir 					exportBooleanPropertyAttribute(
629*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeNamespace(nBooleanPropertyAttributeIds[i]),
630*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeName(nBooleanPropertyAttributeIds[i]),
631*cdf0e10cSrcweir 						*(pBooleanPropertyNames[i]),
632*cdf0e10cSrcweir 						nBooleanPropertyAttrFlags[i]);
633*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
634*cdf0e10cSrcweir 					//  reset the bit for later checking
635*cdf0e10cSrcweir 					m_nIncludeCommon = m_nIncludeCommon & ~nBooleanPropertyAttributeIds[i];
636*cdf0e10cSrcweir 		#endif
637*cdf0e10cSrcweir 				}
638*cdf0e10cSrcweir 		}
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 		// --------------------------------------------------------------------
642*cdf0e10cSrcweir 		// some integer properties
643*cdf0e10cSrcweir 		{
644*cdf0e10cSrcweir 			// now the common handling
645*cdf0e10cSrcweir 			static sal_Int32 nIntegerPropertyAttributeIds[] =
646*cdf0e10cSrcweir 			{	// attribute flags
647*cdf0e10cSrcweir 				CCA_SIZE, CCA_TAB_INDEX
648*cdf0e10cSrcweir 			};
649*cdf0e10cSrcweir 			static const ::rtl::OUString* pIntegerPropertyNames[] =
650*cdf0e10cSrcweir 			{	// property names
651*cdf0e10cSrcweir 				&PROPERTY_LINECOUNT, &PROPERTY_TABINDEX
652*cdf0e10cSrcweir 			};
653*cdf0e10cSrcweir 			static const sal_Int16 nIntegerPropertyAttrDefaults[] =
654*cdf0e10cSrcweir 			{	// attribute defaults
655*cdf0e10cSrcweir 				5, 0
656*cdf0e10cSrcweir 			};
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 			if ( m_nIncludeCommon & CCA_MAX_LENGTH )
659*cdf0e10cSrcweir 				exportedProperty(PROPERTY_MAXTEXTLENGTH);
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
662*cdf0e10cSrcweir 			sal_Int32 nIdCount = sizeof(nIntegerPropertyAttributeIds) / sizeof(nIntegerPropertyAttributeIds[0]);
663*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof(pIntegerPropertyNames) / sizeof(pIntegerPropertyNames[0]);
664*cdf0e10cSrcweir 			sal_Int32 nDefaultCount = sizeof(nIntegerPropertyAttrDefaults) / sizeof(nIntegerPropertyAttrDefaults[0]);
665*cdf0e10cSrcweir 			OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount),
666*cdf0e10cSrcweir 				"OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
667*cdf0e10cSrcweir 		#endif
668*cdf0e10cSrcweir 			for (i=0; i<sizeof(nIntegerPropertyAttributeIds)/sizeof(nIntegerPropertyAttributeIds[0]); ++i)
669*cdf0e10cSrcweir 				if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
670*cdf0e10cSrcweir 				{
671*cdf0e10cSrcweir 					exportInt16PropertyAttribute(
672*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds[i]),
673*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds[i]),
674*cdf0e10cSrcweir 						*(pIntegerPropertyNames[i]),
675*cdf0e10cSrcweir 						nIntegerPropertyAttrDefaults[i]);
676*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
677*cdf0e10cSrcweir 					//  reset the bit for later checking
678*cdf0e10cSrcweir 					m_nIncludeCommon = m_nIncludeCommon & ~nIntegerPropertyAttributeIds[i];
679*cdf0e10cSrcweir 		#endif
680*cdf0e10cSrcweir 				}
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 		}
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 		// --------------------------------------------------------------------
686*cdf0e10cSrcweir 		// some enum properties
687*cdf0e10cSrcweir 		{
688*cdf0e10cSrcweir 			if (m_nIncludeCommon & CCA_BUTTON_TYPE)
689*cdf0e10cSrcweir 			{
690*cdf0e10cSrcweir 				exportEnumPropertyAttribute(
691*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_BUTTON_TYPE),
692*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_BUTTON_TYPE),
693*cdf0e10cSrcweir 					PROPERTY_BUTTONTYPE,
694*cdf0e10cSrcweir 					OEnumMapper::getEnumMap(OEnumMapper::epButtonType),
695*cdf0e10cSrcweir 					FormButtonType_PUSH);
696*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
697*cdf0e10cSrcweir 				//  reset the bit for later checking
698*cdf0e10cSrcweir 				m_nIncludeCommon = m_nIncludeCommon & ~CCA_BUTTON_TYPE;
699*cdf0e10cSrcweir 		#endif
700*cdf0e10cSrcweir 			}
701*cdf0e10cSrcweir 			if ( m_nIncludeCommon & CCA_ORIENTATION )
702*cdf0e10cSrcweir 			{
703*cdf0e10cSrcweir 				exportEnumPropertyAttribute(
704*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace( CCA_ORIENTATION ),
705*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName( CCA_ORIENTATION ),
706*cdf0e10cSrcweir 					PROPERTY_ORIENTATION,
707*cdf0e10cSrcweir 					OEnumMapper::getEnumMap( OEnumMapper::epOrientation ),
708*cdf0e10cSrcweir                     ScrollBarOrientation::HORIZONTAL
709*cdf0e10cSrcweir                 );
710*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
711*cdf0e10cSrcweir 				//  reset the bit for later checking
712*cdf0e10cSrcweir 				m_nIncludeCommon = m_nIncludeCommon & ~CCA_ORIENTATION;
713*cdf0e10cSrcweir 		#endif
714*cdf0e10cSrcweir 			}
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir             if ( m_nIncludeCommon & CCA_VISUAL_EFFECT )
717*cdf0e10cSrcweir             {
718*cdf0e10cSrcweir 				exportEnumPropertyAttribute(
719*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace( CCA_VISUAL_EFFECT ),
720*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName( CCA_VISUAL_EFFECT ),
721*cdf0e10cSrcweir 					PROPERTY_VISUAL_EFFECT,
722*cdf0e10cSrcweir 					OEnumMapper::getEnumMap( OEnumMapper::epVisualEffect ),
723*cdf0e10cSrcweir                     VisualEffect::LOOK3D
724*cdf0e10cSrcweir                 );
725*cdf0e10cSrcweir 			#if OSL_DEBUG_LEVEL > 0
726*cdf0e10cSrcweir 				//  reset the bit for later checking
727*cdf0e10cSrcweir 				m_nIncludeCommon = m_nIncludeCommon & ~CCA_VISUAL_EFFECT;
728*cdf0e10cSrcweir 			#endif
729*cdf0e10cSrcweir             }
730*cdf0e10cSrcweir 		}
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir 		// --------------------------------------------------------------------
733*cdf0e10cSrcweir 		// some properties which require a special handling
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 		// the target frame
736*cdf0e10cSrcweir 		if (m_nIncludeCommon & CCA_TARGET_FRAME)
737*cdf0e10cSrcweir 		{
738*cdf0e10cSrcweir 			exportTargetFrameAttribute();
739*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
740*cdf0e10cSrcweir 			//  reset the bit for later checking
741*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_FRAME;
742*cdf0e10cSrcweir 		#endif
743*cdf0e10cSrcweir 		}
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 		// max text length
746*cdf0e10cSrcweir 		if ( m_nIncludeCommon & CCA_MAX_LENGTH )
747*cdf0e10cSrcweir 		{
748*cdf0e10cSrcweir 			// normally, the respective property would be "MaxTextLen"
749*cdf0e10cSrcweir 			// However, if the model has a property "PersistenceMaxTextLength", then we prefer this
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 			// determine the name of the property to export
752*cdf0e10cSrcweir 			::rtl::OUString sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH );
753*cdf0e10cSrcweir 			if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH ) )
754*cdf0e10cSrcweir 				sTextLenPropertyName = PROPERTY_PERSISTENCE_MAXTEXTLENGTH;
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir 			// export it
757*cdf0e10cSrcweir 			exportInt16PropertyAttribute(
758*cdf0e10cSrcweir 				OAttributeMetaData::getCommonControlAttributeNamespace( CCA_MAX_LENGTH ),
759*cdf0e10cSrcweir 				OAttributeMetaData::getCommonControlAttributeName( CCA_MAX_LENGTH ),
760*cdf0e10cSrcweir 				sTextLenPropertyName,
761*cdf0e10cSrcweir 				0
762*cdf0e10cSrcweir 			);
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir 			// in either way, both properties count as "exported"
765*cdf0e10cSrcweir 			exportedProperty( PROPERTY_MAXTEXTLENGTH );
766*cdf0e10cSrcweir 			exportedProperty( PROPERTY_PERSISTENCE_MAXTEXTLENGTH );
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
769*cdf0e10cSrcweir 			//  reset the bit for later checking
770*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_MAX_LENGTH;
771*cdf0e10cSrcweir 		#endif
772*cdf0e10cSrcweir 		}
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir 		if (m_nIncludeCommon & CCA_TARGET_LOCATION)
775*cdf0e10cSrcweir 		{
776*cdf0e10cSrcweir 			exportTargetLocationAttribute(false);
777*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
778*cdf0e10cSrcweir 			//  reset the bit for later checking
779*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_LOCATION;
780*cdf0e10cSrcweir 		#endif
781*cdf0e10cSrcweir 		}
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 		// OJ #99721#
784*cdf0e10cSrcweir 		if (m_nIncludeCommon & CCA_IMAGE_DATA)
785*cdf0e10cSrcweir 		{
786*cdf0e10cSrcweir 			exportImageDataAttribute();
787*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
788*cdf0e10cSrcweir 			//  reset the bit for later checking
789*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_IMAGE_DATA;
790*cdf0e10cSrcweir 		#endif
791*cdf0e10cSrcweir 		}
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir 		// the for attribute
794*cdf0e10cSrcweir 		// the target frame
795*cdf0e10cSrcweir 		if (m_nIncludeCommon & CCA_FOR)
796*cdf0e10cSrcweir 		{
797*cdf0e10cSrcweir 			if (m_sReferringControls.getLength())
798*cdf0e10cSrcweir 			{	// there is at least one control referring to the one we're handling currently
799*cdf0e10cSrcweir 				AddAttribute(
800*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_FOR),
801*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_FOR),
802*cdf0e10cSrcweir 					m_sReferringControls);
803*cdf0e10cSrcweir 			}
804*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
805*cdf0e10cSrcweir 			//  reset the bit for later checking
806*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~CCA_FOR;
807*cdf0e10cSrcweir 		#endif
808*cdf0e10cSrcweir 		}
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir 		if ((CCA_CURRENT_VALUE | CCA_VALUE) & m_nIncludeCommon)
811*cdf0e10cSrcweir 		{
812*cdf0e10cSrcweir 			const sal_Char* pCurrentValuePropertyName = NULL;
813*cdf0e10cSrcweir 			const sal_Char* pValuePropertyName = NULL;
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir 			// get the property names
816*cdf0e10cSrcweir 			getValuePropertyNames(m_eType, m_nClassId, pCurrentValuePropertyName, pValuePropertyName);
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir 			static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE);
819*cdf0e10cSrcweir 			static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE);
820*cdf0e10cSrcweir 			static const sal_uInt16 nCurrentValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_VALUE);
821*cdf0e10cSrcweir 			static const sal_uInt16 nValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE);
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir 			// add the atrtributes if necessary and possible
824*cdf0e10cSrcweir 			if (pCurrentValuePropertyName && (CCA_CURRENT_VALUE & m_nIncludeCommon))
825*cdf0e10cSrcweir             {
826*cdf0e10cSrcweir                 // don't export the current-value if this value originates from a data binding
827*cdf0e10cSrcweir                 // #i26944# - 2004-05-17 - fs@openoffice.org
828*cdf0e10cSrcweir                 if ( controlHasActiveDataBinding() )
829*cdf0e10cSrcweir                     exportedProperty( ::rtl::OUString::createFromAscii( pCurrentValuePropertyName ) );
830*cdf0e10cSrcweir                 else
831*cdf0e10cSrcweir 				    exportGenericPropertyAttribute(
832*cdf0e10cSrcweir 					    nCurrentValueAttributeNamespaceKey,
833*cdf0e10cSrcweir 					    pCurrentValueAttributeName,
834*cdf0e10cSrcweir 					    pCurrentValuePropertyName
835*cdf0e10cSrcweir                     );
836*cdf0e10cSrcweir             }
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir 			if (pValuePropertyName && (CCA_VALUE & m_nIncludeCommon))
839*cdf0e10cSrcweir 				exportGenericPropertyAttribute(
840*cdf0e10cSrcweir 					nValueAttributeNamespaceKey,
841*cdf0e10cSrcweir 					pValueAttributeName,
842*cdf0e10cSrcweir 					pValuePropertyName);
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 			OSL_ENSURE((NULL == pValuePropertyName) == (0 == (CCA_VALUE & m_nIncludeCommon)),
845*cdf0e10cSrcweir 				"OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
846*cdf0e10cSrcweir 			OSL_ENSURE((NULL == pCurrentValuePropertyName ) == (0 == (CCA_CURRENT_VALUE & m_nIncludeCommon)),
847*cdf0e10cSrcweir 				"OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
850*cdf0e10cSrcweir 			//  reset the bit for later checking
851*cdf0e10cSrcweir 			m_nIncludeCommon = m_nIncludeCommon & ~(CCA_CURRENT_VALUE | CCA_VALUE);
852*cdf0e10cSrcweir 		#endif
853*cdf0e10cSrcweir 		}
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir 		OSL_ENSURE(0 == m_nIncludeCommon,
856*cdf0e10cSrcweir 			"OControlExport::exportCommonControlAttributes: forgot some flags!");
857*cdf0e10cSrcweir 			// in the dbg_util version, we should have removed every bit we handled from the mask, so it should
858*cdf0e10cSrcweir 			// be 0 now ...
859*cdf0e10cSrcweir 	}
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir 	//---------------------------------------------------------------------
862*cdf0e10cSrcweir 	void OControlExport::exportDatabaseAttributes()
863*cdf0e10cSrcweir 	{
864*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
865*cdf0e10cSrcweir 		sal_Int32 nIncludeDatabase = m_nIncludeDatabase;
866*cdf0e10cSrcweir #endif
867*cdf0e10cSrcweir 		// the only string property: DataField
868*cdf0e10cSrcweir 		if (DA_DATA_FIELD & m_nIncludeDatabase)
869*cdf0e10cSrcweir 		{
870*cdf0e10cSrcweir 			exportStringPropertyAttribute(
871*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeNamespace(DA_DATA_FIELD),
872*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD),
873*cdf0e10cSrcweir 				PROPERTY_DATAFIELD);
874*cdf0e10cSrcweir             RESET_BIT( nIncludeDatabase, DA_DATA_FIELD );
875*cdf0e10cSrcweir 		}
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir         // InputRequired
878*cdf0e10cSrcweir         if ( DA_INPUT_REQUIRED & m_nIncludeDatabase )
879*cdf0e10cSrcweir         {
880*cdf0e10cSrcweir             exportBooleanPropertyAttribute(
881*cdf0e10cSrcweir                 OAttributeMetaData::getDatabaseAttributeNamespace( DA_INPUT_REQUIRED ),
882*cdf0e10cSrcweir                 OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED ),
883*cdf0e10cSrcweir                 PROPERTY_INPUT_REQUIRED,
884*cdf0e10cSrcweir                 BOOLATTR_DEFAULT_TRUE
885*cdf0e10cSrcweir             );
886*cdf0e10cSrcweir             RESET_BIT( nIncludeDatabase, DA_INPUT_REQUIRED );
887*cdf0e10cSrcweir         }
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir 		// the only int16 property: BoundColumn
890*cdf0e10cSrcweir 		if (DA_BOUND_COLUMN & m_nIncludeDatabase)
891*cdf0e10cSrcweir 		{
892*cdf0e10cSrcweir 			exportInt16PropertyAttribute(
893*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeNamespace(DA_BOUND_COLUMN),
894*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN),
895*cdf0e10cSrcweir 				PROPERTY_BOUNDCOLUMN,
896*cdf0e10cSrcweir 				0);
897*cdf0e10cSrcweir             RESET_BIT( nIncludeDatabase, DA_BOUND_COLUMN );
898*cdf0e10cSrcweir 		}
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir 		// ConvertEmptyToNull
901*cdf0e10cSrcweir 		if (DA_CONVERT_EMPTY & m_nIncludeDatabase)
902*cdf0e10cSrcweir 		{
903*cdf0e10cSrcweir 			exportBooleanPropertyAttribute(
904*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeNamespace(DA_CONVERT_EMPTY),
905*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY),
906*cdf0e10cSrcweir 				PROPERTY_EMPTY_IS_NULL,
907*cdf0e10cSrcweir 				BOOLATTR_DEFAULT_FALSE
908*cdf0e10cSrcweir 				);
909*cdf0e10cSrcweir             RESET_BIT( nIncludeDatabase, DA_CONVERT_EMPTY );
910*cdf0e10cSrcweir 		}
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 		// the only enum property: ListSourceType
913*cdf0e10cSrcweir 		if (DA_LIST_SOURCE_TYPE & m_nIncludeDatabase)
914*cdf0e10cSrcweir 		{
915*cdf0e10cSrcweir 			exportEnumPropertyAttribute(
916*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE_TYPE),
917*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE),
918*cdf0e10cSrcweir 				PROPERTY_LISTSOURCETYPE,
919*cdf0e10cSrcweir 				OEnumMapper::getEnumMap(OEnumMapper::epListSourceType),
920*cdf0e10cSrcweir 				ListSourceType_VALUELIST
921*cdf0e10cSrcweir 				);
922*cdf0e10cSrcweir             RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE_TYPE );
923*cdf0e10cSrcweir 		}
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 		if (m_nIncludeDatabase & DA_LIST_SOURCE)
926*cdf0e10cSrcweir 		{
927*cdf0e10cSrcweir 			exportListSourceAsAttribute();
928*cdf0e10cSrcweir             RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE );
929*cdf0e10cSrcweir 		}
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
932*cdf0e10cSrcweir 		OSL_ENSURE(0 == nIncludeDatabase,
933*cdf0e10cSrcweir 			"OControlExport::exportDatabaseAttributes: forgot some flags!");
934*cdf0e10cSrcweir 			// in the dbg_util version, we should have removed every bit we handled from the mask, so it should
935*cdf0e10cSrcweir 			// be 0 now ...
936*cdf0e10cSrcweir #endif
937*cdf0e10cSrcweir 	}
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 	//---------------------------------------------------------------------
940*cdf0e10cSrcweir 	void OControlExport::exportBindingAtributes()
941*cdf0e10cSrcweir     {
942*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
943*cdf0e10cSrcweir 		sal_Int32 nIncludeBinding = m_nIncludeBindings;
944*cdf0e10cSrcweir #endif
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir         // ....................................................
947*cdf0e10cSrcweir         if ( m_nIncludeBindings & BA_LINKED_CELL )
948*cdf0e10cSrcweir         {
949*cdf0e10cSrcweir             exportCellBindingAttributes( ( m_nIncludeBindings & BA_LIST_LINKING_TYPE ) != 0 );
950*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 0
951*cdf0e10cSrcweir 			//  reset the bit for later checking
952*cdf0e10cSrcweir 			nIncludeBinding = nIncludeBinding & ~( BA_LINKED_CELL | BA_LIST_LINKING_TYPE );
953*cdf0e10cSrcweir 		#endif
954*cdf0e10cSrcweir         }
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir         // ....................................................
957*cdf0e10cSrcweir         if ( m_nIncludeBindings & BA_LIST_CELL_RANGE )
958*cdf0e10cSrcweir         {
959*cdf0e10cSrcweir             exportCellListSourceRange();
960*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 0
961*cdf0e10cSrcweir 			//  reset the bit for later checking
962*cdf0e10cSrcweir 			nIncludeBinding = nIncludeBinding & ~BA_LIST_CELL_RANGE;
963*cdf0e10cSrcweir 		#endif
964*cdf0e10cSrcweir         }
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir         if ( m_nIncludeBindings & BA_XFORMS_BIND )
967*cdf0e10cSrcweir         {
968*cdf0e10cSrcweir             exportXFormsBindAttributes();
969*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 0
970*cdf0e10cSrcweir 			//  reset the bit for later checking
971*cdf0e10cSrcweir 			nIncludeBinding = nIncludeBinding & ~BA_XFORMS_BIND;
972*cdf0e10cSrcweir 		#endif
973*cdf0e10cSrcweir         }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir         if ( m_nIncludeBindings & BA_XFORMS_LISTBIND )
976*cdf0e10cSrcweir         {
977*cdf0e10cSrcweir             exportXFormsListAttributes();
978*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 0
979*cdf0e10cSrcweir 			//  reset the bit for later checking
980*cdf0e10cSrcweir 			nIncludeBinding = nIncludeBinding & ~BA_XFORMS_LISTBIND;
981*cdf0e10cSrcweir 		#endif
982*cdf0e10cSrcweir         }
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir         if ( m_nIncludeBindings & BA_XFORMS_SUBMISSION )
985*cdf0e10cSrcweir         {
986*cdf0e10cSrcweir             exportXFormsSubmissionAttributes();
987*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 0
988*cdf0e10cSrcweir 			//  reset the bit for later checking
989*cdf0e10cSrcweir 			nIncludeBinding = nIncludeBinding & ~BA_XFORMS_SUBMISSION;
990*cdf0e10cSrcweir 		#endif
991*cdf0e10cSrcweir         }
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir         OSL_ENSURE( 0 == nIncludeBinding,
994*cdf0e10cSrcweir 			"OControlExport::exportBindingAtributes: forgot some flags!");
995*cdf0e10cSrcweir 			// in the debug version, we should have removed every bit we handled from the mask, so it should
996*cdf0e10cSrcweir 			// be 0 now ...
997*cdf0e10cSrcweir     }
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1000*cdf0e10cSrcweir 	void OControlExport::exportSpecialAttributes()
1001*cdf0e10cSrcweir 	{
1002*cdf0e10cSrcweir 		sal_Int32 i=0;
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir 		// ----------------------
1005*cdf0e10cSrcweir 		// the boolean properties
1006*cdf0e10cSrcweir 		{
1007*cdf0e10cSrcweir 			static const sal_Int32 nBooleanPropertyAttributeIds[] =
1008*cdf0e10cSrcweir 			{	// attribute flags
1009*cdf0e10cSrcweir 				SCA_VALIDATION, SCA_MULTI_LINE, SCA_AUTOMATIC_COMPLETION, SCA_MULTIPLE, SCA_DEFAULT_BUTTON, SCA_IS_TRISTATE,
1010*cdf0e10cSrcweir                 SCA_TOGGLE, SCA_FOCUS_ON_CLICK
1011*cdf0e10cSrcweir 			};
1012*cdf0e10cSrcweir 			static const ::rtl::OUString* pBooleanPropertyNames[] =
1013*cdf0e10cSrcweir 			{	// property names
1014*cdf0e10cSrcweir 				&PROPERTY_STRICTFORMAT, &PROPERTY_MULTILINE, &PROPERTY_AUTOCOMPLETE, &PROPERTY_MULTISELECTION, &PROPERTY_DEFAULTBUTTON, &PROPERTY_TRISTATE,
1015*cdf0e10cSrcweir                 &PROPERTY_TOGGLE, &PROPERTY_FOCUS_ON_CLICK
1016*cdf0e10cSrcweir 			};
1017*cdf0e10cSrcweir 			sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
1018*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
1019*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
1020*cdf0e10cSrcweir 			OSL_ENSURE((nIdCount == nNameCount),
1021*cdf0e10cSrcweir 				"OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!");
1022*cdf0e10cSrcweir 		#endif
1023*cdf0e10cSrcweir             const sal_Int32* pAttributeId = nBooleanPropertyAttributeIds;
1024*cdf0e10cSrcweir             const ::rtl::OUString** pPropertyName = pBooleanPropertyNames;
1025*cdf0e10cSrcweir 			for ( i = 0; i < nIdCount; ++i, ++pAttributeId, ++pPropertyName )
1026*cdf0e10cSrcweir             {
1027*cdf0e10cSrcweir 				if ( *pAttributeId& m_nIncludeSpecial)
1028*cdf0e10cSrcweir 				{
1029*cdf0e10cSrcweir 					exportBooleanPropertyAttribute(
1030*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeNamespace( *pAttributeId ),
1031*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeName( *pAttributeId ),
1032*cdf0e10cSrcweir 						*(*pPropertyName),
1033*cdf0e10cSrcweir                         ( *pAttributeId == SCA_FOCUS_ON_CLICK ) ? BOOLATTR_DEFAULT_TRUE : BOOLATTR_DEFAULT_FALSE
1034*cdf0e10cSrcweir 					);
1035*cdf0e10cSrcweir 			#if OSL_DEBUG_LEVEL > 0
1036*cdf0e10cSrcweir 				//  reset the bit for later checking
1037*cdf0e10cSrcweir 				m_nIncludeSpecial = m_nIncludeSpecial & ~*pAttributeId;
1038*cdf0e10cSrcweir 			#endif
1039*cdf0e10cSrcweir 				}
1040*cdf0e10cSrcweir             }
1041*cdf0e10cSrcweir 		}
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir 		// ----------------------
1044*cdf0e10cSrcweir 		// the integer properties
1045*cdf0e10cSrcweir 		{
1046*cdf0e10cSrcweir 			static sal_Int32 nIntegerPropertyAttributeIds[] =
1047*cdf0e10cSrcweir 			{	// attribute flags
1048*cdf0e10cSrcweir 				SCA_PAGE_STEP_SIZE
1049*cdf0e10cSrcweir 			};
1050*cdf0e10cSrcweir 			static const ::rtl::OUString* pIntegerPropertyNames[] =
1051*cdf0e10cSrcweir 			{	// property names
1052*cdf0e10cSrcweir                 &PROPERTY_BLOCK_INCREMENT
1053*cdf0e10cSrcweir 			};
1054*cdf0e10cSrcweir 			static const sal_Int32 nIntegerPropertyAttrDefaults[] =
1055*cdf0e10cSrcweir 			{	// attribute defaults (XML defaults, not runtime defaults!)
1056*cdf0e10cSrcweir 				10
1057*cdf0e10cSrcweir 			};
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir             sal_Int32 nIdCount = sizeof( nIntegerPropertyAttributeIds ) / sizeof( nIntegerPropertyAttributeIds[0] );
1060*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
1061*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof( pIntegerPropertyNames ) / sizeof( pIntegerPropertyNames[0] );
1062*cdf0e10cSrcweir 			OSL_ENSURE( ( nIdCount == nNameCount ),
1063*cdf0e10cSrcweir 				"OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1064*cdf0e10cSrcweir             sal_Int32 nDefaultCount = sizeof( nIntegerPropertyAttrDefaults ) / sizeof( nIntegerPropertyAttrDefaults[0] );
1065*cdf0e10cSrcweir 			OSL_ENSURE( ( nIdCount == nDefaultCount ),
1066*cdf0e10cSrcweir 				"OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" );
1067*cdf0e10cSrcweir 		#endif
1068*cdf0e10cSrcweir 			for ( i = 0; i < nIdCount; ++i )
1069*cdf0e10cSrcweir 				if ( nIntegerPropertyAttributeIds[i] & m_nIncludeSpecial )
1070*cdf0e10cSrcweir 				{
1071*cdf0e10cSrcweir 					exportInt32PropertyAttribute(
1072*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeNamespace( nIntegerPropertyAttributeIds[i] ),
1073*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeName( nIntegerPropertyAttributeIds[i] ),
1074*cdf0e10cSrcweir 						*( pIntegerPropertyNames[i] ),
1075*cdf0e10cSrcweir 						nIntegerPropertyAttrDefaults[i]
1076*cdf0e10cSrcweir 					);
1077*cdf0e10cSrcweir 			#if OSL_DEBUG_LEVEL > 0
1078*cdf0e10cSrcweir 				//  reset the bit for later checking
1079*cdf0e10cSrcweir 				m_nIncludeSpecial = m_nIncludeSpecial & ~nIntegerPropertyAttributeIds[i];
1080*cdf0e10cSrcweir 			#endif
1081*cdf0e10cSrcweir 				}
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir             if ( SCA_STEP_SIZE & m_nIncludeSpecial )
1084*cdf0e10cSrcweir             {
1085*cdf0e10cSrcweir                 ::rtl::OUString sPropertyName;
1086*cdf0e10cSrcweir                 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1087*cdf0e10cSrcweir                     sPropertyName = PROPERTY_LINE_INCREMENT;
1088*cdf0e10cSrcweir                 else if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1089*cdf0e10cSrcweir                     sPropertyName = PROPERTY_SPIN_INCREMENT;
1090*cdf0e10cSrcweir                 else
1091*cdf0e10cSrcweir                     OSL_ENSURE( sal_False, "OControlExport::exportSpecialAttributes: not property which can be mapped to step-size attribute!" );
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir                 if ( sPropertyName.getLength() )
1094*cdf0e10cSrcweir 					exportInt32PropertyAttribute(
1095*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeNamespace( SCA_STEP_SIZE ),
1096*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ),
1097*cdf0e10cSrcweir 						sPropertyName,
1098*cdf0e10cSrcweir 						1
1099*cdf0e10cSrcweir 					);
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir             #if OSL_DEBUG_LEVEL > 0
1102*cdf0e10cSrcweir 				//  reset the bit for later checking
1103*cdf0e10cSrcweir 				m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STEP_SIZE;
1104*cdf0e10cSrcweir 			#endif
1105*cdf0e10cSrcweir             }
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir         }
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir 		// -------------------
1110*cdf0e10cSrcweir 		// the enum properties
1111*cdf0e10cSrcweir 		{
1112*cdf0e10cSrcweir 			if (SCA_STATE & m_nIncludeSpecial)
1113*cdf0e10cSrcweir 			{
1114*cdf0e10cSrcweir 				exportEnumPropertyAttribute(
1115*cdf0e10cSrcweir 					OAttributeMetaData::getSpecialAttributeNamespace(SCA_STATE),
1116*cdf0e10cSrcweir 					OAttributeMetaData::getSpecialAttributeName(SCA_STATE),
1117*cdf0e10cSrcweir 					PROPERTY_DEFAULT_STATE,
1118*cdf0e10cSrcweir 					OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
1119*cdf0e10cSrcweir 					STATE_NOCHECK);
1120*cdf0e10cSrcweir 			#if OSL_DEBUG_LEVEL > 0
1121*cdf0e10cSrcweir 				//  reset the bit for later checking
1122*cdf0e10cSrcweir 				m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STATE;
1123*cdf0e10cSrcweir 			#endif
1124*cdf0e10cSrcweir 			}
1125*cdf0e10cSrcweir 
1126*cdf0e10cSrcweir 			if (SCA_CURRENT_STATE & m_nIncludeSpecial)
1127*cdf0e10cSrcweir 			{
1128*cdf0e10cSrcweir 				exportEnumPropertyAttribute(
1129*cdf0e10cSrcweir 					OAttributeMetaData::getSpecialAttributeNamespace(SCA_CURRENT_STATE),
1130*cdf0e10cSrcweir 					OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE),
1131*cdf0e10cSrcweir 					PROPERTY_STATE,
1132*cdf0e10cSrcweir 					OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
1133*cdf0e10cSrcweir 					STATE_NOCHECK);
1134*cdf0e10cSrcweir 			#if OSL_DEBUG_LEVEL > 0
1135*cdf0e10cSrcweir 				//  reset the bit for later checking
1136*cdf0e10cSrcweir 				m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_CURRENT_STATE;
1137*cdf0e10cSrcweir 			#endif
1138*cdf0e10cSrcweir 			}
1139*cdf0e10cSrcweir 		}
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir 		// --------------------------------------------------------------------
1142*cdf0e10cSrcweir 		// some properties which require a special handling
1143*cdf0e10cSrcweir         // the repeat delay
1144*cdf0e10cSrcweir         {
1145*cdf0e10cSrcweir 		    if ( m_nIncludeSpecial & SCA_REPEAT_DELAY )
1146*cdf0e10cSrcweir 		    {
1147*cdf0e10cSrcweir 		        DBG_CHECK_PROPERTY( PROPERTY_REPEAT_DELAY, sal_Int32 );
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir                 sal_Int32 nRepeatDelay = 0;
1150*cdf0e10cSrcweir                 m_xProps->getPropertyValue( PROPERTY_REPEAT_DELAY ) >>= nRepeatDelay;
1151*cdf0e10cSrcweir                 Time aTime;
1152*cdf0e10cSrcweir                 aTime.MakeTimeFromMS( nRepeatDelay );
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir 			    AddAttribute(OAttributeMetaData::getSpecialAttributeNamespace( SCA_REPEAT_DELAY )
1155*cdf0e10cSrcweir 						    ,OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY )
1156*cdf0e10cSrcweir 						    ,SvXMLUnitConverter::convertTimeDuration( aTime, nRepeatDelay % 1000 ) );
1157*cdf0e10cSrcweir 
1158*cdf0e10cSrcweir 		        exportedProperty( PROPERTY_REPEAT_DELAY );
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir             #if OSL_DEBUG_LEVEL > 0
1161*cdf0e10cSrcweir 			    //  reset the bit for later checking
1162*cdf0e10cSrcweir 			    m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_REPEAT_DELAY;
1163*cdf0e10cSrcweir 		    #endif
1164*cdf0e10cSrcweir 		    }
1165*cdf0e10cSrcweir         }
1166*cdf0e10cSrcweir 
1167*cdf0e10cSrcweir 		// ----------------------------------
1168*cdf0e10cSrcweir 		// the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
1169*cdf0e10cSrcweir 		{
1170*cdf0e10cSrcweir 			if (SCA_ECHO_CHAR & m_nIncludeSpecial)
1171*cdf0e10cSrcweir 			{
1172*cdf0e10cSrcweir 				DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 );
1173*cdf0e10cSrcweir 				sal_Int16 nValue(0);
1174*cdf0e10cSrcweir 				m_xProps->getPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue;
1175*cdf0e10cSrcweir 				if (nValue)
1176*cdf0e10cSrcweir 				{
1177*cdf0e10cSrcweir 					::rtl::OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1);
1178*cdf0e10cSrcweir 					AddAttribute(
1179*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeNamespace(SCA_ECHO_CHAR),
1180*cdf0e10cSrcweir 						OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR),
1181*cdf0e10cSrcweir 						sCharacter);
1182*cdf0e10cSrcweir 				}
1183*cdf0e10cSrcweir 				exportedProperty(PROPERTY_ECHO_CHAR);
1184*cdf0e10cSrcweir 			#if OSL_DEBUG_LEVEL > 0
1185*cdf0e10cSrcweir 				//  reset the bit for later checking
1186*cdf0e10cSrcweir 				m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_ECHO_CHAR;
1187*cdf0e10cSrcweir 			#endif
1188*cdf0e10cSrcweir 			}
1189*cdf0e10cSrcweir 		}
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir 		// ----------------------------------
1192*cdf0e10cSrcweir 		if ((SCA_MIN_VALUE | SCA_MAX_VALUE) & m_nIncludeSpecial)
1193*cdf0e10cSrcweir 		{
1194*cdf0e10cSrcweir 			// need to export the min value and the max value as attributes
1195*cdf0e10cSrcweir 			// It depends on the real type (FormComponentType) of the control, which properties hold these
1196*cdf0e10cSrcweir 			// values
1197*cdf0e10cSrcweir 			const sal_Char* pMinValuePropertyName = NULL;
1198*cdf0e10cSrcweir 			const sal_Char* pMaxValuePropertyName = NULL;
1199*cdf0e10cSrcweir 			getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName);
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir 			OSL_ENSURE((NULL == pMinValuePropertyName) == (0 == (SCA_MIN_VALUE & m_nIncludeSpecial)),
1202*cdf0e10cSrcweir 				"OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
1203*cdf0e10cSrcweir 			OSL_ENSURE((NULL == pMaxValuePropertyName) == (0 == (SCA_MAX_VALUE & m_nIncludeSpecial)),
1204*cdf0e10cSrcweir 				"OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir 			// add the two attributes
1207*cdf0e10cSrcweir 			static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE);
1208*cdf0e10cSrcweir 			static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE);
1209*cdf0e10cSrcweir 			static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MIN_VALUE);
1210*cdf0e10cSrcweir 			static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MAX_VALUE);
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir 			if (pMinValuePropertyName && (SCA_MIN_VALUE & m_nIncludeSpecial))
1213*cdf0e10cSrcweir 				exportGenericPropertyAttribute(
1214*cdf0e10cSrcweir 					nMinValueNamespaceKey,
1215*cdf0e10cSrcweir 					pMinValueAttributeName,
1216*cdf0e10cSrcweir 					pMinValuePropertyName);
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir 			if (pMaxValuePropertyName && (SCA_MAX_VALUE & m_nIncludeSpecial))
1219*cdf0e10cSrcweir 				exportGenericPropertyAttribute(
1220*cdf0e10cSrcweir 					nMaxValueNamespaceKey,
1221*cdf0e10cSrcweir 					pMaxValueAttributeName,
1222*cdf0e10cSrcweir 					pMaxValuePropertyName);
1223*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
1224*cdf0e10cSrcweir 			//  reset the bit for later checking
1225*cdf0e10cSrcweir 			m_nIncludeSpecial = m_nIncludeSpecial & ~(SCA_MIN_VALUE | SCA_MAX_VALUE);
1226*cdf0e10cSrcweir 		#endif
1227*cdf0e10cSrcweir 		}
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 		// ----------------------------------
1230*cdf0e10cSrcweir         if ( SCA_IMAGE_POSITION & m_nIncludeSpecial )
1231*cdf0e10cSrcweir         {
1232*cdf0e10cSrcweir             exportImagePositionAttributes();
1233*cdf0e10cSrcweir             RESET_BIT( m_nIncludeSpecial, SCA_IMAGE_POSITION );
1234*cdf0e10cSrcweir         }
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir 		OSL_ENSURE(0 == m_nIncludeSpecial,
1237*cdf0e10cSrcweir 			"OControlExport::exportSpecialAttributes: forgot some flags!");
1238*cdf0e10cSrcweir 			// in the dbg_util version, we should have removed every bit we handled from the mask, so it should
1239*cdf0e10cSrcweir 			// be 0 now ...
1240*cdf0e10cSrcweir 	}
1241*cdf0e10cSrcweir 
1242*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1243*cdf0e10cSrcweir     ::rtl::OUString OControlExport::getScalarListSourceValue() const
1244*cdf0e10cSrcweir     {
1245*cdf0e10cSrcweir 		::rtl::OUString sListSource;
1246*cdf0e10cSrcweir 		Any aListSource = m_xProps->getPropertyValue( PROPERTY_LISTSOURCE );
1247*cdf0e10cSrcweir 		if ( !( aListSource >>= sListSource ) )
1248*cdf0e10cSrcweir 		{
1249*cdf0e10cSrcweir 			Sequence< ::rtl::OUString > aListSourceSequence;
1250*cdf0e10cSrcweir 			aListSource >>= aListSourceSequence;
1251*cdf0e10cSrcweir 			if ( aListSourceSequence.getLength() )
1252*cdf0e10cSrcweir 				sListSource = aListSourceSequence[ 0 ];
1253*cdf0e10cSrcweir 		}
1254*cdf0e10cSrcweir         return sListSource;
1255*cdf0e10cSrcweir     }
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1258*cdf0e10cSrcweir 	void OControlExport::exportListSourceAsAttribute()
1259*cdf0e10cSrcweir 	{
1260*cdf0e10cSrcweir 		// DA_LIST_SOURCE needs some special handling
1261*cdf0e10cSrcweir 		DBG_CHECK_PROPERTY_NO_TYPE( PROPERTY_LISTSOURCE );
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir         ::rtl::OUString sListSource = getScalarListSourceValue();
1264*cdf0e10cSrcweir 		if ( sListSource.getLength() )
1265*cdf0e10cSrcweir 		{	// the ListSource property needs to be exported as attribute, and it is not empty
1266*cdf0e10cSrcweir 			AddAttribute(
1267*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE),
1268*cdf0e10cSrcweir 				OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE),
1269*cdf0e10cSrcweir 				sListSource);
1270*cdf0e10cSrcweir 		}
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir         exportedProperty( PROPERTY_LISTSOURCE );
1273*cdf0e10cSrcweir 	}
1274*cdf0e10cSrcweir 
1275*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1276*cdf0e10cSrcweir 	void OControlExport::getSequenceInt16PropertyAsSet(const ::rtl::OUString& _rPropertyName, Int16Set& _rOut)
1277*cdf0e10cSrcweir 	{
1278*cdf0e10cSrcweir 		Sequence< sal_Int16 > aValueSequence;
1279*cdf0e10cSrcweir 		DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >);
1280*cdf0e10cSrcweir 		m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence;
1281*cdf0e10cSrcweir 
1282*cdf0e10cSrcweir 		const sal_Int16* pValues = aValueSequence.getConstArray();
1283*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<aValueSequence.getLength(); ++i, ++pValues)
1284*cdf0e10cSrcweir 			_rOut.insert(*pValues);
1285*cdf0e10cSrcweir 	}
1286*cdf0e10cSrcweir 
1287*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1288*cdf0e10cSrcweir 	void OControlExport::exportListSourceAsElements()
1289*cdf0e10cSrcweir 	{
1290*cdf0e10cSrcweir 		// the string lists
1291*cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aItems, aValues;
1292*cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< ::rtl::OUString > );
1293*cdf0e10cSrcweir 		m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems;
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( PROPERTY_LISTSOURCE, Sequence< ::rtl::OUString > );
1296*cdf0e10cSrcweir 		if ( 0 == ( m_nIncludeDatabase & DA_LIST_SOURCE ) )
1297*cdf0e10cSrcweir 			m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues;
1298*cdf0e10cSrcweir 		// if we exported the list source as attribute, we do not repeat it as sub elements
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir 		// the selection lists
1301*cdf0e10cSrcweir 		Int16Set aSelection, aDefaultSelection;
1302*cdf0e10cSrcweir 		getSequenceInt16PropertyAsSet(PROPERTY_SELECT_SEQ, aSelection);
1303*cdf0e10cSrcweir 		getSequenceInt16PropertyAsSet(PROPERTY_DEFAULT_SELECT_SEQ, aDefaultSelection);
1304*cdf0e10cSrcweir 
1305*cdf0e10cSrcweir 		// the string for "true"
1306*cdf0e10cSrcweir 		::rtl::OUString sTrue;
1307*cdf0e10cSrcweir 		::rtl::OUStringBuffer sBuffer;
1308*cdf0e10cSrcweir 		m_rContext.getGlobalContext().GetMM100UnitConverter().convertBool(sBuffer, sal_True);
1309*cdf0e10cSrcweir 		sTrue = sBuffer.makeStringAndClear();
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir 		// loop through both lists ('til the maximum of both lengths)
1312*cdf0e10cSrcweir 		const ::rtl::OUString* pItems = aItems.getConstArray();
1313*cdf0e10cSrcweir 		const ::rtl::OUString* pValues = aValues.getConstArray();
1314*cdf0e10cSrcweir 
1315*cdf0e10cSrcweir 		sal_Int32 nItems = aItems.getLength();
1316*cdf0e10cSrcweir 		sal_Int32 nValues = aValues.getLength();
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir 		sal_Int16 nMaxLen = (sal_Int16)std::max(nItems, nValues);
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir 		for	(sal_Int16 i=0; i<nMaxLen; ++i )
1321*cdf0e10cSrcweir 		{
1322*cdf0e10cSrcweir 			m_rContext.getGlobalContext().ClearAttrList();
1323*cdf0e10cSrcweir 			if (i < nItems)
1324*cdf0e10cSrcweir 			{
1325*cdf0e10cSrcweir 				// there is an item at this position
1326*cdf0e10cSrcweir 				AddAttribute(
1327*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
1328*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
1329*cdf0e10cSrcweir 					*pItems);
1330*cdf0e10cSrcweir 				++pItems;
1331*cdf0e10cSrcweir 			}
1332*cdf0e10cSrcweir 			if (i < nValues)
1333*cdf0e10cSrcweir 			{
1334*cdf0e10cSrcweir 				// there is an value at this position
1335*cdf0e10cSrcweir 				AddAttribute(
1336*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE),
1337*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE),
1338*cdf0e10cSrcweir 					*pValues);
1339*cdf0e10cSrcweir 				++pValues;
1340*cdf0e10cSrcweir 			}
1341*cdf0e10cSrcweir 
1342*cdf0e10cSrcweir 			Int16SetIterator aSelectedPos = aSelection.find(i);
1343*cdf0e10cSrcweir 			if (aSelection.end() != aSelectedPos)
1344*cdf0e10cSrcweir 			{	// the item at this position is selected
1345*cdf0e10cSrcweir 				AddAttribute(
1346*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED),
1347*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED),
1348*cdf0e10cSrcweir 					sTrue
1349*cdf0e10cSrcweir 					);
1350*cdf0e10cSrcweir 				aSelection.erase(aSelectedPos);
1351*cdf0e10cSrcweir 			}
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir 			Int16SetIterator aDefaultSelectedPos = aDefaultSelection.find(i);
1354*cdf0e10cSrcweir 			if (aDefaultSelection.end() != aDefaultSelectedPos)
1355*cdf0e10cSrcweir 			{	// the item at this position is selected as default
1356*cdf0e10cSrcweir 				AddAttribute(
1357*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED),
1358*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED),
1359*cdf0e10cSrcweir 					sTrue
1360*cdf0e10cSrcweir 					);
1361*cdf0e10cSrcweir 				aDefaultSelection.erase(aDefaultSelectedPos);
1362*cdf0e10cSrcweir 			}
1363*cdf0e10cSrcweir 			SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", sal_True, sal_True);
1364*cdf0e10cSrcweir 		}
1365*cdf0e10cSrcweir 
1366*cdf0e10cSrcweir 		// There may be more "selected" or "default-selected" items than there are in the lists in real,
1367*cdf0e10cSrcweir 		// so we need to store some additional "form:option" items which have no name and no label, but
1368*cdf0e10cSrcweir 		// one or both of the selected flags.
1369*cdf0e10cSrcweir 		// 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
1370*cdf0e10cSrcweir 
1371*cdf0e10cSrcweir 		if ( !aSelection.empty() || !aDefaultSelection.empty() )
1372*cdf0e10cSrcweir 		{
1373*cdf0e10cSrcweir 			sal_Int16 nLastSelected = -1;
1374*cdf0e10cSrcweir 			if ( !aSelection.empty() )
1375*cdf0e10cSrcweir 				nLastSelected = *(--aSelection.end());
1376*cdf0e10cSrcweir 
1377*cdf0e10cSrcweir 			sal_Int16 nLastDefaultSelected = -1;
1378*cdf0e10cSrcweir 			if ( !aDefaultSelection.empty() )
1379*cdf0e10cSrcweir 				nLastDefaultSelected = *(--aDefaultSelection.end());
1380*cdf0e10cSrcweir 
1381*cdf0e10cSrcweir 			// the maximum element in both sets
1382*cdf0e10cSrcweir 			sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected);
1383*cdf0e10cSrcweir 			OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!");
1384*cdf0e10cSrcweir 				// if the maximum (selected or default selected) entry number is less than the maximum item count
1385*cdf0e10cSrcweir 				// in both lists, the entry number should have been removed from the set
1386*cdf0e10cSrcweir 
1387*cdf0e10cSrcweir 			for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i)
1388*cdf0e10cSrcweir 			{
1389*cdf0e10cSrcweir 				if (aSelection.end() != aSelection.find(i))
1390*cdf0e10cSrcweir 				{	// the (not existent) item at this position is selected
1391*cdf0e10cSrcweir 					AddAttribute(
1392*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED),
1393*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED),
1394*cdf0e10cSrcweir 						sTrue
1395*cdf0e10cSrcweir 						);
1396*cdf0e10cSrcweir 				}
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir 				if (aDefaultSelection.end() != aDefaultSelection.find(i))
1399*cdf0e10cSrcweir 				{	// the (not existent) item at this position is selected as default
1400*cdf0e10cSrcweir 					AddAttribute(
1401*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED),
1402*cdf0e10cSrcweir 						OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED),
1403*cdf0e10cSrcweir 						sTrue
1404*cdf0e10cSrcweir 						);
1405*cdf0e10cSrcweir 				}
1406*cdf0e10cSrcweir 				SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", sal_True, sal_True);
1407*cdf0e10cSrcweir 			}
1408*cdf0e10cSrcweir 		}
1409*cdf0e10cSrcweir 	}
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1412*cdf0e10cSrcweir 	void OControlExport::implStartElement(const sal_Char* _pName)
1413*cdf0e10cSrcweir 	{
1414*cdf0e10cSrcweir 		// before we let the base class start it's outer element, we add a wrapper element
1415*cdf0e10cSrcweir 		const sal_Char *pOuterElementName = getOuterXMLElementName();
1416*cdf0e10cSrcweir 		m_pOuterElement = pOuterElementName
1417*cdf0e10cSrcweir 		   					? new SvXMLElementExport(
1418*cdf0e10cSrcweir 										m_rContext.getGlobalContext(),
1419*cdf0e10cSrcweir 										XML_NAMESPACE_FORM,
1420*cdf0e10cSrcweir 										pOuterElementName, sal_True,
1421*cdf0e10cSrcweir 										sal_True)
1422*cdf0e10cSrcweir 							: 0;
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir 		// add the attributes for the inner element
1425*cdf0e10cSrcweir 		exportInnerAttributes();
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir 		// and start the inner element
1428*cdf0e10cSrcweir 		OElementExport::implStartElement(_pName);
1429*cdf0e10cSrcweir 	}
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1432*cdf0e10cSrcweir 	void OControlExport::implEndElement()
1433*cdf0e10cSrcweir 	{
1434*cdf0e10cSrcweir 		// end the inner element
1435*cdf0e10cSrcweir 		OElementExport::implEndElement();
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir 		// end the outer element if it exists
1438*cdf0e10cSrcweir 		delete m_pOuterElement;
1439*cdf0e10cSrcweir 		m_pOuterElement = NULL;
1440*cdf0e10cSrcweir 	}
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1443*cdf0e10cSrcweir 	const sal_Char* OControlExport::getOuterXMLElementName() const
1444*cdf0e10cSrcweir 	{
1445*cdf0e10cSrcweir 		return 0;
1446*cdf0e10cSrcweir 	}
1447*cdf0e10cSrcweir 
1448*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1449*cdf0e10cSrcweir 	const sal_Char* OControlExport::getXMLElementName() const
1450*cdf0e10cSrcweir 	{
1451*cdf0e10cSrcweir 		return getElementName(m_eType);
1452*cdf0e10cSrcweir 	}
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1455*cdf0e10cSrcweir 	void OControlExport::examine()
1456*cdf0e10cSrcweir 	{
1457*cdf0e10cSrcweir         OSL_ENSURE( ( m_nIncludeCommon == 0 ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == 0 )
1458*cdf0e10cSrcweir                  && ( m_nIncludeEvents == 0 ) && ( m_nIncludeBindings == 0),
1459*cdf0e10cSrcweir                  "OControlExport::examine: called me twice? Not initialized?" );
1460*cdf0e10cSrcweir 
1461*cdf0e10cSrcweir         // get the class id to decide which kind of element we need in the XML stream
1462*cdf0e10cSrcweir 		m_nClassId = FormComponentType::CONTROL;
1463*cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 );
1464*cdf0e10cSrcweir 		m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId;
1465*cdf0e10cSrcweir         bool knownType = false;
1466*cdf0e10cSrcweir 		switch (m_nClassId)
1467*cdf0e10cSrcweir 		{
1468*cdf0e10cSrcweir 			case FormComponentType::DATEFIELD:
1469*cdf0e10cSrcweir                 m_eType = DATE;
1470*cdf0e10cSrcweir                 knownType = true;
1471*cdf0e10cSrcweir                 // NO BREAK
1472*cdf0e10cSrcweir 			case FormComponentType::TIMEFIELD:
1473*cdf0e10cSrcweir                 if ( !knownType )
1474*cdf0e10cSrcweir                 {
1475*cdf0e10cSrcweir                     m_eType = TIME;
1476*cdf0e10cSrcweir                     knownType = true;
1477*cdf0e10cSrcweir                 }
1478*cdf0e10cSrcweir 				m_nIncludeSpecial |= SCA_VALIDATION;
1479*cdf0e10cSrcweir                 // NO BREAK
1480*cdf0e10cSrcweir 			case FormComponentType::NUMERICFIELD:
1481*cdf0e10cSrcweir 			case FormComponentType::CURRENCYFIELD:
1482*cdf0e10cSrcweir 			case FormComponentType::PATTERNFIELD:
1483*cdf0e10cSrcweir                 if ( !knownType )
1484*cdf0e10cSrcweir                 {
1485*cdf0e10cSrcweir 				    m_eType = FORMATTED_TEXT;
1486*cdf0e10cSrcweir                     knownType = true;
1487*cdf0e10cSrcweir                 }
1488*cdf0e10cSrcweir 				// NO BREAK
1489*cdf0e10cSrcweir 			case FormComponentType::TEXTFIELD:
1490*cdf0e10cSrcweir 			{	// it's some kind of edit. To know which type we need further investigation
1491*cdf0e10cSrcweir 
1492*cdf0e10cSrcweir 				if ( !knownType )
1493*cdf0e10cSrcweir 				{
1494*cdf0e10cSrcweir 					// check if it's a formatted field
1495*cdf0e10cSrcweir 					if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY))
1496*cdf0e10cSrcweir 					{
1497*cdf0e10cSrcweir 						m_eType = FORMATTED_TEXT;
1498*cdf0e10cSrcweir 					}
1499*cdf0e10cSrcweir 					else
1500*cdf0e10cSrcweir 					{
1501*cdf0e10cSrcweir 						// all other controls are represented by an ordinary edit control, but which XML control type
1502*cdf0e10cSrcweir 						// it is depends on the current values of some properties
1503*cdf0e10cSrcweir 
1504*cdf0e10cSrcweir 						// if the EchoChar string is not empty, it is a password field
1505*cdf0e10cSrcweir 						sal_Int16 nEchoChar = 0;
1506*cdf0e10cSrcweir 						if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR))
1507*cdf0e10cSrcweir 							// grid columns do not have this property ....
1508*cdf0e10cSrcweir 							m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar;
1509*cdf0e10cSrcweir 						if (nEchoChar)
1510*cdf0e10cSrcweir 						{
1511*cdf0e10cSrcweir 							m_eType = PASSWORD;
1512*cdf0e10cSrcweir 							m_nIncludeSpecial |= SCA_ECHO_CHAR;
1513*cdf0e10cSrcweir 						}
1514*cdf0e10cSrcweir 						else
1515*cdf0e10cSrcweir 						{
1516*cdf0e10cSrcweir 							// if the MultiLine property is sal_True, it is a TextArea
1517*cdf0e10cSrcweir 							sal_Bool bMultiLine = sal_False;
1518*cdf0e10cSrcweir 							if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE))
1519*cdf0e10cSrcweir 								// grid columns do not have this property ....
1520*cdf0e10cSrcweir 								bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE));
1521*cdf0e10cSrcweir 
1522*cdf0e10cSrcweir                             if ( bMultiLine )
1523*cdf0e10cSrcweir 								m_eType = TEXT_AREA;
1524*cdf0e10cSrcweir 							else
1525*cdf0e10cSrcweir 								// the only case left is represented by a Text element
1526*cdf0e10cSrcweir 								m_eType = TEXT;
1527*cdf0e10cSrcweir 						}
1528*cdf0e10cSrcweir 					}
1529*cdf0e10cSrcweir                     knownType = true;
1530*cdf0e10cSrcweir 				}
1531*cdf0e10cSrcweir 
1532*cdf0e10cSrcweir 				// attributes which are common to all the types:
1533*cdf0e10cSrcweir 				// common attributes
1534*cdf0e10cSrcweir 				m_nIncludeCommon =
1535*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED |
1536*cdf0e10cSrcweir 					CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir                 if  (   ( m_nClassId != FormComponentType::DATEFIELD )
1539*cdf0e10cSrcweir                     &&  ( m_nClassId != FormComponentType::TIMEFIELD )
1540*cdf0e10cSrcweir                     )
1541*cdf0e10cSrcweir                     // date and time field values are handled differently nowadays
1542*cdf0e10cSrcweir                     m_nIncludeCommon |= CCA_VALUE;
1543*cdf0e10cSrcweir 
1544*cdf0e10cSrcweir                 // database attributes
1545*cdf0e10cSrcweir 				m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1546*cdf0e10cSrcweir 
1547*cdf0e10cSrcweir 				// event attributes
1548*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1549*cdf0e10cSrcweir 
1550*cdf0e10cSrcweir 				// only text and pattern fields have a ConvertEmptyToNull property
1551*cdf0e10cSrcweir 				if  (   ( m_nClassId == FormComponentType::TEXTFIELD )
1552*cdf0e10cSrcweir                     ||  ( m_nClassId == FormComponentType::PATTERNFIELD )
1553*cdf0e10cSrcweir                     )
1554*cdf0e10cSrcweir 					m_nIncludeDatabase |= DA_CONVERT_EMPTY;
1555*cdf0e10cSrcweir 
1556*cdf0e10cSrcweir 				// all controls but the file control fields have a readonly property
1557*cdf0e10cSrcweir 				if ( m_nClassId != FormComponentType::FILECONTROL )
1558*cdf0e10cSrcweir 					m_nIncludeCommon |= CCA_READONLY;
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir 				// a text field has a max text len
1561*cdf0e10cSrcweir                 if ( m_nClassId == FormComponentType::TEXTFIELD )
1562*cdf0e10cSrcweir 					m_nIncludeCommon |= CCA_MAX_LENGTH;
1563*cdf0e10cSrcweir 
1564*cdf0e10cSrcweir 				// max and min values and validation:
1565*cdf0e10cSrcweir 				if (FORMATTED_TEXT == m_eType)
1566*cdf0e10cSrcweir 				{	// in general all controls represented as formatted-text have these props
1567*cdf0e10cSrcweir 					if  ( FormComponentType::PATTERNFIELD != m_nClassId )   // except the PatternField
1568*cdf0e10cSrcweir 						m_nIncludeSpecial |= SCA_MAX_VALUE | SCA_MIN_VALUE;
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir 					if (FormComponentType::TEXTFIELD != m_nClassId)
1571*cdf0e10cSrcweir 						// and the FormattedField does not have a validation flag
1572*cdf0e10cSrcweir 						m_nIncludeSpecial |= SCA_VALIDATION;
1573*cdf0e10cSrcweir 				}
1574*cdf0e10cSrcweir 
1575*cdf0e10cSrcweir 				// if it's not a password field or rich text control, the CurrentValue needs to be stored, too
1576*cdf0e10cSrcweir 				if  (   ( PASSWORD != m_eType )
1577*cdf0e10cSrcweir                     &&  ( DATE != m_eType )
1578*cdf0e10cSrcweir                     &&  ( TIME != m_eType )
1579*cdf0e10cSrcweir                     )
1580*cdf0e10cSrcweir                 {
1581*cdf0e10cSrcweir 				    m_nIncludeCommon |= CCA_CURRENT_VALUE;
1582*cdf0e10cSrcweir                 }
1583*cdf0e10cSrcweir 			}
1584*cdf0e10cSrcweir 			break;
1585*cdf0e10cSrcweir 
1586*cdf0e10cSrcweir 			case FormComponentType::FILECONTROL:
1587*cdf0e10cSrcweir 				m_eType = FILE;
1588*cdf0e10cSrcweir 				m_nIncludeCommon =
1589*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE | CCA_DISABLED |
1590*cdf0e10cSrcweir 					CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE |
1591*cdf0e10cSrcweir 					CCA_VALUE;
1592*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1593*cdf0e10cSrcweir 				break;
1594*cdf0e10cSrcweir 
1595*cdf0e10cSrcweir 			case FormComponentType::FIXEDTEXT:
1596*cdf0e10cSrcweir 				m_eType = FIXED_TEXT;
1597*cdf0e10cSrcweir 				m_nIncludeCommon =
1598*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL |
1599*cdf0e10cSrcweir 					CCA_PRINTABLE | CCA_TITLE | CCA_FOR;
1600*cdf0e10cSrcweir 				m_nIncludeSpecial = SCA_MULTI_LINE;
1601*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS;
1602*cdf0e10cSrcweir 				break;
1603*cdf0e10cSrcweir 
1604*cdf0e10cSrcweir 			case FormComponentType::COMBOBOX:
1605*cdf0e10cSrcweir 				m_eType = COMBOBOX;
1606*cdf0e10cSrcweir 				m_nIncludeCommon =
1607*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE |
1608*cdf0e10cSrcweir 					CCA_DISABLED | CCA_DROPDOWN | CCA_MAX_LENGTH | CCA_PRINTABLE | CCA_READONLY | CCA_SIZE |
1609*cdf0e10cSrcweir 					CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE;
1610*cdf0e10cSrcweir 				m_nIncludeSpecial = SCA_AUTOMATIC_COMPLETION;
1611*cdf0e10cSrcweir 				m_nIncludeDatabase = DA_CONVERT_EMPTY | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE | DA_LIST_SOURCE_TYPE;
1612*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1613*cdf0e10cSrcweir 				break;
1614*cdf0e10cSrcweir 
1615*cdf0e10cSrcweir 			case FormComponentType::LISTBOX:
1616*cdf0e10cSrcweir 				m_eType = LISTBOX;
1617*cdf0e10cSrcweir 				m_nIncludeCommon =
1618*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_DROPDOWN |
1619*cdf0e10cSrcweir 					CCA_PRINTABLE | CCA_SIZE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1620*cdf0e10cSrcweir 				m_nIncludeSpecial = SCA_MULTIPLE;
1621*cdf0e10cSrcweir 				m_nIncludeDatabase = DA_BOUND_COLUMN | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE_TYPE;
1622*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_CLICK | EA_ON_DBLCLICK;
1623*cdf0e10cSrcweir 				// check if we need to export the ListSource as attribute
1624*cdf0e10cSrcweir 				{
1625*cdf0e10cSrcweir 					// for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead
1626*cdf0e10cSrcweir 					// a sequence of pairs which is build from the StringItemList and the ValueList
1627*cdf0e10cSrcweir 					ListSourceType eListSourceType = ListSourceType_VALUELIST;
1628*cdf0e10cSrcweir                 #if OSL_DEBUG_LEVEL > 0
1629*cdf0e10cSrcweir 					sal_Bool bSuccess =
1630*cdf0e10cSrcweir 				#endif
1631*cdf0e10cSrcweir 					m_xProps->getPropertyValue(PROPERTY_LISTSOURCETYPE) >>= eListSourceType;
1632*cdf0e10cSrcweir 					OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!");
1633*cdf0e10cSrcweir 					if (ListSourceType_VALUELIST != eListSourceType)
1634*cdf0e10cSrcweir 					{
1635*cdf0e10cSrcweir 						m_nIncludeDatabase |= DA_LIST_SOURCE;
1636*cdf0e10cSrcweir 					}
1637*cdf0e10cSrcweir 				}
1638*cdf0e10cSrcweir 
1639*cdf0e10cSrcweir 				break;
1640*cdf0e10cSrcweir 
1641*cdf0e10cSrcweir 			case FormComponentType::COMMANDBUTTON:
1642*cdf0e10cSrcweir 				m_eType = BUTTON;
1643*cdf0e10cSrcweir 				m_nIncludeCommon |= CCA_TAB_STOP | CCA_LABEL;
1644*cdf0e10cSrcweir 				m_nIncludeSpecial = SCA_DEFAULT_BUTTON | SCA_TOGGLE | SCA_FOCUS_ON_CLICK | SCA_IMAGE_POSITION | SCA_REPEAT_DELAY;
1645*cdf0e10cSrcweir 				// NO BREAK !
1646*cdf0e10cSrcweir 			case FormComponentType::IMAGEBUTTON:
1647*cdf0e10cSrcweir 				if (BUTTON != m_eType)
1648*cdf0e10cSrcweir                 {
1649*cdf0e10cSrcweir 					// not coming from the previous case
1650*cdf0e10cSrcweir 					m_eType = IMAGE;
1651*cdf0e10cSrcweir                 }
1652*cdf0e10cSrcweir 				m_nIncludeCommon |=
1653*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_BUTTON_TYPE | CCA_DISABLED |
1654*cdf0e10cSrcweir 					CCA_IMAGE_DATA | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TARGET_FRAME |
1655*cdf0e10cSrcweir 					CCA_TARGET_LOCATION | CCA_TITLE;
1656*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CLICK	| EA_ON_DBLCLICK;
1657*cdf0e10cSrcweir 				break;
1658*cdf0e10cSrcweir 
1659*cdf0e10cSrcweir 			case FormComponentType::CHECKBOX:
1660*cdf0e10cSrcweir 				m_eType = CHECKBOX;
1661*cdf0e10cSrcweir 				m_nIncludeSpecial = SCA_CURRENT_STATE | SCA_IS_TRISTATE | SCA_STATE;
1662*cdf0e10cSrcweir 				// NO BREAK !
1663*cdf0e10cSrcweir 			case FormComponentType::RADIOBUTTON:
1664*cdf0e10cSrcweir 				m_nIncludeCommon =
1665*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL | CCA_PRINTABLE |
1666*cdf0e10cSrcweir                     CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE | CCA_VISUAL_EFFECT;
1667*cdf0e10cSrcweir 				if (CHECKBOX != m_eType)
1668*cdf0e10cSrcweir 				{	// not coming from the previous case
1669*cdf0e10cSrcweir 					m_eType = RADIO;
1670*cdf0e10cSrcweir 					m_nIncludeCommon |= CCA_CURRENT_SELECTED | CCA_SELECTED;
1671*cdf0e10cSrcweir 				}
1672*cdf0e10cSrcweir                 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_IMAGE_POSITION ) )
1673*cdf0e10cSrcweir                     m_nIncludeSpecial |= SCA_IMAGE_POSITION;
1674*cdf0e10cSrcweir 				m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1675*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE;
1676*cdf0e10cSrcweir 				break;
1677*cdf0e10cSrcweir 
1678*cdf0e10cSrcweir 			case FormComponentType::GROUPBOX:
1679*cdf0e10cSrcweir 				m_eType = FRAME;
1680*cdf0e10cSrcweir 				m_nIncludeCommon =
1681*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL |
1682*cdf0e10cSrcweir 					CCA_PRINTABLE | CCA_TITLE | CCA_FOR;
1683*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS;
1684*cdf0e10cSrcweir 				break;
1685*cdf0e10cSrcweir 
1686*cdf0e10cSrcweir 			case FormComponentType::IMAGECONTROL:
1687*cdf0e10cSrcweir 				m_eType = IMAGE_FRAME;
1688*cdf0e10cSrcweir 				m_nIncludeCommon =
1689*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_IMAGE_DATA |
1690*cdf0e10cSrcweir 					CCA_PRINTABLE | CCA_READONLY | CCA_TITLE;
1691*cdf0e10cSrcweir 				m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1692*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS;
1693*cdf0e10cSrcweir 				break;
1694*cdf0e10cSrcweir 
1695*cdf0e10cSrcweir 			case FormComponentType::HIDDENCONTROL:
1696*cdf0e10cSrcweir 				m_eType = HIDDEN;
1697*cdf0e10cSrcweir 				m_nIncludeCommon =
1698*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_VALUE;
1699*cdf0e10cSrcweir 				break;
1700*cdf0e10cSrcweir 
1701*cdf0e10cSrcweir 			case FormComponentType::GRIDCONTROL:
1702*cdf0e10cSrcweir 				m_eType = GRID;
1703*cdf0e10cSrcweir 				m_nIncludeCommon =
1704*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE |
1705*cdf0e10cSrcweir 					CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1706*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS;
1707*cdf0e10cSrcweir 				break;
1708*cdf0e10cSrcweir 
1709*cdf0e10cSrcweir 			case FormComponentType::SCROLLBAR:
1710*cdf0e10cSrcweir 			case FormComponentType::SPINBUTTON:
1711*cdf0e10cSrcweir 				m_eType = VALUERANGE;
1712*cdf0e10cSrcweir 				m_nIncludeCommon =
1713*cdf0e10cSrcweir 					CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE |
1714*cdf0e10cSrcweir                     CCA_TITLE | CCA_CURRENT_VALUE | CCA_VALUE | CCA_ORIENTATION;
1715*cdf0e10cSrcweir                 m_nIncludeSpecial = SCA_MAX_VALUE | SCA_STEP_SIZE | SCA_MIN_VALUE | SCA_REPEAT_DELAY;
1716*cdf0e10cSrcweir 
1717*cdf0e10cSrcweir                 if ( m_nClassId == FormComponentType::SCROLLBAR )
1718*cdf0e10cSrcweir                     m_nIncludeSpecial |= SCA_PAGE_STEP_SIZE ;
1719*cdf0e10cSrcweir 
1720*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS;
1721*cdf0e10cSrcweir                 break;
1722*cdf0e10cSrcweir 
1723*cdf0e10cSrcweir             default:
1724*cdf0e10cSrcweir 				OSL_ENSURE(sal_False, "OControlExport::examineControl: unknown control type (class id)!");
1725*cdf0e10cSrcweir                 // NO break!
1726*cdf0e10cSrcweir 
1727*cdf0e10cSrcweir             case FormComponentType::NAVIGATIONBAR:
1728*cdf0e10cSrcweir                 // TODO: should we have an own file format for this?
1729*cdf0e10cSrcweir                 // NO break
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir             case FormComponentType::CONTROL:
1732*cdf0e10cSrcweir 				m_eType = GENERIC_CONTROL;
1733*cdf0e10cSrcweir 				// unknown control type
1734*cdf0e10cSrcweir 				m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME;
1735*cdf0e10cSrcweir 					// at least a name should be there, 'cause without a name the control could never have been
1736*cdf0e10cSrcweir 					// inserted into it's parent container
1737*cdf0e10cSrcweir 					// In addition, the service name is absolutely necessary to create the control upon reading.
1738*cdf0e10cSrcweir 				m_nIncludeEvents = EA_CONTROL_EVENTS;
1739*cdf0e10cSrcweir 					// we always should be able to export events - this is not control type dependent
1740*cdf0e10cSrcweir 				break;
1741*cdf0e10cSrcweir 		}
1742*cdf0e10cSrcweir 
1743*cdf0e10cSrcweir 		// in general, all control types need to export the control id
1744*cdf0e10cSrcweir 		m_nIncludeCommon |= CCA_CONTROL_ID;
1745*cdf0e10cSrcweir 
1746*cdf0e10cSrcweir         // is is a control bound to a calc cell?
1747*cdf0e10cSrcweir         if ( FormCellBindingHelper::livesInSpreadsheetDocument( m_xProps ) )
1748*cdf0e10cSrcweir         {
1749*cdf0e10cSrcweir             FormCellBindingHelper aHelper( m_xProps, NULL );
1750*cdf0e10cSrcweir             {
1751*cdf0e10cSrcweir                 if ( aHelper.isCellBinding( aHelper.getCurrentBinding( ) ) )
1752*cdf0e10cSrcweir                 {
1753*cdf0e10cSrcweir                     m_nIncludeBindings |= BA_LINKED_CELL;
1754*cdf0e10cSrcweir                     if ( m_nClassId == FormComponentType::LISTBOX )
1755*cdf0e10cSrcweir                         m_nIncludeBindings |= BA_LIST_LINKING_TYPE;
1756*cdf0e10cSrcweir                 }
1757*cdf0e10cSrcweir             }
1758*cdf0e10cSrcweir 
1759*cdf0e10cSrcweir             // is it a list-like control which uses a calc cell range as list source?
1760*cdf0e10cSrcweir             {
1761*cdf0e10cSrcweir                 if ( aHelper.isCellRangeListSource( aHelper.getCurrentListSource( ) ) )
1762*cdf0e10cSrcweir                     m_nIncludeBindings |= BA_LIST_CELL_RANGE;
1763*cdf0e10cSrcweir             }
1764*cdf0e10cSrcweir         }
1765*cdf0e10cSrcweir 
1766*cdf0e10cSrcweir         // is control bound to XForms?
1767*cdf0e10cSrcweir         if( getXFormsBindName( m_xProps ).getLength() > 0 )
1768*cdf0e10cSrcweir         {
1769*cdf0e10cSrcweir             m_nIncludeBindings |= BA_XFORMS_BIND;
1770*cdf0e10cSrcweir         }
1771*cdf0e10cSrcweir 
1772*cdf0e10cSrcweir         // is (list-)control bound to XForms list?
1773*cdf0e10cSrcweir         if( getXFormsListBindName( m_xProps ).getLength() > 0 )
1774*cdf0e10cSrcweir         {
1775*cdf0e10cSrcweir             m_nIncludeBindings |= BA_XFORMS_LISTBIND;
1776*cdf0e10cSrcweir         }
1777*cdf0e10cSrcweir 
1778*cdf0e10cSrcweir         // does the control have an XForms submission?
1779*cdf0e10cSrcweir         if( getXFormsSubmissionName( m_xProps ).getLength() > 0 )
1780*cdf0e10cSrcweir         {
1781*cdf0e10cSrcweir             m_nIncludeBindings |= BA_XFORMS_SUBMISSION;
1782*cdf0e10cSrcweir         }
1783*cdf0e10cSrcweir 	}
1784*cdf0e10cSrcweir 
1785*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1786*cdf0e10cSrcweir     void OControlExport::exportCellBindingAttributes( bool _bIncludeListLinkageType )
1787*cdf0e10cSrcweir     {
1788*cdf0e10cSrcweir         try
1789*cdf0e10cSrcweir         {
1790*cdf0e10cSrcweir             FormCellBindingHelper aHelper( m_xProps, NULL );
1791*cdf0e10cSrcweir             Reference< XValueBinding > xBinding( aHelper.getCurrentBinding() );
1792*cdf0e10cSrcweir             OSL_ENSURE( xBinding.is(), "OControlExport::exportCellBindingAttributes: invalid bindable or invalid binding!" );
1793*cdf0e10cSrcweir             if ( xBinding.is() )
1794*cdf0e10cSrcweir             {
1795*cdf0e10cSrcweir                 // ....................................................
1796*cdf0e10cSrcweir     			AddAttribute(
1797*cdf0e10cSrcweir                     OAttributeMetaData::getBindingAttributeNamespace( BA_LINKED_CELL ),
1798*cdf0e10cSrcweir                     OAttributeMetaData::getBindingAttributeName( BA_LINKED_CELL ),
1799*cdf0e10cSrcweir                     aHelper.getStringAddressFromCellBinding( xBinding )
1800*cdf0e10cSrcweir                 );
1801*cdf0e10cSrcweir 
1802*cdf0e10cSrcweir                 // ....................................................
1803*cdf0e10cSrcweir                 if ( _bIncludeListLinkageType )
1804*cdf0e10cSrcweir                 {
1805*cdf0e10cSrcweir                     sal_Int16 nLinkageType = aHelper.isCellIntegerBinding( xBinding ) ? 1 : 0;
1806*cdf0e10cSrcweir 
1807*cdf0e10cSrcweir                     ::rtl::OUStringBuffer sBuffer;
1808*cdf0e10cSrcweir 			        m_rContext.getGlobalContext().GetMM100UnitConverter().convertEnum(
1809*cdf0e10cSrcweir                         sBuffer,
1810*cdf0e10cSrcweir                         (sal_uInt16)nLinkageType,
1811*cdf0e10cSrcweir                         OEnumMapper::getEnumMap( OEnumMapper::epListLinkageType )
1812*cdf0e10cSrcweir                     );
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir                     AddAttribute(
1815*cdf0e10cSrcweir                         OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_LINKING_TYPE ),
1816*cdf0e10cSrcweir                         OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ),
1817*cdf0e10cSrcweir                         sBuffer.makeStringAndClear()
1818*cdf0e10cSrcweir                     );
1819*cdf0e10cSrcweir                 }
1820*cdf0e10cSrcweir 
1821*cdf0e10cSrcweir             }
1822*cdf0e10cSrcweir         }
1823*cdf0e10cSrcweir         catch( const Exception& )
1824*cdf0e10cSrcweir         {
1825*cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OControlExport::exportCellBindingAttributes: caught an exception!" );
1826*cdf0e10cSrcweir         }
1827*cdf0e10cSrcweir     }
1828*cdf0e10cSrcweir 
1829*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1830*cdf0e10cSrcweir     void OControlExport::exportXFormsBindAttributes()
1831*cdf0e10cSrcweir     {
1832*cdf0e10cSrcweir         rtl::OUString sBindName = getXFormsBindName( m_xProps );
1833*cdf0e10cSrcweir         AddAttribute( XML_NAMESPACE_XFORMS, XML_BIND, sBindName );
1834*cdf0e10cSrcweir     }
1835*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1836*cdf0e10cSrcweir     void OControlExport::exportXFormsListAttributes()
1837*cdf0e10cSrcweir     {
1838*cdf0e10cSrcweir         rtl::OUString sBindName = getXFormsListBindName( m_xProps );
1839*cdf0e10cSrcweir         AddAttribute( XML_NAMESPACE_FORM, XML_XFORMS_LIST_SOURCE, sBindName );
1840*cdf0e10cSrcweir     }
1841*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1842*cdf0e10cSrcweir     void OControlExport::exportXFormsSubmissionAttributes()
1843*cdf0e10cSrcweir     {
1844*cdf0e10cSrcweir         rtl::OUString sSubmission = getXFormsSubmissionName( m_xProps );
1845*cdf0e10cSrcweir         AddAttribute( XML_NAMESPACE_FORM, XML_XFORMS_SUBMISSION, sSubmission );
1846*cdf0e10cSrcweir     }
1847*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1848*cdf0e10cSrcweir     void OControlExport::exportCellListSourceRange( )
1849*cdf0e10cSrcweir     {
1850*cdf0e10cSrcweir         try
1851*cdf0e10cSrcweir         {
1852*cdf0e10cSrcweir             Reference< XListEntrySink > xSink( m_xProps, UNO_QUERY );
1853*cdf0e10cSrcweir             Reference< XListEntrySource > xSource;
1854*cdf0e10cSrcweir             if ( xSink.is() )
1855*cdf0e10cSrcweir                 xSource = xSource.query( xSink->getListEntrySource() );
1856*cdf0e10cSrcweir             OSL_ENSURE( xSource.is(), "OControlExport::exportCellListSourceRange: list source or sink!" );
1857*cdf0e10cSrcweir             if ( xSource.is() )
1858*cdf0e10cSrcweir             {
1859*cdf0e10cSrcweir                 FormCellBindingHelper aHelper( m_xProps, NULL );
1860*cdf0e10cSrcweir 
1861*cdf0e10cSrcweir     			AddAttribute(
1862*cdf0e10cSrcweir                     OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_CELL_RANGE ),
1863*cdf0e10cSrcweir                     OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ),
1864*cdf0e10cSrcweir                     aHelper.getStringAddressFromCellListSource( xSource )
1865*cdf0e10cSrcweir                 );
1866*cdf0e10cSrcweir             }
1867*cdf0e10cSrcweir         }
1868*cdf0e10cSrcweir         catch( const Exception& )
1869*cdf0e10cSrcweir         {
1870*cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OControlExport::exportCellListSourceRange: caught an exception!" );
1871*cdf0e10cSrcweir         }
1872*cdf0e10cSrcweir     }
1873*cdf0e10cSrcweir 
1874*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1875*cdf0e10cSrcweir     void OControlExport::exportImagePositionAttributes()
1876*cdf0e10cSrcweir     {
1877*cdf0e10cSrcweir         try
1878*cdf0e10cSrcweir         {
1879*cdf0e10cSrcweir             sal_Int16 nImagePosition = ImagePosition::Centered;
1880*cdf0e10cSrcweir             OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_IMAGE_POSITION ) >>= nImagePosition );
1881*cdf0e10cSrcweir             OSL_ENSURE( ( nImagePosition >= ImagePosition::LeftTop ) && ( nImagePosition <= ImagePosition::Centered ),
1882*cdf0e10cSrcweir                 "OControlExport::exportImagePositionAttributes: don't know this image position!" );
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir             if ( ( nImagePosition < ImagePosition::LeftTop ) || ( nImagePosition > ImagePosition::Centered ) )
1885*cdf0e10cSrcweir                 // this is important to prevent potential buffer overflows below, so don't optimize
1886*cdf0e10cSrcweir                 nImagePosition = ImagePosition::Centered;
1887*cdf0e10cSrcweir 
1888*cdf0e10cSrcweir             if ( nImagePosition == ImagePosition::Centered )
1889*cdf0e10cSrcweir             {
1890*cdf0e10cSrcweir     		    AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_POSITION ), GetXMLToken( XML_CENTER ) );
1891*cdf0e10cSrcweir             }
1892*cdf0e10cSrcweir             else
1893*cdf0e10cSrcweir             {
1894*cdf0e10cSrcweir                 XMLTokenEnum eXmlImagePositions[] =
1895*cdf0e10cSrcweir                 {
1896*cdf0e10cSrcweir                     XML_START, XML_END, XML_TOP, XML_BOTTOM
1897*cdf0e10cSrcweir                 };
1898*cdf0e10cSrcweir                 XMLTokenEnum eXmlImageAligns[] =
1899*cdf0e10cSrcweir                 {
1900*cdf0e10cSrcweir                     XML_START, XML_CENTER, XML_END
1901*cdf0e10cSrcweir                 };
1902*cdf0e10cSrcweir 
1903*cdf0e10cSrcweir                 XMLTokenEnum eXmlImagePosition = eXmlImagePositions[ nImagePosition / 3 ];
1904*cdf0e10cSrcweir                 XMLTokenEnum eXmlImageAlign    = eXmlImageAligns   [ nImagePosition % 3 ];
1905*cdf0e10cSrcweir 
1906*cdf0e10cSrcweir     		    AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_POSITION ), GetXMLToken( eXmlImagePosition ) );
1907*cdf0e10cSrcweir     		    AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_ALIGN    ), GetXMLToken( eXmlImageAlign    ) );
1908*cdf0e10cSrcweir             }
1909*cdf0e10cSrcweir 
1910*cdf0e10cSrcweir             exportedProperty( PROPERTY_IMAGE_POSITION );
1911*cdf0e10cSrcweir             // some of the controls which have an ImagePosition also have an ImageAlign for compatibility
1912*cdf0e10cSrcweir             // reasons. Since the ImageAlign values simply represent a sub set of the ImagePosition values,
1913*cdf0e10cSrcweir             // we don't need to export ImageAlign anymore
1914*cdf0e10cSrcweir             exportedProperty( PROPERTY_IMAGE_ALIGN );
1915*cdf0e10cSrcweir         }
1916*cdf0e10cSrcweir         catch( const Exception& )
1917*cdf0e10cSrcweir         {
1918*cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1919*cdf0e10cSrcweir         }
1920*cdf0e10cSrcweir     }
1921*cdf0e10cSrcweir 
1922*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1923*cdf0e10cSrcweir 	bool OControlExport::controlHasActiveDataBinding() const
1924*cdf0e10cSrcweir     {
1925*cdf0e10cSrcweir         try
1926*cdf0e10cSrcweir         {
1927*cdf0e10cSrcweir             // currently exchanging the data with a database column?
1928*cdf0e10cSrcweir             ::rtl::OUString sBoundFieldPropertyName( RTL_CONSTASCII_USTRINGPARAM( "BoundField" ) );
1929*cdf0e10cSrcweir             if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( sBoundFieldPropertyName ) )
1930*cdf0e10cSrcweir             {
1931*cdf0e10cSrcweir                 Reference< XPropertySet > xBoundField;
1932*cdf0e10cSrcweir                 m_xProps->getPropertyValue( sBoundFieldPropertyName ) >>= xBoundField;
1933*cdf0e10cSrcweir                 if ( xBoundField.is() )
1934*cdf0e10cSrcweir                     return true;
1935*cdf0e10cSrcweir             }
1936*cdf0e10cSrcweir 
1937*cdf0e10cSrcweir             // currently exchanging data with an external binding?
1938*cdf0e10cSrcweir             Reference< XBindableValue > xBindable( m_xProps, UNO_QUERY );
1939*cdf0e10cSrcweir             if ( xBindable.is() && xBindable->getValueBinding().is() )
1940*cdf0e10cSrcweir                 return true;
1941*cdf0e10cSrcweir         }
1942*cdf0e10cSrcweir         catch( const Exception& )
1943*cdf0e10cSrcweir         {
1944*cdf0e10cSrcweir         	OSL_ENSURE( sal_False, "OColumnExport::controlHasActiveDataBinding: caught an exception!" );
1945*cdf0e10cSrcweir         }
1946*cdf0e10cSrcweir 
1947*cdf0e10cSrcweir         return false;
1948*cdf0e10cSrcweir     }
1949*cdf0e10cSrcweir 
1950*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1951*cdf0e10cSrcweir 	bool OControlExport::controlHasUserSuppliedListEntries() const
1952*cdf0e10cSrcweir     {
1953*cdf0e10cSrcweir         try
1954*cdf0e10cSrcweir         {
1955*cdf0e10cSrcweir             // an external list source?
1956*cdf0e10cSrcweir             Reference< XListEntrySink > xEntrySink( m_xProps, UNO_QUERY );
1957*cdf0e10cSrcweir             if ( xEntrySink.is() && xEntrySink->getListEntrySource().is() )
1958*cdf0e10cSrcweir                 return false;
1959*cdf0e10cSrcweir 
1960*cdf0e10cSrcweir             if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( PROPERTY_LISTSOURCETYPE ) )
1961*cdf0e10cSrcweir             {
1962*cdf0e10cSrcweir                 ListSourceType eListSourceType = ListSourceType_VALUELIST;
1963*cdf0e10cSrcweir                 OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eListSourceType );
1964*cdf0e10cSrcweir                 if ( eListSourceType == ListSourceType_VALUELIST )
1965*cdf0e10cSrcweir                     // for value lists, the list entries as entered by the user are used
1966*cdf0e10cSrcweir                     return true;
1967*cdf0e10cSrcweir 
1968*cdf0e10cSrcweir                 // for every other type, the list entries are filled with some data obtained
1969*cdf0e10cSrcweir                 // from a database - if and only if the ListSource property is not empty
1970*cdf0e10cSrcweir                 return ( 0 == getScalarListSourceValue().getLength() );
1971*cdf0e10cSrcweir             }
1972*cdf0e10cSrcweir         }
1973*cdf0e10cSrcweir         catch( const Exception& )
1974*cdf0e10cSrcweir         {
1975*cdf0e10cSrcweir         	OSL_ENSURE( sal_False, "OControlExport::controlHasUserSuppliedListEntries: caught an exception!" );
1976*cdf0e10cSrcweir         }
1977*cdf0e10cSrcweir 
1978*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "OControlExport::controlHasUserSuppliedListEntries: unreachable code!" );
1979*cdf0e10cSrcweir             // this method should be called for list and combo boxes only
1980*cdf0e10cSrcweir         return true;
1981*cdf0e10cSrcweir     }
1982*cdf0e10cSrcweir 
1983*cdf0e10cSrcweir 	//=====================================================================
1984*cdf0e10cSrcweir 	//= OColumnExport
1985*cdf0e10cSrcweir 	//=====================================================================
1986*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1987*cdf0e10cSrcweir 	OColumnExport::OColumnExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl, const ::rtl::OUString& _rControlId,
1988*cdf0e10cSrcweir 		const Sequence< ScriptEventDescriptor >& _rEvents)
1989*cdf0e10cSrcweir 		:OControlExport(_rContext, _rxControl, _rControlId, ::rtl::OUString(), _rEvents)
1990*cdf0e10cSrcweir 	{
1991*cdf0e10cSrcweir 	}
1992*cdf0e10cSrcweir 
1993*cdf0e10cSrcweir 	//---------------------------------------------------------------------
1994*cdf0e10cSrcweir 	OColumnExport::~OColumnExport()
1995*cdf0e10cSrcweir 	{
1996*cdf0e10cSrcweir 		implEndElement();
1997*cdf0e10cSrcweir 	}
1998*cdf0e10cSrcweir 
1999*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2000*cdf0e10cSrcweir 	void OColumnExport::exportServiceNameAttribute()
2001*cdf0e10cSrcweir 	{
2002*cdf0e10cSrcweir 		// the attribute "service name" (which has a slightly different meaning for columns
2003*cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( PROPERTY_COLUMNSERVICENAME, ::rtl::OUString );
2004*cdf0e10cSrcweir 		::rtl::OUString sColumnServiceName;
2005*cdf0e10cSrcweir 		m_xProps->getPropertyValue(PROPERTY_COLUMNSERVICENAME) >>= sColumnServiceName;
2006*cdf0e10cSrcweir 		// the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the
2007*cdf0e10cSrcweir 		// real service name for the column (for use with the XGridColumnFactory) is only the last
2008*cdf0e10cSrcweir 		// token of this complete name.
2009*cdf0e10cSrcweir 		sal_Int32 nLastSep = sColumnServiceName.lastIndexOf('.');
2010*cdf0e10cSrcweir 		OSL_ENSURE(-1 != nLastSep, "OColumnExport::startExportElement: invalid service name!");
2011*cdf0e10cSrcweir 		sColumnServiceName = sColumnServiceName.copy(nLastSep + 1);
2012*cdf0e10cSrcweir 		sColumnServiceName =
2013*cdf0e10cSrcweir 			m_rContext.getGlobalContext().GetNamespaceMap().GetQNameByKey(
2014*cdf0e10cSrcweir 				XML_NAMESPACE_OOO, sColumnServiceName );
2015*cdf0e10cSrcweir 		// add the attribute
2016*cdf0e10cSrcweir 		AddAttribute( OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME)
2017*cdf0e10cSrcweir 					, OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME)
2018*cdf0e10cSrcweir 					, sColumnServiceName);
2019*cdf0e10cSrcweir 		// flag the property as "handled"
2020*cdf0e10cSrcweir 		exportedProperty(PROPERTY_COLUMNSERVICENAME);
2021*cdf0e10cSrcweir 
2022*cdf0e10cSrcweir 	}
2023*cdf0e10cSrcweir 
2024*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2025*cdf0e10cSrcweir 	const sal_Char* OColumnExport::getOuterXMLElementName() const
2026*cdf0e10cSrcweir 	{
2027*cdf0e10cSrcweir 		return "column";
2028*cdf0e10cSrcweir 	}
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2031*cdf0e10cSrcweir 	void OColumnExport::exportAttributes()
2032*cdf0e10cSrcweir 	{
2033*cdf0e10cSrcweir 		OControlExport::exportAttributes();
2034*cdf0e10cSrcweir 
2035*cdf0e10cSrcweir 		// the attribute "label"
2036*cdf0e10cSrcweir 		exportStringPropertyAttribute(
2037*cdf0e10cSrcweir 			OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
2038*cdf0e10cSrcweir 			OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
2039*cdf0e10cSrcweir 			PROPERTY_LABEL);
2040*cdf0e10cSrcweir 
2041*cdf0e10cSrcweir 		// the style attribute
2042*cdf0e10cSrcweir 		::rtl::OUString sStyleName = m_rContext.getObjectStyleName( m_xProps );
2043*cdf0e10cSrcweir 		if ( sStyleName.getLength() )
2044*cdf0e10cSrcweir 		{
2045*cdf0e10cSrcweir 			AddAttribute(
2046*cdf0e10cSrcweir 				OAttributeMetaData::getSpecialAttributeNamespace( SCA_COLUMN_STYLE_NAME ),
2047*cdf0e10cSrcweir 				OAttributeMetaData::getSpecialAttributeName( SCA_COLUMN_STYLE_NAME ),
2048*cdf0e10cSrcweir 				sStyleName
2049*cdf0e10cSrcweir 			);
2050*cdf0e10cSrcweir 		}
2051*cdf0e10cSrcweir 	}
2052*cdf0e10cSrcweir 
2053*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2054*cdf0e10cSrcweir 	void OColumnExport::examine()
2055*cdf0e10cSrcweir 	{
2056*cdf0e10cSrcweir 		OControlExport::examine();
2057*cdf0e10cSrcweir 
2058*cdf0e10cSrcweir 		// grid columns miss some properties of the controls they're representing
2059*cdf0e10cSrcweir 		m_nIncludeCommon &= ~(CCA_FOR | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_LABEL);
2060*cdf0e10cSrcweir 		m_nIncludeSpecial &= ~(SCA_ECHO_CHAR | SCA_AUTOMATIC_COMPLETION | SCA_MULTIPLE | SCA_MULTI_LINE);
2061*cdf0e10cSrcweir 
2062*cdf0e10cSrcweir 		if (FormComponentType::DATEFIELD != m_nClassId)
2063*cdf0e10cSrcweir 			// except date fields, no column has the DropDown property
2064*cdf0e10cSrcweir 			m_nIncludeCommon &= ~CCA_DROPDOWN;
2065*cdf0e10cSrcweir 	}
2066*cdf0e10cSrcweir 
2067*cdf0e10cSrcweir 	//=====================================================================
2068*cdf0e10cSrcweir 	//= OFormExport
2069*cdf0e10cSrcweir 	//=====================================================================
2070*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2071*cdf0e10cSrcweir 	OFormExport::OFormExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxForm,
2072*cdf0e10cSrcweir 		const Sequence< ScriptEventDescriptor >& _rEvents)
2073*cdf0e10cSrcweir 		:OElementExport(_rContext, _rxForm, _rEvents)
2074*cdf0e10cSrcweir 		,m_bCreateConnectionResourceElement(sal_False)
2075*cdf0e10cSrcweir 	{
2076*cdf0e10cSrcweir 		OSL_ENSURE(m_xProps.is(), "OFormExport::OFormExport: invalid arguments!");
2077*cdf0e10cSrcweir 	}
2078*cdf0e10cSrcweir 
2079*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2080*cdf0e10cSrcweir 	const sal_Char* OFormExport::getXMLElementName() const
2081*cdf0e10cSrcweir 	{
2082*cdf0e10cSrcweir 		return "form";
2083*cdf0e10cSrcweir 	}
2084*cdf0e10cSrcweir 
2085*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2086*cdf0e10cSrcweir 	void OFormExport::exportSubTags()
2087*cdf0e10cSrcweir 	{
2088*cdf0e10cSrcweir 		if ( m_bCreateConnectionResourceElement && m_xProps.is() )
2089*cdf0e10cSrcweir 		{
2090*cdf0e10cSrcweir 			m_rContext.getGlobalContext().ClearAttrList();
2091*cdf0e10cSrcweir 			::rtl::OUString sPropValue;
2092*cdf0e10cSrcweir 			m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; // if set it is a file url
2093*cdf0e10cSrcweir 			if ( !sPropValue.getLength() )
2094*cdf0e10cSrcweir 				m_xProps->getPropertyValue( PROPERTY_URL ) >>= sPropValue;
2095*cdf0e10cSrcweir 			if ( sPropValue.getLength() )
2096*cdf0e10cSrcweir 				AddAttribute(
2097*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeNamespace(CCA_TARGET_LOCATION),
2098*cdf0e10cSrcweir 					OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_LOCATION),
2099*cdf0e10cSrcweir 					sPropValue);
2100*cdf0e10cSrcweir 			if ( m_rContext.getGlobalContext().GetAttrList().getLength() )
2101*cdf0e10cSrcweir 			{
2102*cdf0e10cSrcweir 				SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, xmloff::token::XML_CONNECTION_RESOURCE, sal_True, sal_True);
2103*cdf0e10cSrcweir 			}
2104*cdf0e10cSrcweir 		}
2105*cdf0e10cSrcweir 
2106*cdf0e10cSrcweir 		// let the base class export the remaining properties and the events
2107*cdf0e10cSrcweir 		OElementExport::exportSubTags();
2108*cdf0e10cSrcweir 		// loop through all children
2109*cdf0e10cSrcweir 		Reference< XIndexAccess > xCollection(m_xProps, UNO_QUERY);
2110*cdf0e10cSrcweir 		OSL_ENSURE(xCollection.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspic�ous!");
2111*cdf0e10cSrcweir 
2112*cdf0e10cSrcweir 		if (xCollection.is())
2113*cdf0e10cSrcweir 			m_rContext.exportCollectionElements(xCollection);
2114*cdf0e10cSrcweir 	}
2115*cdf0e10cSrcweir 
2116*cdf0e10cSrcweir 	//---------------------------------------------------------------------
2117*cdf0e10cSrcweir 	void OFormExport::exportAttributes()
2118*cdf0e10cSrcweir 	{
2119*cdf0e10cSrcweir 		sal_Int32 i=0;
2120*cdf0e10cSrcweir 
2121*cdf0e10cSrcweir 		// ---------------------
2122*cdf0e10cSrcweir 		// the string properties
2123*cdf0e10cSrcweir 		{
2124*cdf0e10cSrcweir 			static FormAttributes eStringPropertyIds[] =
2125*cdf0e10cSrcweir 			{
2126*cdf0e10cSrcweir 				faName, /*faAction,*/ faCommand, faFilter, faOrder
2127*cdf0e10cSrcweir 			};
2128*cdf0e10cSrcweir 			static ::rtl::OUString aStringPropertyNames[] =
2129*cdf0e10cSrcweir 			{
2130*cdf0e10cSrcweir 				PROPERTY_NAME, /*PROPERTY_TARGETURL,*/ PROPERTY_COMMAND, PROPERTY_FILTER, PROPERTY_ORDER
2131*cdf0e10cSrcweir 			};
2132*cdf0e10cSrcweir 			sal_Int32 nIdCount = sizeof(eStringPropertyIds) / sizeof(eStringPropertyIds[0]);
2133*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
2134*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof(aStringPropertyNames) / sizeof(aStringPropertyNames[0]);
2135*cdf0e10cSrcweir 			OSL_ENSURE((nIdCount == nNameCount),
2136*cdf0e10cSrcweir 				"OFormExport::exportAttributes: somebody tampered with the maps (1)!");
2137*cdf0e10cSrcweir 		#endif
2138*cdf0e10cSrcweir 			for (i=0; i<nIdCount; ++i)
2139*cdf0e10cSrcweir 				exportStringPropertyAttribute(
2140*cdf0e10cSrcweir 					OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]),
2141*cdf0e10cSrcweir 					OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]),
2142*cdf0e10cSrcweir 					aStringPropertyNames[i]);
2143*cdf0e10cSrcweir 
2144*cdf0e10cSrcweir             // #i112082# xlink:type is added as part of exportTargetLocationAttribute
2145*cdf0e10cSrcweir 
2146*cdf0e10cSrcweir             // now export the data source name or databaselocation or connection resource
2147*cdf0e10cSrcweir 			::rtl::OUString sPropValue;
2148*cdf0e10cSrcweir 			m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue;
2149*cdf0e10cSrcweir             m_bCreateConnectionResourceElement = !sPropValue.getLength();
2150*cdf0e10cSrcweir 			if ( !m_bCreateConnectionResourceElement )
2151*cdf0e10cSrcweir 			{
2152*cdf0e10cSrcweir 				INetURLObject aURL(sPropValue);
2153*cdf0e10cSrcweir                 m_bCreateConnectionResourceElement = ( aURL.GetProtocol() == INET_PROT_FILE );
2154*cdf0e10cSrcweir 				if ( !m_bCreateConnectionResourceElement )
2155*cdf0e10cSrcweir 					exportStringPropertyAttribute(
2156*cdf0e10cSrcweir 						OAttributeMetaData::getFormAttributeNamespace(faDatasource),
2157*cdf0e10cSrcweir 						OAttributeMetaData::getFormAttributeName(faDatasource),
2158*cdf0e10cSrcweir 						PROPERTY_DATASOURCENAME);
2159*cdf0e10cSrcweir 			}
2160*cdf0e10cSrcweir 			else
2161*cdf0e10cSrcweir 				exportedProperty(PROPERTY_URL);
2162*cdf0e10cSrcweir 			if ( m_bCreateConnectionResourceElement )
2163*cdf0e10cSrcweir 				exportedProperty(PROPERTY_DATASOURCENAME);
2164*cdf0e10cSrcweir 		}
2165*cdf0e10cSrcweir 
2166*cdf0e10cSrcweir 		// ----------------------
2167*cdf0e10cSrcweir 		// the boolean properties
2168*cdf0e10cSrcweir 		{
2169*cdf0e10cSrcweir 			static FormAttributes eBooleanPropertyIds[] =
2170*cdf0e10cSrcweir 			{
2171*cdf0e10cSrcweir 				faAllowDeletes, faAllowInserts, faAllowUpdates, faApplyFilter, faEscapeProcessing, faIgnoreResult
2172*cdf0e10cSrcweir 			};
2173*cdf0e10cSrcweir 			static const ::rtl::OUString* pBooleanPropertyNames[] =
2174*cdf0e10cSrcweir 			{
2175*cdf0e10cSrcweir 				&PROPERTY_ALLOWDELETES, &PROPERTY_ALLOWINSERTS, &PROPERTY_ALLOWUPDATES, &PROPERTY_APPLYFILTER, &PROPERTY_ESCAPEPROCESSING, &PROPERTY_IGNORERESULT
2176*cdf0e10cSrcweir 			};
2177*cdf0e10cSrcweir 			static sal_Int8 nBooleanPropertyAttrFlags[] =
2178*cdf0e10cSrcweir 			{
2179*cdf0e10cSrcweir 				BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE
2180*cdf0e10cSrcweir 			};
2181*cdf0e10cSrcweir 			sal_Int32 nIdCount = sizeof(eBooleanPropertyIds) / sizeof(eBooleanPropertyIds[0]);
2182*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
2183*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
2184*cdf0e10cSrcweir 			sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]);
2185*cdf0e10cSrcweir 			OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
2186*cdf0e10cSrcweir 				"OFormExport::exportAttributes: somebody tampered with the maps (2)!");
2187*cdf0e10cSrcweir 		#endif
2188*cdf0e10cSrcweir 			for (i=0; i<nIdCount; ++i)
2189*cdf0e10cSrcweir 				exportBooleanPropertyAttribute(
2190*cdf0e10cSrcweir 					OAttributeMetaData::getFormAttributeNamespace(eBooleanPropertyIds[i]),
2191*cdf0e10cSrcweir 					OAttributeMetaData::getFormAttributeName(eBooleanPropertyIds[i]),
2192*cdf0e10cSrcweir 					*(pBooleanPropertyNames[i]),
2193*cdf0e10cSrcweir 					nBooleanPropertyAttrFlags[i]
2194*cdf0e10cSrcweir 				);
2195*cdf0e10cSrcweir 		}
2196*cdf0e10cSrcweir 
2197*cdf0e10cSrcweir 		// -------------------
2198*cdf0e10cSrcweir 		// the enum properties
2199*cdf0e10cSrcweir 		{
2200*cdf0e10cSrcweir 			static FormAttributes eEnumPropertyIds[] =
2201*cdf0e10cSrcweir 			{
2202*cdf0e10cSrcweir 				faEnctype, faMethod, faCommandType, faNavigationMode, faTabbingCycle
2203*cdf0e10cSrcweir 			};
2204*cdf0e10cSrcweir 			static const sal_Char* pEnumPropertyNames[] =
2205*cdf0e10cSrcweir 			{
2206*cdf0e10cSrcweir 				PROPERTY_SUBMIT_ENCODING, PROPERTY_SUBMIT_METHOD, PROPERTY_COMMAND_TYPE, PROPERTY_NAVIGATION, PROPERTY_CYCLE
2207*cdf0e10cSrcweir 			};
2208*cdf0e10cSrcweir 			static OEnumMapper::EnumProperties eEnumPropertyMaps[] =
2209*cdf0e10cSrcweir 			{
2210*cdf0e10cSrcweir 				OEnumMapper::epSubmitEncoding, OEnumMapper::epSubmitMethod, OEnumMapper::epCommandType, OEnumMapper::epNavigationType, OEnumMapper::epTabCyle
2211*cdf0e10cSrcweir 			};
2212*cdf0e10cSrcweir 			static sal_Int32 nEnumPropertyAttrDefaults[] =
2213*cdf0e10cSrcweir 			{
2214*cdf0e10cSrcweir 				FormSubmitEncoding_URL, FormSubmitMethod_GET, CommandType::COMMAND, NavigationBarMode_CURRENT, TabulatorCycle_RECORDS
2215*cdf0e10cSrcweir 			};
2216*cdf0e10cSrcweir 			static sal_Bool nEnumPropertyAttrDefaultFlags[] =
2217*cdf0e10cSrcweir 			{
2218*cdf0e10cSrcweir 				sal_False, sal_False, sal_False, sal_False, sal_True
2219*cdf0e10cSrcweir 			};
2220*cdf0e10cSrcweir 			sal_Int32 nIdCount = sizeof(eEnumPropertyIds) / sizeof(eEnumPropertyIds[0]);
2221*cdf0e10cSrcweir 		#if OSL_DEBUG_LEVEL > 0
2222*cdf0e10cSrcweir 			sal_Int32 nNameCount = sizeof(pEnumPropertyNames) / sizeof(pEnumPropertyNames[0]);
2223*cdf0e10cSrcweir 			sal_Int32 nDefaultCount = sizeof(nEnumPropertyAttrDefaults) / sizeof(nEnumPropertyAttrDefaults[0]);
2224*cdf0e10cSrcweir 			sal_Int32 nDefaultFlagCount = sizeof(nEnumPropertyAttrDefaultFlags) / sizeof(nEnumPropertyAttrDefaultFlags[0]);
2225*cdf0e10cSrcweir 			sal_Int32 nMapCount = sizeof(eEnumPropertyMaps) / sizeof(eEnumPropertyMaps[0]);
2226*cdf0e10cSrcweir 			OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount) && (nDefaultCount == nDefaultFlagCount) && (nDefaultFlagCount == nMapCount),
2227*cdf0e10cSrcweir 				"OFormExport::exportAttributes: somebody tampered with the maps (3)!");
2228*cdf0e10cSrcweir 		#endif
2229*cdf0e10cSrcweir 			for (i=0; i<nIdCount; ++i)
2230*cdf0e10cSrcweir 				exportEnumPropertyAttribute(
2231*cdf0e10cSrcweir 					OAttributeMetaData::getFormAttributeNamespace(eEnumPropertyIds[i]),
2232*cdf0e10cSrcweir 					OAttributeMetaData::getFormAttributeName(eEnumPropertyIds[i]),
2233*cdf0e10cSrcweir 					pEnumPropertyNames[i],
2234*cdf0e10cSrcweir 					OEnumMapper::getEnumMap(eEnumPropertyMaps[i]),
2235*cdf0e10cSrcweir 					nEnumPropertyAttrDefaults[i],
2236*cdf0e10cSrcweir 					nEnumPropertyAttrDefaultFlags[i]
2237*cdf0e10cSrcweir                 );
2238*cdf0e10cSrcweir 		}
2239*cdf0e10cSrcweir 
2240*cdf0e10cSrcweir 		// the service name
2241*cdf0e10cSrcweir 		exportServiceNameAttribute();
2242*cdf0e10cSrcweir 		// the target frame
2243*cdf0e10cSrcweir 		exportTargetFrameAttribute();
2244*cdf0e10cSrcweir 		// the target URL
2245*cdf0e10cSrcweir 		exportTargetLocationAttribute(true);    // #i110911# add type attribute (for form, but not for control)
2246*cdf0e10cSrcweir 
2247*cdf0e10cSrcweir 		// master fields
2248*cdf0e10cSrcweir 		exportStringSequenceAttribute(
2249*cdf0e10cSrcweir 			OAttributeMetaData::getFormAttributeNamespace(faMasterFields),
2250*cdf0e10cSrcweir 			OAttributeMetaData::getFormAttributeName(faMasterFields),
2251*cdf0e10cSrcweir 			PROPERTY_MASTERFIELDS);
2252*cdf0e10cSrcweir 		// detail fields
2253*cdf0e10cSrcweir 		exportStringSequenceAttribute(
2254*cdf0e10cSrcweir 			OAttributeMetaData::getFormAttributeNamespace(faDetailFiels),
2255*cdf0e10cSrcweir 			OAttributeMetaData::getFormAttributeName(faDetailFiels),
2256*cdf0e10cSrcweir 			PROPERTY_DETAILFIELDS);
2257*cdf0e10cSrcweir 	}
2258*cdf0e10cSrcweir //.........................................................................
2259*cdf0e10cSrcweir }	// namespace xmloff
2260*cdf0e10cSrcweir //.........................................................................
2261