merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / forms / elementimport_impl.hxx
blob49bd8d8f7fd9a4a9de03b1f554654c704cb83d63
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: elementimport_impl.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // no include protection. This file is included from elementimport.hxx only.
33 #ifndef _INCLUDING_FROM_ELEMENTIMPORT_HXX_
34 #error "do not include this file directly!"
35 #endif
37 // no namespace. Same as above: this file is included from elementimport.hxx only,
38 // and this is done inside the namespace
40 //=========================================================================
41 //= OContainerImport
42 //=========================================================================
43 //-------------------------------------------------------------------------
44 template <class BASE>
45 inline SvXMLImportContext* OContainerImport< BASE >::CreateChildContext(
46 sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
47 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList)
49 // maybe it's a sub control
50 if (_rLocalName == m_sWrapperElementName)
52 if (m_xMeAsContainer.is())
53 return implCreateControlWrapper(_nPrefix, _rLocalName);
54 else
56 OSL_ENSURE(sal_False, "OContainerImport::CreateChildContext: don't have an element!");
57 return NULL;
61 return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
64 //-------------------------------------------------------------------------
65 template <class BASE>
66 inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
67 OContainerImport< BASE >::createElement()
69 // let the base class create the object
70 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement();
71 if (!xReturn.is())
72 return xReturn;
74 // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
75 m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY);
76 if (!m_xMeAsContainer.is())
78 OSL_ENSURE(sal_False, "OContainerImport::createElement: invalid element (no XNameContainer) created!");
79 xReturn.clear();
82 return xReturn;
85 //-------------------------------------------------------------------------
86 template <class BASE>
87 inline void OContainerImport< BASE >::EndElement()
89 BASE::EndElement();
91 // now that we have all children, attach the events
92 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY);
93 if (xIndexContainer.is())
94 ODefaultEventAttacherManager::setEvents(xIndexContainer);
97 //=========================================================================
98 //= OColumnImport
99 //=========================================================================
100 //-------------------------------------------------------------------------
101 template <class BASE>
102 OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
103 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
104 OControlElement::ElementType _eType)
105 :BASE(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
106 ,m_xColumnFactory(_rxParentContainer, ::com::sun::star::uno::UNO_QUERY)
108 OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
111 //-------------------------------------------------------------------------
112 // OElementImport overridables
113 template <class BASE>
114 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement()
116 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn;
117 // no call to the base class' method. We have to use the grid column factory
118 if (m_xColumnFactory.is())
120 // create the column
121 xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
122 OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
124 return xReturn;