merge vcl::DisplayConnectionDispatch with vcl::DisplayConnection

Change-Id: I0eb83905896e1d7549a5bd4adde45e9d69209401
Reviewed-on: https://gerrit.libreoffice.org/26888
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin
2016-07-04 10:41:44 +02:00
committed by Noel Grandin
parent 3459ab4a5d
commit c752aad433
10 changed files with 51 additions and 90 deletions

View File

@@ -390,7 +390,6 @@ merge tdoc_ucp::OfficeDocumentsEventListener with tdoc_ucp::ContentProvider
merge toolkit::ScrollableInterface with toolkit::ScrollableWrapper merge toolkit::ScrollableInterface with toolkit::ScrollableWrapper
merge unographic::GraphicTransformer with unographic::Graphic merge unographic::GraphicTransformer with unographic::Graphic
merge vcl::DeletionNotifier with SalFrame merge vcl::DeletionNotifier with SalFrame
merge vcl::DisplayConnectionDispatch with vcl::DisplayConnection
merge vcl::ExtOutDevData with vcl::PDFExtOutDevData merge vcl::ExtOutDevData with vcl::PDFExtOutDevData
merge vcl::SolarThreadExecutor with vcl::solarthread::detail::GenericSolarThreadExecutor merge vcl::SolarThreadExecutor with vcl::solarthread::detail::GenericSolarThreadExecutor
merge vclcanvas::DeviceHelper with vclcanvas::SpriteDeviceHelper merge vclcanvas::DeviceHelper with vclcanvas::SpriteDeviceHelper

View File

@@ -320,11 +320,11 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/helper/canvasbitmap \ vcl/source/helper/canvasbitmap \
vcl/source/helper/canvastools \ vcl/source/helper/canvastools \
vcl/source/helper/commandinfoprovider \ vcl/source/helper/commandinfoprovider \
vcl/source/helper/displayconnectiondispatch \
vcl/source/helper/evntpost \ vcl/source/helper/evntpost \
vcl/source/helper/lazydelete \ vcl/source/helper/lazydelete \
vcl/source/helper/strhelper \ vcl/source/helper/strhelper \
vcl/source/helper/threadex \ vcl/source/helper/threadex \
vcl/source/helper/xconnection \
vcl/source/app/brand \ vcl/source/app/brand \
vcl/source/app/dbggui \ vcl/source/app/dbggui \
vcl/source/app/dndhelp \ vcl/source/app/dndhelp \

View File

@@ -21,24 +21,46 @@
#define INCLUDED_VCL_INC_DISPLAYCONNECTIONDISPATCH_HXX #define INCLUDED_VCL_INC_DISPLAYCONNECTIONDISPATCH_HXX
#include <sal/config.h> #include <sal/config.h>
#include <com/sun/star/awt/XDisplayConnection.hpp> #include <com/sun/star/awt/XDisplayConnection.hpp>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <list>
namespace vcl { namespace vcl {
class DisplayConnectionDispatch: class DisplayConnectionDispatch :
public cppu::WeakImplHelper< css::awt::XDisplayConnection > public cppu::WeakImplHelper< css::awt::XDisplayConnection >
{ {
::osl::Mutex m_aMutex;
::std::list< css::uno::Reference< css::awt::XEventHandler > >
m_aHandlers;
::std::list< css::uno::Reference< css::awt::XEventHandler > >
m_aErrorHandlers;
css::uno::Any m_aAny;
public: public:
virtual bool dispatchEvent(void * pData, int nBytes) = 0; DisplayConnectionDispatch();
~DisplayConnectionDispatch() override;
void start();
void terminate();
bool dispatchEvent( void* pData, int nBytes );
// XDisplayConnection
virtual void SAL_CALL addEventHandler( const css::uno::Any& window, const css::uno::Reference< css::awt::XEventHandler >& handler, sal_Int32 eventMask ) throw(std::exception) override;
virtual void SAL_CALL removeEventHandler( const css::uno::Any& window, const css::uno::Reference< css::awt::XEventHandler >& handler ) throw(std::exception) override;
virtual void SAL_CALL addErrorHandler( const css::uno::Reference< css::awt::XEventHandler >& handler ) throw(std::exception) override;
virtual void SAL_CALL removeErrorHandler( const css::uno::Reference< css::awt::XEventHandler >& handler ) throw(std::exception) override;
virtual css::uno::Any SAL_CALL getIdentifier() throw(std::exception) override;
protected:
virtual ~DisplayConnectionDispatch() {}
}; };
} }
#endif // INCLUDED_VCL_INC_DISPLAYCONNECTIONDISPATCH_HXX #endif // INCLUDED_VCL_INC_DISPLAYCONNECTIONDISPATCH_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -153,8 +153,7 @@ public:
void SetEventCallback( rtl::Reference< vcl::DisplayConnectionDispatch > const & pInstance ) void SetEventCallback( rtl::Reference< vcl::DisplayConnectionDispatch > const & pInstance )
{ m_pEventInst = pInstance; } { m_pEventInst = pInstance; }
bool CallEventCallback( void* pEvent, int nBytes ) bool CallEventCallback( void* pEvent, int nBytes );
{ return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes ); }
enum ConnectionIdentifierType { AsciiCString, Blob }; enum ConnectionIdentifierType { AsciiCString, Blob };
virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) = 0; virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) = 0;

View File

@@ -32,7 +32,7 @@
#include "vcleventlisteners.hxx" #include "vcleventlisteners.hxx"
#include "impfontcache.hxx" #include "impfontcache.hxx"
#include "salwtype.hxx" #include "salwtype.hxx"
#include "xconnection.hxx" #include "displayconnectiondispatch.hxx"
#include <unordered_map> #include <unordered_map>
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
@@ -87,7 +87,7 @@ class VclEventListeners2;
class SalData; class SalData;
class OpenGLContext; class OpenGLContext;
namespace vcl { class DisplayConnection; class SettingsConfigItem; class DeleteOnDeinitBase; } namespace vcl { class DisplayConnectionDispatch; class SettingsConfigItem; class DeleteOnDeinitBase; }
class LocaleConfigurationListener : public utl::ConfigurationListener class LocaleConfigurationListener : public utl::ConfigurationListener
{ {
@@ -334,7 +334,7 @@ struct ImplSVData
vcl::CommandInfoProvider* mpCommandInfoProvider; vcl::CommandInfoProvider* mpCommandInfoProvider;
oslThreadIdentifier mnMainThreadId; oslThreadIdentifier mnMainThreadId;
rtl::Reference< vcl::DisplayConnection > mxDisplayConnection; rtl::Reference< vcl::DisplayConnectionDispatch > mxDisplayConnection;
css::uno::Reference< css::lang::XComponent > mxAccessBridge; css::uno::Reference< css::lang::XComponent > mxAccessBridge;
vcl::SettingsConfigItem* mpSettingsConfigItem; vcl::SettingsConfigItem* mpSettingsConfigItem;

View File

@@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_VCL_INC_XCONNECTION_HXX
#define INCLUDED_VCL_INC_XCONNECTION_HXX
#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include "displayconnectiondispatch.hxx"
#include <list>
namespace vcl {
class DisplayConnection :
public DisplayConnectionDispatch
{
::osl::Mutex m_aMutex;
::std::list< css::uno::Reference< css::awt::XEventHandler > >
m_aHandlers;
::std::list< css::uno::Reference< css::awt::XEventHandler > >
m_aErrorHandlers;
css::uno::Any m_aAny;
public:
DisplayConnection();
virtual ~DisplayConnection();
void start();
void terminate();
virtual bool dispatchEvent( void* pData, int nBytes ) override;
// XDisplayConnection
virtual void SAL_CALL addEventHandler( const css::uno::Any& window, const css::uno::Reference< css::awt::XEventHandler >& handler, sal_Int32 eventMask ) throw(std::exception) override;
virtual void SAL_CALL removeEventHandler( const css::uno::Any& window, const css::uno::Reference< css::awt::XEventHandler >& handler ) throw(std::exception) override;
virtual void SAL_CALL addErrorHandler( const css::uno::Reference< css::awt::XEventHandler >& handler ) throw(std::exception) override;
virtual void SAL_CALL removeErrorHandler( const css::uno::Reference< css::awt::XEventHandler >& handler ) throw(std::exception) override;
virtual css::uno::Any SAL_CALL getIdentifier() throw(std::exception) override;
};
}
#endif // INCLUDED_VCL_INC_XCONNECTION_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -88,6 +88,11 @@ void SalInstance::DestroyMenuItem( SalMenuItem* pItem )
OSL_ENSURE( pItem == nullptr, "DestroyMenu called with non-native menus" ); OSL_ENSURE( pItem == nullptr, "DestroyMenu called with non-native menus" );
} }
bool SalInstance::CallEventCallback( void* pEvent, int nBytes )
{
return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes );
}
SalTimer::~SalTimer() SalTimer::~SalTimer()
{ {
} }

View File

@@ -60,7 +60,7 @@
#include "salsys.hxx" #include "salsys.hxx"
#include "svdata.hxx" #include "svdata.hxx"
#include "salimestatus.hxx" #include "salimestatus.hxx"
#include "xconnection.hxx" #include "displayconnectiondispatch.hxx"
#include "window.h" #include "window.h"
#include "accmgr.hxx" #include "accmgr.hxx"
#include "idlemgr.hxx" #include "idlemgr.hxx"
@@ -1573,7 +1573,7 @@ css::uno::Reference< css::awt::XDisplayConnection > Application::GetDisplayConne
if( !pSVData->mxDisplayConnection.is() ) if( !pSVData->mxDisplayConnection.is() )
{ {
pSVData->mxDisplayConnection.set( new vcl::DisplayConnection ); pSVData->mxDisplayConnection.set( new vcl::DisplayConnectionDispatch );
pSVData->mxDisplayConnection->start(); pSVData->mxDisplayConnection->start();
} }

View File

@@ -70,7 +70,7 @@
#include "salsys.hxx" #include "salsys.hxx"
#include "saltimer.hxx" #include "saltimer.hxx"
#include "salimestatus.hxx" #include "salimestatus.hxx"
#include "xconnection.hxx" #include "displayconnectiondispatch.hxx"
#include <config_features.h> #include <config_features.h>
#if HAVE_FEATURE_OPENGL #if HAVE_FEATURE_OPENGL

View File

@@ -19,7 +19,7 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include "xconnection.hxx" #include "displayconnectiondispatch.hxx"
#include "svdata.hxx" #include "svdata.hxx"
#include "salinst.hxx" #include "salinst.hxx"
@@ -28,7 +28,7 @@ using namespace vcl;
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::awt; using namespace com::sun::star::awt;
DisplayConnection::DisplayConnection() DisplayConnectionDispatch::DisplayConnectionDispatch()
{ {
SalInstance::ConnectionIdentifierType eType; SalInstance::ConnectionIdentifierType eType;
int nBytes; int nBytes;
@@ -44,17 +44,17 @@ DisplayConnection::DisplayConnection()
} }
} }
DisplayConnection::~DisplayConnection() DisplayConnectionDispatch::~DisplayConnectionDispatch()
{} {}
void DisplayConnection::start() void DisplayConnectionDispatch::start()
{ {
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
pSVData->mpDefInst->SetEventCallback( this ); pSVData->mpDefInst->SetEventCallback( this );
} }
void DisplayConnection::terminate() void DisplayConnectionDispatch::terminate()
{ {
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
@@ -73,40 +73,40 @@ void DisplayConnection::terminate()
(*it)->handleEvent( aEvent ); (*it)->handleEvent( aEvent );
} }
void SAL_CALL DisplayConnection::addEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler, sal_Int32 /*eventMask*/ ) throw(std::exception) void SAL_CALL DisplayConnectionDispatch::addEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler, sal_Int32 /*eventMask*/ ) throw(std::exception)
{ {
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
m_aHandlers.push_back( handler ); m_aHandlers.push_back( handler );
} }
void SAL_CALL DisplayConnection::removeEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler ) throw(std::exception) void SAL_CALL DisplayConnectionDispatch::removeEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler ) throw(std::exception)
{ {
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
m_aHandlers.remove( handler ); m_aHandlers.remove( handler );
} }
void SAL_CALL DisplayConnection::addErrorHandler( const css::uno::Reference< XEventHandler >& handler ) throw(std::exception) void SAL_CALL DisplayConnectionDispatch::addErrorHandler( const css::uno::Reference< XEventHandler >& handler ) throw(std::exception)
{ {
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
m_aErrorHandlers.push_back( handler ); m_aErrorHandlers.push_back( handler );
} }
void SAL_CALL DisplayConnection::removeErrorHandler( const css::uno::Reference< XEventHandler >& handler ) throw(std::exception) void SAL_CALL DisplayConnectionDispatch::removeErrorHandler( const css::uno::Reference< XEventHandler >& handler ) throw(std::exception)
{ {
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
m_aErrorHandlers.remove( handler ); m_aErrorHandlers.remove( handler );
} }
Any SAL_CALL DisplayConnection::getIdentifier() throw(std::exception) Any SAL_CALL DisplayConnectionDispatch::getIdentifier() throw(std::exception)
{ {
return m_aAny; return m_aAny;
} }
bool DisplayConnection::dispatchEvent( void* pData, int nBytes ) bool DisplayConnectionDispatch::dispatchEvent( void* pData, int nBytes )
{ {
SolarMutexReleaser aRel; SolarMutexReleaser aRel;