diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-09-08 11:34:08 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-09-08 11:34:08 +0200 |
commit | a1f9b7f72a15bb44bd8a93a02e98a436abb6df5b (patch) | |
tree | 17a82d78aa54b23ad2120daecc9bd9346b3e6ec5 /ucb | |
parent | 40906e58d26a7536aa2dfff586c3aac787b29638 (diff) | |
parent | f39adb3c348cbbd8dece7f60f88a2f7abeb94fa8 (diff) |
Merge commit 'ooo/OOO330_m7'
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/core/ucb.cxx | 151 | ||||
-rw-r--r-- | ucb/source/core/ucb.hxx | 6 |
2 files changed, 77 insertions, 80 deletions
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index c13ec9d367c8..30f7e32f3828 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/ucb/XParameterizedContentProvider.hpp> #include <com/sun/star/ucb/XContentProviderFactory.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/uno/Any.hxx> #include <ucbhelper/cancelcommandexecution.hxx> @@ -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; +} + } //========================================================================= @@ -647,28 +705,10 @@ void SAL_CALL UniversalContentBroker::changesOccurred( const util::ChangesEvent& sal_Int32 nCount = Event.Changes.getLength(); if ( nCount ) { + uno::Reference< container::XHierarchicalNameAccess > xHierNameAccess; + Event.Base >>= xHierNameAccess; - uno::Reference< lang::XMultiServiceFactory > xConfigProv( - m_xSMgr->createInstance( - rtl::OUString::createFromAscii( - "com.sun.star.configuration.ConfigurationProvider" ) ), - uno::UNO_QUERY_THROW ); - - uno::Sequence< uno::Any > aArguments( 1 ); - beans::PropertyValue aProperty; - aProperty.Name - = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); - aProperty.Value <<= Event.Base; - aArguments[ 0 ] <<= aProperty; - - uno::Reference< uno::XInterface > xInterface( - xConfigProv->createInstanceWithArguments( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess" ) ), - aArguments ) ); - - uno::Reference< container::XHierarchicalNameAccess > - xHierNameAccess( xInterface, uno::UNO_QUERY_THROW ); + OSL_ASSERT( xHierNameAccess.is() ); const util::ElementChange* pElementChanges = Event.Changes.getConstArray(); @@ -682,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); @@ -852,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 ); } @@ -884,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 <com/sun/star/util/XChangesListener.hpp> #include <com/sun/star/util/XChangesNotifier.hpp> #include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <rtl/ustrbuf.hxx> #include <cppuhelper/weak.hxx> @@ -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; |