1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 
31 #ifndef _DBA_COREDATAACCESS_COMMANDCONTAINER_HXX_
32 #include "commandcontainer.hxx"
33 #endif
34 #ifndef _DBA_COREDATAACESS_COMMANDDEFINITION_HXX_
35 #include "commanddefinition.hxx"
36 #endif
37 
38 #ifndef _TOOLS_DEBUG_HXX
39 #include <tools/debug.hxx>
40 #endif
41 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
42 #include "dbastrings.hrc"
43 #endif
44 
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::lang;
47 using namespace ::com::sun::star::beans;
48 using namespace ::com::sun::star::container;
49 using namespace ::com::sun::star::ucb;
50 using namespace ::osl;
51 using namespace ::comphelper;
52 using namespace ::cppu;
53 
54 //........................................................................
55 namespace dbaccess
56 {
57 //........................................................................
58 
59 //==========================================================================
60 //= OCommandContainer
61 //==========================================================================
62 DBG_NAME(OCommandContainer)
63 //--------------------------------------------------------------------------
64 OCommandContainer::OCommandContainer( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
65 									 ,const Reference< XInterface >&	_xParentContainer
66 									 ,const TContentPtr& _pImpl
67 									 ,sal_Bool _bTables
68 									 )
69 	:ODefinitionContainer(_xORB,_xParentContainer,_pImpl,!_bTables)
70 	,m_bTables(_bTables)
71 {
72 	DBG_CTOR(OCommandContainer, NULL);
73 }
74 //--------------------------------------------------------------------------
75 OCommandContainer::~OCommandContainer()
76 {
77 	DBG_DTOR(OCommandContainer, NULL);
78 }
79 // -----------------------------------------------------------------------------
80 IMPLEMENT_FORWARD_XINTERFACE2( OCommandContainer,ODefinitionContainer,OCommandContainer_BASE)
81 IMPLEMENT_TYPEPROVIDER2(OCommandContainer,ODefinitionContainer,OCommandContainer_BASE);
82 //--------------------------------------------------------------------------
83 Reference< XContent > OCommandContainer::createObject( const ::rtl::OUString& _rName)
84 {
85 	const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
86     OSL_ENSURE( rDefinitions.find(_rName) != rDefinitions.end(), "OCommandContainer::createObject: Invalid entry in map!" );
87 
88     const TContentPtr& pElementContent( rDefinitions.find( _rName )->second );
89 	if ( m_bTables )
90 		return new OComponentDefinition( *this, _rName, m_aContext.getLegacyServiceFactory(), pElementContent, m_bTables );
91 	return new OCommandDefinition( *this, _rName, m_aContext.getLegacyServiceFactory(), pElementContent );
92 }
93 
94 // -----------------------------------------------------------------------------
95 Reference< XInterface > SAL_CALL OCommandContainer::createInstanceWithArguments(const Sequence< Any >& /*aArguments*/ ) throw (Exception, RuntimeException)
96 {
97 	return createInstance( );
98 }
99 
100 // -----------------------------------------------------------------------------
101 Reference< XInterface > SAL_CALL OCommandContainer::createInstance( ) throw (Exception, RuntimeException)
102 {
103     return m_aContext.createComponent( (::rtl::OUString)( m_bTables ? SERVICE_SDB_TABLEDEFINITION : SERVICE_SDB_COMMAND_DEFINITION ) );
104 }
105 
106 // -----------------------------------------------------------------------------
107 ::rtl::OUString OCommandContainer::determineContentType() const
108 {
109     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseCommandDefinitionContainer" ) );
110 }
111 
112 //........................................................................
113 }	// namespace dbaccess
114 //........................................................................
115 
116