summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/core/ucb.cxx127
-rw-r--r--ucb/source/core/ucb.hxx6
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 <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,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 <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;