LibreOffice Module connectivity (master) 1
parameters.cxx
Go to the documentation of this file.
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
21
22#include <com/sun/star/form/DatabaseParameterEvent.hpp>
23#include <com/sun/star/form/XDatabaseParameterListener.hpp>
24#include <com/sun/star/sdbc/XParameters.hpp>
25#include <com/sun/star/container/XChild.hpp>
26#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
27#include <com/sun/star/sdb/XParametersSupplier.hpp>
28#include <com/sun/star/sdb/ParametersRequest.hpp>
29#include <com/sun/star/sdbc/SQLException.hpp>
30#include <com/sun/star/task/XInteractionHandler.hpp>
31
34#include <TConnection.hxx>
35
37
38#include <ParameterCont.hxx>
39#include <o3tl/safeint.hxx>
40#include <rtl/ustrbuf.hxx>
41#include <sal/log.hxx>
42
43namespace dbtools
44{
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::sdb;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::sdbcx;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::task;
52 using namespace ::com::sun::star::form;
53 using namespace ::com::sun::star::container;
54
55 using namespace ::comphelper;
56 using namespace ::connectivity;
57
58 ParameterManager::ParameterManager( ::osl::Mutex& _rMutex, const Reference< XComponentContext >& _rxContext )
59 :m_rMutex ( _rMutex )
60 ,m_aParameterListeners( _rMutex )
61 ,m_xContext ( _rxContext )
62 ,m_nInnerCount ( 0 )
63 ,m_bUpToDate ( false )
64 {
65 OSL_ENSURE( m_xContext.is(), "ParameterManager::ParameterManager: no service factory!" );
66 }
67
68
69 void ParameterManager::initialize( const Reference< XPropertySet >& _rxComponent, const Reference< XAggregation >& _rxComponentAggregate )
70 {
71 OSL_ENSURE( !m_xComponent.get().is(), "ParameterManager::initialize: already initialized!" );
72
73 m_xComponent = _rxComponent;
74 m_xAggregatedRowSet = _rxComponentAggregate;
75 if ( m_xAggregatedRowSet.is() )
76 m_xAggregatedRowSet->queryAggregation( cppu::UnoType<decltype(m_xInnerParamUpdate)>::get() ) >>= m_xInnerParamUpdate;
77 OSL_ENSURE( m_xComponent.get().is() && m_xInnerParamUpdate.is(), "ParameterManager::initialize: invalid arguments!" );
78 if ( !m_xComponent.get().is() || !m_xInnerParamUpdate.is() )
79 return;
80 }
81
82
83 void ParameterManager::dispose( )
84 {
85 clearAllParameterInformation();
86
87 m_xComposer.clear();
88 m_xParentComposer.clear();
89 //m_xComponent.clear();
90 m_xInnerParamUpdate.clear();
91 m_xAggregatedRowSet.clear();
92 }
93
94
95 void ParameterManager::clearAllParameterInformation()
96 {
97 m_xInnerParamColumns.clear();
98 if ( m_pOuterParameters.is() )
99 m_pOuterParameters->dispose();
100 m_pOuterParameters = nullptr;
101 m_nInnerCount = 0;
102 ParameterInformation().swap(m_aParameterInformation);
103 m_aMasterFields.clear();
104 m_aDetailFields.clear();
105 m_sIdentifierQuoteString.clear();
106 m_sSpecialCharacters.clear();
107 m_xConnectionMetadata.clear();
108 std::vector< bool >().swap(m_aParametersVisited);
109 m_bUpToDate = false;
110 }
111
112
113 void ParameterManager::setAllParametersNull()
114 {
115 OSL_PRECOND( isAlive(), "ParameterManager::setAllParametersNull: not initialized, or already disposed!" );
116 if ( !isAlive() )
117 return;
118
119 for ( sal_Int32 i = 1; i <= m_nInnerCount; ++i )
120 m_xInnerParamUpdate->setNull( i, DataType::VARCHAR );
121 }
122
123
124 bool ParameterManager::initializeComposerByComponent( const Reference< XPropertySet >& _rxComponent )
125 {
126 OSL_PRECOND( _rxComponent.is(), "ParameterManager::initializeComposerByComponent: invalid !" );
127
128 m_xComposer.clear();
129 m_xInnerParamColumns.clear();
130 m_nInnerCount = 0;
131
132 // create and fill a composer
133 try
134 {
135 // get a query composer for the 's settings
136 m_xComposer.reset( getCurrentSettingsComposer( _rxComponent, m_xContext, nullptr ), SharedQueryComposer::TakeOwnership );
137
138 // see if the composer found parameters
139 Reference< XParametersSupplier > xParamSupp( m_xComposer, UNO_QUERY );
140 if ( xParamSupp.is() )
141 m_xInnerParamColumns = xParamSupp->getParameters();
142
143 if ( m_xInnerParamColumns.is() )
144 m_nInnerCount = m_xInnerParamColumns->getCount();
145 }
146 catch( const SQLException& )
147 {
148 }
149
150 return m_xInnerParamColumns.is();
151 }
152
153
154 void ParameterManager::collectInnerParameters( bool _bSecondRun )
155 {
156 OSL_PRECOND( m_xInnerParamColumns.is(), "ParameterManager::collectInnerParameters: missing some internal data!" );
157 if ( !m_xInnerParamColumns.is() )
158 return;
159
160 // strip previous index information
161 if ( _bSecondRun )
162 {
163 for (auto & paramInfo : m_aParameterInformation)
164 {
165 paramInfo.second.aInnerIndexes.clear();
166 }
167 }
168
169 // we need to map the parameter names (which is all we get from the 's
170 // MasterFields property) to indices, which are needed by the XParameters
171 // interface of the row set)
172 Reference<XPropertySet> xParam;
173 for ( sal_Int32 i = 0; i < m_nInnerCount; ++i )
174 {
175 try
176 {
177 xParam.clear();
178 m_xInnerParamColumns->getByIndex( i ) >>= xParam;
179
180 OUString sName;
181 xParam->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME) ) >>= sName;
182
183 // only append additional parameters when they are not already in the list
184 ParameterInformation::iterator aExistentPos = m_aParameterInformation.find( sName );
185 OSL_ENSURE( !_bSecondRun || ( aExistentPos != m_aParameterInformation.end() ),
186 "ParameterManager::collectInnerParameters: the parameter information should already exist in the second run!" );
187
188 if ( aExistentPos == m_aParameterInformation.end() )
189 {
190 aExistentPos = m_aParameterInformation.emplace(
191 sName, xParam ).first;
192 }
193 else
194 aExistentPos->second.xComposerColumn = xParam;
195
196 aExistentPos->second.aInnerIndexes.push_back( i );
197 }
198 catch( const Exception& )
199 {
200 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::collectInnerParameters" );
201 }
202 }
203 }
204
205
206 OUString ParameterManager::createFilterConditionFromColumnLink(
207 const OUString &_rMasterColumn, const Reference < XPropertySet > &xDetailField, OUString &o_rNewParamName )
208 {
209 OUString sFilter;
210 // format is:
211 // <detail_column> = :<new_param_name>
212 {
213 OUString tblName;
214 xDetailField->getPropertyValue("TableName") >>= tblName;
215 if (!tblName.isEmpty())
216 sFilter = ::dbtools::quoteTableName( m_xConnectionMetadata, tblName, ::dbtools::EComposeRule::InDataManipulation ) + ".";
217 }
218 {
219 OUString colName;
220 xDetailField->getPropertyValue("RealName") >>= colName;
221 bool isFunction(false);
222 xDetailField->getPropertyValue("Function") >>= isFunction;
223 if (isFunction)
224 sFilter += colName;
225 else
226 sFilter += quoteName( m_sIdentifierQuoteString, colName );
227 }
228
229 // generate a parameter name which is not already used
230 o_rNewParamName = "link_from_";
231 o_rNewParamName += convertName2SQLName( _rMasterColumn, m_sSpecialCharacters );
232 while ( m_aParameterInformation.find( o_rNewParamName ) != m_aParameterInformation.end() )
233 {
234 o_rNewParamName += "_";
235 }
236
237 return sFilter + " =:" + o_rNewParamName;
238 }
239
240
241 void ParameterManager::classifyLinks( const Reference< XNameAccess >& _rxParentColumns,
242 const Reference< XNameAccess >& _rxColumns,
243 std::vector< OUString >& _out_rAdditionalFilterComponents,
244 std::vector< OUString >& _out_rAdditionalHavingComponents )
245 {
246 OSL_PRECOND( m_aMasterFields.size() == m_aDetailFields.size(),
247 "ParameterManager::classifyLinks: master and detail fields should have the same length!" );
248 OSL_ENSURE( _rxColumns.is(), "ParameterManager::classifyLinks: invalid columns!" );
249
250 if ( !_rxColumns.is() )
251 return;
252
253 // we may need to strip any links which are invalid, so here go the containers
254 // for temporarily holding the new pairs
255 std::vector< OUString > aStrippedMasterFields;
256 std::vector< OUString > aStrippedDetailFields;
257
258 bool bNeedExchangeLinks = false;
259
260 // classify the links
261 auto pMasterFields = m_aMasterFields.begin();
262 auto pDetailFields = m_aDetailFields.begin();
263 auto pDetailFieldsEnd = m_aDetailFields.end();
264 for ( ; pDetailFields != pDetailFieldsEnd; ++pDetailFields, ++pMasterFields )
265 {
266 if ( pMasterFields->isEmpty() || pDetailFields->isEmpty() )
267 continue;
268
269 // if not even the master part of the relationship exists in the parent, the
270 // link is invalid as a whole #i63674#
271 if ( !_rxParentColumns->hasByName( *pMasterFields ) )
272 {
273 bNeedExchangeLinks = true;
274 continue;
275 }
276
277 bool bValidLink = true;
278
279 // is there an inner parameter with this name? That is, a parameter which is already part of
280 // the very original statement (not the one we create ourselves, with the additional parameters)
281 ParameterInformation::iterator aPos = m_aParameterInformation.find( *pDetailFields );
282 if ( aPos != m_aParameterInformation.end() )
283 { // there is an inner parameter with this name
284 aPos->second.eType = ParameterClassification::LinkedByParamName;
285 aStrippedDetailFields.push_back( *pDetailFields );
286 }
287 else
288 {
289 // does the detail name denote a column?
290 if ( _rxColumns->hasByName( *pDetailFields ) )
291 {
292 Reference< XPropertySet > xDetailField(_rxColumns->getByName( *pDetailFields ), UNO_QUERY);
293 assert(xDetailField.is());
294
295 OUString sNewParamName;
296 const OUString sFilterCondition = createFilterConditionFromColumnLink( *pMasterFields, xDetailField, sNewParamName );
297 OSL_PRECOND( !sNewParamName.isEmpty(), "ParameterManager::classifyLinks: createFilterConditionFromColumnLink returned nonsense!" );
298
299 // remember meta information about this new parameter
300 std::pair< ParameterInformation::iterator, bool > aInsertionPos =
301 m_aParameterInformation.emplace(
302 sNewParamName, ParameterMetaData( nullptr )
303 );
304 OSL_ENSURE( aInsertionPos.second, "ParameterManager::classifyLinks: there already was a parameter with this name!" );
305 aInsertionPos.first->second.eType = ParameterClassification::LinkedByColumnName;
306
307 // remember the filter component
308 if (isAggregateColumn(xDetailField))
309 _out_rAdditionalHavingComponents.push_back( sFilterCondition );
310 else
311 _out_rAdditionalFilterComponents.push_back( sFilterCondition );
312
313 // remember the new "detail field" for this link
314 aStrippedDetailFields.push_back( sNewParamName );
315 bNeedExchangeLinks = true;
316 }
317 else
318 {
319 // the detail field neither denotes a column name, nor a parameter name
320 bValidLink = false;
321 bNeedExchangeLinks = true;
322 }
323 }
324
325 if ( bValidLink )
326 aStrippedMasterFields.push_back( *pMasterFields );
327 }
328 SAL_WARN_IF( aStrippedMasterFields.size() != aStrippedDetailFields.size(),
329 "connectivity.commontools",
330 "ParameterManager::classifyLinks: inconsistency in new link pairs!" );
331
332 if ( bNeedExchangeLinks )
333 {
334 m_aMasterFields.swap(aStrippedMasterFields);
335 m_aDetailFields.swap(aStrippedDetailFields);
336 }
337 }
338
339
340 void ParameterManager::analyzeFieldLinks( FilterManager& _rFilterManager, bool& /* [out] */ _rColumnsInLinkDetails )
341 {
342 OSL_PRECOND( isAlive(), "ParameterManager::analyzeFieldLinks: not initialized, or already disposed!" );
343 if ( !isAlive() )
344 return;
345
346 _rColumnsInLinkDetails = false;
347 try
348 {
349 // the links as determined by the properties
350 Reference< XPropertySet > xProp = m_xComponent;
351 OSL_ENSURE(xProp.is(),"Someone already released my component!");
352 if ( xProp.is() )
353 {
354 Sequence<OUString> aTmp;
355 if (xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MASTERFIELDS) ) >>= aTmp)
356 comphelper::sequenceToContainer(m_aMasterFields, aTmp);
357 if (xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DETAILFIELDS) ) >>= aTmp)
358 comphelper::sequenceToContainer(m_aDetailFields, aTmp);
359 }
360
361 {
362 // normalize to equal length
363 sal_Int32 nMasterLength = m_aMasterFields.size();
364 sal_Int32 nDetailLength = m_aDetailFields.size();
365
366 if ( nMasterLength > nDetailLength )
367 m_aMasterFields.resize( nDetailLength );
368 else if ( nDetailLength > nMasterLength )
369 m_aDetailFields.resize( nMasterLength );
370 }
371
372 Reference< XNameAccess > xColumns;
373 if ( !getColumns( xColumns, true ) )
374 // already asserted in getColumns
375 return;
376
377 Reference< XNameAccess > xParentColumns;
378 if ( !getParentColumns( xParentColumns, true ) )
379 return;
380
381 // classify the links - depending on what the detail fields in each link pair denotes
382 std::vector< OUString > aAdditionalFilterComponents;
383 std::vector< OUString > aAdditionalHavingComponents;
384 classifyLinks( xParentColumns, xColumns, aAdditionalFilterComponents, aAdditionalHavingComponents );
385
386 // did we find links where the detail field refers to a detail column (instead of a parameter name)?
387 if ( !aAdditionalFilterComponents.empty() )
388 {
389 // build a conjunction of all the filter components
390 OUStringBuffer sAdditionalFilter;
391 for (auto const& elem : aAdditionalFilterComponents)
392 {
393 if ( !sAdditionalFilter.isEmpty() )
394 sAdditionalFilter.append(" AND ");
395
396 sAdditionalFilter.append("( " + elem + " )");
397 }
398
399 // now set this filter at the filter manager
400 _rFilterManager.setFilterComponent( FilterManager::FilterComponent::LinkFilter, sAdditionalFilter.makeStringAndClear() );
401
402 _rColumnsInLinkDetails = true;
403 }
404
405 if ( !aAdditionalHavingComponents.empty() )
406 {
407 // build a conjunction of all the filter components
408 OUStringBuffer sAdditionalHaving;
409 for (auto const& elem : aAdditionalHavingComponents)
410 {
411 if ( !sAdditionalHaving.isEmpty() )
412 sAdditionalHaving.append(" AND ");
413
414 sAdditionalHaving.append("( " + elem + " )");
415 }
416
417 // now set this having clause at the filter manager
418 _rFilterManager.setFilterComponent( FilterManager::FilterComponent::LinkHaving, sAdditionalHaving.makeStringAndClear() );
419
420 _rColumnsInLinkDetails = true;
421 }
422 }
423 catch( const Exception& )
424 {
425 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::analyzeFieldLinks" );
426 }
427 }
428
429
430 void ParameterManager::createOuterParameters()
431 {
432 OSL_PRECOND( !m_pOuterParameters.is(), "ParameterManager::createOuterParameters: outer parameters not initialized!" );
433 OSL_PRECOND( m_xInnerParamUpdate.is(), "ParameterManager::createOuterParameters: no write access to the inner parameters!" );
434 if ( !m_xInnerParamUpdate.is() )
435 return;
436
437 m_pOuterParameters = new param::ParameterWrapperContainer;
438
439#if OSL_DEBUG_LEVEL > 0
440 sal_Int32 nSmallestIndexLinkedByColumnName = -1;
441 sal_Int32 nLargestIndexNotLinkedByColumnName = -1;
442#endif
443 for (auto & aParam : m_aParameterInformation)
444 {
445#if OSL_DEBUG_LEVEL > 0
446 if ( aParam.second.aInnerIndexes.size() )
447 {
448 if ( aParam.second.eType == ParameterClassification::LinkedByColumnName )
449 {
450 if ( nSmallestIndexLinkedByColumnName == -1 )
451 nSmallestIndexLinkedByColumnName = aParam.second.aInnerIndexes[ 0 ];
452 }
453 else
454 {
455 nLargestIndexNotLinkedByColumnName = aParam.second.aInnerIndexes[ aParam.second.aInnerIndexes.size() - 1 ];
456 }
457 }
458#endif
459 if ( aParam.second.eType != ParameterClassification::FilledExternally )
460 continue;
461
462 // check which of the parameters have already been visited (e.g. filled via XParameters)
463 size_t nAlreadyVisited = 0;
464 for (auto & aIndex : aParam.second.aInnerIndexes)
465 {
466 if ( ( m_aParametersVisited.size() > o3tl::make_unsigned(aIndex) ) && m_aParametersVisited[ aIndex ] )
467 { // exclude this index
468 aIndex = -1;
469 ++nAlreadyVisited;
470 }
471 }
472 if ( nAlreadyVisited == aParam.second.aInnerIndexes.size() )
473 continue;
474
475 // need a wrapper for this... the "inner parameters" as supplied by a result set don't have a "Value"
476 // property, but the parameter listeners expect such a property. So we need an object "aggregating"
477 // xParam and supplying an additional property ("Value")
478 // (it's no real aggregation of course...)
479 m_pOuterParameters->push_back( new param::ParameterWrapper( aParam.second.xComposerColumn, m_xInnerParamUpdate, std::vector(aParam.second.aInnerIndexes) ) );
480 }
481
482#if OSL_DEBUG_LEVEL > 0
483 OSL_ENSURE( ( nSmallestIndexLinkedByColumnName == -1 ) || ( nLargestIndexNotLinkedByColumnName == -1 ) ||
484 ( nSmallestIndexLinkedByColumnName > nLargestIndexNotLinkedByColumnName ),
485 "ParameterManager::createOuterParameters: inconsistency!" );
486
487 // for the master-detail links, where the detail field denoted a column name, we created an additional ("artificial")
488 // filter, and *appended* it to all other (potentially) existing filters of the row set. This means that the indexes
489 // for the parameters resulting from the artificial filter should be larger than any other parameter index, and this
490 // is what the assertion checks.
491 // If the assertion fails, then we would need another handling for the "parameters visited" flags, since they're based
492 // on parameter indexes *without* the artificial filter (because this filter is not visible from the outside).
493#endif
494 }
495
496
497 void ParameterManager::updateParameterInfo( FilterManager& _rFilterManager )
498 {
499 OSL_PRECOND( isAlive(), "ParameterManager::updateParameterInfo: not initialized, or already disposed!" );
500 if ( !isAlive() )
501 return;
502
503 clearAllParameterInformation();
504 cacheConnectionInfo();
505
506 // check whether the is based on a statement/query which requires parameters
507 Reference< XPropertySet > xProp = m_xComponent;
508 OSL_ENSURE(xProp.is(),"Some already released my component!");
509 if ( xProp.is() )
510 {
511 if ( !initializeComposerByComponent( xProp ) )
512 { // okay, nothing to do
513 m_bUpToDate = true;
514 return;
515 } // if ( !initializeComposerByComponent( m_xComponent ) )
516 }
517 SAL_WARN_IF( !m_xInnerParamColumns.is(),
518 "connectivity.commontools",
519 "ParameterManager::updateParameterInfo: initializeComposerByComponent did nonsense (1)!" );
520
521 // collect all parameters which are defined by the "inner parameters"
522 collectInnerParameters( false );
523
524 // analyze the master-detail relationships
525 bool bColumnsInLinkDetails = false;
526 analyzeFieldLinks( _rFilterManager, bColumnsInLinkDetails );
527
528 if ( bColumnsInLinkDetails )
529 {
530 // okay, in this case, analyzeFieldLinks modified the "real" filter at the RowSet, to contain
531 // an additional restriction (which we created ourself)
532 // So we need to update all information about our inner parameter columns
533 Reference< XPropertySet > xDirectRowSetProps;
534 m_xAggregatedRowSet->queryAggregation( cppu::UnoType<decltype(xDirectRowSetProps)>::get() ) >>= xDirectRowSetProps;
535 OSL_VERIFY( initializeComposerByComponent( xDirectRowSetProps ) );
536 collectInnerParameters( true );
537 }
538
539 if ( !m_nInnerCount )
540 { // no parameters at all
541 m_bUpToDate = true;
542 return;
543 }
544
545 // for what now remains as outer parameters, create the wrappers for the single
546 // parameter columns
547 createOuterParameters();
548
549 m_bUpToDate = true;
550 }
551
552
553 void ParameterManager::fillLinkedParameters( const Reference< XNameAccess >& _rxParentColumns )
554 {
555 OSL_PRECOND( isAlive(), "ParameterManager::fillLinkedParameters: not initialized, or already disposed!" );
556 if ( !isAlive() )
557 return;
558 OSL_PRECOND( m_xInnerParamColumns.is(), "ParameterManager::fillLinkedParameters: no inner parameters found!" );
559 OSL_ENSURE ( _rxParentColumns.is(), "ParameterManager::fillLinkedParameters: invalid parent columns!" );
560
561 try
562 {
563 // the master and detail field( name)s of the
564 auto pMasterFields = m_aMasterFields.begin();
565 auto pDetailFields = m_aDetailFields.begin();
566
567 sal_Int32 nMasterLen = m_aMasterFields.size();
568
569 // loop through all master fields. For each of them, get the respective column from the
570 // parent , and forward its current value as parameter value to the (inner) row set
571 for ( sal_Int32 i = 0; i < nMasterLen; ++i, ++pMasterFields, ++pDetailFields )
572 {
573 // does the name denote a valid column in the parent?
574 if ( !_rxParentColumns->hasByName( *pMasterFields ) )
575 {
576 SAL_WARN( "connectivity.commontools", "ParameterManager::fillLinkedParameters: invalid master names should have been stripped long before!" );
577 continue;
578 }
579
580 // do we, for this name, know where to place the values?
581 ParameterInformation::const_iterator aParamInfo = m_aParameterInformation.find( *pDetailFields );
582 if ( ( aParamInfo == m_aParameterInformation.end() )
583 || ( aParamInfo->second.aInnerIndexes.empty() )
584 )
585 {
586 SAL_WARN( "connectivity.commontools", "ParameterManager::fillLinkedParameters: nothing known about this detail field!" );
587 continue;
588 }
589
590 // the concrete master field
591 Reference< XPropertySet > xMasterField(_rxParentColumns->getByName( *pMasterFields ),UNO_QUERY);
592
593 // the positions where we have to fill in values for the current parameter name
594 for (auto const& aPosition : aParamInfo->second.aInnerIndexes)
595 {
596 // the concrete detail field
597 Reference< XPropertySet > xDetailField(m_xInnerParamColumns->getByIndex(aPosition),UNO_QUERY);
598 OSL_ENSURE( xDetailField.is(), "ParameterManager::fillLinkedParameters: invalid detail field!" );
599 if ( !xDetailField.is() )
600 continue;
601
602 // type and scale of the parameter field
603 sal_Int32 nParamType = DataType::VARCHAR;
604 OSL_VERIFY( xDetailField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE) ) >>= nParamType );
605
606 sal_Int32 nScale = 0;
607 if ( xDetailField->getPropertySetInfo()->hasPropertyByName( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE) ) )
608 OSL_VERIFY( xDetailField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE) ) >>= nScale );
609
610 // transfer the param value
611 try
612 {
613 m_xInnerParamUpdate->setObjectWithInfo(
614 aPosition + 1, // parameters are based at 1
615 xMasterField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE) ),
616 nParamType,
617 nScale
618 );
619 }
620 catch( const Exception& )
621 {
622 DBG_UNHANDLED_EXCEPTION("connectivity.commontools");
623 SAL_WARN( "connectivity.commontools", "ParameterManager::fillLinkedParameters: master-detail parameter number " <<
624 sal_Int32( aPosition + 1 ) << " could not be filled!" );
625 }
626 }
627 }
628 }
629 catch( const Exception& )
630 {
631 DBG_UNHANDLED_EXCEPTION("connectivity.commontools");
632 }
633 }
634
635
636 bool ParameterManager::completeParameters( const Reference< XInteractionHandler >& _rxCompletionHandler, const Reference< XConnection >& _rxConnection )
637 {
638 OSL_PRECOND( isAlive(), "ParameterManager::completeParameters: not initialized, or already disposed!" );
639 OSL_ENSURE ( _rxCompletionHandler.is(), "ParameterManager::completeParameters: invalid interaction handler!" );
640
641 // two continuations (Ok and Cancel)
644
645 // the request
646 ParametersRequest aRequest;
647 aRequest.Parameters = m_pOuterParameters.get();
648 aRequest.Connection = _rxConnection;
649 rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest( Any( aRequest ) );
650
651 // some knittings
652 pRequest->addContinuation( pAbort );
653 pRequest->addContinuation( pParams );
654
655 // execute the request
656 try
657 {
658 _rxCompletionHandler->handle( pRequest );
659 }
660 catch( const Exception& )
661 {
662 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::completeParameters: caught an exception while calling the handler" );
663 }
664
665 if ( !pParams->wasSelected() )
666 // canceled by the user (i.e. (s)he canceled the dialog)
667 return false;
668
669 try
670 {
671 // transfer the values from the continuation object to the parameter columns
672 const Sequence< PropertyValue >& aFinalValues = pParams->getValues();
673 const PropertyValue* pFinalValues = aFinalValues.getConstArray();
674 for ( sal_Int32 i = 0; i < aFinalValues.getLength(); ++i, ++pFinalValues )
675 {
676 Reference< XPropertySet > xParamColumn(aRequest.Parameters->getByIndex( i ),UNO_QUERY);
677 if ( xParamColumn.is() )
678 {
679 #ifdef DBG_UTIL
680 OUString sName;
681 xParamColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME) ) >>= sName;
682 OSL_ENSURE( sName == pFinalValues->Name, "ParameterManager::completeParameters: inconsistent parameter names!" );
683 #endif
684 xParamColumn->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE), pFinalValues->Value );
685 // the property sets are wrapper classes, translating the Value property into a call to
686 // the appropriate XParameters interface
687 }
688 }
689 }
690 catch( const Exception& )
691 {
692 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::completeParameters: caught an exception while propagating the values" );
693 }
694 return true;
695 }
696
697
698 bool ParameterManager::consultParameterListeners( ::osl::ResettableMutexGuard& _rClearForNotifies )
699 {
700 bool bCanceled = false;
701
702 sal_Int32 nParamsLeft = m_pOuterParameters->getParameters().size();
703 // TODO: shouldn't we subtract all the parameters which were already visited?
704 if ( nParamsLeft )
705 {
706 ::comphelper::OInterfaceIteratorHelper3 aIter( m_aParameterListeners );
707 Reference< XPropertySet > xProp = m_xComponent;
708 OSL_ENSURE(xProp.is(),"Some already released my component!");
709 DatabaseParameterEvent aEvent( xProp, m_pOuterParameters );
710
711 _rClearForNotifies.clear();
712 while ( aIter.hasMoreElements() && !bCanceled )
713 bCanceled = !aIter.next()->approveParameter( aEvent );
714 _rClearForNotifies.reset();
715 }
716
717 return !bCanceled;
718 }
719
720
721 bool ParameterManager::fillParameterValues( const Reference< XInteractionHandler >& _rxCompletionHandler, ::osl::ResettableMutexGuard& _rClearForNotifies )
722 {
723 OSL_PRECOND( isAlive(), "ParameterManager::fillParameterValues: not initialized, or already disposed!" );
724 if ( !isAlive() )
725 return true;
726
727 if ( m_nInnerCount == 0 )
728 // no parameters at all
729 return true;
730
731 // fill the parameters from the master-detail relationship
732 Reference< XNameAccess > xParentColumns;
733 if ( getParentColumns( xParentColumns, false ) && xParentColumns->hasElements() && !m_aMasterFields.empty() )
734 fillLinkedParameters( xParentColumns );
735
736 // let the user (via the interaction handler) fill all remaining parameters
737 Reference< XConnection > xConnection;
738 getConnection( xConnection );
739
740 if ( _rxCompletionHandler.is() )
741 return completeParameters( _rxCompletionHandler, xConnection );
742
743 return consultParameterListeners( _rClearForNotifies );
744 }
745
746
747 void ParameterManager::getConnection( Reference< XConnection >& /* [out] */ _rxConnection )
748 {
749 OSL_PRECOND( isAlive(), "ParameterManager::getConnection: not initialized, or already disposed!" );
750 if ( !isAlive() )
751 return;
752
753 _rxConnection.clear();
754 try
755 {
756 Reference< XPropertySet > xProp = m_xComponent;
757 OSL_ENSURE(xProp.is(),"Some already released my component!");
758 if ( xProp.is() )
759 xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ACTIVE_CONNECTION) ) >>= _rxConnection;
760 }
761 catch( const Exception& )
762 {
763 SAL_WARN( "connectivity.commontools", "ParameterManager::getConnection: could not retrieve the connection of the !" );
764 }
765 }
766
767
768 void ParameterManager::cacheConnectionInfo()
769 {
770 try
771 {
772 Reference< XConnection > xConnection;
773 getConnection( xConnection );
774 Reference< XDatabaseMetaData > xMeta;
775 if ( xConnection.is() )
776 xMeta = xConnection->getMetaData();
777 if ( xMeta.is() )
778 {
779 m_xConnectionMetadata = xMeta;
780 m_sIdentifierQuoteString = xMeta->getIdentifierQuoteString();
781 m_sSpecialCharacters = xMeta->getExtraNameCharacters();
782 }
783 }
784 catch( const Exception& )
785 {
786 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::cacheConnectionInfo: caught an exception" );
787 }
788 }
789
790
791 bool ParameterManager::getColumns( Reference< XNameAccess >& /* [out] */ _rxColumns, bool _bFromComposer )
792 {
793 _rxColumns.clear();
794
795 Reference< XColumnsSupplier > xColumnSupp;
796 if ( _bFromComposer )
797 xColumnSupp.set(m_xComposer, css::uno::UNO_QUERY);
798 else
799 xColumnSupp.set( m_xComponent.get(),UNO_QUERY);
800 if ( xColumnSupp.is() )
801 _rxColumns = xColumnSupp->getColumns();
802 OSL_ENSURE( _rxColumns.is(), "ParameterManager::getColumns: could not retrieve the columns for the detail !" );
803
804 return _rxColumns.is();
805 }
806
807
808 bool ParameterManager::getParentColumns( Reference< XNameAccess >& /* [out] */ _out_rxParentColumns, bool _bFromComposer )
809 {
810 OSL_PRECOND( isAlive(), "ParameterManager::getParentColumns: not initialized, or already disposed!" );
811
812 _out_rxParentColumns.clear();
813 try
814 {
815 // get the parent of the component we're working for
816 Reference< XChild > xAsChild( m_xComponent.get(), UNO_QUERY_THROW );
817 Reference< XPropertySet > xParent( xAsChild->getParent(), UNO_QUERY );
818 if ( !xParent.is() )
819 return false;
820
821 // the columns supplier: either from a composer, or directly from the
822 Reference< XColumnsSupplier > xParentColSupp;
823 if ( _bFromComposer )
824 {
825 // re-create the parent composer all the time. Else, we'd have to bother with
826 // being a listener at its properties, its loaded state, and event the parent-relationship.
827 m_xParentComposer.reset(
828 getCurrentSettingsComposer( xParent, m_xContext, nullptr ),
829 SharedQueryComposer::TakeOwnership
830 );
831 xParentColSupp.set(m_xParentComposer, css::uno::UNO_QUERY);
832 }
833 else
834 xParentColSupp.set(xParent, css::uno::UNO_QUERY);
835
836 // get the columns of the parent
837 if ( xParentColSupp.is() )
838 _out_rxParentColumns = xParentColSupp->getColumns();
839 }
840 catch( const Exception& )
841 {
842 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::getParentColumns" );
843 }
844 return _out_rxParentColumns.is();
845 }
846
847
848 void ParameterManager::addParameterListener( const Reference< XDatabaseParameterListener >& _rxListener )
849 {
850 if ( _rxListener.is() )
851 m_aParameterListeners.addInterface( _rxListener );
852 }
853
854
855 void ParameterManager::removeParameterListener( const Reference< XDatabaseParameterListener >& _rxListener )
856 {
857 m_aParameterListeners.removeInterface( _rxListener );
858 }
859
860
861 void ParameterManager::resetParameterValues( )
862 {
863 OSL_PRECOND( isAlive(), "ParameterManager::resetParameterValues: not initialized, or already disposed!" );
864 if ( !isAlive() )
865 return;
866
867 if ( !m_nInnerCount )
868 // no parameters at all
869 return;
870
871 try
872 {
873 Reference< XNameAccess > xColumns;
874 if ( !getColumns( xColumns, false ) )
875 // already asserted in getColumns
876 return;
877
878 Reference< XNameAccess > xParentColumns;
879 if ( !getParentColumns( xParentColumns, false ) )
880 return;
881
882 // loop through all links pairs
883 auto pMasterFields = m_aMasterFields.begin();
884 auto pDetailFields = m_aDetailFields.begin();
885
886 Reference< XPropertySet > xMasterField;
887 Reference< XPropertySet > xDetailField;
888
889 // now really ....
890 auto pDetailFieldsEnd = m_aDetailFields.end();
891 for ( ; pDetailFields != pDetailFieldsEnd; ++pDetailFields, ++pMasterFields )
892 {
893 if ( !xParentColumns->hasByName( *pMasterFields ) )
894 {
895 // if this name is unknown in the parent columns, then we don't have a source
896 // for copying the value to the detail columns
897 SAL_WARN( "connectivity.commontools", "ParameterManager::resetParameterValues: this should have been stripped long before!" );
898 continue;
899 }
900
901 // for all inner parameters which are bound to the name as specified by the
902 // slave element of the link, propagate the value from the master column to this
903 // parameter column
904 ParameterInformation::const_iterator aParamInfo = m_aParameterInformation.find( *pDetailFields );
905 if ( ( aParamInfo == m_aParameterInformation.end() )
906 || ( aParamInfo->second.aInnerIndexes.empty() )
907 )
908 {
909 SAL_WARN( "connectivity.commontools", "ParameterManager::resetParameterValues: nothing known about this detail field!" );
910 continue;
911 }
912
913 xParentColumns->getByName( *pMasterFields ) >>= xMasterField;
914 if ( !xMasterField.is() )
915 continue;
916
917 for (auto const& aPosition : aParamInfo->second.aInnerIndexes)
918 {
919 Reference< XPropertySet > xInnerParameter;
920 m_xInnerParamColumns->getByIndex(aPosition) >>= xInnerParameter;
921 if ( !xInnerParameter.is() )
922 continue;
923
924 OUString sParamColumnRealName;
925 xInnerParameter->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME) ) >>= sParamColumnRealName;
926 if ( xColumns->hasByName( sParamColumnRealName ) )
927 { // our own columns have a column which's name equals the real name of the param column
928 // -> transfer the value property
929 xColumns->getByName( sParamColumnRealName ) >>= xDetailField;
930 if ( xDetailField.is() )
931 xDetailField->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE), xMasterField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE) ) );
932 }
933 }
934 }
935 }
936 catch( const Exception& )
937 {
938 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "ParameterManager::resetParameterValues" );
939 }
940
941 }
942
943
944 void ParameterManager::externalParameterVisited( sal_Int32 _nIndex )
945 {
946 if ( m_aParametersVisited.size() < o3tl::make_unsigned(_nIndex) )
947 {
948 m_aParametersVisited.reserve( _nIndex );
949 for ( sal_Int32 i = m_aParametersVisited.size(); i < _nIndex; ++i )
950 m_aParametersVisited.push_back( false );
951 }
952 m_aParametersVisited[ _nIndex - 1 ] = true;
953 }
954
955 void ParameterManager::setNull( sal_Int32 _nIndex, sal_Int32 sqlType )
956 {
957 ::osl::MutexGuard aGuard(m_rMutex);
958 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
959 if (!m_xInnerParamUpdate.is())
960 return;
961 m_xInnerParamUpdate->setNull(_nIndex, sqlType);
962 externalParameterVisited(_nIndex);
963 }
964
965
966 void ParameterManager::setObjectNull( sal_Int32 _nIndex, sal_Int32 sqlType, const OUString& typeName )
967 {
968 ::osl::MutexGuard aGuard(m_rMutex);
969 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
970 if (!m_xInnerParamUpdate.is())
971 return;
972 m_xInnerParamUpdate->setObjectNull(_nIndex, sqlType, typeName);
973 externalParameterVisited(_nIndex);
974 }
975
976
977 void ParameterManager::setBoolean( sal_Int32 _nIndex, bool x )
978 {
979 ::osl::MutexGuard aGuard(m_rMutex);
980 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
981 if (!m_xInnerParamUpdate.is())
982 return;
983 m_xInnerParamUpdate->setBoolean(_nIndex, x);
984 externalParameterVisited(_nIndex);
985 }
986
987
988 void ParameterManager::setByte( sal_Int32 _nIndex, sal_Int8 x )
989 {
990 ::osl::MutexGuard aGuard(m_rMutex);
991 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
992 if (!m_xInnerParamUpdate.is())
993 return;
994 m_xInnerParamUpdate->setByte(_nIndex, x);
995 externalParameterVisited(_nIndex);
996 }
997
998
999 void ParameterManager::setShort( sal_Int32 _nIndex, sal_Int16 x )
1000 {
1001 ::osl::MutexGuard aGuard(m_rMutex);
1002 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1003 if (!m_xInnerParamUpdate.is())
1004 return;
1005 m_xInnerParamUpdate->setShort(_nIndex, x);
1006 externalParameterVisited(_nIndex);
1007 }
1008
1009
1010 void ParameterManager::setInt( sal_Int32 _nIndex, sal_Int32 x )
1011 {
1012 ::osl::MutexGuard aGuard(m_rMutex);
1013 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1014 if (!m_xInnerParamUpdate.is())
1015 return;
1016 m_xInnerParamUpdate->setInt(_nIndex, x);
1017 externalParameterVisited(_nIndex);
1018 }
1019
1020
1021 void ParameterManager::setLong( sal_Int32 _nIndex, sal_Int64 x )
1022 {
1023 ::osl::MutexGuard aGuard(m_rMutex);
1024 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1025 if (!m_xInnerParamUpdate.is())
1026 return;
1027 m_xInnerParamUpdate->setLong(_nIndex, x);
1028 externalParameterVisited(_nIndex);
1029 }
1030
1031
1032 void ParameterManager::setFloat( sal_Int32 _nIndex, float x )
1033 {
1034 ::osl::MutexGuard aGuard(m_rMutex);
1035 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1036 if (!m_xInnerParamUpdate.is())
1037 return;
1038 m_xInnerParamUpdate->setFloat(_nIndex, x);
1039 externalParameterVisited(_nIndex);
1040 }
1041
1042
1043 void ParameterManager::setDouble( sal_Int32 _nIndex, double x )
1044 {
1045 ::osl::MutexGuard aGuard(m_rMutex);
1046 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1047 if (!m_xInnerParamUpdate.is())
1048 return;
1049 m_xInnerParamUpdate->setDouble(_nIndex, x);
1050 externalParameterVisited(_nIndex);
1051 }
1052
1053
1054 void ParameterManager::setString( sal_Int32 _nIndex, const OUString& x )
1055 {
1056 ::osl::MutexGuard aGuard(m_rMutex);
1057 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1058 if (!m_xInnerParamUpdate.is())
1059 return;
1060 m_xInnerParamUpdate->setString(_nIndex, x);
1061 externalParameterVisited(_nIndex);
1062 }
1063
1064
1065 void ParameterManager::setBytes( sal_Int32 _nIndex, const css::uno::Sequence< sal_Int8 >& x )
1066 {
1067 ::osl::MutexGuard aGuard(m_rMutex);
1068 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1069 if (!m_xInnerParamUpdate.is())
1070 return;
1071 m_xInnerParamUpdate->setBytes(_nIndex, x);
1072 externalParameterVisited(_nIndex);
1073 }
1074
1075
1076 void ParameterManager::setDate( sal_Int32 _nIndex, const css::util::Date& x )
1077 {
1078 ::osl::MutexGuard aGuard(m_rMutex);
1079 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1080 if (!m_xInnerParamUpdate.is())
1081 return;
1082 m_xInnerParamUpdate->setDate(_nIndex, x);
1083 externalParameterVisited(_nIndex);
1084 }
1085
1086
1087 void ParameterManager::setTime( sal_Int32 _nIndex, const css::util::Time& x )
1088 {
1089 ::osl::MutexGuard aGuard(m_rMutex);
1090 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1091 if (!m_xInnerParamUpdate.is())
1092 return;
1093 m_xInnerParamUpdate->setTime(_nIndex, x);
1094 externalParameterVisited(_nIndex);
1095 }
1096
1097
1098 void ParameterManager::setTimestamp( sal_Int32 _nIndex, const css::util::DateTime& x )
1099 {
1100 ::osl::MutexGuard aGuard(m_rMutex);
1101 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1102 if (!m_xInnerParamUpdate.is())
1103 return;
1104 m_xInnerParamUpdate->setTimestamp(_nIndex, x);
1105 externalParameterVisited(_nIndex);
1106 }
1107
1108
1109 void ParameterManager::setBinaryStream( sal_Int32 _nIndex, const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length )
1110 {
1111 ::osl::MutexGuard aGuard(m_rMutex);
1112 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1113 if (!m_xInnerParamUpdate.is())
1114 return;
1115 m_xInnerParamUpdate->setBinaryStream(_nIndex, x, length);
1116 externalParameterVisited(_nIndex);
1117 }
1118
1119
1120 void ParameterManager::setCharacterStream( sal_Int32 _nIndex, const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length )
1121 {
1122 ::osl::MutexGuard aGuard(m_rMutex);
1123 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1124 if (!m_xInnerParamUpdate.is())
1125 return;
1126 m_xInnerParamUpdate->setCharacterStream(_nIndex, x, length);
1127 externalParameterVisited(_nIndex);
1128 }
1129
1130
1131 void ParameterManager::setObject( sal_Int32 _nIndex, const css::uno::Any& x )
1132 {
1133 ::osl::MutexGuard aGuard(m_rMutex);
1134 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1135 if (!m_xInnerParamUpdate.is())
1136 return;
1137 m_xInnerParamUpdate->setObject(_nIndex, x);
1138 externalParameterVisited(_nIndex);
1139 }
1140
1141
1142 void ParameterManager::setObjectWithInfo( sal_Int32 _nIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale )
1143 {
1144 ::osl::MutexGuard aGuard(m_rMutex);
1145 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1146 if (!m_xInnerParamUpdate.is())
1147 return;
1148 m_xInnerParamUpdate->setObjectWithInfo(_nIndex, x, targetSqlType, scale);
1149 externalParameterVisited(_nIndex);
1150 }
1151
1152
1153 void ParameterManager::setRef( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XRef>& x )
1154 {
1155 ::osl::MutexGuard aGuard(m_rMutex);
1156 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1157 if (!m_xInnerParamUpdate.is())
1158 return;
1159 m_xInnerParamUpdate->setRef(_nIndex, x);
1160 externalParameterVisited(_nIndex);
1161 }
1162
1163
1164 void ParameterManager::setBlob( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XBlob>& x )
1165 {
1166 ::osl::MutexGuard aGuard(m_rMutex);
1167 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1168 if (!m_xInnerParamUpdate.is())
1169 return;
1170 m_xInnerParamUpdate->setBlob(_nIndex, x);
1171 externalParameterVisited(_nIndex);
1172 }
1173
1174
1175 void ParameterManager::setClob( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XClob>& x )
1176 {
1177 ::osl::MutexGuard aGuard(m_rMutex);
1178 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1179 if (!m_xInnerParamUpdate.is())
1180 return;
1181 m_xInnerParamUpdate->setClob(_nIndex, x);
1182 externalParameterVisited(_nIndex);
1183 }
1184
1185
1186 void ParameterManager::setArray( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XArray>& x )
1187 {
1188 ::osl::MutexGuard aGuard(m_rMutex);
1189 OSL_ENSURE(m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
1190 if (!m_xInnerParamUpdate.is())
1191 return;
1192 m_xInnerParamUpdate->setArray(_nIndex, x);
1193 externalParameterVisited(_nIndex);
1194 }
1195
1196
1197 void ParameterManager::clearParameters( )
1198 {
1199 if ( m_xInnerParamUpdate.is() )
1200 m_xInnerParamUpdate->clearParameters( );
1201 }
1202
1203 void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues )
1204 {
1205 m_aValues = _rValues;
1206 }
1207
1208
1209} // namespace frm
1210
1211
1212/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
AnyEventRef aEvent
css::uno::Reference< ListenerT > const & next()
manages the filter of a database component with filter properties
void setFilterComponent(FilterComponent _eWhich, const OUString &_rComponent)
::std::map< OUString, ParameterMetaData > ParameterInformation
Definition: parameters.hxx:98
ParameterManager(::osl::Mutex &_rMutex, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
ctor
class for the parameter event
wraps a parameter column as got from an SQLQueryComposer, so that it has an additional property "Valu...
::osl::Mutex & m_rMutex
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
float x
std::deque< AttacherIndex_Impl > aIndex
Sequence< PropertyValue > m_aValues
OUString sName
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
@ Exception
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
OUString quoteTableName(const Reference< XDatabaseMetaData > &_rxMeta, const OUString &_rName, EComposeRule _eComposeRule)
Definition: dbtools.cxx:853
Reference< XConnection > getConnection(const Reference< XRowSet > &_rxRowSet)
Definition: dbtools.cxx:348
Reference< XSingleSelectQueryComposer > getCurrentSettingsComposer(const Reference< XPropertySet > &_rxRowSetProps, const Reference< XComponentContext > &_rxContext, const Reference< XWindow > &_rxParent)
Definition: dbtools.cxx:1264
bool isAggregateColumn(const Reference< XSingleSelectQueryComposer > &_xParser, const Reference< XPropertySet > &_xField)
Definition: dbtools2.cxx:971
void setObjectWithInfo(const Reference< XParameters > &_xParams, sal_Int32 parameterIndex, const Any &x, sal_Int32 sqlType, sal_Int32 scale)
Definition: dbtools.cxx:1765
OUString quoteName(std::u16string_view _rQuote, const OUString &_rName)
quote the given name with the given quote string.
OUString convertName2SQLName(const OUString &rName, std::u16string_view _rSpecials)
create a name which is a valid SQL 92 identifier name
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool isAlive()
#define PROPERTY_ID_VALUE
OUString typeName
sal_Int32 scale
Definition: pq_statics.cxx:62
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
#define PROPERTY_ID_ACTIVE_CONNECTION
#define PROPERTY_ID_TYPE
Definition: propertyids.hxx:51
#define PROPERTY_ID_MASTERFIELDS
#define PROPERTY_ID_DETAILFIELDS
#define PROPERTY_ID_REALNAME
Definition: propertyids.hxx:79
#define PROPERTY_ID_SCALE
Definition: propertyids.hxx:54
meta data about an inner parameter
Definition: parameters.hxx:81
signed char sal_Int8