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 #include "commanddefinition.hxx"
28cdf0e10cSrcweir #include "apitools.hxx"
29cdf0e10cSrcweir #include "dbastrings.hrc"
30cdf0e10cSrcweir #include "module_dba.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir #include <comphelper/sequence.hxx>
37cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
41cdf0e10cSrcweir using namespace ::com::sun::star::lang;
42cdf0e10cSrcweir using namespace ::com::sun::star::beans;
43cdf0e10cSrcweir using namespace ::com::sun::star::container;
44cdf0e10cSrcweir using namespace ::osl;
45cdf0e10cSrcweir using namespace ::comphelper;
46cdf0e10cSrcweir using namespace ::cppu;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //........................................................................
49cdf0e10cSrcweir namespace dbaccess
50cdf0e10cSrcweir {
51cdf0e10cSrcweir //........................................................................
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //==========================================================================
54cdf0e10cSrcweir //= OCommandDefinition
55cdf0e10cSrcweir //==========================================================================
createRegistryInfo_OCommandDefinition()56cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	static ::dba::OAutoRegistration< OCommandDefinition > aAutoRegistration;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //--------------------------------------------------------------------------
DBG_NAME(OCommandDefinition)62cdf0e10cSrcweir DBG_NAME(OCommandDefinition)
63cdf0e10cSrcweir //--------------------------------------------------------------------------
64cdf0e10cSrcweir void OCommandDefinition::registerProperties()
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     OCommandDefinition_Impl& rCommandDefinition( getCommandDefinition() );
67cdf0e10cSrcweir 	registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
68cdf0e10cSrcweir 					&rCommandDefinition.m_sCommand, ::getCppuType(&rCommandDefinition.m_sCommand));
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
71cdf0e10cSrcweir 					&rCommandDefinition.m_bEscapeProcessing, ::getBooleanCppuType());
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
74cdf0e10cSrcweir 					&rCommandDefinition.m_sUpdateTableName, ::getCppuType(&rCommandDefinition.m_sUpdateTableName));
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
77cdf0e10cSrcweir 					&rCommandDefinition.m_sUpdateSchemaName, ::getCppuType(&rCommandDefinition.m_sUpdateSchemaName));
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
80cdf0e10cSrcweir 					&rCommandDefinition.m_sUpdateCatalogName, ::getCppuType(&rCommandDefinition.m_sUpdateCatalogName));
81cdf0e10cSrcweir 	registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
82cdf0e10cSrcweir 					&rCommandDefinition.m_aLayoutInformation, ::getCppuType(&rCommandDefinition.m_aLayoutInformation));
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //--------------------------------------------------------------------------
OCommandDefinition(const Reference<XMultiServiceFactory> & _xORB,const Reference<XInterface> & _rxContainer,const TContentPtr & _pImpl)86cdf0e10cSrcweir OCommandDefinition::OCommandDefinition(const Reference< XMultiServiceFactory >& _xORB
87cdf0e10cSrcweir 									   ,const Reference< XInterface >& _rxContainer
88cdf0e10cSrcweir 									   ,const TContentPtr& _pImpl)
89cdf0e10cSrcweir 	:OComponentDefinition(_xORB,_rxContainer,_pImpl,sal_False)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	DBG_CTOR(OCommandDefinition, NULL);
92cdf0e10cSrcweir 	registerProperties();
93cdf0e10cSrcweir }
94cdf0e10cSrcweir //--------------------------------------------------------------------------
~OCommandDefinition()95cdf0e10cSrcweir OCommandDefinition::~OCommandDefinition()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	DBG_DTOR(OCommandDefinition, NULL);
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir //--------------------------------------------------------------------------
OCommandDefinition(const Reference<XInterface> & _rxContainer,const::rtl::OUString & _rElementName,const Reference<XMultiServiceFactory> & _xORB,const TContentPtr & _pImpl)101cdf0e10cSrcweir OCommandDefinition::OCommandDefinition(	const Reference< XInterface >& _rxContainer
102cdf0e10cSrcweir 									   ,const ::rtl::OUString& _rElementName
103cdf0e10cSrcweir 									   ,const Reference< XMultiServiceFactory >& _xORB
104cdf0e10cSrcweir 									   ,const TContentPtr& _pImpl)
105cdf0e10cSrcweir 	:OComponentDefinition(_rxContainer,_rElementName,_xORB,_pImpl,sal_False)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	DBG_CTOR(OCommandDefinition, NULL);
108cdf0e10cSrcweir 	registerProperties();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //--------------------------------------------------------------------------
112cdf0e10cSrcweir IMPLEMENT_IMPLEMENTATION_ID(OCommandDefinition);
113cdf0e10cSrcweir IMPLEMENT_GETTYPES2(OCommandDefinition,OCommandDefinition_Base,OComponentDefinition);
IMPLEMENT_FORWARD_XINTERFACE2(OCommandDefinition,OComponentDefinition,OCommandDefinition_Base)114cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( OCommandDefinition,OComponentDefinition,OCommandDefinition_Base)
115cdf0e10cSrcweir IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2(OCommandDefinition,OCommandDefinition_PROP)
116cdf0e10cSrcweir //--------------------------------------------------------------------------
117cdf0e10cSrcweir ::rtl::OUString OCommandDefinition::getImplementationName_static(  ) throw(RuntimeException)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii("com.sun.star.comp.dba.OCommandDefinition");
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir //--------------------------------------------------------------------------
getImplementationName()123cdf0e10cSrcweir ::rtl::OUString SAL_CALL OCommandDefinition::getImplementationName(  ) throw(RuntimeException)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	return getImplementationName_static();
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir //--------------------------------------------------------------------------
getSupportedServiceNames_static()129cdf0e10cSrcweir Sequence< ::rtl::OUString > OCommandDefinition::getSupportedServiceNames_static(  ) throw(RuntimeException)
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aServices(3);
132cdf0e10cSrcweir 	aServices.getArray()[0] = SERVICE_SDB_QUERYDEFINITION;
133cdf0e10cSrcweir 	aServices.getArray()[1] = SERVICE_SDB_COMMAND_DEFINITION;
134cdf0e10cSrcweir 	aServices.getArray()[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.Content"));
135cdf0e10cSrcweir 	return aServices;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir //--------------------------------------------------------------------------
getSupportedServiceNames()139cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OCommandDefinition::getSupportedServiceNames(  ) throw(RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	return getSupportedServiceNames_static();
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir //------------------------------------------------------------------------------
Create(const Reference<XComponentContext> & _rxContext)145cdf0e10cSrcweir Reference< XInterface > OCommandDefinition::Create(const Reference< XComponentContext >& _rxContext)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     ::comphelper::ComponentContext aContext( _rxContext );
148cdf0e10cSrcweir 	return *(new OCommandDefinition( aContext.getLegacyServiceFactory(), NULL, TContentPtr( new OCommandDefinition_Impl ) ) );
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir // -----------------------------------------------------------------------------
rename(const::rtl::OUString & newName)152cdf0e10cSrcweir void SAL_CALL OCommandDefinition::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	try
155cdf0e10cSrcweir 	{
156cdf0e10cSrcweir 		sal_Int32 nHandle = PROPERTY_ID_NAME;
157cdf0e10cSrcweir 		osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
158cdf0e10cSrcweir 		Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
159cdf0e10cSrcweir 		aGuard.clear();
160cdf0e10cSrcweir 		Any aNew = makeAny(newName);
161cdf0e10cSrcweir 		fire(&nHandle, &aNew, &aOld, 1, sal_True );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 		m_pImpl->m_aProps.aTitle = newName;
164cdf0e10cSrcweir 		fire(&nHandle, &aNew, &aOld, 1, sal_False );
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir 	catch(const PropertyVetoException&)
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir 		throw ElementExistException(newName,*this);
169cdf0e10cSrcweir 	}
170cdf0e10cSrcweir }
171cdf0e10cSrcweir // -----------------------------------------------------------------------------
172cdf0e10cSrcweir //........................................................................
173cdf0e10cSrcweir }	// namespace dbaccess
174cdf0e10cSrcweir //........................................................................
175cdf0e10cSrcweir 
176