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