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