sb130: #i113096# UniversalContentBroker::changesOccurred is now also called for removed items
This commit is contained in:
parent
d7fd47ed54
commit
abccae0c72
2 changed files with 74 additions and 59 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
|
@ -664,10 +722,19 @@ void SAL_CALL UniversalContentBroker::changesOccurred( const util::ChangesEvent&
|
|||
|
||||
ContentProviderData aInfo;
|
||||
|
||||
createContentProviderData(aKey, xHierNameAccess, 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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue