summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-02-23 09:58:44 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-02-23 09:58:44 +0100
commit2a722a41a6819844227216dcf884c49f916eb91a (patch)
treeb08d3588e11b8e415612c3055d4407187ff4ce2e /ucb/source/ucp/tdoc/tdoc_docmgr.cxx
parent4940c2e354be0e577e96de60976e84be1235cf28 (diff)
parent87c0b74710557e0ae8669f0873a7e49dff222ff4 (diff)
debuglevels: merged to-be-m101
Diffstat (limited to 'ucb/source/ucp/tdoc/tdoc_docmgr.cxx')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.cxx105
1 files changed, 91 insertions, 14 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index 261bedb7b4f9..1e24940e5ecd 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -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() )
{
@@ -192,10 +238,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!" );
@@ -206,12 +261,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 >
@@ -232,8 +293,6 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent(
rtl::OUString aDocId( (*it).first );
m_pDocEventListener->notifyDocumentClosed( aDocId );
}
-
-
break;
}
++it;
@@ -242,8 +301,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(
@@ -311,7 +380,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;
@@ -338,7 +407,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.
@@ -479,6 +548,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 );
}
}
}