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