Simplify unocontrols::BaseControl hierarchy
Change-Id: I7c690cd429b2ac52f8aac602b4c9129bdd774b09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178052 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
parent
cd9976d2b1
commit
05eb50c396
8 changed files with 34 additions and 327 deletions
|
@ -33,9 +33,11 @@ struct IMPL_ControlInfo
|
|||
OUString sName;
|
||||
};
|
||||
|
||||
class BaseContainerControl : public css::awt::XControlModel
|
||||
, public css::awt::XControlContainer
|
||||
, public BaseControl
|
||||
using BaseContainerControl_BASE = cppu::ImplInheritanceHelper<BaseControl,
|
||||
css::awt::XControlModel,
|
||||
css::awt::XControlContainer>;
|
||||
|
||||
class BaseContainerControl : public BaseContainerControl_BASE
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -43,37 +45,6 @@ public:
|
|||
|
||||
virtual ~BaseContainerControl() override;
|
||||
|
||||
// XInterface
|
||||
|
||||
/**
|
||||
@short give answer, if interface is supported
|
||||
@descr The interfaces are searched by type.
|
||||
|
||||
@seealso XInterface
|
||||
|
||||
@param "rType" is the type of searched interface.
|
||||
|
||||
@return Any information about found interface
|
||||
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual css::uno::Any SAL_CALL queryInterface(
|
||||
const css::uno::Type& aType
|
||||
) override;
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
/**
|
||||
@short get information about supported interfaces
|
||||
@seealso XTypeProvider
|
||||
@return Sequence of types of all supported interfaces
|
||||
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
|
||||
|
||||
// XControl
|
||||
|
||||
virtual void SAL_CALL createPeer(
|
||||
|
@ -121,7 +92,7 @@ public:
|
|||
virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
|
||||
|
||||
protected:
|
||||
using WeakComponentImplHelper::disposing;
|
||||
using WeakComponentImplHelperBase::disposing;
|
||||
|
||||
virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
|
||||
const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
|
||||
|
|
|
@ -39,82 +39,19 @@ namespace unocontrols { class OMRCListenerMultiplexerHelper; }
|
|||
|
||||
namespace unocontrols {
|
||||
|
||||
class BaseControl : public css::lang::XServiceInfo
|
||||
, public css::awt::XPaintListener
|
||||
, public css::awt::XWindowListener
|
||||
, public css::awt::XView
|
||||
, public css::awt::XWindow
|
||||
, public css::awt::XControl
|
||||
, public cppu::BaseMutex
|
||||
, public ::cppu::WeakComponentImplHelper<>
|
||||
class BaseControl : public cppu::BaseMutex,
|
||||
public cppu::WeakComponentImplHelper<css::lang::XServiceInfo,
|
||||
css::awt::XPaintListener,
|
||||
css::awt::XWindowListener,
|
||||
css::awt::XView,
|
||||
css::awt::XWindow,
|
||||
css::awt::XControl>
|
||||
{
|
||||
public:
|
||||
BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
|
||||
|
||||
virtual ~BaseControl() override;
|
||||
|
||||
// XInterface
|
||||
|
||||
/**
|
||||
@short give answer, if interface is supported
|
||||
@descr The interfaces are searched by type.
|
||||
|
||||
@seealso XInterface
|
||||
|
||||
@param "rType" is the type of searched interface.
|
||||
|
||||
@return Any information about found interface
|
||||
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual css::uno::Any SAL_CALL queryInterface(
|
||||
const css::uno::Type& aType
|
||||
) override;
|
||||
|
||||
/**
|
||||
@short increment refcount
|
||||
@seealso XInterface
|
||||
@seealso release()
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual void SAL_CALL acquire() noexcept override;
|
||||
|
||||
/**
|
||||
@short decrement refcount
|
||||
@seealso XInterface
|
||||
@seealso acquire()
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual void SAL_CALL release() noexcept override;
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
/**
|
||||
@short get information about supported interfaces
|
||||
@seealso XTypeProvider
|
||||
@return Sequence of types of all supported interfaces
|
||||
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
|
||||
|
||||
/**
|
||||
@short get implementation id
|
||||
@descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
|
||||
Another way, cache is enabled.
|
||||
|
||||
@seealso XTypeProvider
|
||||
@return ID as Sequence of byte
|
||||
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
|
||||
|
||||
// XServiceInfo
|
||||
|
||||
virtual sal_Bool SAL_CALL supportsService(
|
||||
|
@ -265,7 +202,7 @@ public:
|
|||
virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
|
||||
|
||||
protected:
|
||||
using WeakComponentImplHelper::disposing;
|
||||
using WeakComponentImplHelperBase::disposing;
|
||||
|
||||
const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace unocontrols {
|
|||
// construct/destruct
|
||||
|
||||
BaseContainerControl::BaseContainerControl( const Reference< XComponentContext >& rxContext )
|
||||
: BaseControl ( rxContext )
|
||||
: BaseContainerControl_BASE(rxContext)
|
||||
, m_aListeners ( m_aMutex )
|
||||
{
|
||||
}
|
||||
|
@ -49,43 +49,6 @@ BaseContainerControl::~BaseContainerControl()
|
|||
{
|
||||
}
|
||||
|
||||
// XInterface
|
||||
|
||||
Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType )
|
||||
{
|
||||
// Ask for my own supported interfaces ...
|
||||
// Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper!
|
||||
Any aReturn ( ::cppu::queryInterface( rType ,
|
||||
static_cast< XControlModel* > ( this ) ,
|
||||
static_cast< XControlContainer* > ( this )
|
||||
)
|
||||
);
|
||||
|
||||
// If searched interface supported by this class ...
|
||||
if ( aReturn.hasValue() )
|
||||
{
|
||||
// ... return this information.
|
||||
return aReturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Else; ... ask baseclass for interfaces!
|
||||
return BaseControl::queryInterface( rType );
|
||||
}
|
||||
}
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
Sequence< Type > SAL_CALL BaseContainerControl::getTypes()
|
||||
{
|
||||
static OTypeCollection ourTypeCollection(
|
||||
cppu::UnoType<XControlModel>::get(),
|
||||
cppu::UnoType<XControlContainer>::get(),
|
||||
BaseControl::getTypes() );
|
||||
|
||||
return ourTypeCollection.getTypes();
|
||||
}
|
||||
|
||||
// XControl
|
||||
|
||||
void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& xToolkit ,
|
||||
|
|
|
@ -65,80 +65,6 @@ BaseControl::~BaseControl()
|
|||
{
|
||||
}
|
||||
|
||||
// XInterface
|
||||
|
||||
Any SAL_CALL BaseControl::queryInterface( const Type& rType )
|
||||
{
|
||||
// Ask for my own supported interfaces ...
|
||||
// Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper!
|
||||
Any aReturn ( ::cppu::queryInterface( rType ,
|
||||
static_cast< XPaintListener*> ( this ) ,
|
||||
static_cast< XWindowListener*> ( this ) ,
|
||||
static_cast< XView* > ( this ) ,
|
||||
static_cast< XWindow* > ( this ) ,
|
||||
static_cast< XServiceInfo* > ( this ) ,
|
||||
static_cast< XControl* > ( this )
|
||||
)
|
||||
);
|
||||
|
||||
// If searched interface supported by this class ...
|
||||
if ( aReturn.hasValue() )
|
||||
{
|
||||
// ... return this information.
|
||||
return aReturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Else; ... ask baseclass for interfaces!
|
||||
return WeakComponentImplHelper::queryInterface( rType );
|
||||
}
|
||||
}
|
||||
|
||||
// XInterface
|
||||
|
||||
void SAL_CALL BaseControl::acquire() noexcept
|
||||
{
|
||||
// Attention:
|
||||
// Don't use mutex or guard in this method!!! Is a method of XInterface.
|
||||
|
||||
// Forward to baseclass
|
||||
WeakComponentImplHelper::acquire();
|
||||
}
|
||||
|
||||
// XInterface
|
||||
|
||||
void SAL_CALL BaseControl::release() noexcept
|
||||
{
|
||||
// Attention:
|
||||
// Don't use mutex or guard in this method!!! Is a method of XInterface.
|
||||
|
||||
// Forward to baseclass
|
||||
WeakComponentImplHelper::release();
|
||||
}
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
Sequence< Type > SAL_CALL BaseControl::getTypes()
|
||||
{
|
||||
static OTypeCollection ourTypeCollection(
|
||||
cppu::UnoType<XPaintListener>::get(),
|
||||
cppu::UnoType<XWindowListener>::get(),
|
||||
cppu::UnoType<XView>::get(),
|
||||
cppu::UnoType<XWindow>::get(),
|
||||
cppu::UnoType<XServiceInfo>::get(),
|
||||
cppu::UnoType<XControl>::get(),
|
||||
WeakComponentImplHelper::getTypes() );
|
||||
|
||||
return ourTypeCollection.getTypes();
|
||||
}
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId()
|
||||
{
|
||||
return css::uno::Sequence<sal_Int8>();
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
|
||||
OUString SAL_CALL BaseControl::getImplementationName()
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <com/sun/star/frame/XDispatch.hpp>
|
||||
#include <com/sun/star/util/URLTransformer.hpp>
|
||||
#include <com/sun/star/util/XURLTransformer.hpp>
|
||||
#include <comphelper/sequence.hxx>
|
||||
#include <cppuhelper/queryinterface.hxx>
|
||||
#include <cppuhelper/typeprovider.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
|
@ -58,7 +59,7 @@ enum PropertyHandle // values represent index in PropertyArray
|
|||
// construct/destruct
|
||||
|
||||
FrameControl::FrameControl( const Reference< XComponentContext >& rxContext)
|
||||
: BaseControl ( rxContext )
|
||||
: FrameControl_BASE ( rxContext )
|
||||
, OBroadcastHelper ( m_aMutex )
|
||||
, OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) )
|
||||
, m_aConnectionPointContainer ( new OConnectionPointContainerHelper(m_aMutex) )
|
||||
|
@ -72,23 +73,10 @@ FrameControl::~FrameControl()
|
|||
// XInterface
|
||||
Any SAL_CALL FrameControl::queryInterface( const Type& rType )
|
||||
{
|
||||
// Ask for my own supported interfaces ...
|
||||
// Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper!
|
||||
Any aReturn ( ::cppu::queryInterface( rType ,
|
||||
static_cast< XControlModel* > ( this ) ,
|
||||
static_cast< XConnectionPointContainer* > ( this )
|
||||
)
|
||||
);
|
||||
|
||||
Any aReturn = OPropertySetHelper::queryInterface(rType);
|
||||
if (aReturn.hasValue())
|
||||
return aReturn;
|
||||
|
||||
// If searched interface not supported by this class ...
|
||||
// ... ask baseclasses.
|
||||
aReturn = OPropertySetHelper::queryInterface(rType);
|
||||
if (aReturn.hasValue())
|
||||
return aReturn;
|
||||
return BaseControl::queryInterface(rType);
|
||||
return FrameControl_BASE::queryInterface(rType);
|
||||
}
|
||||
|
||||
// XInterface
|
||||
|
@ -98,7 +86,7 @@ void SAL_CALL FrameControl::acquire() noexcept
|
|||
// Don't use mutex or guard in this method!!! Is a method of XInterface.
|
||||
|
||||
// Forward to baseclass
|
||||
BaseControl::acquire();
|
||||
FrameControl_BASE::acquire();
|
||||
}
|
||||
|
||||
// XInterface
|
||||
|
@ -108,20 +96,16 @@ void SAL_CALL FrameControl::release() noexcept
|
|||
// Don't use mutex or guard in this method!!! Is a method of XInterface.
|
||||
|
||||
// Forward to baseclass
|
||||
BaseControl::release();
|
||||
FrameControl_BASE::release();
|
||||
}
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
Sequence< Type > SAL_CALL FrameControl::getTypes()
|
||||
{
|
||||
static OTypeCollection ourTypeCollection(
|
||||
cppu::UnoType<XControlModel>::get(),
|
||||
cppu::UnoType<XControlContainer>::get(),
|
||||
cppu::UnoType<XConnectionPointContainer>::get(),
|
||||
BaseControl::getTypes() );
|
||||
|
||||
return ourTypeCollection.getTypes();
|
||||
static Sequence myTypes = comphelper::concatSequences(FrameControl_BASE::getTypes(),
|
||||
OPropertySetHelper::getTypes());
|
||||
return myTypes;
|
||||
}
|
||||
|
||||
OUString FrameControl::getImplementationName()
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace unocontrols {
|
|||
// construct/destruct
|
||||
|
||||
ProgressBar::ProgressBar( const Reference< XComponentContext >& rxContext )
|
||||
: BaseControl ( rxContext )
|
||||
: ProgressBar_BASE ( rxContext )
|
||||
, m_bHorizontal ( PROGRESSBAR_DEFAULT_HORIZONTAL )
|
||||
, m_aBlockSize ( PROGRESSBAR_DEFAULT_BLOCKDIMENSION )
|
||||
, m_nForegroundColor ( PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR )
|
||||
|
@ -50,57 +50,6 @@ ProgressBar::~ProgressBar()
|
|||
{
|
||||
}
|
||||
|
||||
// XInterface
|
||||
Any SAL_CALL ProgressBar::queryInterface( const Type& rType )
|
||||
{
|
||||
// Ask for my own supported interfaces ...
|
||||
// Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper!
|
||||
Any aReturn ( ::cppu::queryInterface( rType ,
|
||||
static_cast< XControlModel* > ( this ) ,
|
||||
static_cast< XProgressBar* > ( this )
|
||||
)
|
||||
);
|
||||
|
||||
if (aReturn.hasValue())
|
||||
return aReturn;
|
||||
|
||||
// If searched interface not supported by this class ...
|
||||
// ... ask baseclasses.
|
||||
return BaseControl::queryInterface(rType);
|
||||
}
|
||||
|
||||
// XInterface
|
||||
void SAL_CALL ProgressBar::acquire() noexcept
|
||||
{
|
||||
// Attention:
|
||||
// Don't use mutex or guard in this method!!! Is a method of XInterface.
|
||||
|
||||
// Forward to baseclass
|
||||
BaseControl::acquire();
|
||||
}
|
||||
|
||||
// XInterface
|
||||
void SAL_CALL ProgressBar::release() noexcept
|
||||
{
|
||||
// Attention:
|
||||
// Don't use mutex or guard in this method!!! Is a method of XInterface.
|
||||
|
||||
// Forward to baseclass
|
||||
BaseControl::release();
|
||||
}
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
Sequence< Type > SAL_CALL ProgressBar::getTypes()
|
||||
{
|
||||
static OTypeCollection ourTypeCollection(
|
||||
cppu::UnoType<XControlModel>::get(),
|
||||
cppu::UnoType<XProgressBar>::get(),
|
||||
BaseControl::getTypes() );
|
||||
|
||||
return ourTypeCollection.getTypes();
|
||||
}
|
||||
|
||||
// XProgressBar
|
||||
|
||||
void SAL_CALL ProgressBar::setForegroundColor( sal_Int32 nColor )
|
||||
|
|
|
@ -31,9 +31,10 @@ namespace unocontrols { class OConnectionPointContainerHelper; }
|
|||
|
||||
namespace unocontrols {
|
||||
|
||||
class FrameControl final : public css::awt::XControlModel
|
||||
, public css::lang::XConnectionPointContainer
|
||||
, public BaseControl // This order is necessary for right initialization of m_aMutex!
|
||||
using FrameControl_BASE = cppu::ImplInheritanceHelper<BaseControl, css::awt::XControlModel,
|
||||
css::lang::XConnectionPointContainer>;
|
||||
|
||||
class FrameControl final : public FrameControl_BASE // This order is necessary for right initialization of m_aMutex!
|
||||
, public ::cppu::OBroadcastHelper
|
||||
, public ::cppu::OPropertySetHelper
|
||||
{
|
||||
|
|
|
@ -41,9 +41,11 @@ constexpr auto PROGRESSBAR_DEFAULT_BLOCKVALUE = 1;
|
|||
constexpr sal_Int32 PROGRESSBAR_LINECOLOR_BRIGHT = sal_Int32(COL_WHITE);
|
||||
constexpr sal_Int32 PROGRESSBAR_LINECOLOR_SHADOW = sal_Int32(COL_BLACK);
|
||||
|
||||
class ProgressBar final : public css::awt::XControlModel
|
||||
, public css::awt::XProgressBar
|
||||
, public BaseControl
|
||||
using ProgressBar_BASE = cppu::ImplInheritanceHelper<BaseControl,
|
||||
css::awt::XControlModel,
|
||||
css::awt::XProgressBar>;
|
||||
|
||||
class ProgressBar final : public ProgressBar_BASE
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -51,32 +53,6 @@ public:
|
|||
|
||||
virtual ~ProgressBar() override;
|
||||
|
||||
// XInterface
|
||||
|
||||
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
|
||||
|
||||
/**
|
||||
@short increment refcount
|
||||
@seealso XInterface
|
||||
@seealso release()
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual void SAL_CALL acquire() noexcept override;
|
||||
|
||||
/**
|
||||
@short decrement refcount
|
||||
@seealso XInterface
|
||||
@seealso acquire()
|
||||
@onerror A RuntimeException is thrown.
|
||||
*/
|
||||
|
||||
virtual void SAL_CALL release() noexcept override;
|
||||
|
||||
// XTypeProvider
|
||||
|
||||
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
|
||||
|
||||
// XProgressBar
|
||||
|
||||
virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override;
|
||||
|
|
Loading…
Reference in a new issue