1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10*9b5730f6SAndrew Rist * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9b5730f6SAndrew Rist * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19*9b5730f6SAndrew Rist * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir #include <connectivity/sdbcx/VDescriptor.hxx> 27cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <functional> 30cdf0e10cSrcweir #include <algorithm> 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace connectivity 33cdf0e10cSrcweir { 34cdf0e10cSrcweir namespace sdbcx 35cdf0e10cSrcweir { 36cdf0e10cSrcweir using namespace ::com::sun::star::uno; 37cdf0e10cSrcweir using namespace ::com::sun::star::lang; 38cdf0e10cSrcweir using namespace ::com::sun::star::beans; 39cdf0e10cSrcweir 40cdf0e10cSrcweir // ========================================================================= 41cdf0e10cSrcweir // = ODescriptor 42cdf0e10cSrcweir // ========================================================================= 43cdf0e10cSrcweir // ------------------------------------------------------------------------- ODescriptor(::cppu::OBroadcastHelper & _rBHelper,sal_Bool _bCase,sal_Bool _bNew)44cdf0e10cSrcweir ODescriptor::ODescriptor(::cppu::OBroadcastHelper& _rBHelper,sal_Bool _bCase, sal_Bool _bNew) 45cdf0e10cSrcweir :ODescriptor_PBASE(_rBHelper) 46cdf0e10cSrcweir ,m_aCase(_bCase) 47cdf0e10cSrcweir ,m_bNew(_bNew) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir // ------------------------------------------------------------------------- 52cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel getSomething(const Sequence<sal_Int8> & rId)53cdf0e10cSrcweir sal_Int64 SAL_CALL ODescriptor::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) 56cdf0e10cSrcweir ? reinterpret_cast< sal_Int64 >( this ) 57cdf0e10cSrcweir : 0; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementation(const Reference<XInterface> & _rxSomeComp)61cdf0e10cSrcweir ODescriptor* ODescriptor::getImplementation( const Reference< XInterface >& _rxSomeComp ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir Reference< XUnoTunnel > xTunnel( _rxSomeComp, UNO_QUERY ); 64cdf0e10cSrcweir if ( xTunnel.is() ) 65cdf0e10cSrcweir return reinterpret_cast< ODescriptor* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) ); 66cdf0e10cSrcweir return NULL; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir // ----------------------------------------------------------------------------- 70cdf0e10cSrcweir namespace 71cdf0e10cSrcweir { 72cdf0e10cSrcweir struct ResetROAttribute : public ::std::unary_function< Property, void > 73cdf0e10cSrcweir { operator ()connectivity::sdbcx::__anon08d3f39e0111::ResetROAttribute74cdf0e10cSrcweir void operator ()( Property& _rProperty ) const 75cdf0e10cSrcweir { 76cdf0e10cSrcweir _rProperty.Attributes &= ~PropertyAttribute::READONLY; 77cdf0e10cSrcweir } 78cdf0e10cSrcweir }; 79cdf0e10cSrcweir struct SetROAttribute : public ::std::unary_function< Property, void > 80cdf0e10cSrcweir { operator ()connectivity::sdbcx::__anon08d3f39e0111::SetROAttribute81cdf0e10cSrcweir void operator ()( Property& _rProperty ) const 82cdf0e10cSrcweir { 83cdf0e10cSrcweir _rProperty.Attributes |= PropertyAttribute::READONLY; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir }; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir // ----------------------------------------------------------------------------- doCreateArrayHelper() const89cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ODescriptor::doCreateArrayHelper() const 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Sequence< Property > aProperties; 92cdf0e10cSrcweir describeProperties( aProperties ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir if ( isNew() ) 95cdf0e10cSrcweir ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), ResetROAttribute() ); 96cdf0e10cSrcweir else 97cdf0e10cSrcweir ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), SetROAttribute() ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper( aProperties ); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir // ----------------------------------------------------------------------------- isNew(const Reference<XInterface> & _rxDescriptor)103cdf0e10cSrcweir sal_Bool ODescriptor::isNew( const Reference< XInterface >& _rxDescriptor ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir ODescriptor* pImplementation = getImplementation( _rxDescriptor ); 106cdf0e10cSrcweir return pImplementation != NULL ? pImplementation->isNew() : sal_False; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir // ----------------------------------------------------------------------------- getUnoTunnelImplementationId()110cdf0e10cSrcweir Sequence< sal_Int8 > ODescriptor::getUnoTunnelImplementationId() 111cdf0e10cSrcweir { 112cdf0e10cSrcweir static ::cppu::OImplementationId * pId = 0; 113cdf0e10cSrcweir if (! pId) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 116cdf0e10cSrcweir if (! pId) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir static ::cppu::OImplementationId aId; 119cdf0e10cSrcweir pId = &aId; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir } 122cdf0e10cSrcweir return pId->getImplementationId(); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir // ----------------------------------------------------------------------------- queryInterface(const Type & rType)126cdf0e10cSrcweir Any SAL_CALL ODescriptor::queryInterface( const Type & rType ) throw(RuntimeException) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir Any aRet = ::cppu::queryInterface(rType,static_cast< XUnoTunnel*> (this)); 129cdf0e10cSrcweir return aRet.hasValue() ? aRet : ODescriptor_PBASE::queryInterface(rType); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir // ----------------------------------------------------------------------------- setNew(sal_Bool _bNew)133cdf0e10cSrcweir void ODescriptor::setNew(sal_Bool _bNew) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir m_bNew = _bNew; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir // ----------------------------------------------------------------------------- getTypes()139cdf0e10cSrcweir Sequence< Type > SAL_CALL ODescriptor::getTypes( ) throw(RuntimeException) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ), 142cdf0e10cSrcweir ::getCppuType( (const Reference< XFastPropertySet > *)0 ), 143cdf0e10cSrcweir ::getCppuType( (const Reference< XPropertySet > *)0 ), 144cdf0e10cSrcweir ::getCppuType( (const Reference< XUnoTunnel > *)0 )); 145cdf0e10cSrcweir return aTypes.getTypes(); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir 152