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>
40#include <rtl/ustrbuf.hxx>
60 ,m_aParameterListeners( _rMutex )
63 ,m_bUpToDate ( false )
65 OSL_ENSURE(
m_xContext.is(),
"ParameterManager::ParameterManager: no service factory!" );
69 void ParameterManager::initialize(
const Reference< XPropertySet >& _rxComponent,
const Reference< XAggregation >& _rxComponentAggregate )
71 OSL_ENSURE( !m_xComponent.get().is(),
"ParameterManager::initialize: already initialized!" );
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() )
83 void ParameterManager::dispose( )
85 clearAllParameterInformation();
88 m_xParentComposer.clear();
90 m_xInnerParamUpdate.clear();
91 m_xAggregatedRowSet.clear();
95 void ParameterManager::clearAllParameterInformation()
97 m_xInnerParamColumns.clear();
98 if ( m_pOuterParameters.is() )
99 m_pOuterParameters->dispose();
100 m_pOuterParameters =
nullptr;
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);
113 void ParameterManager::setAllParametersNull()
115 OSL_PRECOND(
isAlive(),
"ParameterManager::setAllParametersNull: not initialized, or already disposed!" );
119 for ( sal_Int32
i = 1;
i <= m_nInnerCount; ++
i )
120 m_xInnerParamUpdate->setNull(
i, DataType::VARCHAR );
124 bool ParameterManager::initializeComposerByComponent(
const Reference< XPropertySet >& _rxComponent )
126 OSL_PRECOND( _rxComponent.is(),
"ParameterManager::initializeComposerByComponent: invalid !" );
129 m_xInnerParamColumns.clear();
139 Reference< XParametersSupplier > xParamSupp( m_xComposer, UNO_QUERY );
140 if ( xParamSupp.is() )
141 m_xInnerParamColumns = xParamSupp->getParameters();
143 if ( m_xInnerParamColumns.is() )
144 m_nInnerCount = m_xInnerParamColumns->getCount();
146 catch(
const SQLException& )
150 return m_xInnerParamColumns.is();
154 void ParameterManager::collectInnerParameters(
bool _bSecondRun )
156 OSL_PRECOND( m_xInnerParamColumns.is(),
"ParameterManager::collectInnerParameters: missing some internal data!" );
157 if ( !m_xInnerParamColumns.is() )
163 for (
auto & paramInfo : m_aParameterInformation)
165 paramInfo.second.aInnerIndexes.clear();
172 Reference<XPropertySet> xParam;
173 for ( sal_Int32
i = 0;
i < m_nInnerCount; ++
i )
178 m_xInnerParamColumns->getByIndex(
i ) >>= xParam;
181 xParam->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_NAME) ) >>=
sName;
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!" );
188 if ( aExistentPos == m_aParameterInformation.end() )
190 aExistentPos = m_aParameterInformation.emplace(
191 sName, xParam ).first;
194 aExistentPos->second.xComposerColumn = xParam;
196 aExistentPos->second.aInnerIndexes.push_back(
i );
206 OUString ParameterManager::createFilterConditionFromColumnLink(
207 const OUString &_rMasterColumn,
const Reference < XPropertySet > &xDetailField, OUString &o_rNewParamName )
214 xDetailField->getPropertyValue(
"TableName") >>= tblName;
215 if (!tblName.isEmpty())
216 sFilter =
::dbtools::quoteTableName( m_xConnectionMetadata, tblName, ::dbtools::EComposeRule::InDataManipulation ) +
".";
220 xDetailField->getPropertyValue(
"RealName") >>= colName;
221 bool isFunction(
false);
222 xDetailField->getPropertyValue(
"Function") >>= isFunction;
226 sFilter +=
quoteName( m_sIdentifierQuoteString, colName );
230 o_rNewParamName =
"link_from_";
232 while ( m_aParameterInformation.find( o_rNewParamName ) != m_aParameterInformation.end() )
234 o_rNewParamName +=
"_";
237 return sFilter +
" =:" + o_rNewParamName;
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 )
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!" );
250 if ( !_rxColumns.is() )
255 std::vector< OUString > aStrippedMasterFields;
256 std::vector< OUString > aStrippedDetailFields;
258 bool bNeedExchangeLinks =
false;
261 auto pMasterFields = m_aMasterFields.begin();
262 auto pDetailFields = m_aDetailFields.begin();
263 auto pDetailFieldsEnd = m_aDetailFields.end();
264 for ( ; pDetailFields != pDetailFieldsEnd; ++pDetailFields, ++pMasterFields )
266 if ( pMasterFields->isEmpty() || pDetailFields->isEmpty() )
271 if ( !_rxParentColumns->hasByName( *pMasterFields ) )
273 bNeedExchangeLinks =
true;
277 bool bValidLink =
true;
281 ParameterInformation::iterator aPos = m_aParameterInformation.find( *pDetailFields );
282 if ( aPos != m_aParameterInformation.end() )
284 aPos->second.eType = ParameterClassification::LinkedByParamName;
285 aStrippedDetailFields.push_back( *pDetailFields );
290 if ( _rxColumns->hasByName( *pDetailFields ) )
292 Reference< XPropertySet > xDetailField(_rxColumns->getByName( *pDetailFields ), UNO_QUERY);
293 assert(xDetailField.is());
295 OUString sNewParamName;
296 const OUString sFilterCondition = createFilterConditionFromColumnLink( *pMasterFields, xDetailField, sNewParamName );
297 OSL_PRECOND( !sNewParamName.isEmpty(),
"ParameterManager::classifyLinks: createFilterConditionFromColumnLink returned nonsense!" );
300 std::pair< ParameterInformation::iterator, bool > aInsertionPos =
301 m_aParameterInformation.emplace(
304 OSL_ENSURE( aInsertionPos.second,
"ParameterManager::classifyLinks: there already was a parameter with this name!" );
305 aInsertionPos.first->second.eType = ParameterClassification::LinkedByColumnName;
309 _out_rAdditionalHavingComponents.push_back( sFilterCondition );
311 _out_rAdditionalFilterComponents.push_back( sFilterCondition );
314 aStrippedDetailFields.push_back( sNewParamName );
315 bNeedExchangeLinks =
true;
321 bNeedExchangeLinks =
true;
326 aStrippedMasterFields.push_back( *pMasterFields );
328 SAL_WARN_IF( aStrippedMasterFields.size() != aStrippedDetailFields.size(),
329 "connectivity.commontools",
330 "ParameterManager::classifyLinks: inconsistency in new link pairs!" );
332 if ( bNeedExchangeLinks )
334 m_aMasterFields.swap(aStrippedMasterFields);
335 m_aDetailFields.swap(aStrippedDetailFields);
340 void ParameterManager::analyzeFieldLinks(
FilterManager& _rFilterManager,
bool& _rColumnsInLinkDetails )
342 OSL_PRECOND(
isAlive(),
"ParameterManager::analyzeFieldLinks: not initialized, or already disposed!" );
346 _rColumnsInLinkDetails =
false;
350 Reference< XPropertySet > xProp = m_xComponent;
351 OSL_ENSURE(xProp.is(),
"Someone already released my component!");
354 Sequence<OUString> aTmp;
363 sal_Int32 nMasterLength = m_aMasterFields.size();
364 sal_Int32 nDetailLength = m_aDetailFields.size();
366 if ( nMasterLength > nDetailLength )
367 m_aMasterFields.resize( nDetailLength );
368 else if ( nDetailLength > nMasterLength )
369 m_aDetailFields.resize( nMasterLength );
372 Reference< XNameAccess > xColumns;
373 if ( !getColumns( xColumns,
true ) )
377 Reference< XNameAccess > xParentColumns;
378 if ( !getParentColumns( xParentColumns,
true ) )
382 std::vector< OUString > aAdditionalFilterComponents;
383 std::vector< OUString > aAdditionalHavingComponents;
384 classifyLinks( xParentColumns, xColumns, aAdditionalFilterComponents, aAdditionalHavingComponents );
387 if ( !aAdditionalFilterComponents.empty() )
390 OUStringBuffer sAdditionalFilter;
391 for (
auto const& elem : aAdditionalFilterComponents)
393 if ( !sAdditionalFilter.isEmpty() )
394 sAdditionalFilter.append(
" AND ");
396 sAdditionalFilter.append(
"( " + elem +
" )");
400 _rFilterManager.
setFilterComponent( FilterManager::FilterComponent::LinkFilter, sAdditionalFilter.makeStringAndClear() );
402 _rColumnsInLinkDetails =
true;
405 if ( !aAdditionalHavingComponents.empty() )
408 OUStringBuffer sAdditionalHaving;
409 for (
auto const& elem : aAdditionalHavingComponents)
411 if ( !sAdditionalHaving.isEmpty() )
412 sAdditionalHaving.append(
" AND ");
414 sAdditionalHaving.append(
"( " + elem +
" )");
418 _rFilterManager.
setFilterComponent( FilterManager::FilterComponent::LinkHaving, sAdditionalHaving.makeStringAndClear() );
420 _rColumnsInLinkDetails =
true;
430 void ParameterManager::createOuterParameters()
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() )
439#if OSL_DEBUG_LEVEL > 0
440 sal_Int32 nSmallestIndexLinkedByColumnName = -1;
441 sal_Int32 nLargestIndexNotLinkedByColumnName = -1;
443 for (
auto & aParam : m_aParameterInformation)
445#if OSL_DEBUG_LEVEL > 0
446 if ( aParam.second.aInnerIndexes.size() )
448 if ( aParam.second.eType == ParameterClassification::LinkedByColumnName )
450 if ( nSmallestIndexLinkedByColumnName == -1 )
451 nSmallestIndexLinkedByColumnName = aParam.second.aInnerIndexes[ 0 ];
455 nLargestIndexNotLinkedByColumnName = aParam.second.aInnerIndexes[ aParam.second.aInnerIndexes.size() - 1 ];
459 if ( aParam.second.eType != ParameterClassification::FilledExternally )
463 size_t nAlreadyVisited = 0;
464 for (
auto &
aIndex : aParam.second.aInnerIndexes)
472 if ( nAlreadyVisited == aParam.second.aInnerIndexes.size() )
479 m_pOuterParameters->push_back(
new param::ParameterWrapper( aParam.second.xComposerColumn, m_xInnerParamUpdate, std::vector(aParam.second.aInnerIndexes) ) );
482#if OSL_DEBUG_LEVEL > 0
483 OSL_ENSURE( ( nSmallestIndexLinkedByColumnName == -1 ) || ( nLargestIndexNotLinkedByColumnName == -1 ) ||
484 ( nSmallestIndexLinkedByColumnName > nLargestIndexNotLinkedByColumnName ),
485 "ParameterManager::createOuterParameters: inconsistency!" );
497 void ParameterManager::updateParameterInfo(
FilterManager& _rFilterManager )
499 OSL_PRECOND(
isAlive(),
"ParameterManager::updateParameterInfo: not initialized, or already disposed!" );
503 clearAllParameterInformation();
504 cacheConnectionInfo();
507 Reference< XPropertySet > xProp = m_xComponent;
508 OSL_ENSURE(xProp.is(),
"Some already released my component!");
511 if ( !initializeComposerByComponent( xProp ) )
518 "connectivity.commontools",
519 "ParameterManager::updateParameterInfo: initializeComposerByComponent did nonsense (1)!" );
522 collectInnerParameters(
false );
525 bool bColumnsInLinkDetails =
false;
526 analyzeFieldLinks( _rFilterManager, bColumnsInLinkDetails );
528 if ( bColumnsInLinkDetails )
533 Reference< XPropertySet > xDirectRowSetProps;
534 m_xAggregatedRowSet->queryAggregation(
cppu::UnoType<
decltype(xDirectRowSetProps)>::get() ) >>= xDirectRowSetProps;
535 OSL_VERIFY( initializeComposerByComponent( xDirectRowSetProps ) );
536 collectInnerParameters(
true );
539 if ( !m_nInnerCount )
547 createOuterParameters();
553 void ParameterManager::fillLinkedParameters(
const Reference< XNameAccess >& _rxParentColumns )
555 OSL_PRECOND(
isAlive(),
"ParameterManager::fillLinkedParameters: not initialized, or already disposed!" );
558 OSL_PRECOND( m_xInnerParamColumns.is(),
"ParameterManager::fillLinkedParameters: no inner parameters found!" );
559 OSL_ENSURE ( _rxParentColumns.is(),
"ParameterManager::fillLinkedParameters: invalid parent columns!" );
564 auto pMasterFields = m_aMasterFields.begin();
565 auto pDetailFields = m_aDetailFields.begin();
567 sal_Int32 nMasterLen = m_aMasterFields.size();
571 for ( sal_Int32
i = 0;
i < nMasterLen; ++
i, ++pMasterFields, ++pDetailFields )
574 if ( !_rxParentColumns->hasByName( *pMasterFields ) )
576 SAL_WARN(
"connectivity.commontools",
"ParameterManager::fillLinkedParameters: invalid master names should have been stripped long before!" );
581 ParameterInformation::const_iterator aParamInfo = m_aParameterInformation.find( *pDetailFields );
582 if ( ( aParamInfo == m_aParameterInformation.end() )
583 || ( aParamInfo->second.aInnerIndexes.empty() )
586 SAL_WARN(
"connectivity.commontools",
"ParameterManager::fillLinkedParameters: nothing known about this detail field!" );
591 Reference< XPropertySet > xMasterField(_rxParentColumns->getByName( *pMasterFields ),UNO_QUERY);
594 for (
auto const& aPosition : aParamInfo->second.aInnerIndexes)
597 Reference< XPropertySet > xDetailField(m_xInnerParamColumns->getByIndex(aPosition),UNO_QUERY);
598 OSL_ENSURE( xDetailField.is(),
"ParameterManager::fillLinkedParameters: invalid detail field!" );
599 if ( !xDetailField.is() )
603 sal_Int32 nParamType = DataType::VARCHAR;
604 OSL_VERIFY( xDetailField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_TYPE) ) >>= nParamType );
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 );
613 m_xInnerParamUpdate->setObjectWithInfo(
615 xMasterField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_VALUE) ),
623 SAL_WARN(
"connectivity.commontools",
"ParameterManager::fillLinkedParameters: master-detail parameter number " <<
624 sal_Int32( aPosition + 1 ) <<
" could not be filled!" );
636 bool ParameterManager::completeParameters(
const Reference< XInteractionHandler >& _rxCompletionHandler,
const Reference< XConnection >& _rxConnection )
638 OSL_PRECOND(
isAlive(),
"ParameterManager::completeParameters: not initialized, or already disposed!" );
639 OSL_ENSURE ( _rxCompletionHandler.is(),
"ParameterManager::completeParameters: invalid interaction handler!" );
646 ParametersRequest aRequest;
647 aRequest.Parameters = m_pOuterParameters.get();
648 aRequest.Connection = _rxConnection;
652 pRequest->addContinuation( pAbort );
653 pRequest->addContinuation( pParams );
658 _rxCompletionHandler->handle( pRequest );
662 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"ParameterManager::completeParameters: caught an exception while calling the handler" );
665 if ( !pParams->wasSelected() )
672 const Sequence< PropertyValue >& aFinalValues = pParams->getValues();
673 const PropertyValue* pFinalValues = aFinalValues.getConstArray();
674 for ( sal_Int32
i = 0;
i < aFinalValues.getLength(); ++
i, ++pFinalValues )
676 Reference< XPropertySet > xParamColumn(aRequest.Parameters->getByIndex(
i ),UNO_QUERY);
677 if ( xParamColumn.is() )
681 xParamColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_NAME) ) >>=
sName;
682 OSL_ENSURE(
sName == pFinalValues->Name,
"ParameterManager::completeParameters: inconsistent parameter names!" );
684 xParamColumn->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_VALUE), pFinalValues->Value );
692 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"ParameterManager::completeParameters: caught an exception while propagating the values" );
698 bool ParameterManager::consultParameterListeners( ::osl::ResettableMutexGuard& _rClearForNotifies )
700 bool bCanceled =
false;
702 sal_Int32 nParamsLeft = m_pOuterParameters->getParameters().size();
707 Reference< XPropertySet > xProp = m_xComponent;
708 OSL_ENSURE(xProp.is(),
"Some already released my component!");
709 DatabaseParameterEvent
aEvent( xProp, m_pOuterParameters );
711 _rClearForNotifies.clear();
713 bCanceled = !aIter.
next()->approveParameter(
aEvent );
714 _rClearForNotifies.reset();
721 bool ParameterManager::fillParameterValues(
const Reference< XInteractionHandler >& _rxCompletionHandler, ::osl::ResettableMutexGuard& _rClearForNotifies )
723 OSL_PRECOND(
isAlive(),
"ParameterManager::fillParameterValues: not initialized, or already disposed!" );
727 if ( m_nInnerCount == 0 )
732 Reference< XNameAccess > xParentColumns;
733 if ( getParentColumns( xParentColumns,
false ) && xParentColumns->hasElements() && !m_aMasterFields.empty() )
734 fillLinkedParameters( xParentColumns );
737 Reference< XConnection > xConnection;
740 if ( _rxCompletionHandler.is() )
741 return completeParameters( _rxCompletionHandler, xConnection );
743 return consultParameterListeners( _rClearForNotifies );
749 OSL_PRECOND(
isAlive(),
"ParameterManager::getConnection: not initialized, or already disposed!" );
753 _rxConnection.clear();
756 Reference< XPropertySet > xProp = m_xComponent;
757 OSL_ENSURE(xProp.is(),
"Some already released my component!");
763 SAL_WARN(
"connectivity.commontools",
"ParameterManager::getConnection: could not retrieve the connection of the !" );
768 void ParameterManager::cacheConnectionInfo()
772 Reference< XConnection > xConnection;
774 Reference< XDatabaseMetaData > xMeta;
775 if ( xConnection.is() )
776 xMeta = xConnection->getMetaData();
779 m_xConnectionMetadata = xMeta;
780 m_sIdentifierQuoteString = xMeta->getIdentifierQuoteString();
781 m_sSpecialCharacters = xMeta->getExtraNameCharacters();
786 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"ParameterManager::cacheConnectionInfo: caught an exception" );
791 bool ParameterManager::getColumns( Reference< XNameAccess >& _rxColumns,
bool _bFromComposer )
795 Reference< XColumnsSupplier > xColumnSupp;
796 if ( _bFromComposer )
797 xColumnSupp.set(m_xComposer, css::uno::UNO_QUERY);
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 !" );
804 return _rxColumns.is();
808 bool ParameterManager::getParentColumns( Reference< XNameAccess >& _out_rxParentColumns,
bool _bFromComposer )
810 OSL_PRECOND(
isAlive(),
"ParameterManager::getParentColumns: not initialized, or already disposed!" );
812 _out_rxParentColumns.clear();
816 Reference< XChild > xAsChild( m_xComponent.get(), UNO_QUERY_THROW );
817 Reference< XPropertySet > xParent( xAsChild->getParent(), UNO_QUERY );
822 Reference< XColumnsSupplier > xParentColSupp;
823 if ( _bFromComposer )
827 m_xParentComposer.reset(
829 SharedQueryComposer::TakeOwnership
831 xParentColSupp.set(m_xParentComposer, css::uno::UNO_QUERY);
834 xParentColSupp.set(xParent, css::uno::UNO_QUERY);
837 if ( xParentColSupp.is() )
838 _out_rxParentColumns = xParentColSupp->getColumns();
844 return _out_rxParentColumns.is();
848 void ParameterManager::addParameterListener(
const Reference< XDatabaseParameterListener >& _rxListener )
850 if ( _rxListener.is() )
851 m_aParameterListeners.addInterface( _rxListener );
855 void ParameterManager::removeParameterListener(
const Reference< XDatabaseParameterListener >& _rxListener )
857 m_aParameterListeners.removeInterface( _rxListener );
861 void ParameterManager::resetParameterValues( )
863 OSL_PRECOND(
isAlive(),
"ParameterManager::resetParameterValues: not initialized, or already disposed!" );
867 if ( !m_nInnerCount )
873 Reference< XNameAccess > xColumns;
874 if ( !getColumns( xColumns,
false ) )
878 Reference< XNameAccess > xParentColumns;
879 if ( !getParentColumns( xParentColumns,
false ) )
883 auto pMasterFields = m_aMasterFields.begin();
884 auto pDetailFields = m_aDetailFields.begin();
886 Reference< XPropertySet > xMasterField;
887 Reference< XPropertySet > xDetailField;
890 auto pDetailFieldsEnd = m_aDetailFields.end();
891 for ( ; pDetailFields != pDetailFieldsEnd; ++pDetailFields, ++pMasterFields )
893 if ( !xParentColumns->hasByName( *pMasterFields ) )
897 SAL_WARN(
"connectivity.commontools",
"ParameterManager::resetParameterValues: this should have been stripped long before!" );
904 ParameterInformation::const_iterator aParamInfo = m_aParameterInformation.find( *pDetailFields );
905 if ( ( aParamInfo == m_aParameterInformation.end() )
906 || ( aParamInfo->second.aInnerIndexes.empty() )
909 SAL_WARN(
"connectivity.commontools",
"ParameterManager::resetParameterValues: nothing known about this detail field!" );
913 xParentColumns->getByName( *pMasterFields ) >>= xMasterField;
914 if ( !xMasterField.is() )
917 for (
auto const& aPosition : aParamInfo->second.aInnerIndexes)
919 Reference< XPropertySet > xInnerParameter;
920 m_xInnerParamColumns->getByIndex(aPosition) >>= xInnerParameter;
921 if ( !xInnerParameter.is() )
924 OUString sParamColumnRealName;
925 xInnerParameter->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_REALNAME) ) >>= sParamColumnRealName;
926 if ( xColumns->hasByName( sParamColumnRealName ) )
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) ) );
944 void ParameterManager::externalParameterVisited( sal_Int32 _nIndex )
948 m_aParametersVisited.reserve( _nIndex );
949 for ( sal_Int32
i = m_aParametersVisited.size();
i < _nIndex; ++
i )
950 m_aParametersVisited.push_back(
false );
952 m_aParametersVisited[ _nIndex - 1 ] =
true;
955 void ParameterManager::setNull( sal_Int32 _nIndex, sal_Int32 sqlType )
958 OSL_ENSURE(m_xInnerParamUpdate.is(),
"ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
959 if (!m_xInnerParamUpdate.is())
961 m_xInnerParamUpdate->setNull(_nIndex, sqlType);
962 externalParameterVisited(_nIndex);
966 void ParameterManager::setObjectNull( sal_Int32 _nIndex, sal_Int32 sqlType,
const OUString&
typeName )
969 OSL_ENSURE(m_xInnerParamUpdate.is(),
"ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
970 if (!m_xInnerParamUpdate.is())
972 m_xInnerParamUpdate->setObjectNull(_nIndex, sqlType,
typeName);
973 externalParameterVisited(_nIndex);
977 void ParameterManager::setBoolean( sal_Int32 _nIndex,
bool x )
980 OSL_ENSURE(m_xInnerParamUpdate.is(),
"ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
981 if (!m_xInnerParamUpdate.is())
983 m_xInnerParamUpdate->setBoolean(_nIndex,
x);
984 externalParameterVisited(_nIndex);
988 void ParameterManager::setByte( sal_Int32 _nIndex,
sal_Int8 x )
991 OSL_ENSURE(m_xInnerParamUpdate.is(),
"ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!");
992 if (!m_xInnerParamUpdate.is())
994 m_xInnerParamUpdate->setByte(_nIndex,
x);
995 externalParameterVisited(_nIndex);
999 void ParameterManager::setShort( sal_Int32 _nIndex, sal_Int16 x )
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())
1005 m_xInnerParamUpdate->setShort(_nIndex,
x);
1006 externalParameterVisited(_nIndex);
1010 void ParameterManager::setInt( sal_Int32 _nIndex, sal_Int32 x )
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())
1016 m_xInnerParamUpdate->setInt(_nIndex,
x);
1017 externalParameterVisited(_nIndex);
1021 void ParameterManager::setLong( sal_Int32 _nIndex, sal_Int64 x )
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())
1027 m_xInnerParamUpdate->setLong(_nIndex,
x);
1028 externalParameterVisited(_nIndex);
1032 void ParameterManager::setFloat( sal_Int32 _nIndex,
float x )
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())
1038 m_xInnerParamUpdate->setFloat(_nIndex,
x);
1039 externalParameterVisited(_nIndex);
1043 void ParameterManager::setDouble( sal_Int32 _nIndex,
double x )
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())
1049 m_xInnerParamUpdate->setDouble(_nIndex,
x);
1050 externalParameterVisited(_nIndex);
1054 void ParameterManager::setString( sal_Int32 _nIndex,
const OUString& x )
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())
1060 m_xInnerParamUpdate->setString(_nIndex,
x);
1061 externalParameterVisited(_nIndex);
1065 void ParameterManager::setBytes( sal_Int32 _nIndex,
const css::uno::Sequence< sal_Int8 >& x )
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())
1071 m_xInnerParamUpdate->setBytes(_nIndex,
x);
1072 externalParameterVisited(_nIndex);
1076 void ParameterManager::setDate( sal_Int32 _nIndex,
const css::util::Date& x )
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())
1082 m_xInnerParamUpdate->setDate(_nIndex,
x);
1083 externalParameterVisited(_nIndex);
1087 void ParameterManager::setTime( sal_Int32 _nIndex,
const css::util::Time& x )
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())
1093 m_xInnerParamUpdate->setTime(_nIndex,
x);
1094 externalParameterVisited(_nIndex);
1098 void ParameterManager::setTimestamp( sal_Int32 _nIndex,
const css::util::DateTime& x )
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())
1104 m_xInnerParamUpdate->setTimestamp(_nIndex,
x);
1105 externalParameterVisited(_nIndex);
1109 void ParameterManager::setBinaryStream( sal_Int32 _nIndex,
const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length )
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())
1115 m_xInnerParamUpdate->setBinaryStream(_nIndex,
x,
length);
1116 externalParameterVisited(_nIndex);
1120 void ParameterManager::setCharacterStream( sal_Int32 _nIndex,
const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length )
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())
1126 m_xInnerParamUpdate->setCharacterStream(_nIndex,
x,
length);
1127 externalParameterVisited(_nIndex);
1131 void ParameterManager::setObject( sal_Int32 _nIndex,
const css::uno::Any& x )
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())
1137 m_xInnerParamUpdate->setObject(_nIndex,
x);
1138 externalParameterVisited(_nIndex);
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())
1148 m_xInnerParamUpdate->setObjectWithInfo(_nIndex,
x, targetSqlType,
scale);
1149 externalParameterVisited(_nIndex);
1153 void ParameterManager::setRef( sal_Int32 _nIndex,
const css::uno::Reference< css::sdbc::XRef>& x )
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())
1159 m_xInnerParamUpdate->setRef(_nIndex,
x);
1160 externalParameterVisited(_nIndex);
1164 void ParameterManager::setBlob( sal_Int32 _nIndex,
const css::uno::Reference< css::sdbc::XBlob>& x )
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())
1170 m_xInnerParamUpdate->setBlob(_nIndex,
x);
1171 externalParameterVisited(_nIndex);
1175 void ParameterManager::setClob( sal_Int32 _nIndex,
const css::uno::Reference< css::sdbc::XClob>& x )
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())
1181 m_xInnerParamUpdate->setClob(_nIndex,
x);
1182 externalParameterVisited(_nIndex);
1186 void ParameterManager::setArray( sal_Int32 _nIndex,
const css::uno::Reference< css::sdbc::XArray>& x )
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())
1192 m_xInnerParamUpdate->setArray(_nIndex,
x);
1193 externalParameterVisited(_nIndex);
1197 void ParameterManager::clearParameters( )
1199 if ( m_xInnerParamUpdate.is() )
1200 m_xInnerParamUpdate->clearParameters( );
1203 void SAL_CALL OParameterContinuation::setParameters(
const Sequence< PropertyValue >& _rValues )
Reference< XComponentContext > m_xContext
bool hasMoreElements() const
css::uno::Reference< ListenerT > const & next()
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
std::deque< AttacherIndex_Impl > aIndex
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
#define PROPERTY_ID_VALUE
#define PROPERTY_ID_ACTIVE_CONNECTION
#define PROPERTY_ID_MASTERFIELDS
#define PROPERTY_ID_DETAILFIELDS
#define PROPERTY_ID_REALNAME
#define PROPERTY_ID_SCALE