1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*96de5490SAndrew Rist * distributed with this work for additional information
6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10*96de5490SAndrew Rist *
11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist *
13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist * software distributed under the License is distributed on an
15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the
17*96de5490SAndrew Rist * specific language governing permissions and limitations
18*96de5490SAndrew Rist * under the License.
19*96de5490SAndrew Rist *
20*96de5490SAndrew Rist *************************************************************/
21*96de5490SAndrew Rist
22*96de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef _DBA_COREDATAACCESS_COMMANDCONTAINER_HXX_
28cdf0e10cSrcweir #include "commandcontainer.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _DBA_COREDATAACESS_COMMANDDEFINITION_HXX_
31cdf0e10cSrcweir #include "commanddefinition.hxx"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
38cdf0e10cSrcweir #include "dbastrings.hrc"
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir
41cdf0e10cSrcweir using namespace ::com::sun::star::uno;
42cdf0e10cSrcweir using namespace ::com::sun::star::lang;
43cdf0e10cSrcweir using namespace ::com::sun::star::beans;
44cdf0e10cSrcweir using namespace ::com::sun::star::container;
45cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
46cdf0e10cSrcweir using namespace ::osl;
47cdf0e10cSrcweir using namespace ::comphelper;
48cdf0e10cSrcweir using namespace ::cppu;
49cdf0e10cSrcweir
50cdf0e10cSrcweir //........................................................................
51cdf0e10cSrcweir namespace dbaccess
52cdf0e10cSrcweir {
53cdf0e10cSrcweir //........................................................................
54cdf0e10cSrcweir
55cdf0e10cSrcweir //==========================================================================
56cdf0e10cSrcweir //= OCommandContainer
57cdf0e10cSrcweir //==========================================================================
DBG_NAME(OCommandContainer)58cdf0e10cSrcweir DBG_NAME(OCommandContainer)
59cdf0e10cSrcweir //--------------------------------------------------------------------------
60cdf0e10cSrcweir OCommandContainer::OCommandContainer( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
61cdf0e10cSrcweir ,const Reference< XInterface >& _xParentContainer
62cdf0e10cSrcweir ,const TContentPtr& _pImpl
63cdf0e10cSrcweir ,sal_Bool _bTables
64cdf0e10cSrcweir )
65cdf0e10cSrcweir :ODefinitionContainer(_xORB,_xParentContainer,_pImpl,!_bTables)
66cdf0e10cSrcweir ,m_bTables(_bTables)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir DBG_CTOR(OCommandContainer, NULL);
69cdf0e10cSrcweir }
70cdf0e10cSrcweir //--------------------------------------------------------------------------
~OCommandContainer()71cdf0e10cSrcweir OCommandContainer::~OCommandContainer()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir DBG_DTOR(OCommandContainer, NULL);
74cdf0e10cSrcweir }
75cdf0e10cSrcweir // -----------------------------------------------------------------------------
76cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( OCommandContainer,ODefinitionContainer,OCommandContainer_BASE)
77cdf0e10cSrcweir IMPLEMENT_TYPEPROVIDER2(OCommandContainer,ODefinitionContainer,OCommandContainer_BASE);
78cdf0e10cSrcweir //--------------------------------------------------------------------------
createObject(const::rtl::OUString & _rName)79cdf0e10cSrcweir Reference< XContent > OCommandContainer::createObject( const ::rtl::OUString& _rName)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
82cdf0e10cSrcweir OSL_ENSURE( rDefinitions.find(_rName) != rDefinitions.end(), "OCommandContainer::createObject: Invalid entry in map!" );
83cdf0e10cSrcweir
84cdf0e10cSrcweir const TContentPtr& pElementContent( rDefinitions.find( _rName )->second );
85cdf0e10cSrcweir if ( m_bTables )
86cdf0e10cSrcweir return new OComponentDefinition( *this, _rName, m_aContext.getLegacyServiceFactory(), pElementContent, m_bTables );
87cdf0e10cSrcweir return new OCommandDefinition( *this, _rName, m_aContext.getLegacyServiceFactory(), pElementContent );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir // -----------------------------------------------------------------------------
createInstanceWithArguments(const Sequence<Any> &)91cdf0e10cSrcweir Reference< XInterface > SAL_CALL OCommandContainer::createInstanceWithArguments(const Sequence< Any >& /*aArguments*/ ) throw (Exception, RuntimeException)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir return createInstance( );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir // -----------------------------------------------------------------------------
createInstance()97cdf0e10cSrcweir Reference< XInterface > SAL_CALL OCommandContainer::createInstance( ) throw (Exception, RuntimeException)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir return m_aContext.createComponent( (::rtl::OUString)( m_bTables ? SERVICE_SDB_TABLEDEFINITION : SERVICE_SDB_COMMAND_DEFINITION ) );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir // -----------------------------------------------------------------------------
determineContentType() const103cdf0e10cSrcweir ::rtl::OUString OCommandContainer::determineContentType() const
104cdf0e10cSrcweir {
105cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseCommandDefinitionContainer" ) );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir //........................................................................
109cdf0e10cSrcweir } // namespace dbaccess
110cdf0e10cSrcweir //........................................................................
111cdf0e10cSrcweir
112