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