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 : #include <osl/diagnose.h>
27 :
28 : // no namespace. Same as above: this file is included from elementimport.hxx only,
29 : // and this is done inside the namespace
30 :
31 : //= OContainerImport
32 : template <class BASE>
33 0 : 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)
36 : {
37 : // maybe it's a sub control
38 0 : if (_rLocalName == m_sWrapperElementName)
39 : {
40 0 : if (m_xMeAsContainer.is())
41 0 : return implCreateControlWrapper(_nPrefix, _rLocalName);
42 : else
43 : {
44 : OSL_FAIL("OContainerImport::CreateChildContext: don't have an element!");
45 0 : return NULL;
46 : }
47 : }
48 :
49 0 : return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
50 : }
51 :
52 : template <class BASE>
53 : inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
54 15 : OContainerImport< BASE >::createElement()
55 : {
56 : // let the base class create the object
57 15 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement();
58 15 : if (!xReturn.is())
59 0 : return xReturn;
60 :
61 : // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
62 15 : m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY);
63 15 : if (!m_xMeAsContainer.is())
64 : {
65 : OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
66 0 : xReturn.clear();
67 : }
68 :
69 15 : return xReturn;
70 : }
71 :
72 : template <class BASE>
73 15 : inline void OContainerImport< BASE >::EndElement()
74 : {
75 15 : BASE::EndElement();
76 :
77 : // now that we have all children, attach the events
78 15 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY);
79 15 : if (xIndexContainer.is())
80 15 : ODefaultEventAttacherManager::setEvents(xIndexContainer);
81 15 : }
82 :
83 : //= OColumnImport
84 : template <class BASE>
85 0 : 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 0 : ,m_xColumnFactory(_rxParentContainer, ::com::sun::star::uno::UNO_QUERY)
90 : {
91 : OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
92 0 : }
93 :
94 : // OElementImport overridables
95 : template <class BASE>
96 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement()
97 : {
98 0 : ::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 0 : if (m_xColumnFactory.is())
101 : {
102 : // create the column
103 0 : xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
104 : OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
105 : }
106 0 : return xReturn;
107 : }
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|