LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/misc - DatabaseDataProvider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 551 0.0 %
Date: 2012-12-27 Functions: 0 124 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10