summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-09-27 10:19:04 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-27 10:30:42 +0200
commit272f0e97b12e634cdf49a1bff45e1b9068af7d9c (patch)
treed3ba7bf2885c4d5e2285caf3bb89aaedacc08a4c /ucb
parentcd693ff598bbabba66d8ca353a32bcbd81a5b12b (diff)
Improvements on previous commit
* Made XGlobalEventBroadcaster inherit document::XDocumentEventBroadcaster/ Listener replacements for obsolete document::XEventBroadcaster/Listener. This means some client sides unfortunately still need to use UNO_QUERY_THROW to obtain the obsolete interfaces; those client sides should be cleaned up to use the replacement interfaces instead. * Added @since tag (even to unpublished entities, on "it doesn't hurt" grounds). * Made client sides use XGlobalEventBroadcaster directly instead of querying for its super-interfaces. * Replaced new uses of comphelper::ComponentContext::getUNOContext with comphelper::getComponentContext (see 03a9f139bd9ea1a4f9096fc982e6b326def58532 "ComponentContext::getUnoContext -> getComponentContext simplification;" I intend to get rid of comphelper/componentcontext.hxx much sooner than of comphelper/processfactory.hxx). Change-Id: I6d971ebdaea83d0c3fa9ba299fb6b37e58cdfe9b
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.cxx63
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.hxx10
-rw-r--r--ucb/source/ucp/tdoc/tdoc_provider.cxx4
3 files changed, 13 insertions, 64 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index c4e4bd6b67b2..b9c7c81c1dc3 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -42,7 +42,7 @@
#include "com/sun/star/awt/XTopWindow.hpp"
#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/container/XEnumerationAccess.hpp"
+#include "com/sun/star/document/XEventBroadcaster.hpp"
#include "com/sun/star/document/XStorageBasedDocument.hpp"
#include "com/sun/star/frame/GlobalEventBroadcaster.hpp"
#include "com/sun/star/frame/XStorable.hpp"
@@ -115,16 +115,14 @@ OfficeDocumentsManager::OfficeDocumentsManager(
const uno::Reference< uno::XComponentContext > & rxContext,
OfficeDocumentsEventListener * pDocEventListener )
: m_xContext( rxContext ),
- m_xDocEvtNotifier( createDocumentEventNotifier( rxContext ) ),
+ m_xDocEvtNotifier( frame::GlobalEventBroadcaster::create( rxContext ) ),
m_pDocEventListener( pDocEventListener ),
m_xDocCloseListener( new OfficeDocumentsCloseListener( this ) )
{
- if ( m_xDocEvtNotifier.is() )
- {
- // Order is important (multithreaded environment)
- m_xDocEvtNotifier->addEventListener( this );
- buildDocumentsList();
- }
+ // Order is important (multithreaded environment)
+ uno::Reference< document::XEventBroadcaster >(
+ m_xDocEvtNotifier, uno::UNO_QUERY_THROW )->addEventListener( this );
+ buildDocumentsList();
}
//=========================================================================
@@ -141,8 +139,8 @@ OfficeDocumentsManager::~OfficeDocumentsManager()
//=========================================================================
void OfficeDocumentsManager::destroy()
{
- if ( m_xDocEvtNotifier.is() )
- m_xDocEvtNotifier->removeEventListener( this );
+ uno::Reference< document::XEventBroadcaster >(
+ m_xDocEvtNotifier, uno::UNO_QUERY_THROW )->removeEventListener( this );
}
//=========================================================================
@@ -457,53 +455,10 @@ void SAL_CALL OfficeDocumentsManager::disposing(
//
//=========================================================================
-// static
-uno::Reference< document::XEventBroadcaster >
-OfficeDocumentsManager::createDocumentEventNotifier(
- const uno::Reference< uno::XComponentContext >& rxContext )
-{
- uno::Reference< uno::XInterface > xIfc;
- try
- {
- xIfc = frame::GlobalEventBroadcaster::create(rxContext);
- }
- catch ( uno::Exception const & )
- {
- // handled below.
- }
-
- OSL_ENSURE(
- xIfc.is(),
- "Could not instanciate com.sun.star.frame.GlobalEventBroadcaster" );
-
- if ( xIfc.is() )
- {
- uno::Reference< document::XEventBroadcaster > xBC(
- xIfc, uno::UNO_QUERY );
-
- OSL_ENSURE(
- xBC.is(),
- "com.sun.star.frame.GlobalEventBroadcaster does not implement "
- "interface com.sun.star.document.XEventBroadcaster!" );
-
- return xBC;
- }
- else
- return uno::Reference< document::XEventBroadcaster >();
-}
-
-//=========================================================================
void OfficeDocumentsManager::buildDocumentsList()
{
- OSL_ENSURE( m_xDocEvtNotifier.is(),
- "OfficeDocumentsManager::buildDocumentsList - "
- "No document event notifier!" );
-
- uno::Reference< container::XEnumerationAccess > xEnumAccess(
- m_xDocEvtNotifier, uno::UNO_QUERY_THROW );
-
uno::Reference< container::XEnumeration > xEnum
- = xEnumAccess->createEnumeration();
+ = m_xDocEvtNotifier->createEnumeration();
osl::MutexGuard aGuard( m_aMtx );
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
index 3ba30a4a7e91..086f71433c9a 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
@@ -35,11 +35,11 @@
#include "cppuhelper/implbase1.hxx"
-#include "com/sun/star/document/XEventBroadcaster.hpp"
#include "com/sun/star/document/XEventListener.hpp"
#include "com/sun/star/embed/XStorage.hpp"
#include "com/sun/star/frame/XModel.hpp"
#include "com/sun/star/frame/XModuleManager2.hpp"
+#include "com/sun/star/frame/XGlobalEventBroadcaster.hpp"
#include "com/sun/star/util/XCloseListener.hpp"
namespace tdoc_ucp {
@@ -158,12 +158,6 @@ namespace tdoc_ucp {
queryStorageTitle( const rtl::OUString & rDocId );
private:
- static com::sun::star::uno::Reference<
- com::sun::star::document::XEventBroadcaster >
- createDocumentEventNotifier(
- const com::sun::star::uno::Reference<
- com::sun::star::uno::XComponentContext >& rxContext );
-
void buildDocumentsList();
bool
@@ -195,7 +189,7 @@ namespace tdoc_ucp {
com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext > m_xContext;
com::sun::star::uno::Reference<
- com::sun::star::document::XEventBroadcaster > m_xDocEvtNotifier;
+ com::sun::star::frame::XGlobalEventBroadcaster > m_xDocEvtNotifier;
com::sun::star::uno::Reference<
com::sun::star::frame::XModuleManager2 > m_xModuleMgr;
DocumentList m_aDocs;
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx
index b2f06d575477..494fa71ee7a1 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx
@@ -38,7 +38,7 @@
#include "com/sun/star/container/XNameAccess.hpp"
#include "com/sun/star/embed/XStorage.hpp"
-#include "comphelper/componentcontext.hxx"
+#include "comphelper/processfactory.hxx"
#include "ucbhelper/contentidentifier.hxx"
#include "tdoc_provider.hxx"
@@ -61,7 +61,7 @@ using namespace tdoc_ucp;
ContentProvider::ContentProvider(
const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
: ::ucbhelper::ContentProviderImplHelper( xSMgr ),
- m_xDocsMgr( new OfficeDocumentsManager( comphelper::ComponentContext(xSMgr).getUNOContext(), this ) ),
+ m_xDocsMgr( new OfficeDocumentsManager( comphelper::getComponentContext(xSMgr), this ) ),
m_xStgElemFac( new StorageElementFactory( xSMgr, m_xDocsMgr ) )
{
}