1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir #include "connectivity/sdbcx/VColumn.hxx" 31*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 32*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 33*cdf0e10cSrcweir #include "TConnection.hxx" 34*cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 35*cdf0e10cSrcweir // ------------------------------------------------------------------------- 36*cdf0e10cSrcweir using namespace connectivity; 37*cdf0e10cSrcweir using namespace connectivity::sdbcx; 38*cdf0e10cSrcweir using namespace cppu; 39*cdf0e10cSrcweir using namespace connectivity; 40*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 41*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 42*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 43*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 46*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir if(isNew()) 49*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumnDescription"); 50*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumn"); 51*cdf0e10cSrcweir } 52*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 53*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1); 56*cdf0e10cSrcweir if(isNew()) 57*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ColumnDescription"); 58*cdf0e10cSrcweir else 59*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column"); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir return aSupported; 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 64*cdf0e10cSrcweir sal_Bool SAL_CALL OColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 67*cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 68*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 69*cdf0e10cSrcweir for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 70*cdf0e10cSrcweir ; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir return pSupported != pEnd; 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir // ------------------------------------------------------------------------- 75*cdf0e10cSrcweir OColumn::OColumn(sal_Bool _bCase) 76*cdf0e10cSrcweir :OColumnDescriptor_BASE(m_aMutex) 77*cdf0e10cSrcweir ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,sal_True) 78*cdf0e10cSrcweir ,m_IsNullable(ColumnValue::NULLABLE) 79*cdf0e10cSrcweir ,m_Precision(0) 80*cdf0e10cSrcweir ,m_Scale(0) 81*cdf0e10cSrcweir ,m_Type(0) 82*cdf0e10cSrcweir ,m_IsAutoIncrement(sal_False) 83*cdf0e10cSrcweir ,m_IsRowVersion(sal_False) 84*cdf0e10cSrcweir ,m_IsCurrency(sal_False) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir construct(); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir // ------------------------------------------------------------------------- 89*cdf0e10cSrcweir OColumn::OColumn( const ::rtl::OUString& _Name, 90*cdf0e10cSrcweir const ::rtl::OUString& _TypeName, 91*cdf0e10cSrcweir const ::rtl::OUString& _DefaultValue, 92*cdf0e10cSrcweir const ::rtl::OUString& _Description, 93*cdf0e10cSrcweir sal_Int32 _IsNullable, 94*cdf0e10cSrcweir sal_Int32 _Precision, 95*cdf0e10cSrcweir sal_Int32 _Scale, 96*cdf0e10cSrcweir sal_Int32 _Type, 97*cdf0e10cSrcweir sal_Bool _IsAutoIncrement, 98*cdf0e10cSrcweir sal_Bool _IsRowVersion, 99*cdf0e10cSrcweir sal_Bool _IsCurrency, 100*cdf0e10cSrcweir sal_Bool _bCase) 101*cdf0e10cSrcweir :OColumnDescriptor_BASE(m_aMutex) 102*cdf0e10cSrcweir ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase) 103*cdf0e10cSrcweir ,m_TypeName(_TypeName) 104*cdf0e10cSrcweir ,m_Description(_Description) 105*cdf0e10cSrcweir ,m_DefaultValue(_DefaultValue) 106*cdf0e10cSrcweir ,m_IsNullable(_IsNullable) 107*cdf0e10cSrcweir ,m_Precision(_Precision) 108*cdf0e10cSrcweir ,m_Scale(_Scale) 109*cdf0e10cSrcweir ,m_Type(_Type) 110*cdf0e10cSrcweir ,m_IsAutoIncrement(_IsAutoIncrement) 111*cdf0e10cSrcweir ,m_IsRowVersion(_IsRowVersion) 112*cdf0e10cSrcweir ,m_IsCurrency(_IsCurrency) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir m_Name = _Name; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir construct(); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir // ------------------------------------------------------------------------- 119*cdf0e10cSrcweir OColumn::~OColumn() 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 123*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir return doCreateArrayHelper(); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 128*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper() 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 133*cdf0e10cSrcweir void SAL_CALL OColumn::acquire() throw() 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir OColumnDescriptor_BASE::acquire(); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 138*cdf0e10cSrcweir void SAL_CALL OColumn::release() throw() 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir OColumnDescriptor_BASE::release(); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 143*cdf0e10cSrcweir Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir Any aRet = ODescriptor::queryInterface( rType); 146*cdf0e10cSrcweir if(!aRet.hasValue()) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir if(!isNew()) 149*cdf0e10cSrcweir aRet = OColumn_BASE::queryInterface(rType); 150*cdf0e10cSrcweir if(!aRet.hasValue()) 151*cdf0e10cSrcweir aRet = OColumnDescriptor_BASE::queryInterface( rType); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir return aRet; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir // ------------------------------------------------------------------------- 156*cdf0e10cSrcweir Sequence< Type > SAL_CALL OColumn::getTypes( ) throw(RuntimeException) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir if(isNew()) 159*cdf0e10cSrcweir return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes()); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes()); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir // ------------------------------------------------------------------------- 164*cdf0e10cSrcweir void OColumn::construct() 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir ODescriptor::construct(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME), PROPERTY_ID_TYPENAME, nAttrib,&m_TypeName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); 171*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION, nAttrib,&m_Description, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); 172*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), PROPERTY_ID_DEFAULTVALUE, nAttrib,&m_DefaultValue, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); 173*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION), PROPERTY_ID_PRECISION, nAttrib,&m_Precision, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 174*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 175*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), PROPERTY_ID_SCALE, nAttrib,&m_Scale, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 176*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE), PROPERTY_ID_ISNULLABLE, nAttrib,&m_IsNullable, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 177*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT, nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType()); 178*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION), PROPERTY_ID_ISROWVERSION, nAttrib,&m_IsRowVersion, ::getBooleanCppuType()); 179*cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY), PROPERTY_ID_ISCURRENCY, nAttrib,&m_IsCurrency, ::getBooleanCppuType()); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir // ------------------------------------------------------------------------- 182*cdf0e10cSrcweir void OColumn::disposing(void) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir OPropertySetHelper::disposing(); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 187*cdf0e10cSrcweir checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir // ------------------------------------------------------------------------- 191*cdf0e10cSrcweir Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( ) throw(RuntimeException) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 194*cdf0e10cSrcweir checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir OColumn* pNewColumn = new OColumn( m_Name, 198*cdf0e10cSrcweir m_TypeName, 199*cdf0e10cSrcweir m_DefaultValue, 200*cdf0e10cSrcweir m_Description, 201*cdf0e10cSrcweir m_IsNullable, 202*cdf0e10cSrcweir m_Precision, 203*cdf0e10cSrcweir m_Scale, 204*cdf0e10cSrcweir m_Type, 205*cdf0e10cSrcweir m_IsAutoIncrement, 206*cdf0e10cSrcweir m_IsRowVersion, 207*cdf0e10cSrcweir m_IsCurrency, 208*cdf0e10cSrcweir isCaseSensitive()); 209*cdf0e10cSrcweir pNewColumn->setNew(sal_True); 210*cdf0e10cSrcweir return pNewColumn; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 213*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 218*cdf0e10cSrcweir // XNamed 219*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir return m_Name; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 224*cdf0e10cSrcweir void SAL_CALL OColumn::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir m_Name = aName; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 229*cdf0e10cSrcweir 230