bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / forms / elementimport_impl.hxx
bloba9cfc99aa9c2c62f052c4837c21e59de33632f7a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // no include protection. This file is included from elementimport.hxx only.
22 #ifndef _INCLUDING_FROM_ELEMENTIMPORT_HXX_
23 #error "do not include this file directly!"
24 #endif
26 #include <osl/diagnose.h>
28 // no namespace. Same as above: this file is included from elementimport.hxx only,
29 // and this is done inside the namespace
31 //= OContainerImport
32 template <class BASE>
33 inline SvXMLImportContext* OContainerImport< BASE >::CreateChildContext(
34 sal_uInt16 _nPrefix, const OUString& _rLocalName,
35 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList)
37 // maybe it's a sub control
38 if (_rLocalName == m_sWrapperElementName)
40 if (m_xMeAsContainer.is())
41 return implCreateControlWrapper(_nPrefix, _rLocalName);
42 else
44 OSL_FAIL("OContainerImport::CreateChildContext: don't have an element!");
45 return NULL;
49 return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
52 template <class BASE>
53 inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
54 OContainerImport< BASE >::createElement()
56 // let the base class create the object
57 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement();
58 if (!xReturn.is())
59 return xReturn;
61 // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
62 m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY);
63 if (!m_xMeAsContainer.is())
65 OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
66 xReturn.clear();
69 return xReturn;
72 template <class BASE>
73 inline void OContainerImport< BASE >::EndElement()
75 BASE::EndElement();
77 // now that we have all children, attach the events
78 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY);
79 if (xIndexContainer.is())
80 ODefaultEventAttacherManager::setEvents(xIndexContainer);
83 //= OColumnImport
84 template <class BASE>
85 OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
86 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
87 OControlElement::ElementType _eType)
88 :BASE(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
89 ,m_xColumnFactory(_rxParentContainer, ::com::sun::star::uno::UNO_QUERY)
91 OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
94 // OElementImport overridables
95 template <class BASE>
96 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement()
98 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn;
99 // no call to the base class' method. We have to use the grid column factory
100 if (m_xColumnFactory.is())
102 // create the column
103 xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
104 OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
106 return xReturn;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */