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