use more concrete UNO types in dbaccess

Change-Id: Ibcf54e3bbdad4888c5da1f52f636951356e0aa51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173818
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2024-09-20 15:30:38 +02:00
parent 59915ec921
commit fff43a2e76
2 changed files with 13 additions and 14 deletions

View File

@@ -18,6 +18,7 @@
*/
#include "documenteventexecutor.hxx"
#include "databasedocument.hxx"
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
@@ -60,11 +61,11 @@ namespace dbaccess
namespace
{
void lcl_dispatchScriptURL_throw(
css::uno::WeakReference< css::document::XEventsSupplier > const & xWeakDocument,
::unotools::WeakReference< ODatabaseDocument > const & xWeakDocument,
css::uno::Reference< css::util::XURLTransformer > const & xURLTransformer,
const OUString& _rScriptURL, const DocumentEvent& _rTrigger )
{
Reference< XModel > xDocument( xWeakDocument.get(), UNO_QUERY_THROW );
rtl::Reference< ODatabaseDocument > xDocument( xWeakDocument.get() );
Reference< XController > xController( xDocument->getCurrentController() );
Reference< XDispatchProvider > xDispProv;
@@ -102,14 +103,12 @@ namespace dbaccess
// DocumentEventExecutor
DocumentEventExecutor::DocumentEventExecutor( const Reference<XComponentContext> & _rContext,
const Reference< XEventsSupplier >& _rxDocument )
const rtl::Reference< ODatabaseDocument >& _rxDocument )
:mxDocument( _rxDocument )
{
Reference< XDocumentEventBroadcaster > xBroadcaster( _rxDocument, UNO_QUERY_THROW );
osl_atomic_increment( &m_refCount );
{
xBroadcaster->addDocumentEventListener( this );
_rxDocument->addDocumentEventListener( this );
}
osl_atomic_decrement( &m_refCount );
@@ -129,18 +128,16 @@ namespace dbaccess
void SAL_CALL DocumentEventExecutor::documentEventOccured( const DocumentEvent& Event )
{
Reference< XEventsSupplier > xEventsSupplier( mxDocument.get(), UNO_QUERY );
if ( !xEventsSupplier )
rtl::Reference< ODatabaseDocument > xDocument( mxDocument.get() );
if ( !xDocument )
{
OSL_FAIL( "DocumentEventExecutor::documentEventOccurred: no document anymore, but still being notified?" );
return;
}
Reference< XModel > xDocument( xEventsSupplier, UNO_QUERY_THROW );
try
{
Reference< XNameAccess > xDocEvents( xEventsSupplier->getEvents(), UNO_SET_THROW );
Reference< XNameAccess > xDocEvents( xDocument->getEvents(), UNO_SET_THROW );
if ( !xDocEvents->hasByName( Event.EventName ) )
{
// this is worth an assertion: We are listener at the very same document which we just asked

View File

@@ -23,13 +23,15 @@
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/weakref.hxx>
#include <unotools/weakref.hxx>
namespace com::sun::star::uno { class XComponentContext; }
namespace com::sun::star::util { class XURLTransformer; }
namespace dbaccess
{
class ODatabaseDocument;
// DocumentEventExecutor
typedef ::cppu::WeakImplHelper < css::document::XDocumentEventListener
> DocumentEventExecutor_Base;
@@ -38,7 +40,7 @@ namespace dbaccess
public:
DocumentEventExecutor(
const css::uno::Reference< css::uno::XComponentContext >& _rContext,
const css::uno::Reference< css::document::XEventsSupplier >& _rxDocument );
const rtl::Reference< ODatabaseDocument >& _rxDocument );
protected:
virtual ~DocumentEventExecutor() override;
@@ -49,7 +51,7 @@ namespace dbaccess
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
private:
css::uno::WeakReference< css::document::XEventsSupplier > mxDocument;
unotools::WeakReference< ODatabaseDocument > mxDocument;
css::uno::Reference< css::util::XURLTransformer > mxURLTransformer;
};