From abccae0c72bb7ec1b813653b256fe34ffb047279 Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 26 Aug 2010 13:28:53 +0200 Subject: sb130: #i113096# UniversalContentBroker::changesOccurred is now also called for removed items --- ucb/source/core/ucb.cxx | 127 ++++++++++++++++++++++++++++-------------------- ucb/source/core/ucb.hxx | 6 --- 2 files changed, 74 insertions(+), 59 deletions(-) diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index 4c4539080a13..30f7e32f3828 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -182,6 +183,63 @@ void makeAndAppendXMLName( } } +bool createContentProviderData( + const rtl::OUString & rProvider, + const uno::Reference< container::XHierarchicalNameAccess >& rxHierNameAccess, + ContentProviderData & rInfo) +{ + // Obtain service name. + rtl::OUStringBuffer aKeyBuffer (rProvider); + aKeyBuffer.appendAscii( "/ServiceName" ); + + rtl::OUString aValue; + try + { + if ( !( rxHierNameAccess->getByHierarchicalName( + aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + { + OSL_ENSURE( false, + "UniversalContentBroker::getContentProviderData - " + "Error getting item value!" ); + } + } + catch (container::NoSuchElementException &) + { + return false; + } + + rInfo.ServiceName = aValue; + + // Obtain URL Template. + aKeyBuffer.append(rProvider); + aKeyBuffer.appendAscii( "/URLTemplate" ); + + if ( !( rxHierNameAccess->getByHierarchicalName( + aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + { + OSL_ENSURE( false, + "UniversalContentBroker::getContentProviderData - " + "Error getting item value!" ); + } + + rInfo.URLTemplate = aValue; + + // Obtain Arguments. + aKeyBuffer.append(rProvider); + aKeyBuffer.appendAscii( "/Arguments" ); + + if ( !( rxHierNameAccess->getByHierarchicalName( + aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + { + OSL_ENSURE( false, + "UniversalContentBroker::getContentProviderData - " + "Error getting item value!" ); + } + + rInfo.Arguments = aValue; + return true; +} + } //========================================================================= @@ -664,9 +722,18 @@ void SAL_CALL UniversalContentBroker::changesOccurred( const util::ChangesEvent& ContentProviderData aInfo; - createContentProviderData(aKey, xHierNameAccess, aInfo); - - aData.push_back(aInfo); + // Removal of UCPs from the configuration leads to changesOccurred + // notifications, too, but it is hard to tell for a given + // ElementChange whether it is an addition or a removal, so as a + // heuristic consider as removals those that cause a + // NoSuchElementException in createContentProviderData. + // + // For now, removal of UCPs from the configuration is simply ignored + // (and not reflected in the UCB's data structures): + if (createContentProviderData(aKey, xHierNameAccess, aInfo)) + { + aData.push_back(aInfo); + } } prepareAndRegister(aData); @@ -834,7 +901,10 @@ bool UniversalContentBroker::getContentProviderData( makeAndAppendXMLName( aElemBuffer, pElems[ n ] ); aElemBuffer.appendAscii( "']" ); - createContentProviderData(aElemBuffer.makeStringAndClear(), xHierNameAccess, aInfo); + OSL_VERIFY( + createContentProviderData( + aElemBuffer.makeStringAndClear(), xHierNameAccess, + aInfo)); rListToFill.push_back( aInfo ); } @@ -866,55 +936,6 @@ bool UniversalContentBroker::getContentProviderData( return true; } -void UniversalContentBroker::createContentProviderData( - const rtl::OUString & rProvider, - const uno::Reference< container::XHierarchicalNameAccess >& rxHierNameAccess, - ContentProviderData & rInfo) -{ - // Obtain service name. - rtl::OUStringBuffer aKeyBuffer (rProvider); - aKeyBuffer.appendAscii( "/ServiceName" ); - - rtl::OUString aValue; - if ( !( rxHierNameAccess->getByHierarchicalName( - aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) - { - OSL_ENSURE( false, - "UniversalContentBroker::getContentProviderData - " - "Error getting item value!" ); - } - - rInfo.ServiceName = aValue; - - // Obtain URL Template. - aKeyBuffer.append(rProvider); - aKeyBuffer.appendAscii( "/URLTemplate" ); - - if ( !( rxHierNameAccess->getByHierarchicalName( - aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) - { - OSL_ENSURE( false, - "UniversalContentBroker::getContentProviderData - " - "Error getting item value!" ); - } - - rInfo.URLTemplate = aValue; - - // Obtain Arguments. - aKeyBuffer.append(rProvider); - aKeyBuffer.appendAscii( "/Arguments" ); - - if ( !( rxHierNameAccess->getByHierarchicalName( - aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) - { - OSL_ENSURE( false, - "UniversalContentBroker::getContentProviderData - " - "Error getting item value!" ); - } - - rInfo.Arguments = aValue; -} - //========================================================================= // // ProviderListEntry_Impl implementation. diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx index 0e44c5bc99b5..d2f6e4e4c41e 100644 --- a/ucb/source/core/ucb.hxx +++ b/ucb/source/core/ucb.hxx @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -204,11 +203,6 @@ private: void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData); - void createContentProviderData( - const rtl::OUString& rProvider, - const com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess >& rxHierNameAccess, - ucbhelper::ContentProviderData& rInfo); - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; -- cgit v1.2.3