LibreOffice Module dbaccess (master) 1
commandcontainer.cxx
Go to the documentation of this file.
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#include "commandcontainer.hxx"
21#include "commanddefinition.hxx"
22
23#include <com/sun/star/sdb/TableDefinition.hpp>
24#include <com/sun/star/sdb/CommandDefinition.hpp>
25
26using namespace ::com::sun::star::uno;
27using namespace ::com::sun::star::lang;
28using namespace ::com::sun::star::beans;
29using namespace ::com::sun::star::container;
30using namespace ::com::sun::star::ucb;
31using namespace ::osl;
32using namespace ::comphelper;
33using namespace ::cppu;
34
35namespace dbaccess
36{
37
38// OCommandContainer
39
40OCommandContainer::OCommandContainer( const Reference< css::uno::XComponentContext >& _xORB
41 ,const Reference< XInterface >& _xParentContainer
42 ,const TContentPtr& _pImpl
43 ,bool _bTables
44 )
45 :ODefinitionContainer(_xORB,_xParentContainer,_pImpl,!_bTables)
46 ,m_bTables(_bTables)
47{
48}
49
51{
52}
53
55css::uno::Sequence< css::uno::Type > OCommandContainer::getTypes()
56{
57 return ::comphelper::concatSequences(
60 );
61}
62
63css::uno::Sequence<sal_Int8> OCommandContainer::getImplementationId()
64{
65 return css::uno::Sequence<sal_Int8>();
66}
67
68Reference< XContent > OCommandContainer::createObject( const OUString& _rName)
69{
70 const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
71 OSL_ENSURE( rDefinitions.find(_rName) != rDefinitions.end(), "OCommandContainer::createObject: Invalid entry in map!" );
72
73 const TContentPtr& pElementContent( rDefinitions.find( _rName )->second );
74 if ( m_bTables )
75 return new OComponentDefinition( *this, _rName, m_aContext, pElementContent, m_bTables );
76 else
77 return static_cast< css::sdb::XQueryDefinition * > ( new OCommandDefinition( *this, _rName, m_aContext, pElementContent ) );
78}
79
80Reference< XInterface > SAL_CALL OCommandContainer::createInstanceWithArguments(const Sequence< Any >& /*aArguments*/ )
81{
82 return createInstance( );
83}
84
85Reference< XInterface > SAL_CALL OCommandContainer::createInstance( )
86{
87 if(m_bTables)
88 return css::sdb::TableDefinition::createDefault( m_aContext );
89 else
90 return css::sdb::CommandDefinition::create( m_aContext );
91}
92
94{
95 return "application/vnd.org.openoffice.DatabaseCommandDefinitionContainer";
96}
97
98} // namespace dbaccess
99
100/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
OCommandContainer(const css::uno::Reference< css::uno::XComponentContext > &_xORB, const css::uno::Reference< css::uno::XInterface > &_xParentContainer, const TContentPtr &_pImpl, bool _bTables)
constructs the container.
virtual ~OCommandContainer() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::uno::Reference< css::ucb::XContent > createObject(const OUString &_rName) override
create an object from its persistent data within the configuration.
virtual OUString determineContentType() const override
const css::uno::Reference< css::uno::XComponentContext > m_aContext
const_iterator find(const OUString &_rName) const
const ODefinitionContainer_Impl & getDefinitions() const
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Type
std::shared_ptr< OContentHelper_Impl > TContentPtr
IMPLEMENT_FORWARD_XINTERFACE2(OStatement, OStatementBase, OStatement_IFACE)