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