1*ecfe53c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ecfe53c5SAndrew Rist  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ecfe53c5SAndrew Rist  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19*ecfe53c5SAndrew Rist  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // no include protection. This file is included from elementimport.hxx only.
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _INCLUDING_FROM_ELEMENTIMPORT_HXX_
27cdf0e10cSrcweir #error "do not include this file directly!"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir // no namespace. Same as above: this file is included from elementimport.hxx only,
31cdf0e10cSrcweir // and this is done inside the namespace
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //=========================================================================
34cdf0e10cSrcweir //= OContainerImport
35cdf0e10cSrcweir //=========================================================================
36cdf0e10cSrcweir //-------------------------------------------------------------------------
37cdf0e10cSrcweir template <class BASE>
CreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & _rxAttrList)38cdf0e10cSrcweir inline SvXMLImportContext* OContainerImport< BASE >::CreateChildContext(
39cdf0e10cSrcweir 	sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
40cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList)
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	// maybe it's a sub control
43cdf0e10cSrcweir 	if (_rLocalName == m_sWrapperElementName)
44cdf0e10cSrcweir 	{
45cdf0e10cSrcweir 		if (m_xMeAsContainer.is())
46cdf0e10cSrcweir 			return implCreateControlWrapper(_nPrefix, _rLocalName);
47cdf0e10cSrcweir 		else
48cdf0e10cSrcweir 		{
49cdf0e10cSrcweir 			OSL_ENSURE(sal_False, "OContainerImport::CreateChildContext: don't have an element!");
50cdf0e10cSrcweir 			return NULL;
51cdf0e10cSrcweir 		}
52cdf0e10cSrcweir 	}
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //-------------------------------------------------------------------------
58cdf0e10cSrcweir template <class BASE>
59cdf0e10cSrcweir inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
createElement()60cdf0e10cSrcweir 	OContainerImport< BASE >::createElement()
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	// let the base class create the object
63cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement();
64cdf0e10cSrcweir 	if (!xReturn.is())
65cdf0e10cSrcweir 		return xReturn;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	// ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
68cdf0e10cSrcweir 	m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY);
69cdf0e10cSrcweir 	if (!m_xMeAsContainer.is())
70cdf0e10cSrcweir 	{
71cdf0e10cSrcweir 		OSL_ENSURE(sal_False, "OContainerImport::createElement: invalid element (no XNameContainer) created!");
72cdf0e10cSrcweir 		xReturn.clear();
73cdf0e10cSrcweir 	}
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	return xReturn;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir //-------------------------------------------------------------------------
79cdf0e10cSrcweir template <class BASE>
EndElement()80cdf0e10cSrcweir inline void OContainerImport< BASE >::EndElement()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	BASE::EndElement();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	// now that we have all children, attach the events
85cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY);
86cdf0e10cSrcweir 	if (xIndexContainer.is())
87cdf0e10cSrcweir 		ODefaultEventAttacherManager::setEvents(xIndexContainer);
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir //=========================================================================
91cdf0e10cSrcweir //= OColumnImport
92cdf0e10cSrcweir //=========================================================================
93cdf0e10cSrcweir //-------------------------------------------------------------------------
94cdf0e10cSrcweir template <class BASE>
OColumnImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const::com::sun::star::uno::Reference<::com::sun::star::container::XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)95cdf0e10cSrcweir OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
96cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
97cdf0e10cSrcweir 		OControlElement::ElementType _eType)
98cdf0e10cSrcweir 	:BASE(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
99cdf0e10cSrcweir 	,m_xColumnFactory(_rxParentContainer, ::com::sun::star::uno::UNO_QUERY)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir //-------------------------------------------------------------------------
105cdf0e10cSrcweir // OElementImport overridables
106cdf0e10cSrcweir template <class BASE>
createElement()107cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn;
110cdf0e10cSrcweir 	// no call to the base class' method. We have to use the grid column factory
111cdf0e10cSrcweir 	if (m_xColumnFactory.is())
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		// create the column
114cdf0e10cSrcweir 		xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
115cdf0e10cSrcweir 		OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
116cdf0e10cSrcweir 	}
117cdf0e10cSrcweir 	return xReturn;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120