summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorRelease Engineering <releng@openoffice.org>2011-02-18 11:14:19 +0100
committerRelease Engineering <releng@openoffice.org>2011-02-18 11:14:19 +0100
commit1e8a500fdd8939caecb9ed760957e09c0d1b90d6 (patch)
tree546b92a8ac6cc6723ec5c9f65147c3f594e246d5 /ucb
parentaed6bcebef74ed9b4260aca16e20586babef45ca (diff)
parentabc679ccf476074d188c8e60e930cd51926685e2 (diff)
merged DEV300
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.cxx107
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.hxx36
2 files changed, 126 insertions, 17 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index 8361e4bbbc..5bd774d618 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -27,14 +27,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_ucb.hxx"
+
/**************************************************************************
TODO
**************************************************************************
- - filter unwanted models notified by global document event broadcaster
- - help documents
- - others, which I don't know yet
-
*************************************************************************/
#include "osl/diagnose.h"
@@ -44,12 +41,13 @@
#include "comphelper/namedvaluecollection.hxx"
#include "comphelper/documentinfo.hxx"
+#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/XStorageBasedDocument.hpp"
#include "com/sun/star/frame/XStorable.hpp"
#include "com/sun/star/lang/DisposedException.hpp"
-#include "com/sun/star/document/XStorageBasedDocument.hpp"
-#include "com/sun/star/awt/XTopWindow.hpp"
+#include "com/sun/star/util/XCloseBroadcaster.hpp"
#include "tdoc_docmgr.hxx"
@@ -60,6 +58,53 @@ using ::comphelper::DocumentInfo;
//=========================================================================
//=========================================================================
//
+// OfficeDocumentsCloseListener Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// util::XCloseListener
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::queryClosing(
+ const lang::EventObject& /*Source*/, sal_Bool /*GetsOwnership*/ )
+ throw ( util::CloseVetoException,
+ uno::RuntimeException )
+{
+}
+
+//=========================================================================
+void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::notifyClosing(
+ const lang::EventObject& Source )
+ throw ( uno::RuntimeException )
+{
+ document::EventObject aDocEvent;
+ aDocEvent.Source = Source.Source;
+ aDocEvent.EventName = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "OfficeDocumentsListener::notifyClosing" ) );
+ m_pManager->notifyEvent( aDocEvent );
+}
+
+//=========================================================================
+//
+// lang::XEventListener (base of util::XCloseListener)
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::disposing(
+ const lang::EventObject& /*Source*/ )
+ throw ( uno::RuntimeException )
+{
+}
+
+//=========================================================================
+//=========================================================================
+//
// OfficeDocumentsManager Implementation.
//
//=========================================================================
@@ -70,7 +115,8 @@ OfficeDocumentsManager::OfficeDocumentsManager(
OfficeDocumentsEventListener * pDocEventListener )
: m_xSMgr( xSMgr ),
m_xDocEvtNotifier( createDocumentEventNotifier( xSMgr ) ),
- m_pDocEventListener( pDocEventListener )
+ m_pDocEventListener( pDocEventListener ),
+ m_xDocCloseListener( new OfficeDocumentsCloseListener( this ) )
{
if ( m_xDocEvtNotifier.is() )
{
@@ -188,10 +234,19 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
OSL_ENSURE( xStorage.is(), "Got no document storage!" );
rtl:: OUString aDocId = getDocumentId( Event.Source );
- rtl:: OUString aTitle = DocumentInfo::getDocumentTitle( uno::Reference< frame::XModel >( Event.Source, uno::UNO_QUERY ) );
+ rtl:: OUString aTitle = DocumentInfo::getDocumentTitle(
+ uno::Reference< frame::XModel >( Event.Source, uno::UNO_QUERY ) );
m_aDocs[ aDocId ] = StorageInfo( aTitle, xStorage, xModel );
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster(
+ Event.Source, uno::UNO_QUERY );
+ OSL_ENSURE( xCloseBroadcaster.is(),
+ "OnLoadFinished/OnCreate event: got no close broadcaster!" );
+
+ if ( xCloseBroadcaster.is() )
+ xCloseBroadcaster->addCloseListener( m_xDocCloseListener );
+
// Propagate document closure.
OSL_ENSURE( m_pDocEventListener,
"OnLoadFinished/OnCreate event: no owner for insert event propagation!" );
@@ -202,12 +257,18 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
}
}
else if ( Event.EventName.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( "OnUnload" ) ) )
+ RTL_CONSTASCII_STRINGPARAM( "OfficeDocumentsListener::notifyClosing" ) ) )
{
if ( isOfficeDocument( Event.Source ) )
{
// Document has been closed (unloaded)
+ // #163732# - Official event "OnUnload" does not work here. Event
+ // gets fired to early. Other OnUnload listeners called after this
+ // listener may still need TDOC access to the document. Remove the
+ // document from TDOC docs list on XCloseListener::notifyClosing.
+ // See OfficeDocumentsManager::OfficeDocumentsListener::notifyClosing.
+
osl::MutexGuard aGuard( m_aMtx );
uno::Reference< frame::XModel >
@@ -228,8 +289,6 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
rtl::OUString aDocId( (*it).first );
m_pDocEventListener->notifyDocumentClosed( aDocId );
}
-
-
break;
}
++it;
@@ -238,8 +297,18 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
OSL_ENSURE( it != m_aDocs.end(),
"OnUnload event notified for unknown document!" );
- if( it != m_aDocs.end() )
+ if ( it != m_aDocs.end() )
+ {
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster(
+ Event.Source, uno::UNO_QUERY );
+ OSL_ENSURE( xCloseBroadcaster.is(),
+ "OnUnload event: got no XCloseBroadcaster from XModel" );
+
+ if ( xCloseBroadcaster.is() )
+ xCloseBroadcaster->removeCloseListener( m_xDocCloseListener );
+
m_aDocs.erase( it );
+ }
}
}
else if ( Event.EventName.equalsAsciiL(
@@ -307,7 +376,7 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
(*it).second.xStorage = xStorage;
// Adjust title.
- (*it).second.aTitle = DocumentInfo::getDocumentTitle( uno::Reference< frame::XModel >( Event.Source, uno::UNO_QUERY ) );
+ (*it).second.aTitle = DocumentInfo::getDocumentTitle( xModel );
break;
}
++it;
@@ -334,7 +403,7 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
if ( (*it).second.xModel == xModel )
{
// Adjust title.
- rtl:: OUString aTitle = DocumentInfo::getDocumentTitle( uno::Reference< frame::XModel >( Event.Source, uno::UNO_QUERY ) );
+ rtl:: OUString aTitle = DocumentInfo::getDocumentTitle( xModel );
(*it).second.aTitle = aTitle;
// Adjust storage.
@@ -475,6 +544,14 @@ void OfficeDocumentsManager::buildDocumentsList()
m_aDocs[ aDocId ]
= StorageInfo( aTitle, xStorage, xModel );
+
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster(
+ xModel, uno::UNO_QUERY );
+ OSL_ENSURE( xCloseBroadcaster.is(),
+ "buildDocumentsList: got no close broadcaster!" );
+
+ if ( xCloseBroadcaster.is() )
+ xCloseBroadcaster->addCloseListener( m_xDocCloseListener );
}
}
}
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
index c9d68e5f7f..b1c0ed41d9 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -39,6 +39,7 @@
#include "com/sun/star/embed/XStorage.hpp"
#include "com/sun/star/frame/XModel.hpp"
#include "com/sun/star/frame/XModuleManager.hpp"
+#include "com/sun/star/util/XCloseListener.hpp"
namespace tdoc_ucp {
@@ -88,6 +89,33 @@ namespace tdoc_ucp {
class OfficeDocumentsManager :
public cppu::WeakImplHelper1< com::sun::star::document::XEventListener >
{
+ class OfficeDocumentsCloseListener :
+ public cppu::WeakImplHelper1< com::sun::star::util::XCloseListener >
+
+ {
+ public:
+ OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
+ : m_pManager( pMgr ) {};
+
+ // util::XCloseListener
+ virtual void SAL_CALL queryClosing(
+ const ::com::sun::star::lang::EventObject& Source,
+ ::sal_Bool GetsOwnership )
+ throw (::com::sun::star::util::CloseVetoException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL notifyClosing(
+ const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // lang::XEventListener (base of util::XCloseListener)
+ virtual void SAL_CALL disposing(
+ const com::sun::star::lang::EventObject & Source )
+ throw ( com::sun::star::uno::RuntimeException );
+ private:
+ OfficeDocumentsManager * m_pManager;
+ };
+
public:
OfficeDocumentsManager(
const com::sun::star::uno::Reference<
@@ -131,7 +159,9 @@ namespace tdoc_ucp {
createDocumentEventNotifier(
const com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
+
void buildDocumentsList();
+
bool
isOfficeDocument(
const com::sun::star::uno::Reference<
@@ -163,9 +193,11 @@ namespace tdoc_ucp {
com::sun::star::uno::Reference<
com::sun::star::document::XEventBroadcaster > m_xDocEvtNotifier;
com::sun::star::uno::Reference<
- com::sun::star::frame::XModuleManager > m_xModuleMgr;
+ com::sun::star::frame::XModuleManager > m_xModuleMgr;
DocumentList m_aDocs;
OfficeDocumentsEventListener * m_pDocEventListener;
+ com::sun::star::uno::Reference<
+ com::sun::star::util::XCloseListener > m_xDocCloseListener;
};
} // namespace tdoc_ucp