1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _XMLOFF_FORMS_ELEMENTIMPORT_HXX_
29 #define _XMLOFF_FORMS_ELEMENTIMPORT_HXX_
30 
31 #include "propertyimport.hxx"
32 #include "controlelement.hxx"
33 #include "valueproperties.hxx"
34 #include "eventimport.hxx"
35 #include "logging.hxx"
36 #include "property_description.hxx"
37 
38 /** === begin UNO includes === **/
39 #include <com/sun/star/text/XTextCursor.hpp>
40 #include <com/sun/star/container/XNameContainer.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/form/XGridColumnFactory.hpp>
43 #include <com/sun/star/script/XEventAttacherManager.hpp>
44 /** === end UNO includes === **/
45 
46 #include <comphelper/stl_types.hxx>
47 
48 class XMLTextStyleContext;
49 //.........................................................................
50 namespace xmloff
51 {
52 //.........................................................................
53 
54 	class IControlIdMap;
55 	class OFormLayerXMLImport_Impl;
56 
57 	//=====================================================================
58 	//= OElementNameMap
59 	//=====================================================================
60 	const OControlElement::ElementType& operator ++(OControlElement::ElementType& _e);
61 
62 	/** helper class which allows fast translation of xml tag names into element types.
63 	*/
64 	class OElementNameMap : public OControlElement
65 	{
66 	protected:
67 		DECLARE_STL_USTRINGACCESS_MAP( ElementType, MapString2Element );
68 		static MapString2Element	s_sElementTranslations;
69 
70 	protected:
71 		OElementNameMap() { }
72 
73 	public:
74 		static ElementType getElementType(const ::rtl::OUString& _rName);
75 	};
76 
77 	//=====================================================================
78 	//= OElementImport
79 	//=====================================================================
80 	/** implements common behaviour for importing forms, controls and columns
81 	*/
82 	class OElementImport
83 				:public OPropertyImport
84 				,public IEventAttacher
85 				,public OStackedLogging
86 	{
87 	protected:
88 		::rtl::OUString			    m_sServiceName;		// the service name as extracted from the service-name attribute
89 		::rtl::OUString			    m_sName;			// the name of the object (redundant, already contained in the base class' array)
90 		OFormLayerXMLImport_Impl&	m_rFormImport;		// the form import context
91 		IEventAttacherManager&	    m_rEventManager;	// the event attacher manager
92 
93 		const XMLTextStyleContext*	m_pStyleElement;	// the XML element which describes the style we encountered
94 														// while reading our element
95 
96 		/// the parent container to insert the new element into
97 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
98 						            m_xParentContainer;
99 
100         /// the element we're creating. Valid after StartElement
101 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
102 						            m_xElement;
103         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
104                                     m_xInfo;
105 
106         bool                        m_bImplicitGenericAttributeHandling;
107 
108 	public:
109 		/** ctor
110 			@param _rImport
111 				the importer
112 			@param _rEventManager
113 				the event attacher manager for the control beeing imported
114 			@param _nPrefix
115 				the namespace prefix
116 			@param _rName
117 				the element name
118 			@param _rAttributeMap
119 				the attribute map to be used for translating attributes into properties
120 			@param _rxParentContainer
121 				the container in which the new element should be inserted
122 		*/
123 		OElementImport(
124 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
125 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
126 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer
127 		);
128         virtual ~OElementImport();
129 
130 	protected:
131 		// SvXMLImportContext overridables
132 		virtual void StartElement(
133 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
134 		virtual SvXMLImportContext* CreateChildContext(
135 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
136 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
137 		virtual void	EndElement();
138 
139 		// OPropertyImport overridables
140 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
141 			const ::rtl::OUString& _rLocalName,
142 			const ::rtl::OUString& _rValue);
143 
144 		// IEventAttacher
145 		virtual void registerEvents(
146 			const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rEvents
147 			);
148 
149 		/** create the (uninitialized) element which is to represent the read data
150 
151 			<p>The default implementation uses <member>m_xORB</member> to create a object with <member>m_sServiceName</member>.
152 		*/
153 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
154 						createElement();
155 
156 	protected:
157 		/** can be used to handle properties where the attribute default and the property default differ.
158 			<p>In such case, if the property had the attribute default upon writing, nothing is read, so upon reading,
159 			the property is still at it's own default (which is not the attribute default).<p/>
160 			<p>This method, if told the attribute and the property, and the (implied) attribute default, sets the
161 			property value as if the attribute was encountered.</p>
162 			@see encounteredAttribute
163 		*/
164 		void		simulateDefaultedAttribute(const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, const sal_Char* _pAttributeDefault);
165 
166         /** to be called from within handleAttribute, checks whether the given attribute is covered by our generic
167             attribute handler mechanisms
168         */
169         bool        tryGenericAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue );
170 
171         /** controls whether |handleAttribute| implicitly calls |tryGenericAttribute|, or whether the derived class
172             must do this explicitly at a suitable place in its own |handleAttribute|
173         */
174         void        disableImplicitGenericAttributeHandling() { m_bImplicitGenericAttributeHandling = false; }
175 
176 	private:
177 		::rtl::OUString implGetDefaultName() const;
178 		void implApplyGenericProperties();
179         void implApplySpecificProperties();
180 
181 		/** sets the style properties which have been read for the element (if any)
182 		*/
183 		void implSetStyleProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject );
184 
185         PropertyGroups::const_iterator impl_matchPropertyGroup( const PropertyGroups& i_propertyGroups ) const;
186 
187         virtual ::rtl::OUString determineDefaultServiceName() const;
188 	};
189 
190 	//=====================================================================
191 	//= OControlImport
192 	//=====================================================================
193 	/** helper class for importing the description of a single control
194 	*/
195 	class OControlImport
196 				:public OElementImport
197 				,public OValuePropertiesMetaData
198 	{
199 	protected:
200 		::rtl::OUString					m_sControlId;
201 		OControlElement::ElementType	m_eElementType;
202 
203 		PropertyValueArray				m_aValueProperties;
204 		// the value properties (value, current-value, min-value, max-value) require some special
205 		// handling
206 
207 		// we fake the attributes our base class gets: we add the attributes of the outer wrapper
208 		// element which encloses us
209 		::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >
210 										m_xOuterAttributes;
211 
212         /** the address of the calc cell which the control model should be bound to,
213             if applicable
214         */
215         ::rtl::OUString                 m_sBoundCellAddress;
216 
217         /** name of a value binding (xforms:bind attribute) */
218         ::rtl::OUString                 m_sBindingID;
219 
220         /** name of a list binding (form:xforms-list-source attribute) */
221         ::rtl::OUString                 m_sListBindingID;
222 
223         /** name of a submission (xforms:submission attribute) */
224         ::rtl::OUString                 m_sSubmissionID;
225 
226 	protected:
227 		// for use by derived classes only
228 		OControlImport(
229 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
230 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
231 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer
232 			);
233 
234 	public:
235 		OControlImport(
236 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
237 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
238 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
239 			OControlElement::ElementType _eType
240 		);
241 
242 		// SvXMLImportContext overridables
243 		virtual void StartElement(
244 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
245 		virtual void	EndElement();
246 
247 		// OPropertyImport overridables
248 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
249 			const ::rtl::OUString& _rLocalName,
250 			const ::rtl::OUString& _rValue);
251 
252 		void addOuterAttributes(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxOuterAttribs);
253 
254 	protected:
255 		void setElementType(OControlElement::ElementType _eType) { m_eElementType = _eType; }
256 
257 	protected:
258 		void implTranslateValueProperty(
259 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >& _rxPropInfo,
260 			::com::sun::star::beans::PropertyValue& /* [in/out] */ _rPropValue);
261 
262         virtual ::rtl::OUString determineDefaultServiceName() const;
263 
264         /** registers the given cell address as value binding address for our element
265 
266             <p>The default implementation simply calls registerCellValueBinding at our import
267             context, but you may want to override this behaviour.</p>
268 
269             @param _rBoundCellAddress
270                 the cell address to register for our element. Must not be <NULL/>.
271             @precond
272                 we have a valid element (m_xElement)
273         */
274         virtual void doRegisterCellValueBinding( const ::rtl::OUString& _rBoundCellAddress );
275 
276         /** register the given XForms binding */
277         virtual void doRegisterXFormsValueBinding( const ::rtl::OUString& );
278 
279         /** register the given XForms list binding */
280         virtual void doRegisterXFormsListBinding( const ::rtl::OUString& );
281 
282         /** register the given XForms submission */
283         virtual void doRegisterXFormsSubmission( const ::rtl::OUString& );
284 
285 	protected:
286         //added by BerryJia for fixing bug102407 2002-11-5
287 		// OElementImport overridables
288         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
289 		                createElement();
290 	};
291 
292     // TODO:
293     // this whole mechanism doesn't scale. Instead of deriving even more classes for every new attribute,
294     // we should have dedicated attribute handlers
295     // The rest of xmloff implements it this way - why don't we do, too?
296 
297 	//=====================================================================
298 	//= OImagePositionImport
299 	//=====================================================================
300     class OImagePositionImport : public OControlImport
301     {
302         sal_Int16   m_nImagePosition;
303         sal_Int16   m_nImageAlign;
304         sal_Bool    m_bHaveImagePosition;
305 
306     public:
307 		OImagePositionImport(
308 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
309 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
310 			OControlElement::ElementType _eType
311 		);
312 
313     protected:
314 		// SvXMLImportContext overridables
315 		virtual void StartElement(
316 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
317 
318         // OPropertyImport overridables
319 		virtual bool    handleAttribute( sal_uInt16 _nNamespaceKey,
320 			const ::rtl::OUString& _rLocalName,
321 			const ::rtl::OUString& _rValue
322        );
323     };
324 
325 	//=====================================================================
326 	//= OReferredControlImport
327 	//=====================================================================
328 	class OReferredControlImport : public OControlImport
329 	{
330 	protected:
331 		::rtl::OUString	m_sReferringControls;	// the list of ids of controls referring to the one beeing imported
332 
333 	public:
334 		OReferredControlImport(
335 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
336 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
337 			OControlElement::ElementType _eType
338 		);
339 
340 		// SvXMLImportContext overridables
341 		virtual void StartElement(
342 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
343 
344 		// OPropertyImport overridables
345 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
346 			const ::rtl::OUString& _rLocalName,
347 			const ::rtl::OUString& _rValue);
348 	};
349 
350 	//=====================================================================
351 	//= OPasswordImport
352 	//=====================================================================
353 	class OPasswordImport : public OControlImport
354 	{
355 	public:
356 		OPasswordImport(
357 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
358 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
359 			OControlElement::ElementType _eType
360 		);
361 
362 		// OPropertyImport overridables
363 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
364 			const ::rtl::OUString& _rLocalName,
365 			const ::rtl::OUString& _rValue);
366 	};
367 
368 	//=====================================================================
369 	//= ORadioImport
370 	//=====================================================================
371 	class ORadioImport : public OImagePositionImport
372 	{
373 	public:
374 		ORadioImport(
375 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
376 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
377 			OControlElement::ElementType _eType
378 		);
379 
380 	protected:
381 		// OPropertyImport overridables
382 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
383 			const ::rtl::OUString& _rLocalName,
384 			const ::rtl::OUString& _rValue);
385 	};
386 
387 	//=====================================================================
388 	//= OURLReferenceImport
389 	//=====================================================================
390 	/** a specialized version of the <type>OControlImport</type> class, which is able
391 		to handle attributes which denote URLs (and stored relative)
392 	*/
393 	class OURLReferenceImport : public OImagePositionImport
394 	{
395 	public:
396 		OURLReferenceImport(
397 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
398 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
399 			OControlElement::ElementType _eType
400 		);
401 
402 	protected:
403 		// OPropertyImport overridables
404 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
405 			const ::rtl::OUString& _rLocalName,
406 			const ::rtl::OUString& _rValue);
407 	};
408 
409 	//=====================================================================
410 	//= OButtonImport
411 	//=====================================================================
412 	/** A specialized version of the <type>OControlImport</type> class, which handles
413 		the target frame for image and command buttons
414 	*/
415 	class OButtonImport : public OURLReferenceImport
416 	{
417 	public:
418 		OButtonImport(
419 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
420 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
421 			OControlElement::ElementType _eType
422 		);
423 
424 	protected:
425 		// SvXMLImportContext overridables
426 		virtual void StartElement(
427 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
428 	};
429 
430 	//=====================================================================
431 	//= OValueRangeImport
432 	//=====================================================================
433 	/** A specialized version of the <type>OControlImport</type> class, which imports
434 		the value-range elements
435 	*/
436 	class OValueRangeImport : public OControlImport
437 	{
438     private:
439         sal_Int32   m_nStepSizeValue;
440 
441 	public:
442 		OValueRangeImport(
443 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
444 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
445 			OControlElement::ElementType _eType
446 		);
447 
448 	protected:
449 		// SvXMLImportContext overridables
450 		virtual void StartElement(
451 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList );
452 
453         // OPropertyImport overridables
454 		virtual bool    handleAttribute( sal_uInt16 _nNamespaceKey,
455 			const ::rtl::OUString& _rLocalName,
456 			const ::rtl::OUString& _rValue );
457 	};
458 
459 	//=====================================================================
460 	//= OTextLikeImport
461 	//=====================================================================
462 	/** A specialized version of the <type>OControlImport</type> class, which handles
463 		text like controls which have the convert-empty-to-null attribute</p>
464 	*/
465 	class OTextLikeImport : public OControlImport
466 	{
467     private:
468         ::com::sun::star::uno::Reference< com::sun::star::text::XTextCursor >   m_xCursor;
469         ::com::sun::star::uno::Reference< com::sun::star::text::XTextCursor >   m_xOldCursor;
470         bool                                                                    m_bEncounteredTextPara;
471 
472     public:
473 		OTextLikeImport(
474 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
475 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
476 			OControlElement::ElementType _eType
477 		);
478 
479 		// SvXMLImportContext overridables
480 		virtual void StartElement(
481 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
482 		virtual SvXMLImportContext* CreateChildContext(
483 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
484 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
485 		virtual void	EndElement();
486 
487     private:
488         void    adjustDefaultControlProperty();
489         void    removeRedundantCurrentValue();
490 	};
491 
492 	//=====================================================================
493 	//= OListAndComboImport
494 	//=====================================================================
495 	/** A specialized version of the <type>OControlImport</type> class, which handles
496 		attributes / sub elements which are special to list and combo boxes
497 	*/
498 	class OListAndComboImport : public OControlImport
499 	{
500 		friend class OListOptionImport;
501 		friend class OComboItemImport;
502 
503 	protected:
504 		::com::sun::star::uno::Sequence< ::rtl::OUString >
505 						m_aListSource;
506 		::com::sun::star::uno::Sequence< ::rtl::OUString >
507 						m_aValueList;
508 
509 		::com::sun::star::uno::Sequence< sal_Int16 >
510 						m_aSelectedSeq;
511 		::com::sun::star::uno::Sequence< sal_Int16 >
512 						m_aDefaultSelectedSeq;
513 
514         ::rtl::OUString m_sCellListSource;      /// the cell range which acts as list source for the control
515 
516         sal_Int32		m_nEmptyListItems;      /// number of empty list items encountered during reading
517 		sal_Int32		m_nEmptyValueItems;     /// number of empty value items encountered during reading
518 
519 		sal_Bool		m_bEncounteredLSAttrib;
520         sal_Bool        m_bLinkWithIndexes;     /** <TRUE/> if and only if we should use a cell value binding
521                                                     which exchanges the selection index (instead of the selection text
522                                                 */
523 
524 	public:
525 		OListAndComboImport(
526 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
527 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
528 			OControlElement::ElementType _eType
529 		);
530 
531 		// SvXMLImportContext overridables
532 		virtual void StartElement(
533 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
534 		virtual SvXMLImportContext* CreateChildContext(
535 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
536 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
537 		virtual void	EndElement();
538 
539 		// OPropertyImport overridables
540 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
541 			const ::rtl::OUString& _rLocalName,
542 			const ::rtl::OUString& _rValue);
543 
544         // OControlImport ovrridables
545         virtual void doRegisterCellValueBinding( const ::rtl::OUString& _rBoundCellAddress );
546 
547     protected:
548 		void implPushBackLabel(const ::rtl::OUString& _rLabel);
549 		void implPushBackValue(const ::rtl::OUString& _rValue);
550 
551 		void implEmptyLabelFound();
552 		void implEmptyValueFound();
553 
554 		void implSelectCurrentItem();
555 		void implDefaultSelectCurrentItem();
556 	};
557 	SV_DECL_IMPL_REF(OListAndComboImport);
558 
559 	//=====================================================================
560 	//= OListOptionImport
561 	//=====================================================================
562 	/** helper class for importing a single &lt;form:option&gt; element.
563 	*/
564 	class OListOptionImport
565 				:public SvXMLImportContext
566 	{
567 		OListAndComboImportRef	m_xListBoxImport;
568 
569 	public:
570 		OListOptionImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
571 			const OListAndComboImportRef& _rListBox);
572 
573 		virtual void StartElement(
574 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
575 	};
576 
577 	//=====================================================================
578 	//= OComboItemImport
579 	//=====================================================================
580 	/** helper class for importing a single &lt;form:item&gt; element.
581 	*/
582 	class OComboItemImport
583 				:public SvXMLImportContext
584 	{
585 		OListAndComboImportRef	m_xListBoxImport;
586 
587 	public:
588 		OComboItemImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
589 			const OListAndComboImportRef& _rListBox);
590 
591 	protected:
592 		// SvXMLImportContext overridables
593 		virtual void StartElement(
594 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
595 	};
596 
597 	//=====================================================================
598 	//= OContainerImport
599 	//=====================================================================
600 	// BASE must be a derivee of OElementImport
601 	template <class BASE>
602 	class OContainerImport
603 				:public BASE
604 				,public ODefaultEventAttacherManager
605 	{
606 	protected:
607 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
608 						m_xMeAsContainer;
609 		::rtl::OUString	m_sWrapperElementName;
610 
611 	protected:
612 		OContainerImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
613 				const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
614 				const sal_Char* _pWrapperElementName)
615 			:BASE(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer)
616 			,m_sWrapperElementName(::rtl::OUString::createFromAscii(_pWrapperElementName))
617 		{
618 		}
619 
620 		// SvXMLImportContext overridables
621 		virtual SvXMLImportContext* CreateChildContext(
622 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
623 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
624 		virtual void EndElement();
625 
626 	protected:
627 		// OElementImport overridables
628 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
629 						createElement();
630 
631 		// create the child context for the given control type
632 		virtual SvXMLImportContext*	implCreateControlWrapper(
633 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName) = 0;
634 	};
635 
636 	//=====================================================================
637 	//= OColumnImport
638 	//=====================================================================
639 	/** helper class importing a single grid column (without the &lt;form:column&gt; element wrapping
640 		the column).
641 
642 		<p>BASE (the template argument) must be a derivee of OControlImport</p>
643 	*/
644 	template <class BASE>
645 	class OColumnImport : public BASE
646 	{
647 	protected:
648 		::com::sun::star::uno::Reference< ::com::sun::star::form::XGridColumnFactory >
649 					m_xColumnFactory;
650 
651 	public:
652 		OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
653 				const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
654 				OControlElement::ElementType _eType);
655 
656 	protected:
657 		// OElementImport overridables
658 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
659 						createElement();
660 	};
661 
662 	//=====================================================================
663 	//= OColumnWrapperImport
664 	//=====================================================================
665 	class OColumnWrapperImport : public SvXMLImportContext
666 	{
667 	protected:
668 		::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >
669 								m_xOwnAttributes;
670 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
671 								m_xParentContainer;
672 		OFormLayerXMLImport_Impl&	m_rFormImport;
673 		IEventAttacherManager&	m_rEventManager;
674 
675 	public:
676 		OColumnWrapperImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
677 				const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer);
678 
679 		// SvXMLImportContext overridables
680 		virtual SvXMLImportContext* CreateChildContext(
681 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
682 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
683 		virtual void StartElement(
684 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
685 	protected:
686 		OControlImport* implCreateChildContext(
687 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
688 			OControlElement::ElementType _eType);
689 	};
690 
691 	//=====================================================================
692 	//= OGridImport
693 	//=====================================================================
694 	typedef OContainerImport< OControlImport >	OGridImport_Base;
695 	/** helper class importing a single &lt;form:grid&gt; element
696 	*/
697 	class OGridImport : public OGridImport_Base
698 	{
699 	public:
700 		OGridImport(
701 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
702 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
703 			OControlElement::ElementType _eType);
704 
705 	protected:
706 		// OContainerImport overridables
707 		virtual SvXMLImportContext*	implCreateControlWrapper(
708 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName);
709 	};
710 
711 	//=====================================================================
712 	//= OFormImport
713 	//=====================================================================
714 	typedef OContainerImport< OElementImport >	OFormImport_Base;
715 	/** helper class importing a single &lt;form:form&gt; element
716 	*/
717 	class OFormImport : public OFormImport_Base
718 	{
719 	public:
720 		OFormImport(
721 			OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
722 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer
723 		);
724 
725 	protected:
726 		// SvXMLImportContext overridables
727 		virtual SvXMLImportContext* CreateChildContext(
728 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
729 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
730 		virtual void	StartElement(
731 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
732 		virtual void	EndElement();
733 
734 		// OContainerImport overridables
735 		virtual SvXMLImportContext*	implCreateControlWrapper(
736 			sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName);
737 
738 		// OPropertyImport overridables
739 		virtual bool    handleAttribute(sal_uInt16 _nNamespaceKey,
740 			const ::rtl::OUString& _rLocalName,
741 			const ::rtl::OUString& _rValue);
742 
743 		OControlImport* implCreateChildContext(
744 				sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
745 				OControlElement::ElementType _eType );
746 
747 
748 		void implTranslateStringListProperty(const ::rtl::OUString& _rPropertyName, const ::rtl::OUString& _rValue);
749 	};
750 
751 	//=====================================================================
752 	//= OXMLDataSourceImport
753 	//=====================================================================
754 	class OXMLDataSourceImport : public SvXMLImportContext
755 	{
756 	public:
757 		OXMLDataSourceImport( SvXMLImport& _rImport
758 					,sal_uInt16 nPrfx
759 					,const ::rtl::OUString& rLName
760 					,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
761 					,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xElement);
762 	};
763 
764 #define _INCLUDING_FROM_ELEMENTIMPORT_HXX_
765 #include "elementimport_impl.hxx"
766 #undef _INCLUDING_FROM_ELEMENTIMPORT_HXX_
767 
768 //.........................................................................
769 }	// namespace xmloff
770 //.........................................................................
771 
772 #endif // _XMLOFF_FORMS_ELEMENTIMPORT_HXX_
773 
774