Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : // no include protection. This file is included from elementimport.hxx only.
21 :
22 : #ifndef _INCLUDING_FROM_ELEMENTIMPORT_HXX_
23 : #error "do not include this file directly!"
24 : #endif
25 :
26 : // no namespace. Same as above: this file is included from elementimport.hxx only,
27 : // and this is done inside the namespace
28 :
29 : //=========================================================================
30 : //= OContainerImport
31 : //=========================================================================
32 : //-------------------------------------------------------------------------
33 : template <class BASE>
34 0 : inline SvXMLImportContext* OContainerImport< BASE >::CreateChildContext(
35 : sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
36 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList)
37 : {
38 : // maybe it's a sub control
39 0 : if (_rLocalName == m_sWrapperElementName)
40 : {
41 0 : if (m_xMeAsContainer.is())
42 0 : return implCreateControlWrapper(_nPrefix, _rLocalName);
43 : else
44 : {
45 : OSL_FAIL("OContainerImport::CreateChildContext: don't have an element!");
46 0 : return NULL;
47 : }
48 : }
49 :
50 0 : return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
51 : }
52 :
53 : //-------------------------------------------------------------------------
54 : template <class BASE>
55 : inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
56 0 : OContainerImport< BASE >::createElement()
57 : {
58 : // let the base class create the object
59 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement();
60 0 : if (!xReturn.is())
61 0 : return xReturn;
62 :
63 : // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
64 0 : m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY);
65 0 : if (!m_xMeAsContainer.is())
66 : {
67 : OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
68 0 : xReturn.clear();
69 : }
70 :
71 0 : return xReturn;
72 : }
73 :
74 : //-------------------------------------------------------------------------
75 : template <class BASE>
76 0 : inline void OContainerImport< BASE >::EndElement()
77 : {
78 0 : BASE::EndElement();
79 :
80 : // now that we have all children, attach the events
81 0 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY);
82 0 : if (xIndexContainer.is())
83 0 : ODefaultEventAttacherManager::setEvents(xIndexContainer);
84 0 : }
85 :
86 : //=========================================================================
87 : //= OColumnImport
88 : //=========================================================================
89 : //-------------------------------------------------------------------------
90 : template <class BASE>
91 0 : OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::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 0 : ,m_xColumnFactory(_rxParentContainer, ::com::sun::star::uno::UNO_QUERY)
96 : {
97 : OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
98 0 : }
99 :
100 : //-------------------------------------------------------------------------
101 : // OElementImport overridables
102 : template <class BASE>
103 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement()
104 : {
105 0 : ::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 0 : if (m_xColumnFactory.is())
108 : {
109 : // create the column
110 0 : xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
111 : OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
112 : }
113 0 : return xReturn;
114 : }
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|