From eb0f90d33200e26d128672bbb6a105e815144cfc Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 26 Nov 2009 09:07:47 +0100 Subject: dba33d: #i106526# askParameter now compress duplicate parameter names --- connectivity/source/commontools/dbtools.cxx | 53 ++++++++++++++++++----------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'connectivity/source/commontools') diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index bb088937c313..d5502fc0272c 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -1388,16 +1388,18 @@ namespace ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); Reference< XPropertySetInfo > xInfo = _xTable->getPropertySetInfo(); if ( xInfo.is() - && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) - && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) ) { ::rtl::OUString aCatalog; ::rtl::OUString aSchema; ::rtl::OUString aTable; - _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog; - _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= _out_rSchema; + if ( xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) + && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) ) + { + _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog; + _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= _out_rSchema; + } _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= _out_rName; } else @@ -1779,15 +1781,31 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, Reference xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference(); Reference xParamsAsNames(xParamsAsIndicies, UNO_QUERY); sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0; - if ( (nParamCount && _aParametersSet.empty()) || ::std::count(_aParametersSet.begin(),_aParametersSet.end(),true) != nParamCount ) + ::std::bit_vector aNewParameterSet( _aParametersSet ); + if ( nParamCount || ::std::count(aNewParameterSet.begin(),aNewParameterSet.end(),true) != nParamCount ) { + static const ::rtl::OUString PROPERTY_NAME(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)); + aNewParameterSet.resize(nParamCount ,false); + typedef ::std::map< ::rtl::OUString, ::std::vector > TParameterPositions; + TParameterPositions aParameterNames; + for(sal_Int32 i = 0; i < nParamCount; ++i) + { + Reference xParam(xParamsAsIndicies->getByIndex(i),UNO_QUERY); + ::rtl::OUString sName; + xParam->getPropertyValue(PROPERTY_NAME) >>= sName; + + TParameterPositions::iterator aFind = aParameterNames.find(sName); + if ( aFind != aParameterNames.end() ) + aNewParameterSet[i] = true; + aParameterNames[sName].push_back(i+1); + } // build an interaction request // two continuations (Ok and Cancel) OInteractionAbort* pAbort = new OInteractionAbort; OParameterContinuation* pParams = new OParameterContinuation; // the request ParametersRequest aRequest; - Reference xWrappedParameters = new OParameterWrapper(_aParametersSet,xParamsAsIndicies); + Reference xWrappedParameters = new OParameterWrapper(aNewParameterSet,xParamsAsIndicies); aRequest.Parameters = xWrappedParameters; aRequest.Connection = _xConnection; OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest)); @@ -1815,11 +1833,10 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(i),UNO_QUERY); if (xParamColumn.is()) { -#ifdef DBG_UTIL ::rtl::OUString sName; - xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sName; + xParamColumn->getPropertyValue(PROPERTY_NAME) >>= sName; OSL_ENSURE(sName.equals(pFinalValues->Name), "::dbaui::askForParameters: inconsistent parameter names!"); -#endif + // determine the field type and ... sal_Int32 nParamType = 0; xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nParamType; @@ -1827,21 +1844,17 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, sal_Int32 nScale = 0; if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), xParamColumn)) xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale; - // and set the value - ::std::bit_vector::const_iterator aIter = _aParametersSet.begin(); - ::std::bit_vector::const_iterator aEnd = _aParametersSet.end(); - sal_Int32 j = 0; - sal_Int32 nParamPos = -1; - for(; aIter != aEnd && j <= i; ++aIter) + // (the index of the parameters is one-based) + TParameterPositions::iterator aFind = aParameterNames.find(pFinalValues->Name); + ::std::vector::iterator aIterPos = aFind->second.begin(); + ::std::vector::iterator aEndPos = aFind->second.end(); + for(;aIterPos != aEndPos;++aIterPos) { - ++nParamPos; - if ( !*aIter ) + if ( _aParametersSet.empty() || !_aParametersSet[(*aIterPos)-1] ) { - ++j; + _xParameters->setObjectWithInfo(*aIterPos, pFinalValues->Value, nParamType, nScale); } } - _xParameters->setObjectWithInfo(nParamPos + 1, pFinalValues->Value, nParamType, nScale); - // (the index of the parameters is one-based) } } } -- cgit From e469ee0ef7a27b7fe74de6961bb2fca7836bf9b9 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 10 Dec 2009 11:45:59 +0100 Subject: dba33d: merge --- connectivity/source/commontools/FValue.cxx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'connectivity/source/commontools') diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 36d5bd2db16c..7ea68e099dc3 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -1921,6 +1921,9 @@ namespace detail virtual Sequence< sal_Int8 > getBytes() const = 0; virtual Reference< XInputStream > getBinaryStream() const = 0; virtual Reference< XInputStream > getCharacterStream() const = 0; + virtual Reference< XClob > getClob() const = 0; + virtual Reference< XBlob > getBlob() const = 0; + virtual Any getObject() const = 0; virtual sal_Bool wasNull() const = 0; virtual ~IValueSource() { } @@ -1950,6 +1953,9 @@ namespace detail virtual Sequence< sal_Int8 > getBytes() const { return m_xRow->getBytes( m_nPos ); }; virtual Reference< XInputStream > getBinaryStream() const { return m_xRow->getBinaryStream( m_nPos ); }; virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); }; + virtual Reference< XClob > getClob() const { return m_xRow->getClob( m_nPos ); }; + virtual Reference< XBlob > getBlob() const { return m_xRow->getBlob( m_nPos ); }; + virtual Any getObject() const { return m_xRow->getObject( m_nPos ,NULL); }; virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); }; private: @@ -1980,6 +1986,9 @@ namespace detail virtual Sequence< sal_Int8 > getBytes() const { return m_xColumn->getBytes(); }; virtual Reference< XInputStream > getBinaryStream() const { return m_xColumn->getBinaryStream(); }; virtual Reference< XInputStream > getCharacterStream() const { return m_xColumn->getCharacterStream(); }; + virtual Reference< XClob > getClob() const { return m_xColumn->getClob(); }; + virtual Reference< XBlob > getBlob() const { return m_xColumn->getBlob(); }; + virtual Any getObject() const { return m_xColumn->getObject(NULL); }; virtual sal_Bool wasNull() const { return m_xColumn->wasNull( ); }; private: @@ -2075,23 +2084,15 @@ void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const (*this) = _rValueSource.getLong(); break; case DataType::CLOB: -<<<<<<< local - (*this) = ::com::sun::star::uno::makeAny(_xRow->getClob(_nPos)); -======= - (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getCharacterStream()); ->>>>>>> other + (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getClob()); setTypeKind(DataType::CLOB); break; case DataType::BLOB: -<<<<<<< local - (*this) = ::com::sun::star::uno::makeAny(_xRow->getBlob(_nPos)); -======= - (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBinaryStream()); ->>>>>>> other + (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBlob()); setTypeKind(DataType::BLOB); break; case DataType::OTHER: - (*this) = _xRow->getObject(_nPos,NULL); + (*this) = _rValueSource.getObject(); setTypeKind(DataType::OTHER); break; default: -- cgit