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 : #include "commandcontainer.hxx"
21 : #include "commanddefinition.hxx"
22 :
23 : #include <tools/debug.hxx>
24 : #include "dbastrings.hrc"
25 : #include <com/sun/star/sdb/TableDefinition.hpp>
26 : #include <com/sun/star/sdb/CommandDefinition.hpp>
27 :
28 : using namespace ::com::sun::star::uno;
29 : using namespace ::com::sun::star::lang;
30 : using namespace ::com::sun::star::beans;
31 : using namespace ::com::sun::star::container;
32 : using namespace ::com::sun::star::ucb;
33 : using namespace ::osl;
34 : using namespace ::comphelper;
35 : using namespace ::cppu;
36 :
37 : namespace dbaccess
38 : {
39 :
40 : // OCommandContainer
41 :
42 576 : OCommandContainer::OCommandContainer( const Reference< ::com::sun::star::uno::XComponentContext >& _xORB
43 : ,const Reference< XInterface >& _xParentContainer
44 : ,const TContentPtr& _pImpl
45 : ,bool _bTables
46 : )
47 576 : :ODefinitionContainer(_xORB,_xParentContainer,_pImpl,!_bTables)
48 576 : ,m_bTables(_bTables)
49 : {
50 576 : }
51 :
52 1148 : OCommandContainer::~OCommandContainer()
53 : {
54 1148 : }
55 :
56 25414 : IMPLEMENT_FORWARD_XINTERFACE2( OCommandContainer,ODefinitionContainer,OCommandContainer_BASE)
57 2 : IMPLEMENT_GETTYPES2(OCommandContainer,ODefinitionContainer,OCommandContainer_BASE);
58 :
59 0 : css::uno::Sequence<sal_Int8> OCommandContainer::getImplementationId()
60 : throw (css::uno::RuntimeException, std::exception)
61 : {
62 0 : return css::uno::Sequence<sal_Int8>();
63 : }
64 :
65 29 : Reference< XContent > OCommandContainer::createObject( const OUString& _rName)
66 : {
67 29 : const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
68 : OSL_ENSURE( rDefinitions.find(_rName) != rDefinitions.end(), "OCommandContainer::createObject: Invalid entry in map!" );
69 :
70 29 : const TContentPtr& pElementContent( rDefinitions.find( _rName )->second );
71 29 : if ( m_bTables )
72 20 : return new OComponentDefinition( *this, _rName, m_aContext, pElementContent, m_bTables );
73 : else
74 9 : return static_cast< css::sdb::XQueryDefinition * > ( new OCommandDefinition( *this, _rName, m_aContext, pElementContent ) );
75 : }
76 :
77 0 : Reference< XInterface > SAL_CALL OCommandContainer::createInstanceWithArguments(const Sequence< Any >& /*aArguments*/ ) throw (Exception, RuntimeException, std::exception)
78 : {
79 0 : return createInstance( );
80 : }
81 :
82 25 : Reference< XInterface > SAL_CALL OCommandContainer::createInstance( ) throw (Exception, RuntimeException, std::exception)
83 : {
84 25 : if(m_bTables)
85 0 : return css::sdb::TableDefinition::createDefault( m_aContext );
86 : else
87 25 : return css::sdb::CommandDefinition::create( m_aContext );
88 : }
89 :
90 0 : OUString OCommandContainer::determineContentType() const
91 : {
92 0 : return OUString( "application/vnd.org.openoffice.DatabaseCommandDefinitionContainer" );
93 : }
94 :
95 : } // namespace dbaccess
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|