Update ooo320-m1
[ooovba.git] / dbaccess / source / core / dataaccess / commanddefinition.cxx
blob8c3d584770cbb6617950399cd81d9d3bf907a972
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: commanddefinition.cxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include "commanddefinition.hxx"
35 #include "apitools.hxx"
36 #include "dbastrings.hrc"
37 #include "module_dba.hxx"
39 #include <com/sun/star/lang/DisposedException.hpp>
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <tools/debug.hxx>
43 #include <comphelper/sequence.hxx>
44 #include <comphelper/componentcontext.hxx>
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::beans;
50 using namespace ::com::sun::star::container;
51 using namespace ::osl;
52 using namespace ::comphelper;
53 using namespace ::cppu;
55 //........................................................................
56 namespace dbaccess
58 //........................................................................
60 //==========================================================================
61 //= OCommandDefinition
62 //==========================================================================
63 extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition()
65 static ::dba::OAutoRegistration< OCommandDefinition > aAutoRegistration;
68 //--------------------------------------------------------------------------
69 DBG_NAME(OCommandDefinition)
70 //--------------------------------------------------------------------------
71 void OCommandDefinition::registerProperties()
73 OCommandDefinition_Impl& rCommandDefinition( getCommandDefinition() );
74 registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
75 &rCommandDefinition.m_sCommand, ::getCppuType(&rCommandDefinition.m_sCommand));
77 registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
78 &rCommandDefinition.m_bEscapeProcessing, ::getBooleanCppuType());
80 registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
81 &rCommandDefinition.m_sUpdateTableName, ::getCppuType(&rCommandDefinition.m_sUpdateTableName));
83 registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
84 &rCommandDefinition.m_sUpdateSchemaName, ::getCppuType(&rCommandDefinition.m_sUpdateSchemaName));
86 registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
87 &rCommandDefinition.m_sUpdateCatalogName, ::getCppuType(&rCommandDefinition.m_sUpdateCatalogName));
88 registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
89 &rCommandDefinition.m_aLayoutInformation, ::getCppuType(&rCommandDefinition.m_aLayoutInformation));
92 //--------------------------------------------------------------------------
93 OCommandDefinition::OCommandDefinition(const Reference< XMultiServiceFactory >& _xORB
94 ,const Reference< XInterface >& _rxContainer
95 ,const TContentPtr& _pImpl)
96 :OComponentDefinition(_xORB,_rxContainer,_pImpl,sal_False)
98 DBG_CTOR(OCommandDefinition, NULL);
99 registerProperties();
101 //--------------------------------------------------------------------------
102 OCommandDefinition::~OCommandDefinition()
104 DBG_DTOR(OCommandDefinition, NULL);
107 //--------------------------------------------------------------------------
108 OCommandDefinition::OCommandDefinition( const Reference< XInterface >& _rxContainer
109 ,const ::rtl::OUString& _rElementName
110 ,const Reference< XMultiServiceFactory >& _xORB
111 ,const TContentPtr& _pImpl)
112 :OComponentDefinition(_rxContainer,_rElementName,_xORB,_pImpl,sal_False)
114 DBG_CTOR(OCommandDefinition, NULL);
115 registerProperties();
118 //--------------------------------------------------------------------------
119 IMPLEMENT_IMPLEMENTATION_ID(OCommandDefinition);
120 IMPLEMENT_GETTYPES2(OCommandDefinition,OCommandDefinition_Base,OComponentDefinition);
121 IMPLEMENT_FORWARD_XINTERFACE2( OCommandDefinition,OComponentDefinition,OCommandDefinition_Base)
122 IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2(OCommandDefinition,OCommandDefinition_PROP)
123 //--------------------------------------------------------------------------
124 ::rtl::OUString OCommandDefinition::getImplementationName_static( ) throw(RuntimeException)
126 return ::rtl::OUString::createFromAscii("com.sun.star.comp.dba.OCommandDefinition");
129 //--------------------------------------------------------------------------
130 ::rtl::OUString SAL_CALL OCommandDefinition::getImplementationName( ) throw(RuntimeException)
132 return getImplementationName_static();
135 //--------------------------------------------------------------------------
136 Sequence< ::rtl::OUString > OCommandDefinition::getSupportedServiceNames_static( ) throw(RuntimeException)
138 Sequence< ::rtl::OUString > aServices(3);
139 aServices.getArray()[0] = SERVICE_SDB_QUERYDEFINITION;
140 aServices.getArray()[1] = SERVICE_SDB_COMMAND_DEFINITION;
141 aServices.getArray()[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.Content"));
142 return aServices;
145 //--------------------------------------------------------------------------
146 Sequence< ::rtl::OUString > SAL_CALL OCommandDefinition::getSupportedServiceNames( ) throw(RuntimeException)
148 return getSupportedServiceNames_static();
151 //------------------------------------------------------------------------------
152 Reference< XInterface > OCommandDefinition::Create(const Reference< XComponentContext >& _rxContext)
154 ::comphelper::ComponentContext aContext( _rxContext );
155 return *(new OCommandDefinition( aContext.getLegacyServiceFactory(), NULL, TContentPtr( new OCommandDefinition_Impl ) ) );
158 // -----------------------------------------------------------------------------
159 void SAL_CALL OCommandDefinition::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
163 sal_Int32 nHandle = PROPERTY_ID_NAME;
164 osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
165 Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
166 aGuard.clear();
167 Any aNew = makeAny(newName);
168 fire(&nHandle, &aNew, &aOld, 1, sal_True );
170 m_pImpl->m_aProps.aTitle = newName;
171 fire(&nHandle, &aNew, &aOld, 1, sal_False );
173 catch(const PropertyVetoException&)
175 throw ElementExistException(newName,*this);
178 // -----------------------------------------------------------------------------
179 //........................................................................
180 } // namespace dbaccess
181 //........................................................................