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 // MARKER(update_precomp.py): autogen include statement, do not remove 28 #include "precompiled_dbaccess.hxx" 29 30 #include "DatabaseDataProvider.hxx" 31 #include "dbastrings.hrc" 32 #include "cppuhelper/implbase1.hxx" 33 #include <comphelper/types.hxx> 34 #include <comphelper/namedvaluecollection.hxx> 35 #include <connectivity/FValue.hxx> 36 #include <connectivity/dbtools.hxx> 37 #include <rtl/ustrbuf.hxx> 38 #include <rtl/math.hxx> 39 #include <tools/diagnose_ex.h> 40 41 #include <com/sun/star/task/XInteractionHandler.hpp> 42 #include <com/sun/star/sdb/XCompletedExecution.hpp> 43 #include <com/sun/star/sdb/CommandType.hpp> 44 #include <com/sun/star/sdbc/DataType.hpp> 45 #include <com/sun/star/sdbc/XRow.hpp> 46 #include <com/sun/star/sdbc/XResultSet.hpp> 47 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> 48 #include <com/sun/star/sdbc/XResultSetMetaData.hpp> 49 #include <com/sun/star/sdbc/XColumnLocate.hpp> 50 #include <com/sun/star/beans/NamedValue.hpp> 51 #include <com/sun/star/chart/ChartDataRowSource.hpp> 52 #include <com/sun/star/chart/XChartDataArray.hpp> 53 #include <com/sun/star/chart/XDateCategories.hpp> 54 55 #include <vector> 56 #include <list> 57 58 namespace dbaccess 59 { 60 using namespace ::com::sun::star; 61 using ::com::sun::star::sdbc::SQLException; 62 using ::com::sun::star::uno::Reference; 63 using ::com::sun::star::uno::RuntimeException; 64 // ----------------------------------------------------------------------------- 65 DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContext > const & context) : 66 TDatabaseDataProvider(m_aMutex), 67 ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >( 68 context, static_cast< Implements >( 69 IMPLEMENTS_PROPERTY_SET), uno::Sequence< ::rtl::OUString >()), 70 m_aParameterManager( m_aMutex, uno::Reference< lang::XMultiServiceFactory >(context->getServiceManager(),uno::UNO_QUERY) ), 71 m_aFilterManager( uno::Reference< lang::XMultiServiceFactory >(context->getServiceManager(),uno::UNO_QUERY) ), 72 m_xContext(context), 73 m_CommandType(sdb::CommandType::COMMAND), // #i94114 74 m_RowLimit(0), 75 m_EscapeProcessing(sal_True), 76 m_ApplyFilter(sal_True) 77 { 78 m_xInternal.set( m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart.InternalDataProvider")),m_xContext ), uno::UNO_QUERY ); 79 m_xRangeConversion.set(m_xInternal,uno::UNO_QUERY); 80 m_xComplexDescriptionAccess.set(m_xInternal,uno::UNO_QUERY); 81 82 osl_incrementInterlockedCount( &m_refCount ); 83 { 84 m_xRowSet.set( m_xContext->getServiceManager()->createInstanceWithContext(SERVICE_SDB_ROWSET,m_xContext ), uno::UNO_QUERY ); 85 m_xAggregate.set(m_xRowSet,uno::UNO_QUERY); 86 m_xAggregateSet.set(m_xRowSet,uno::UNO_QUERY); 87 uno::Reference<beans::XPropertySet> xProp(static_cast< ::cppu::OWeakObject* >( this ),uno::UNO_QUERY); 88 m_aFilterManager.initialize( m_xAggregateSet ); 89 m_aParameterManager.initialize( xProp, m_xAggregate ); 90 m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND_TYPE,uno::makeAny(m_CommandType)); 91 m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,uno::makeAny(m_EscapeProcessing)); 92 } 93 osl_decrementInterlockedCount( &m_refCount ); 94 } 95 // ----------------------------------------------------------------------------- 96 void SAL_CALL DatabaseDataProvider::disposing() 97 { 98 lang::EventObject aEvt(static_cast<XWeak*>(this)); 99 m_aParameterManager.disposing( aEvt ); 100 101 m_aParameterManager.dispose(); // (to free any references it may have to me) 102 m_aFilterManager.dispose(); // (dito) 103 104 m_xParent.clear(); 105 m_xAggregateSet.clear(); 106 m_xAggregate.clear(); 107 m_xRangeConversion.clear(); 108 ::comphelper::disposeComponent(m_xRowSet); 109 ::comphelper::disposeComponent(m_xInternal); 110 m_xActiveConnection.clear(); 111 } 112 // ----------------------------------------------------------------------------- 113 uno::Any DatabaseDataProvider::queryInterface(uno::Type const & type) throw (uno::RuntimeException) 114 { 115 return TDatabaseDataProvider::queryInterface(type); 116 } 117 // ----------------------------------------------------------------------------- 118 119 //------------------------------------------------------------------------------ 120 rtl::OUString DatabaseDataProvider::getImplementationName_Static( ) throw(uno::RuntimeException) 121 { 122 return rtl::OUString::createFromAscii("com.sun.star.comp.chart2.data.DatabaseDataProvider"); 123 } 124 // ----------------------------------------------------------------------------- 125 // ------------------------------------------------------------------------- 126 // XServiceInfo 127 ::rtl::OUString SAL_CALL DatabaseDataProvider::getImplementationName( ) throw(uno::RuntimeException) 128 { 129 return getImplementationName_Static(); 130 } 131 // ----------------------------------------------------------------------------- 132 // ------------------------------------------------------------------------- 133 sal_Bool SAL_CALL DatabaseDataProvider::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException) 134 { 135 return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0; 136 } 137 // ----------------------------------------------------------------------------- 138 //------------------------------------------------------------------------------ 139 uno::Sequence< ::rtl::OUString > DatabaseDataProvider::getSupportedServiceNames_Static( ) throw (uno::RuntimeException) 140 { 141 uno::Sequence< rtl::OUString > aSNS( 1 ); 142 aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DatabaseDataProvider")); 143 return aSNS; 144 } 145 // ----------------------------------------------------------------------------- 146 uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getSupportedServiceNames( ) throw(uno::RuntimeException) 147 { 148 return getSupportedServiceNames_Static(); 149 } 150 // ----------------------------------------------------------------------------- 151 uno::Reference< uno::XInterface > DatabaseDataProvider::Create(uno::Reference< uno::XComponentContext > const & context) 152 { 153 return *(new DatabaseDataProvider(context)) ; 154 } 155 // ----------------------------------------------------------------------------- 156 // lang::XInitialization: 157 void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception) 158 { 159 osl::MutexGuard g(m_aMutex); 160 const uno::Any* pIter = aArguments.getConstArray(); 161 const uno::Any* pEnd = pIter + aArguments.getLength(); 162 for(;pIter != pEnd;++pIter) 163 { 164 if ( !m_xActiveConnection.is() ) 165 (*pIter) >>= m_xActiveConnection; 166 else if ( !m_xHandler.is() ) 167 (*pIter) >>= m_xHandler; 168 } 169 m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::makeAny( m_xActiveConnection ) ); 170 } 171 // ----------------------------------------------------------------------------- 172 173 // chart2::data::XDataProvider: 174 ::sal_Bool SAL_CALL DatabaseDataProvider::createDataSourcePossible(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException) 175 { 176 //::osl::ResettableMutexGuard aClearForNotifies(m_aMutex); 177 const beans::PropertyValue* pArgIter = _aArguments.getConstArray(); 178 const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength(); 179 for(;pArgIter != pArgEnd;++pArgIter) 180 { 181 if ( pArgIter->Name.equalsAscii("DataRowSource") ) 182 { 183 ::com::sun::star::chart::ChartDataRowSource eRowSource = ::com::sun::star::chart::ChartDataRowSource_COLUMNS; 184 pArgIter->Value >>= eRowSource; 185 if ( eRowSource != ::com::sun::star::chart::ChartDataRowSource_COLUMNS ) 186 return sal_False; 187 } // if ( pArgIter->Name.equalsAscii("DataRowSource") ) 188 else if ( pArgIter->Name.equalsAscii("CellRangeRepresentation") ) 189 { 190 ::rtl::OUString sRange; 191 pArgIter->Value >>= sRange; 192 if ( !sRange.equalsAscii("all") ) 193 return sal_False; 194 } 195 else if ( pArgIter->Name.equalsAscii("FirstCellAsLabel") ) 196 { 197 sal_Bool bFirstCellAsLabel = sal_True; 198 pArgIter->Value >>= bFirstCellAsLabel; 199 if ( !bFirstCellAsLabel ) 200 return sal_False; 201 } 202 } 203 return sal_True; 204 } 205 // ----------------------------------------------------------------------------- 206 // ----------------------------------------------------------------------------- 207 uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::createDataSource(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException, lang::IllegalArgumentException) 208 { 209 osl::ResettableMutexGuard aClearForNotifies(m_aMutex); 210 if ( createDataSourcePossible(_aArguments) ) 211 { 212 try 213 { 214 uno::Reference< chart::XChartDataArray> xChartData( m_xInternal, uno::UNO_QUERY_THROW ); 215 xChartData->setData( uno::Sequence< uno::Sequence< double > >() ); 216 xChartData->setColumnDescriptions( uno::Sequence< ::rtl::OUString >() ); 217 if ( m_xInternal->hasDataByRangeRepresentation( ::rtl::OUString::valueOf( sal_Int32(0) ) ) ) 218 m_xInternal->deleteSequence(0); 219 } 220 catch( const uno::Exception& ) 221 { 222 DBG_UNHANDLED_EXCEPTION(); 223 } 224 225 ::comphelper::NamedValueCollection aArgs( _aArguments ); 226 const sal_Bool bHasCategories = aArgs.getOrDefault( "HasCategories", sal_True ); 227 uno::Sequence< ::rtl::OUString > aColumnNames = 228 aArgs.getOrDefault( "ColumnDescriptions", uno::Sequence< ::rtl::OUString >() ); 229 230 bool bRet = false; 231 if ( m_Command.getLength() != 0 && m_xActiveConnection.is() ) 232 { 233 try 234 { 235 impl_fillRowSet_throw(); 236 impl_executeRowSet_throw(aClearForNotifies); 237 impl_fillInternalDataProvider_throw(bHasCategories,aColumnNames); 238 bRet = true; 239 } 240 catch(const uno::Exception& /*e*/) 241 { 242 } 243 } 244 if ( !bRet ) // no command set or an error occured, use Internal data handler 245 { 246 uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY); 247 if ( xIni.is() ) 248 { 249 uno::Sequence< uno::Any > aInitArgs(1); 250 beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True)); 251 aInitArgs[0] <<= aParam; 252 xIni->initialize(aInitArgs); 253 } 254 } 255 256 } 257 return m_xInternal->createDataSource(_aArguments); 258 } 259 // ----------------------------------------------------------------------------- 260 261 uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException) 262 { 263 ::comphelper::NamedValueCollection aArguments; 264 aArguments.put( "CellRangeRepresentation", uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); 265 aArguments.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); 266 // internal data always contains labels and categories 267 aArguments.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); 268 269 sal_Bool bHasCategories = sal_False; 270 if( _xDataSource.is()) 271 { 272 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences()); 273 const sal_Int32 nCount( aSequences.getLength()); 274 for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx ) 275 { 276 if( aSequences[nIdx].is() ) 277 { 278 uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY ); 279 ::rtl::OUString aRole; 280 if ( xSeqProp.is() 281 && ( xSeqProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ) ) ) >>= aRole ) 282 && aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "categories" ) ) 283 ) 284 { 285 bHasCategories = sal_True; 286 break; 287 } 288 } 289 } 290 } 291 aArguments.put( "HasCategories", uno::makeAny( bHasCategories ) ); 292 return aArguments.getPropertyValues(); 293 } 294 // ----------------------------------------------------------------------------- 295 296 ::sal_Bool SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentationPossible(const ::rtl::OUString & /*aRangeRepresentation*/) throw (uno::RuntimeException) 297 { 298 return sal_True; 299 } 300 // ----------------------------------------------------------------------------- 301 uno::Any DatabaseDataProvider::impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const 302 { 303 ::std::map< ::rtl::OUString,com::sun::star::uno::Any>::const_iterator aFind = m_aNumberFormats.find(_sRangeRepresentation); 304 if ( aFind != m_aNumberFormats.end() ) 305 return aFind->second; 306 return uno::makeAny(sal_Int32(0)); 307 } 308 // ----------------------------------------------------------------------------- 309 uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentation(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException) 310 { 311 osl::MutexGuard g(m_aMutex); 312 uno::Reference< chart2::data::XDataSequence > xData = m_xInternal->createDataSequenceByRangeRepresentation(_sRangeRepresentation);; 313 uno::Reference<beans::XPropertySet> xProp(xData,uno::UNO_QUERY); 314 const static ::rtl::OUString s_sNumberFormatKey(RTL_CONSTASCII_USTRINGPARAM("NumberFormatKey")); 315 if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(s_sNumberFormatKey) ) 316 { 317 xProp->setPropertyValue(s_sNumberFormatKey,impl_getNumberFormatKey_nothrow(_sRangeRepresentation)); 318 } 319 return xData; 320 } 321 322 uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL DatabaseDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException) 323 { 324 return m_xComplexDescriptionAccess->getComplexRowDescriptions(); 325 } 326 void SAL_CALL DatabaseDataProvider::setComplexRowDescriptions( const uno::Sequence< uno::Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException) 327 { 328 m_xComplexDescriptionAccess->setComplexRowDescriptions(aRowDescriptions); 329 } 330 uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL DatabaseDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException) 331 { 332 return m_xComplexDescriptionAccess->getComplexColumnDescriptions(); 333 } 334 void SAL_CALL DatabaseDataProvider::setComplexColumnDescriptions( const uno::Sequence< uno::Sequence< rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException) 335 { 336 m_xComplexDescriptionAccess->setComplexColumnDescriptions(aColumnDescriptions); 337 } 338 // ____ XChartDataArray ____ 339 uno::Sequence< uno::Sequence< double > > SAL_CALL DatabaseDataProvider::getData() throw (uno::RuntimeException) 340 { 341 return m_xComplexDescriptionAccess->getData(); 342 } 343 344 void SAL_CALL DatabaseDataProvider::setData( const uno::Sequence< uno::Sequence< double > >& rDataInRows ) throw (uno::RuntimeException) 345 { 346 m_xComplexDescriptionAccess->setData(rDataInRows); 347 } 348 349 void SAL_CALL DatabaseDataProvider::setRowDescriptions( const uno::Sequence< rtl::OUString >& aRowDescriptions ) throw (uno::RuntimeException) 350 { 351 m_xComplexDescriptionAccess->setRowDescriptions(aRowDescriptions); 352 } 353 354 void SAL_CALL DatabaseDataProvider::setColumnDescriptions( const uno::Sequence< rtl::OUString >& aColumnDescriptions ) throw (uno::RuntimeException) 355 { 356 m_xComplexDescriptionAccess->setColumnDescriptions(aColumnDescriptions); 357 } 358 359 uno::Sequence< rtl::OUString > SAL_CALL DatabaseDataProvider::getRowDescriptions() throw (uno::RuntimeException) 360 { 361 return m_xComplexDescriptionAccess->getRowDescriptions(); 362 } 363 364 uno::Sequence< rtl::OUString > SAL_CALL DatabaseDataProvider::getColumnDescriptions() throw (uno::RuntimeException) 365 { 366 return m_xComplexDescriptionAccess->getColumnDescriptions(); 367 } 368 369 // ____ XChartData (base of XChartDataArray) ____ 370 void SAL_CALL DatabaseDataProvider::addChartDataChangeEventListener(const uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& x) throw (uno::RuntimeException) 371 { 372 m_xComplexDescriptionAccess->addChartDataChangeEventListener(x); 373 } 374 375 void SAL_CALL DatabaseDataProvider::removeChartDataChangeEventListener(const uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& x) throw (uno::RuntimeException) 376 { 377 m_xComplexDescriptionAccess->removeChartDataChangeEventListener(x); 378 } 379 380 double SAL_CALL DatabaseDataProvider::getNotANumber() throw (uno::RuntimeException) 381 { 382 return m_xComplexDescriptionAccess->getNotANumber(); 383 } 384 385 ::sal_Bool SAL_CALL DatabaseDataProvider::isNotANumber( double nNumber ) throw (uno::RuntimeException) 386 { 387 return m_xComplexDescriptionAccess->isNotANumber(nNumber); 388 } 389 390 // ----------------------------------------------------------------------------- 391 392 uno::Reference< sheet::XRangeSelection > SAL_CALL DatabaseDataProvider::getRangeSelection() throw (uno::RuntimeException) 393 { 394 // TODO: Exchange the default return implementation for "getRangeSelection" !!! 395 // Exchange the default return implementation. 396 // NOTE: Default initialized polymorphic structs can cause problems because of 397 // missing default initialization of primitive types of some C++ compilers or 398 // different Any initialization in Java and C++ polymorphic structs. 399 return uno::Reference< sheet::XRangeSelection >(); 400 } 401 // ----------------------------------------------------------------------------- 402 // chart2::data::XRangeXMLConversion: 403 ::rtl::OUString SAL_CALL DatabaseDataProvider::convertRangeToXML(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException) 404 { 405 osl::MutexGuard g(m_aMutex); 406 return m_xRangeConversion->convertRangeToXML(_sRangeRepresentation); 407 } 408 // ----------------------------------------------------------------------------- 409 410 ::rtl::OUString SAL_CALL DatabaseDataProvider::convertRangeFromXML(const ::rtl::OUString & _sXMLRange) throw (uno::RuntimeException, lang::IllegalArgumentException) 411 { 412 osl::MutexGuard g(m_aMutex); 413 return m_xRangeConversion->convertRangeFromXML(_sXMLRange); 414 } 415 // ----------------------------------------------------------------------------- 416 417 // com.sun.star.beans.XPropertySet: 418 uno::Reference< beans::XPropertySetInfo > SAL_CALL DatabaseDataProvider::getPropertySetInfo() throw (uno::RuntimeException) 419 { 420 return ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::getPropertySetInfo(); 421 } 422 // ----------------------------------------------------------------------------- 423 424 void SAL_CALL DatabaseDataProvider::setPropertyValue(const ::rtl::OUString & aPropertyName, const uno::Any & aValue) throw (uno::RuntimeException, beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException) 425 { 426 ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::setPropertyValue(aPropertyName, aValue); 427 } 428 // ----------------------------------------------------------------------------- 429 430 uno::Any SAL_CALL DatabaseDataProvider::getPropertyValue(const ::rtl::OUString & aPropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException) 431 { 432 return ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::getPropertyValue(aPropertyName); 433 } 434 // ----------------------------------------------------------------------------- 435 436 void SAL_CALL DatabaseDataProvider::addPropertyChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XPropertyChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException) 437 { 438 ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::addPropertyChangeListener(aPropertyName, xListener); 439 } 440 // ----------------------------------------------------------------------------- 441 442 void SAL_CALL DatabaseDataProvider::removePropertyChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XPropertyChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException) 443 { 444 ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::removePropertyChangeListener(aPropertyName, xListener); 445 } 446 // ----------------------------------------------------------------------------- 447 448 void SAL_CALL DatabaseDataProvider::addVetoableChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XVetoableChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException) 449 { 450 ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::addVetoableChangeListener(aPropertyName, xListener); 451 } 452 // ----------------------------------------------------------------------------- 453 454 void SAL_CALL DatabaseDataProvider::removeVetoableChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XVetoableChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException) 455 { 456 ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::removeVetoableChangeListener(aPropertyName, xListener); 457 } 458 // ----------------------------------------------------------------------------- 459 460 // chart2::data::XDatabaseDataProvider: 461 uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getMasterFields() throw (uno::RuntimeException) 462 { 463 osl::MutexGuard g(m_aMutex); 464 return m_MasterFields; 465 } 466 // ----------------------------------------------------------------------------- 467 468 void SAL_CALL DatabaseDataProvider::setMasterFields(const uno::Sequence< ::rtl::OUString > & the_value) throw (uno::RuntimeException) 469 { 470 impl_invalidateParameter_nothrow(); 471 set(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MasterFields")),the_value,m_MasterFields); 472 } 473 // ----------------------------------------------------------------------------- 474 475 uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getDetailFields() throw (uno::RuntimeException) 476 { 477 osl::MutexGuard g(m_aMutex); 478 return m_DetailFields; 479 } 480 // ----------------------------------------------------------------------------- 481 482 void SAL_CALL DatabaseDataProvider::setDetailFields(const uno::Sequence< ::rtl::OUString > & the_value) throw (uno::RuntimeException) 483 { 484 set(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DetailFields")),the_value,m_DetailFields); 485 } 486 // ----------------------------------------------------------------------------- 487 ::rtl::OUString SAL_CALL DatabaseDataProvider::getCommand() throw (uno::RuntimeException) 488 { 489 osl::MutexGuard g(m_aMutex); 490 return m_Command; 491 } 492 // ----------------------------------------------------------------------------- 493 494 void SAL_CALL DatabaseDataProvider::setCommand(const ::rtl::OUString & the_value) throw (uno::RuntimeException) 495 { 496 { 497 osl::MutexGuard g(m_aMutex); 498 impl_invalidateParameter_nothrow(); 499 m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND, uno::makeAny( the_value ) ); 500 } 501 set(PROPERTY_COMMAND,the_value,m_Command); 502 } 503 // ----------------------------------------------------------------------------- 504 505 ::sal_Int32 SAL_CALL DatabaseDataProvider::getCommandType() throw (uno::RuntimeException) 506 { 507 osl::MutexGuard g(m_aMutex); 508 return m_CommandType; 509 } 510 // ----------------------------------------------------------------------------- 511 512 void SAL_CALL DatabaseDataProvider::setCommandType(::sal_Int32 the_value) throw (uno::RuntimeException) 513 { 514 { 515 osl::MutexGuard g(m_aMutex); 516 m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND_TYPE, uno::makeAny( the_value ) ); 517 } 518 set(PROPERTY_COMMAND_TYPE,the_value,m_CommandType); 519 } 520 // ----------------------------------------------------------------------------- 521 522 ::rtl::OUString SAL_CALL DatabaseDataProvider::getFilter() throw (uno::RuntimeException) 523 { 524 osl::MutexGuard g(m_aMutex); 525 return m_aFilterManager.getFilterComponent( dbtools::FilterManager::fcPublicFilter ); 526 } 527 // ----------------------------------------------------------------------------- 528 529 void SAL_CALL DatabaseDataProvider::setFilter(const ::rtl::OUString & the_value) throw (uno::RuntimeException) 530 { 531 { 532 osl::MutexGuard g(m_aMutex); 533 m_aFilterManager.setFilterComponent( dbtools::FilterManager::fcPublicFilter, the_value ); 534 } 535 set(PROPERTY_FILTER,the_value,m_Filter); 536 } 537 // ----------------------------------------------------------------------------- 538 ::sal_Bool SAL_CALL DatabaseDataProvider::getApplyFilter() throw (RuntimeException) 539 { 540 osl::MutexGuard g(m_aMutex); 541 return m_ApplyFilter; 542 } 543 // ----------------------------------------------------------------------------- 544 void SAL_CALL DatabaseDataProvider::setApplyFilter( ::sal_Bool the_value ) throw (RuntimeException) 545 { 546 { 547 osl::MutexGuard g(m_aMutex); 548 m_xAggregateSet->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( the_value ) ); 549 } 550 set(PROPERTY_APPLYFILTER,the_value,m_ApplyFilter); 551 } 552 // ----------------------------------------------------------------------------- 553 ::rtl::OUString SAL_CALL DatabaseDataProvider::getHavingClause() throw (uno::RuntimeException) 554 { 555 osl::MutexGuard g(m_aMutex); 556 return m_HavingClause; 557 } 558 // ----------------------------------------------------------------------------- 559 void SAL_CALL DatabaseDataProvider::setHavingClause( const ::rtl::OUString& the_value ) throw (beans::UnknownPropertyException, uno::RuntimeException) 560 { 561 { 562 osl::MutexGuard g(m_aMutex); 563 m_xAggregateSet->setPropertyValue( PROPERTY_HAVING_CLAUSE, uno::makeAny( the_value ) ); 564 } 565 set(PROPERTY_HAVING_CLAUSE,the_value,m_HavingClause); 566 } 567 // ----------------------------------------------------------------------------- 568 ::rtl::OUString SAL_CALL DatabaseDataProvider::getGroupBy() throw (uno::RuntimeException) 569 { 570 osl::MutexGuard g(m_aMutex); 571 return m_GroupBy; 572 } 573 // ----------------------------------------------------------------------------- 574 void SAL_CALL DatabaseDataProvider::setGroupBy( const ::rtl::OUString& the_value ) throw (beans::UnknownPropertyException, uno::RuntimeException) 575 { 576 { 577 osl::MutexGuard g(m_aMutex); 578 m_xAggregateSet->setPropertyValue( PROPERTY_GROUP_BY, uno::makeAny( the_value ) ); 579 } 580 set(PROPERTY_GROUP_BY,the_value,m_GroupBy); 581 } 582 // ----------------------------------------------------------------------------- 583 ::rtl::OUString SAL_CALL DatabaseDataProvider::getOrder() throw (uno::RuntimeException) 584 { 585 osl::MutexGuard g(m_aMutex); 586 return m_Order; 587 } 588 // ----------------------------------------------------------------------------- 589 void SAL_CALL DatabaseDataProvider::setOrder( const ::rtl::OUString& the_value ) throw (uno::RuntimeException) 590 { 591 { 592 osl::MutexGuard g(m_aMutex); 593 m_xAggregateSet->setPropertyValue( PROPERTY_ORDER, uno::makeAny( the_value ) ); 594 } 595 set(PROPERTY_ORDER,the_value,m_Order); 596 } 597 // ----------------------------------------------------------------------------- 598 ::sal_Bool SAL_CALL DatabaseDataProvider::getEscapeProcessing() throw (uno::RuntimeException) 599 { 600 osl::MutexGuard g(m_aMutex); 601 return m_EscapeProcessing; 602 } 603 // ----------------------------------------------------------------------------- 604 605 void SAL_CALL DatabaseDataProvider::setEscapeProcessing(::sal_Bool the_value) throw (uno::RuntimeException) 606 { 607 set(PROPERTY_ESCAPE_PROCESSING,the_value,m_EscapeProcessing); 608 } 609 // ----------------------------------------------------------------------------- 610 ::sal_Int32 SAL_CALL DatabaseDataProvider::getRowLimit() throw (uno::RuntimeException) 611 { 612 osl::MutexGuard g(m_aMutex); 613 return m_RowLimit; 614 } 615 // ----------------------------------------------------------------------------- 616 617 void SAL_CALL DatabaseDataProvider::setRowLimit(::sal_Int32 the_value) throw (uno::RuntimeException) 618 { 619 set(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RowLimit")),the_value,m_RowLimit); 620 } 621 // ----------------------------------------------------------------------------- 622 uno::Reference< sdbc::XConnection > SAL_CALL DatabaseDataProvider::getActiveConnection() throw (uno::RuntimeException) 623 { 624 osl::MutexGuard g(m_aMutex); 625 return m_xActiveConnection; 626 } 627 // ----------------------------------------------------------------------------- 628 629 void SAL_CALL DatabaseDataProvider::setActiveConnection(const uno::Reference< sdbc::XConnection > & the_value) throw (uno::RuntimeException, lang::IllegalArgumentException) 630 { 631 if ( !the_value.is() ) 632 throw lang::IllegalArgumentException(); 633 set(PROPERTY_ACTIVE_CONNECTION,the_value,m_xActiveConnection); 634 } 635 // ----------------------------------------------------------------------------- 636 ::rtl::OUString SAL_CALL DatabaseDataProvider::getDataSourceName() throw (uno::RuntimeException) 637 { 638 osl::MutexGuard g(m_aMutex); 639 return m_DataSourceName; 640 } 641 // ----------------------------------------------------------------------------- 642 643 void SAL_CALL DatabaseDataProvider::setDataSourceName(const ::rtl::OUString& the_value) throw (uno::RuntimeException) 644 { 645 set(PROPERTY_DATASOURCENAME,the_value,m_DataSourceName); 646 } 647 // ----------------------------------------------------------------------------- 648 void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies) 649 { 650 if ( impl_fillParameters_nothrow(_rClearForNotifies) ) 651 m_xRowSet->execute(); 652 } 653 654 // ----------------------------------------------------------------------------- 655 namespace 656 { 657 struct ColumnDescription 658 { 659 ::rtl::OUString sName; 660 sal_Int32 nResultSetPosition; 661 sal_Int32 nDataType; 662 663 ColumnDescription() 664 :sName() 665 ,nResultSetPosition( 0 ) 666 ,nDataType( sdbc::DataType::VARCHAR ) 667 { 668 } 669 explicit ColumnDescription( const ::rtl::OUString& i_rName ) 670 :sName( i_rName ) 671 ,nResultSetPosition( 0 ) 672 ,nDataType( sdbc::DataType::VARCHAR ) 673 { 674 } 675 }; 676 677 struct CreateColumnDescription : public ::std::unary_function< ::rtl::OUString, ColumnDescription > 678 { 679 ColumnDescription operator()( const ::rtl::OUString& i_rName ) 680 { 681 return ColumnDescription( i_rName ); 682 } 683 }; 684 685 struct SelectColumnName : public ::std::unary_function< ColumnDescription, ::rtl::OUString > 686 { 687 const ::rtl::OUString& operator()( const ColumnDescription& i_rColumn ) 688 { 689 return i_rColumn.sName; 690 } 691 }; 692 } 693 694 // ----------------------------------------------------------------------------- 695 void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< ::rtl::OUString >& i_aColumnNames) 696 { 697 // clear the data before fill the new one 698 uno::Reference< sdbcx::XColumnsSupplier > xColSup(m_xRowSet,uno::UNO_QUERY_THROW); 699 uno::Reference< container::XNameAccess > xColumns( xColSup->getColumns(), uno::UNO_SET_THROW ); 700 const uno::Sequence< ::rtl::OUString > aRowSetColumnNames( xColumns->getElementNames() ); 701 702 typedef ::std::vector< ColumnDescription > ColumnDescriptions; 703 ColumnDescriptions aColumns; 704 bool bFirstColumnIsCategory = _bHasCategories; 705 if ( i_aColumnNames.getLength() ) 706 { 707 // some normalizations ... 708 uno::Sequence< ::rtl::OUString > aImposedColumnNames( i_aColumnNames ); 709 710 // strangely, there exist documents where the ColumnDescriptions end with a number of empty strings. /me 711 // thinks they're generated when you have a chart based on a result set with n columns, but remove some 712 // of those columns from the chart - it looks like a bug in the report XML export to me. 713 // So, get rid of the "trailing" empty columns 714 sal_Int32 nLastNonEmptyColName = aImposedColumnNames.getLength() - 1; 715 for ( ; nLastNonEmptyColName >= 0; --nLastNonEmptyColName ) 716 { 717 if ( aImposedColumnNames[ nLastNonEmptyColName ].getLength() != 0 ) 718 break; 719 } 720 aImposedColumnNames.realloc( nLastNonEmptyColName + 1 ); 721 722 // second, for X-Y-charts the ColumnDescriptions exported by chart miss the name of the first (non-category) 723 // column. This, this results in a ColumnDescriptions array like <"", "col2", "col3">, where you'd expect 724 // <"col1", "col2", "col3">. 725 // Fix this with some heuristics: 726 if ( ( aImposedColumnNames.getLength() > 0 ) && ( aImposedColumnNames[0].getLength() == 0 ) ) 727 { 728 const sal_Int32 nAssumedRowSetColumnIndex = _bHasCategories ? 1 : 0; 729 if ( nAssumedRowSetColumnIndex < aRowSetColumnNames.getLength() ) 730 aImposedColumnNames[0] = aRowSetColumnNames[ nAssumedRowSetColumnIndex ]; 731 } 732 733 const sal_Int32 nCount = aImposedColumnNames.getLength(); 734 for ( sal_Int32 i = 0 ; i < nCount; ++i ) 735 { 736 const ::rtl::OUString sColumnName( aImposedColumnNames[i] ); 737 if ( !xColumns->hasByName( sColumnName ) ) 738 continue; 739 740 if ( _bHasCategories && aColumns.empty() ) 741 { 742 if ( aRowSetColumnNames.getLength() ) 743 aColumns.push_back( ColumnDescription( aRowSetColumnNames[0] ) ); 744 else 745 aColumns.push_back( ColumnDescription( sColumnName ) ); 746 bFirstColumnIsCategory = true; 747 } 748 aColumns.push_back( ColumnDescription( sColumnName ) ); 749 } 750 } 751 if ( aColumns.empty() ) 752 { 753 aColumns.resize( aRowSetColumnNames.getLength() ); 754 ::std::transform( 755 aRowSetColumnNames.getConstArray(), 756 aRowSetColumnNames.getConstArray() + aRowSetColumnNames.getLength(), 757 aColumns.begin(), 758 CreateColumnDescription() 759 ); 760 } 761 762 // fill the data 763 uno::Reference< sdbc::XResultSet> xRes( m_xRowSet, uno::UNO_QUERY_THROW ); 764 uno::Reference< sdbc::XRow> xRow( m_xRowSet,uno::UNO_QUERY_THROW ); 765 uno::Reference< sdbc::XResultSetMetaDataSupplier > xSuppMeta( m_xRowSet,uno::UNO_QUERY_THROW ); 766 uno::Reference< sdbc::XResultSetMetaData > xResultSetMetaData( xSuppMeta->getMetaData(), uno::UNO_SET_THROW ); 767 uno::Reference< sdbc::XColumnLocate > xColumnLocate( m_xRowSet, uno::UNO_QUERY_THROW ); 768 769 for ( ColumnDescriptions::iterator col = aColumns.begin(); 770 col != aColumns.end(); 771 ++col 772 ) 773 { 774 col->nResultSetPosition = xColumnLocate->findColumn( col->sName ); 775 776 const uno::Reference< beans::XPropertySet > xColumn( xColumns->getByName( col->sName ), uno::UNO_QUERY_THROW ); 777 const uno::Any aNumberFormat( xColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) ); 778 OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= col->nDataType ); 779 780 const sal_Int32 columnIndex = col - aColumns.begin(); 781 const ::rtl::OUString sRangeName = ::rtl::OUString::valueOf( columnIndex ); 782 m_aNumberFormats.insert( ::std::map< ::rtl::OUString, uno::Any >::value_type( sRangeName, aNumberFormat ) ); 783 } 784 785 ::std::vector< ::rtl::OUString > aRowLabels; 786 ::std::vector< ::std::vector< double > > aDataValues; 787 sal_Int32 nRowCount = 0; 788 ::connectivity::ORowSetValue aValue; 789 while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) 790 { 791 ++nRowCount; 792 793 aValue.fill( aColumns[0].nResultSetPosition, aColumns[0].nDataType, xRow ); 794 aRowLabels.push_back( aValue.getString() ); 795 796 ::std::vector< double > aRow; 797 for ( ColumnDescriptions::const_iterator col = aColumns.begin(); 798 col != aColumns.end(); 799 ++col 800 ) 801 { 802 if ( bFirstColumnIsCategory && ( col == aColumns.begin() ) ) 803 continue; 804 805 aValue.fill( col->nResultSetPosition, col->nDataType, xRow ); 806 if ( aValue.isNull() ) 807 { 808 double nValue; 809 ::rtl::math::setNan( &nValue ); 810 aRow.push_back( nValue ); 811 } 812 else 813 aRow.push_back( aValue.getDouble() ); 814 } 815 816 aDataValues.push_back( aRow ); 817 } 818 819 // insert default data when no rows exist 820 if ( !nRowCount ) 821 { 822 nRowCount = 3; 823 const double fDefaultData[ ] = 824 { 9.10, 3.20, 4.54, 825 2.40, 8.80, 9.65, 826 3.10, 1.50, 3.70, 827 4.30, 9.02, 6.20 }; 828 for(sal_Int32 h = 0,k = 0; h < nRowCount; ++h,++k ) 829 { 830 aRowLabels.push_back(::rtl::OUString::valueOf(h+1)); 831 ::std::vector< double > aRow; 832 const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); 833 for (size_t j = 0; j < (aColumns.size()-1); ++j,++k) 834 { 835 if ( k >= nSize ) 836 k = 0; 837 aRow.push_back(fDefaultData[k]); 838 } // for (sal_Int32 j = 0,k = 0; j < (aColumns.size()-1); ++j,++k) 839 aDataValues.push_back(aRow); 840 } 841 } // if ( !nRowCount ) 842 843 uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY); 844 xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size())); 845 846 const size_t nOffset = bFirstColumnIsCategory ? 1 : 0; 847 uno::Sequence< ::rtl::OUString > aColumnDescriptions( aColumns.size() - nOffset ); 848 ::std::transform( 849 aColumns.begin() + nOffset, 850 aColumns.end(), 851 aColumnDescriptions.getArray(), 852 SelectColumnName() 853 ); 854 xData->setColumnDescriptions( aColumnDescriptions ); 855 856 uno::Sequence< uno::Sequence< double > > aData(aDataValues.size()); 857 uno::Sequence< double >* pDataIter = aData.getArray(); 858 uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength(); 859 for(sal_Int32 i= 0;pDataIter != pDataEnd; ++pDataIter,++i ) 860 { 861 if ( !aDataValues[i].empty() ) 862 *pDataIter = uno::Sequence< double >(&(*(aDataValues[i]).begin()),(aDataValues[i]).size()); 863 } 864 xData->setData(aData); 865 } 866 // ----------------------------------------------------------------------------- 867 void DatabaseDataProvider::impl_fillRowSet_throw() 868 { 869 m_xAggregateSet->setPropertyValue( PROPERTY_FILTER, uno::makeAny( getFilter() ) ); 870 uno::Reference< sdbc::XParameters> xParam(m_xRowSet,uno::UNO_QUERY_THROW); 871 xParam->clearParameters( ); 872 } 873 // ----------------------------------------------------------------------------- 874 bool DatabaseDataProvider::impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies) 875 { 876 // do we have to fill the parameters again? 877 if ( !m_aParameterManager.isUpToDate() ) 878 m_aParameterManager.updateParameterInfo( m_aFilterManager ); 879 880 if ( m_aParameterManager.isUpToDate() ) 881 return m_aParameterManager.fillParameterValues( m_xHandler, _rClearForNotifies ); 882 883 return true; 884 } 885 // com::sun::star::sdbc::XParameters 886 //------------------------------------------------------------------------------ 887 void SAL_CALL DatabaseDataProvider::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( SQLException, RuntimeException ) 888 { 889 m_aParameterManager.setNull(parameterIndex, sqlType); 890 } 891 892 //------------------------------------------------------------------------------ 893 void SAL_CALL DatabaseDataProvider::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( SQLException, RuntimeException ) 894 { 895 m_aParameterManager.setObjectNull(parameterIndex, sqlType, typeName); 896 } 897 898 //------------------------------------------------------------------------------ 899 void SAL_CALL DatabaseDataProvider::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( SQLException, RuntimeException ) 900 { 901 m_aParameterManager.setBoolean(parameterIndex, x); 902 } 903 904 //------------------------------------------------------------------------------ 905 void SAL_CALL DatabaseDataProvider::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( SQLException, RuntimeException ) 906 { 907 m_aParameterManager.setByte(parameterIndex, x); 908 } 909 910 //------------------------------------------------------------------------------ 911 void SAL_CALL DatabaseDataProvider::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( SQLException, RuntimeException ) 912 { 913 m_aParameterManager.setShort(parameterIndex, x); 914 } 915 916 //------------------------------------------------------------------------------ 917 void SAL_CALL DatabaseDataProvider::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( SQLException, RuntimeException ) 918 { 919 m_aParameterManager.setInt(parameterIndex, x); 920 } 921 922 //------------------------------------------------------------------------------ 923 void SAL_CALL DatabaseDataProvider::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( SQLException, RuntimeException ) 924 { 925 m_aParameterManager.setLong(parameterIndex, x); 926 } 927 928 //------------------------------------------------------------------------------ 929 void SAL_CALL DatabaseDataProvider::setFloat(sal_Int32 parameterIndex, float x) throw( SQLException, RuntimeException ) 930 { 931 m_aParameterManager.setFloat(parameterIndex, x); 932 } 933 934 //------------------------------------------------------------------------------ 935 void SAL_CALL DatabaseDataProvider::setDouble(sal_Int32 parameterIndex, double x) throw( SQLException, RuntimeException ) 936 { 937 m_aParameterManager.setDouble(parameterIndex, x); 938 } 939 940 //------------------------------------------------------------------------------ 941 void SAL_CALL DatabaseDataProvider::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( SQLException, RuntimeException ) 942 { 943 m_aParameterManager.setString(parameterIndex, x); 944 } 945 946 //------------------------------------------------------------------------------ 947 void SAL_CALL DatabaseDataProvider::setBytes(sal_Int32 parameterIndex, const uno::Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException ) 948 { 949 m_aParameterManager.setBytes(parameterIndex, x); 950 } 951 952 //------------------------------------------------------------------------------ 953 void SAL_CALL DatabaseDataProvider::setDate(sal_Int32 parameterIndex, const util::Date& x) throw( SQLException, RuntimeException ) 954 { 955 m_aParameterManager.setDate(parameterIndex, x); 956 } 957 958 //------------------------------------------------------------------------------ 959 void SAL_CALL DatabaseDataProvider::setTime(sal_Int32 parameterIndex, const util::Time& x) throw( SQLException, RuntimeException ) 960 { 961 m_aParameterManager.setTime(parameterIndex, x); 962 } 963 964 //------------------------------------------------------------------------------ 965 void SAL_CALL DatabaseDataProvider::setTimestamp(sal_Int32 parameterIndex, const util::DateTime& x) throw( SQLException, RuntimeException ) 966 { 967 m_aParameterManager.setTimestamp(parameterIndex, x); 968 } 969 970 //------------------------------------------------------------------------------ 971 void SAL_CALL DatabaseDataProvider::setBinaryStream(sal_Int32 parameterIndex, const uno::Reference<io::XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException ) 972 { 973 m_aParameterManager.setBinaryStream(parameterIndex, x, length); 974 } 975 976 //------------------------------------------------------------------------------ 977 void SAL_CALL DatabaseDataProvider::setCharacterStream(sal_Int32 parameterIndex, const uno::Reference<io::XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException ) 978 { 979 m_aParameterManager.setCharacterStream(parameterIndex, x, length); 980 } 981 982 //------------------------------------------------------------------------------ 983 void SAL_CALL DatabaseDataProvider::setObjectWithInfo(sal_Int32 parameterIndex, const uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( SQLException, RuntimeException ) 984 { 985 m_aParameterManager.setObjectWithInfo(parameterIndex, x, targetSqlType, scale); 986 } 987 988 //------------------------------------------------------------------------------ 989 void SAL_CALL DatabaseDataProvider::setObject(sal_Int32 parameterIndex, const uno::Any& x) throw( SQLException, RuntimeException ) 990 { 991 m_aParameterManager.setObject(parameterIndex, x); 992 } 993 994 //------------------------------------------------------------------------------ 995 void SAL_CALL DatabaseDataProvider::setRef(sal_Int32 parameterIndex, const uno::Reference<sdbc::XRef>& x) throw( SQLException, RuntimeException ) 996 { 997 m_aParameterManager.setRef(parameterIndex, x); 998 } 999 1000 //------------------------------------------------------------------------------ 1001 void SAL_CALL DatabaseDataProvider::setBlob(sal_Int32 parameterIndex, const uno::Reference<sdbc::XBlob>& x) throw( SQLException, RuntimeException ) 1002 { 1003 m_aParameterManager.setBlob(parameterIndex, x); 1004 } 1005 1006 //------------------------------------------------------------------------------ 1007 void SAL_CALL DatabaseDataProvider::setClob(sal_Int32 parameterIndex, const uno::Reference<sdbc::XClob>& x) throw( SQLException, RuntimeException ) 1008 { 1009 m_aParameterManager.setClob(parameterIndex, x); 1010 } 1011 1012 //------------------------------------------------------------------------------ 1013 void SAL_CALL DatabaseDataProvider::setArray(sal_Int32 parameterIndex, const Reference<sdbc::XArray>& x) throw( SQLException, RuntimeException ) 1014 { 1015 m_aParameterManager.setArray(parameterIndex, x); 1016 } 1017 1018 //------------------------------------------------------------------------------ 1019 void SAL_CALL DatabaseDataProvider::clearParameters() throw( SQLException, RuntimeException ) 1020 { 1021 m_aParameterManager.clearParameters(); 1022 } 1023 //============================================================================== 1024 // com::sun::star::sdbc::XRowSet 1025 //------------------------------------------------------------------------------ 1026 void SAL_CALL DatabaseDataProvider::execute() throw( SQLException, RuntimeException ) 1027 { 1028 uno::Sequence< beans::PropertyValue > aEmpty; 1029 createDataSource(aEmpty); 1030 } 1031 //------------------------------------------------------------------------------ 1032 void SAL_CALL DatabaseDataProvider::addRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException ) 1033 { 1034 if (m_xRowSet.is()) 1035 m_xRowSet->addRowSetListener(_rListener); 1036 } 1037 1038 //------------------------------------------------------------------------------ 1039 void SAL_CALL DatabaseDataProvider::removeRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException ) 1040 { 1041 if (m_xRowSet.is()) 1042 m_xRowSet->removeRowSetListener(_rListener); 1043 } 1044 //============================================================================== 1045 // com::sun::star::sdbc::XResultSet 1046 //------------------------------------------------------------------------------ 1047 sal_Bool SAL_CALL DatabaseDataProvider::next() throw( SQLException, RuntimeException ) 1048 { 1049 return m_xRowSet->next(); 1050 } 1051 1052 //------------------------------------------------------------------------------ 1053 sal_Bool SAL_CALL DatabaseDataProvider::isBeforeFirst() throw( SQLException, RuntimeException ) 1054 { 1055 return m_xRowSet->isBeforeFirst(); 1056 } 1057 1058 //------------------------------------------------------------------------------ 1059 sal_Bool SAL_CALL DatabaseDataProvider::isAfterLast() throw( SQLException, RuntimeException ) 1060 { 1061 return m_xRowSet->isAfterLast(); 1062 } 1063 1064 //------------------------------------------------------------------------------ 1065 sal_Bool SAL_CALL DatabaseDataProvider::isFirst() throw( SQLException, RuntimeException ) 1066 { 1067 return m_xRowSet->isFirst(); 1068 } 1069 1070 //------------------------------------------------------------------------------ 1071 sal_Bool SAL_CALL DatabaseDataProvider::isLast() throw( SQLException, RuntimeException ) 1072 { 1073 return m_xRowSet->isLast(); 1074 } 1075 1076 //------------------------------------------------------------------------------ 1077 void SAL_CALL DatabaseDataProvider::beforeFirst() throw( SQLException, RuntimeException ) 1078 { 1079 m_xRowSet->beforeFirst(); 1080 } 1081 1082 //------------------------------------------------------------------------------ 1083 void SAL_CALL DatabaseDataProvider::afterLast() throw( SQLException, RuntimeException ) 1084 { 1085 m_xRowSet->afterLast(); 1086 } 1087 1088 //------------------------------------------------------------------------------ 1089 sal_Bool SAL_CALL DatabaseDataProvider::first() throw( SQLException, RuntimeException ) 1090 { 1091 return m_xRowSet->first(); 1092 } 1093 1094 //------------------------------------------------------------------------------ 1095 sal_Bool SAL_CALL DatabaseDataProvider::last() throw( SQLException, RuntimeException ) 1096 { 1097 return m_xRowSet->last(); 1098 } 1099 1100 //------------------------------------------------------------------------------ 1101 sal_Int32 SAL_CALL DatabaseDataProvider::getRow() throw( SQLException, RuntimeException ) 1102 { 1103 return m_xRowSet->getRow(); 1104 } 1105 1106 //------------------------------------------------------------------------------ 1107 sal_Bool SAL_CALL DatabaseDataProvider::absolute(sal_Int32 row) throw( SQLException, RuntimeException ) 1108 { 1109 return m_xRowSet->absolute(row); 1110 } 1111 1112 //------------------------------------------------------------------------------ 1113 sal_Bool SAL_CALL DatabaseDataProvider::relative(sal_Int32 rows) throw( SQLException, RuntimeException ) 1114 { 1115 return m_xRowSet->relative(rows); 1116 } 1117 1118 //------------------------------------------------------------------------------ 1119 sal_Bool SAL_CALL DatabaseDataProvider::previous() throw( SQLException, RuntimeException ) 1120 { 1121 return m_xRowSet->previous(); 1122 } 1123 1124 //------------------------------------------------------------------------------ 1125 void SAL_CALL DatabaseDataProvider::refreshRow() throw( SQLException, RuntimeException ) 1126 { 1127 m_xRowSet->refreshRow(); 1128 } 1129 1130 //------------------------------------------------------------------------------ 1131 sal_Bool SAL_CALL DatabaseDataProvider::rowUpdated() throw( SQLException, RuntimeException ) 1132 { 1133 return m_xRowSet->rowUpdated(); 1134 } 1135 1136 //------------------------------------------------------------------------------ 1137 sal_Bool SAL_CALL DatabaseDataProvider::rowInserted() throw( SQLException, RuntimeException ) 1138 { 1139 return m_xRowSet->rowInserted(); 1140 } 1141 1142 //------------------------------------------------------------------------------ 1143 sal_Bool SAL_CALL DatabaseDataProvider::rowDeleted() throw( SQLException, RuntimeException ) 1144 { 1145 return m_xRowSet->rowDeleted(); 1146 } 1147 1148 //------------------------------------------------------------------------------ 1149 uno::Reference< uno::XInterface > SAL_CALL DatabaseDataProvider::getStatement() throw( SQLException, RuntimeException ) 1150 { 1151 return m_xRowSet->getStatement(); 1152 } 1153 // ----------------------------------------------------------------------------- 1154 uno::Reference< uno::XInterface > SAL_CALL DatabaseDataProvider::getParent( ) throw (uno::RuntimeException) 1155 { 1156 return m_xParent; 1157 } 1158 // ----------------------------------------------------------------------------- 1159 void SAL_CALL DatabaseDataProvider::setParent( const uno::Reference< uno::XInterface >& _xParent ) throw (lang::NoSupportException, uno::RuntimeException) 1160 { 1161 osl::MutexGuard g(m_aMutex); 1162 m_xParent = _xParent; 1163 } 1164 // ----------------------------------------------------------------------------- 1165 void DatabaseDataProvider::impl_invalidateParameter_nothrow() 1166 { 1167 osl::MutexGuard g(m_aMutex); 1168 m_aParameterManager.clearAllParameterInformation(); 1169 } 1170 // ----------------------------------------------------------------------------- 1171 } // namespace dbaccess 1172