diff --git a/connectivity/inc/connectivity/IParseContext.hxx b/connectivity/inc/connectivity/IParseContext.hxx index c51484fe1a6f..bcf90755a709 100644 --- a/connectivity/inc/connectivity/IParseContext.hxx +++ b/connectivity/inc/connectivity/IParseContext.hxx @@ -41,7 +41,7 @@ namespace connectivity //========================================================================== //= IParseContext //========================================================================== - class OOO_DLLPUBLIC_DBTOOLS IParseContext + class IParseContext { public: enum ErrorCode diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index c1432d90c3f8..891fd41dae3f 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1066,6 +1066,26 @@ bool OSQLParseTreeIterator::traverseGroupByColumnNames(const OSQLParseNode* pSel traverseByColumnNames( pSelectNode, sal_False ); return !hasErrors(); } + +// ----------------------------------------------------------------------------- +namespace +{ + ::rtl::OUString lcl_generateParameterName( const OSQLParseNode& _rParentNode, const OSQLParseNode& _rParamNode ) + { + ::rtl::OUString sColumnName( RTL_CONSTASCII_USTRINGPARAM( "param" ) ); + const sal_Int32 nCount = (sal_Int32)_rParentNode.count(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + if ( _rParentNode.getChild(i) == &_rParamNode ) + { + sColumnName += ::rtl::OUString::valueOf( i+1 ); + break; + } + } + return sColumnName; + } +} + // ----------------------------------------------------------------------------- void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode) { @@ -1081,33 +1101,34 @@ void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode) sal_uInt32 nPos = 0; if ( pParent->getChild(nPos) == _pNode ) nPos = 2; - pParent->getChild(nPos)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + const OSQLParseNode* pOther = pParent->getChild(nPos); + if ( SQL_ISRULE( pOther, column_ref ) ) + getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias); + else + pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); } // if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X else if ( SQL_ISRULE(pParent,like_predicate) ) { - pParent->getChild(0)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + const OSQLParseNode* pOther = pParent->getChild(0); + if ( SQL_ISRULE( pOther, column_ref ) ) + getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias); + else + pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); } else if ( SQL_ISRULE(pParent,between_predicate) ) { - sal_Int32 nPos = 2; - if ( pParent->getChild(3) == _pNode ) - nPos = 1; - pParent->getChild(0)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - sColumnName += ::rtl::OUString::valueOf(nPos); + const OSQLParseNode* pOther = pParent->getChild(0); + if ( SQL_ISRULE( pOther, column_ref ) ) + getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias); + else + { + pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + lcl_generateParameterName( *pParent, *_pNode ); + } } else if ( pParent->getNodeType() == SQL_NODE_COMMALISTRULE ) { - const sal_Int32 nParamCount = (sal_Int32)pParent->count(); - for (sal_Int32 i = 0; i < nParamCount; ++i) - { - if ( pParent->getChild(i) == _pNode ) - { - static const ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM("param")); - sColumnName = s_sParam; - sColumnName += ::rtl::OUString::valueOf(i+1); - break; - } - } + lcl_generateParameterName( *pParent, *_pNode ); } } traverseParameter( _pNode, pParent, sColumnName, sTableRange, aColumnAlias ); diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index a0c67b47d057..ec26c3e6bbaf 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -73,6 +73,8 @@ #define UNO_QUERY ::com::sun::star::uno::UNO_QUERY namespace css = ::com::sun::star; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::PropertyValue; //-------------------------------------------------------------------------------------------------------- // --- XNameReplace --- @@ -83,55 +85,58 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY & { ::osl::MutexGuard aGuard( maMutex ); - bool bReset = !rElement.hasValue(); // find the event in the list and replace the data long nCount = maEventNames.getLength(); for ( long i=0; i aProperties; // check for correct type of the element - if ( bReset || ::getCppuType( (const SEQUENCE < PROPERTYVALUE > *)0 ) == rElement.getValueType() ) - { - // create Configuration at first, creation might call this method also and that would overwrite everything - // we might have stored before! - USHORT nID = (USHORT) SfxEventConfiguration::GetEventId_Impl( aName ); - if ( nID ) - { - // pConfig becomes the owner of the new SvxMacro - if ( mpObjShell && !mpObjShell->IsLoading() ) - mpObjShell->SetModified( TRUE ); - - if ( bReset ) - { - maEventData[i] = ANY(); - } - else - { - ANY aValue; - BlowUpMacro( rElement, aValue, mpObjShell ); - - SEQUENCE < PROPERTYVALUE > aProperties; - if ( aValue >>= aProperties ) - { - ::rtl::OUString aType; - if (( aProperties[0].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 ) && - ( aProperties[0].Value >>= aType ) && - aType.getLength() == 0 ) - { - // An empty event type means no binding. Therefore reset data - // to reflect that state. - maEventData[i] = ANY(); - } - else - maEventData[i] = aValue; - } - } - } - } - else + if ( rElement.hasValue() && !( rElement >>= aProperties ) ) throw ILLEGALARGUMENTEXCEPTION(); + // create Configuration at first, creation might call this method also and that would overwrite everything + // we might have stored before! + USHORT nID = (USHORT) SfxEventConfiguration::GetEventId_Impl( aName ); + OSL_ENSURE( nID, "SfxEvents_Impl::replaceByName: no ID for the given event!" ); + if ( !nID ) + // throw? + return; + + if ( mpObjShell && !mpObjShell->IsLoading() ) + mpObjShell->SetModified( TRUE ); + + if ( aProperties.getLength() ) + { + // "normalize" the macro descriptor + ANY aValue; + BlowUpMacro( rElement, aValue, mpObjShell ); + aValue >>= aProperties; + + ::rtl::OUString sType; + if ( ( aProperties.getLength() == 1 ) + && ( aProperties[0].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 ) + && ( aProperties[0].Value >>= sType ) + && ( sType.getLength() == 0 ) + ) + { + // An empty event type means no binding. Therefore reset data + // to reflect that state. + // (that's for compatibility only. Nowadays, the Tools/Customize dialog should + // set an empty sequence to indicate the request for resetting the assignment.) + aProperties.realloc( 0 ); + } + } + + if ( aProperties.getLength() ) + { + maEventData[i] = makeAny( aProperties ); + } + else + { + maEventData[i].clear(); + } return; } }