From 482f97926e1090c50ef05eed6badf311a7aa02f9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 7 Jul 2014 11:26:58 +0200 Subject: use SimpleReferenceObject in svtools module to replace hand-rolled version Change-Id: I7a1048ff1ea335c3934fe7e91a09489a4d7aeb96 --- accessibility/source/helper/acc_factory.cxx | 24 --------- include/svtools/accessiblefactory.hxx | 5 +- include/svtools/toolpanel/decklayouter.hxx | 3 +- include/svtools/toolpanel/drawerlayouter.hxx | 7 +-- include/svtools/toolpanel/refbase.hxx | 75 ---------------------------- include/svtools/toolpanel/tablayouter.hxx | 8 +-- include/svtools/toolpanel/toolpanel.hxx | 9 ++-- include/toolkit/helper/accessiblefactory.hxx | 2 +- sfx2/Library_sfx.mk | 1 + svtools/Library_svt.mk | 1 - svtools/source/misc/svtaccessiblefactory.cxx | 24 --------- svtools/source/table/defaultinputhandler.cxx | 10 ++-- svtools/source/table/mousefunction.cxx | 21 -------- svtools/source/table/mousefunction.hxx | 37 +++----------- svtools/source/toolpanel/drawerlayouter.cxx | 3 -- svtools/source/toolpanel/dummypanel.cxx | 3 -- svtools/source/toolpanel/dummypanel.hxx | 7 +-- svtools/source/toolpanel/refbase.cxx | 50 ------------------- svtools/source/toolpanel/tablayouter.cxx | 3 -- svtools/source/toolpanel/toolpanel.cxx | 4 -- 20 files changed, 28 insertions(+), 269 deletions(-) delete mode 100644 include/svtools/toolpanel/refbase.hxx delete mode 100644 svtools/source/toolpanel/refbase.cxx diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx index ed4d2daf2d64..495d93d9b0f3 100644 --- a/accessibility/source/helper/acc_factory.cxx +++ b/accessibility/source/helper/acc_factory.cxx @@ -87,16 +87,9 @@ inline bool hasFloatingChild(Window *pWindow) class AccessibleFactory :public ::toolkit::IAccessibleFactory ,public ::svt::IAccessibleFactory { -private: - oslInterlockedCount m_refCount; - public: AccessibleFactory(); - // IReference - virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE; - virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE; - // ::toolkit::IAccessibleFactory virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > createAccessibleContext( VCLXButton* _pXWindow ) SAL_OVERRIDE; @@ -228,7 +221,6 @@ protected: }; AccessibleFactory::AccessibleFactory() - :m_refCount( 0 ) { } @@ -236,22 +228,6 @@ AccessibleFactory::~AccessibleFactory() { } -oslInterlockedCount SAL_CALL AccessibleFactory::acquire() -{ - return osl_atomic_increment( &m_refCount ); -} - -oslInterlockedCount SAL_CALL AccessibleFactory::release() -{ - if ( 0 == osl_atomic_decrement( &m_refCount ) ) - { - delete this; - return 0; - } - - return m_refCount; -} - Reference< XAccessible > AccessibleFactory::createAccessible( Menu* _pMenu, sal_Bool _bIsMenuBar ) { OAccessibleMenuBaseComponent* pAccessible; diff --git a/include/svtools/accessiblefactory.hxx b/include/svtools/accessiblefactory.hxx index b13dabde0b08..21ba910b8d94 100644 --- a/include/svtools/accessiblefactory.hxx +++ b/include/svtools/accessiblefactory.hxx @@ -26,6 +26,7 @@ #include #include +#include namespace com { namespace sun { namespace star { namespace accessibility { @@ -70,7 +71,7 @@ namespace svt //= IAccessibleFactory - class IAccessibleFactory : public ::rtl::IReference + class IAccessibleFactory : public virtual ::salhelper::SimpleReferenceObject { public: virtual IAccessibleTabListBox* @@ -172,7 +173,7 @@ namespace svt ) = 0; protected: - ~IAccessibleFactory() {} + virtual ~IAccessibleFactory() {} }; diff --git a/include/svtools/toolpanel/decklayouter.hxx b/include/svtools/toolpanel/decklayouter.hxx index 11345e7106a3..e5b9e9319b28 100644 --- a/include/svtools/toolpanel/decklayouter.hxx +++ b/include/svtools/toolpanel/decklayouter.hxx @@ -23,6 +23,7 @@ #include #include +#include #include @@ -40,7 +41,7 @@ namespace svt //= IDeckLayouter - class IDeckLayouter : public ::rtl::IReference + class IDeckLayouter : public salhelper::SimpleReferenceObject { public: /** re-arranges the elements of the tool deck, taking into account the diff --git a/include/svtools/toolpanel/drawerlayouter.hxx b/include/svtools/toolpanel/drawerlayouter.hxx index 4ee46ae2a065..2cef5d718d68 100644 --- a/include/svtools/toolpanel/drawerlayouter.hxx +++ b/include/svtools/toolpanel/drawerlayouter.hxx @@ -21,7 +21,6 @@ #define INCLUDED_SVTOOLS_TOOLPANEL_DRAWERLAYOUTER_HXX #include -#include #include #include @@ -41,8 +40,7 @@ namespace svt /** a class which implements a tool panel selector in the form of the classical drawers */ - class SVT_DLLPUBLIC DrawerDeckLayouter :public RefBase - ,public IDeckLayouter + class SVT_DLLPUBLIC DrawerDeckLayouter :public IDeckLayouter ,public IToolPanelDeckListener { public: @@ -52,9 +50,6 @@ namespace svt ); virtual ~DrawerDeckLayouter(); - // IReference - DECLARE_IREFERENCE() - // IDeckLayouter virtual Rectangle Layout( const Rectangle& i_rDeckPlayground ) SAL_OVERRIDE; virtual void Destroy() SAL_OVERRIDE; diff --git a/include/svtools/toolpanel/refbase.hxx b/include/svtools/toolpanel/refbase.hxx deleted file mode 100644 index 15fda1805fb1..000000000000 --- a/include/svtools/toolpanel/refbase.hxx +++ /dev/null @@ -1,75 +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_SVTOOLS_TOOLPANEL_REFBASE_HXX -#define INCLUDED_SVTOOLS_TOOLPANEL_REFBASE_HXX - -#include - -#include - - -namespace svt -{ - - - - //= RefBase - - class SVT_DLLPUBLIC RefBase : public ::rtl::IReference - { - protected: - RefBase() - :m_refCount( 0 ) - { - } - - virtual ~RefBase() - { - } - - virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE; - virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE; - - private: - oslInterlockedCount m_refCount; - }; - -#define DECLARE_IREFERENCE() \ - virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE; \ - virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE; - - -#define IMPLEMENT_IREFERENCE( classname ) \ - oslInterlockedCount classname::acquire() \ - { \ - return RefBase::acquire(); \ - } \ - oslInterlockedCount classname::release() \ - { \ - return RefBase::release(); \ - } - - -} // namespace svt - - -#endif // INCLUDED_SVTOOLS_TOOLPANEL_REFBASE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/toolpanel/tablayouter.hxx b/include/svtools/toolpanel/tablayouter.hxx index 17b5c4fa6429..db89736db832 100644 --- a/include/svtools/toolpanel/tablayouter.hxx +++ b/include/svtools/toolpanel/tablayouter.hxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include @@ -44,8 +44,7 @@ namespace svt //= TabDeckLayouter - class SVT_DLLPUBLIC TabDeckLayouter :public RefBase - ,public IDeckLayouter + class SVT_DLLPUBLIC TabDeckLayouter :public IDeckLayouter ,public ::boost::noncopyable { public: @@ -83,9 +82,6 @@ namespace svt const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible ) SAL_OVERRIDE; - // IReference - DECLARE_IREFERENCE() - private: ::std::auto_ptr< TabDeckLayouter_Data > m_pData; }; diff --git a/include/svtools/toolpanel/toolpanel.hxx b/include/svtools/toolpanel/toolpanel.hxx index 7fea98826098..27084d8bd460 100644 --- a/include/svtools/toolpanel/toolpanel.hxx +++ b/include/svtools/toolpanel/toolpanel.hxx @@ -21,8 +21,9 @@ #define INCLUDED_SVTOOLS_TOOLPANEL_TOOLPANEL_HXX #include -#include +#include +#include #include #include @@ -44,7 +45,7 @@ namespace svt /** abstract interface for a single tool panel */ - class SVT_DLLPUBLIC IToolPanel : public ::rtl::IReference + class SVT_DLLPUBLIC IToolPanel : public salhelper::SimpleReferenceObject { public: /// retrieves the display name of the panel @@ -118,15 +119,11 @@ namespace svt but still being abstract */ class SVT_DLLPUBLIC ToolPanelBase :public IToolPanel - ,public RefBase ,public ::boost::noncopyable { protected: ToolPanelBase(); virtual ~ToolPanelBase(); - - public: - DECLARE_IREFERENCE() }; diff --git a/include/toolkit/helper/accessiblefactory.hxx b/include/toolkit/helper/accessiblefactory.hxx index bcd3dce3b4a4..e56eda24b7d1 100644 --- a/include/toolkit/helper/accessiblefactory.hxx +++ b/include/toolkit/helper/accessiblefactory.hxx @@ -58,7 +58,7 @@ namespace toolkit //= IAccessibleFactory - class IAccessibleFactory : public salhelper::SimpleReferenceObject + class IAccessibleFactory : public virtual salhelper::SimpleReferenceObject { public: /** creates an accessible context for a button window diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 9ff7a3775849..249cdd832596 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -62,6 +62,7 @@ $(eval $(call gb_Library_use_libraries,sfx,\ i18nlangtag \ i18nutil \ sal \ + salhelper \ sax \ sb \ sot \ diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 192f14a31c81..ea5e95316f95 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -216,7 +216,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/toolpanel/paneldecklisteners \ svtools/source/toolpanel/paneltabbar \ svtools/source/toolpanel/paneltabbarpeer \ - svtools/source/toolpanel/refbase \ svtools/source/toolpanel/tabbargeometry \ svtools/source/toolpanel/tablayouter \ svtools/source/toolpanel/toolpanel \ diff --git a/svtools/source/misc/svtaccessiblefactory.cxx b/svtools/source/misc/svtaccessiblefactory.cxx index 4704e4f28ed8..02f9dfb212ce 100644 --- a/svtools/source/misc/svtaccessiblefactory.cxx +++ b/svtools/source/misc/svtaccessiblefactory.cxx @@ -52,14 +52,7 @@ namespace svt protected: virtual ~AccessibleDummyFactory(); - private: - oslInterlockedCount m_refCount; - public: - // IReference - virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE; - virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE; - // IAccessibleFactory virtual IAccessibleTabListBox* createAccessibleTabListBox( @@ -205,7 +198,6 @@ namespace svt AccessibleDummyFactory::AccessibleDummyFactory() - : m_refCount(0) { } @@ -214,22 +206,6 @@ namespace svt { } - - oslInterlockedCount SAL_CALL AccessibleDummyFactory::acquire() - { - return osl_atomic_increment( &m_refCount ); - } - - - oslInterlockedCount SAL_CALL AccessibleDummyFactory::release() - { - if ( 0 == osl_atomic_decrement( &m_refCount ) ) - { - delete this; - return 0; - } - return m_refCount; - } } diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index ff006aa711a3..292121eefb6f 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -32,7 +32,7 @@ namespace svt { namespace table { - typedef ::rtl::Reference< IMouseFunction > PMouseFunction; + typedef ::rtl::Reference< MouseFunction > PMouseFunction; typedef ::std::vector< PMouseFunction > MouseFunctions; struct DefaultInputHandler_Impl { @@ -61,7 +61,7 @@ namespace svt { namespace table namespace { bool lcl_delegateMouseEvent( DefaultInputHandler_Impl& i_impl, ITableControl& i_control, const MouseEvent& i_event, - FunctionResult ( IMouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) ) + FunctionResult ( MouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) ) { if ( i_impl.pActiveFunction.is() ) { @@ -118,19 +118,19 @@ namespace svt { namespace table bool DefaultInputHandler::MouseMove( ITableControl& i_tableControl, const MouseEvent& i_event ) { - return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseMove ); + return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &MouseFunction::handleMouseMove ); } bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& i_event ) { - return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseDown ); + return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &MouseFunction::handleMouseDown ); } bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& i_event ) { - return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseUp ); + return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &MouseFunction::handleMouseUp ); } diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx index f921435c7901..dcd55b0797ae 100644 --- a/svtools/source/table/mousefunction.cxx +++ b/svtools/source/table/mousefunction.cxx @@ -30,27 +30,6 @@ namespace svt { namespace table - //= MouseFunction - - - oslInterlockedCount MouseFunction::acquire() - { - return osl_atomic_increment( &m_refCount ); - } - - - oslInterlockedCount MouseFunction::release() - { - oslInterlockedCount newCount = osl_atomic_decrement( &m_refCount ); - if ( newCount == 0 ) - { - delete this; - return 0; - } - return newCount; - } - - //= ColumnResize diff --git a/svtools/source/table/mousefunction.hxx b/svtools/source/table/mousefunction.hxx index 71f7aa032cc2..6256259e6bd6 100644 --- a/svtools/source/table/mousefunction.hxx +++ b/svtools/source/table/mousefunction.hxx @@ -23,6 +23,7 @@ #include #include +#include #include @@ -48,40 +49,18 @@ namespace svt { namespace table }; - //= IMouseFunction + //= MouseFunction - class IMouseFunction : public ::rtl::IReference, public ::boost::noncopyable + class MouseFunction : public ::salhelper::SimpleReferenceObject, public ::boost::noncopyable { public: + MouseFunction() {} virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; protected: - virtual ~IMouseFunction() { } - }; - - - //= MouseFunction - - class MouseFunction : public IMouseFunction - { - public: - MouseFunction() - :m_refCount( 0 ) - { - } - protected: - virtual ~MouseFunction() - { - } - - public: - virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE; - virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE; - - private: - oslInterlockedCount m_refCount; + virtual ~MouseFunction() { } }; @@ -96,7 +75,7 @@ namespace svt { namespace table } public: - // IMouseFunction + // MouseFunction virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; @@ -117,7 +96,7 @@ namespace svt { namespace table } public: - // IMouseFunction + // MouseFunction virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; @@ -138,7 +117,7 @@ namespace svt { namespace table } public: - // IMouseFunction + // MouseFunction virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) SAL_OVERRIDE; diff --git a/svtools/source/toolpanel/drawerlayouter.cxx b/svtools/source/toolpanel/drawerlayouter.cxx index 565d8588ec27..97ff39552519 100644 --- a/svtools/source/toolpanel/drawerlayouter.cxx +++ b/svtools/source/toolpanel/drawerlayouter.cxx @@ -57,9 +57,6 @@ namespace svt } - IMPLEMENT_IREFERENCE( DrawerDeckLayouter ) - - Rectangle DrawerDeckLayouter::Layout( const Rectangle& i_rDeckPlayground ) { const size_t nPanelCount( m_rPanelDeck.GetPanelCount() ); diff --git a/svtools/source/toolpanel/dummypanel.cxx b/svtools/source/toolpanel/dummypanel.cxx index 1b40bf04fc6f..95dffda0f0a2 100644 --- a/svtools/source/toolpanel/dummypanel.cxx +++ b/svtools/source/toolpanel/dummypanel.cxx @@ -42,9 +42,6 @@ namespace svt } - IMPLEMENT_IREFERENCE( DummyPanel ) - - void DummyPanel::Activate( Window& ) { } diff --git a/svtools/source/toolpanel/dummypanel.hxx b/svtools/source/toolpanel/dummypanel.hxx index 0632786e911c..f4a884aaad27 100644 --- a/svtools/source/toolpanel/dummypanel.hxx +++ b/svtools/source/toolpanel/dummypanel.hxx @@ -21,7 +21,7 @@ #define INCLUDED_SVTOOLS_SOURCE_TOOLPANEL_DUMMYPANEL_HXX #include -#include +#include namespace svt @@ -32,8 +32,7 @@ namespace svt //= DummyPanel /// is a dummy implementation of the IToolPanel interface - class DummyPanel :public RefBase - ,public IToolPanel + class DummyPanel :public IToolPanel { public: DummyPanel(); @@ -52,8 +51,6 @@ namespace svt CreatePanelAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible ) SAL_OVERRIDE; - - DECLARE_IREFERENCE() }; diff --git a/svtools/source/toolpanel/refbase.cxx b/svtools/source/toolpanel/refbase.cxx deleted file mode 100644 index 4ff9969330c6..000000000000 --- a/svtools/source/toolpanel/refbase.cxx +++ /dev/null @@ -1,50 +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 . - */ - - -#include - - -namespace svt -{ - - - - //= RefBase - - - oslInterlockedCount SAL_CALL RefBase::acquire() - { - return osl_atomic_increment( &m_refCount ); - } - - - oslInterlockedCount SAL_CALL RefBase::release() - { - oslInterlockedCount newCount = osl_atomic_decrement( &m_refCount ); - if ( 0 == newCount ) - delete this; - return newCount; - } - - -} // namespace svt - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/toolpanel/tablayouter.cxx b/svtools/source/toolpanel/tablayouter.cxx index 518b088e96f5..0f82dd40b0a4 100644 --- a/svtools/source/toolpanel/tablayouter.cxx +++ b/svtools/source/toolpanel/tablayouter.cxx @@ -92,9 +92,6 @@ namespace svt } - IMPLEMENT_IREFERENCE( TabDeckLayouter ) - - TabItemContent TabDeckLayouter::GetTabItemContent() const { if ( lcl_checkDisposed( *m_pData ) ) diff --git a/svtools/source/toolpanel/toolpanel.cxx b/svtools/source/toolpanel/toolpanel.cxx index b0e65c8e9161..59185651f733 100644 --- a/svtools/source/toolpanel/toolpanel.cxx +++ b/svtools/source/toolpanel/toolpanel.cxx @@ -38,10 +38,6 @@ namespace svt { } - - IMPLEMENT_IREFERENCE( ToolPanelBase ) - - } // namespace svt -- cgit