1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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!"
26 // no namespace. Same as above: this file is included from elementimport.hxx only,
27 // and this is done inside the namespace
29 //=========================================================================
31 //=========================================================================
32 //-------------------------------------------------------------------------
34 inline SvXMLImportContext
* OContainerImport
< BASE
>::CreateChildContext(
35 sal_uInt16 _nPrefix
, const OUString
& _rLocalName
,
36 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& _rxAttrList
)
38 // maybe it's a sub control
39 if (_rLocalName
== m_sWrapperElementName
)
41 if (m_xMeAsContainer
.is())
42 return implCreateControlWrapper(_nPrefix
, _rLocalName
);
45 OSL_FAIL("OContainerImport::CreateChildContext: don't have an element!");
50 return BASE::CreateChildContext(_nPrefix
, _rLocalName
, _rxAttrList
);
53 //-------------------------------------------------------------------------
55 inline ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
56 OContainerImport
< BASE
>::createElement()
58 // let the base class create the object
59 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xReturn
= BASE::createElement();
63 // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
64 m_xMeAsContainer
= ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>(xReturn
, ::com::sun::star::uno::UNO_QUERY
);
65 if (!m_xMeAsContainer
.is())
67 OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
74 //-------------------------------------------------------------------------
76 inline void OContainerImport
< BASE
>::EndElement()
80 // now that we have all children, attach the events
81 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> xIndexContainer(m_xMeAsContainer
, ::com::sun::star::uno::UNO_QUERY
);
82 if (xIndexContainer
.is())
83 ODefaultEventAttacherManager::setEvents(xIndexContainer
);
86 //=========================================================================
88 //=========================================================================
89 //-------------------------------------------------------------------------
91 OColumnImport
< BASE
>::OColumnImport(OFormLayerXMLImport_Impl
& _rImport
, IEventAttacherManager
& _rEventManager
, sal_uInt16 _nPrefix
, const OUString
& _rName
,
92 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>& _rxParentContainer
,
93 OControlElement::ElementType _eType
)
94 :BASE(_rImport
, _rEventManager
, _nPrefix
, _rName
, _rxParentContainer
, _eType
)
95 ,m_xColumnFactory(_rxParentContainer
, ::com::sun::star::uno::UNO_QUERY
)
97 OSL_ENSURE(m_xColumnFactory
.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
100 //-------------------------------------------------------------------------
101 // OElementImport overridables
102 template <class BASE
>
103 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> OColumnImport
< BASE
>::createElement()
105 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xReturn
;
106 // no call to the base class' method. We have to use the grid column factory
107 if (m_xColumnFactory
.is())
110 xReturn
= m_xColumnFactory
->createColumn(this->m_sServiceName
);
111 OSL_ENSURE(xReturn
.is(), "OColumnImport::createElement: the factory returned an invalid object!");
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */