From df9e93750bb7ff39f4346f0e23a0493409b31c2b Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 4 Dec 2015 16:28:27 +0100 Subject: tdf#85767 Enable rotated/flipped icons in the Sidebar This is a combination of 3 commits: * Make buttonstatuslistener a generic listener for any widgets ac97f32307feb488c86d6fa962258fe79320d31b * Move icon rotation/flip handling from ToolbarManager to vcl's Toolbar c5fe98905deac6de4f9e76a17097ce83fe381ac3 * These should still be virtual. e20df218257c45c5daa234daafac9609d53aa77f Change-Id: I34e2446660ec94d60654b4db40ce1bbb8014477f Reviewed-on: https://gerrit.libreoffice.org/20466 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt --- framework/inc/uielement/toolbarmanager.hxx | 13 +-- framework/source/uielement/toolbarmanager.cxx | 145 -------------------------- include/vcl/button.hxx | 4 +- include/vcl/buttonstatuslistener.hxx | 45 -------- include/vcl/commandinfoprovider.hxx | 4 + include/vcl/toolbox.hxx | 13 ++- include/vcl/vclstatuslistener.hxx | 99 ++++++++++++++++++ vcl/Library_vcl.mk | 1 - vcl/source/control/button.cxx | 12 +-- vcl/source/control/buttonstatuslistener.cxx | 66 ------------ vcl/source/helper/commandinfoprovider.cxx | 36 +++++++ vcl/source/window/toolbox.cxx | 32 +++++- vcl/source/window/toolbox2.cxx | 11 ++ 13 files changed, 197 insertions(+), 284 deletions(-) delete mode 100644 include/vcl/buttonstatuslistener.hxx create mode 100644 include/vcl/vclstatuslistener.hxx delete mode 100644 vcl/source/control/buttonstatuslistener.cxx diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx index 655228aec03b..f109f142eb17 100644 --- a/framework/inc/uielement/toolbarmanager.hxx +++ b/framework/inc/uielement/toolbarmanager.hxx @@ -61,7 +61,6 @@ namespace framework typedef ::cppu::WeakImplHelper< css::frame::XFrameActionListener, - css::frame::XStatusListener, css::lang::XComponent, css::ui::XUIConfigurationListener > ToolbarManager_Base; @@ -80,9 +79,6 @@ class ToolBarManager : public ToolbarManager_Base // XFrameActionListener virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) throw ( css::uno::RuntimeException, std::exception ) override; - // XStatusListener - virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override; - // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override; @@ -147,8 +143,6 @@ class ToolBarManager : public ToolbarManager_Base void UpdateController( css::uno::Reference< css::frame::XToolbarController > xController); //end void AddFrameActionListener(); - void AddImageOrientationListener(); - void UpdateImageOrientation(); void ImplClearPopupMenu( ToolBox *pToolBar ); void RequestImages(); ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle ); @@ -170,11 +164,7 @@ class ToolBarManager : public ToolbarManager_Base m_bSmallSymbols : 1, m_bAddedToTaskPaneList : 1, m_bFrameActionRegistered : 1, - m_bUpdateControllers : 1, - m_bImageOrientationRegistered : 1, - m_bImageMirrored : 1; - - long m_lImageRotation; + m_bUpdateControllers : 1; VclPtr m_pToolBar; @@ -191,7 +181,6 @@ class ToolBarManager : public ToolbarManager_Base css::uno::Reference< css::frame::XUIControllerFactory > m_xToolbarControllerFactory; css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager; css::uno::Reference< css::ui::XImageManager > m_xDocImageManager; - css::uno::Reference< css::lang::XComponent > m_xImageOrientationListener; css::uno::Reference< css::ui::XUIConfigurationManager > m_xUICfgMgr; css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocUICfgMgr; diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 49588d78f782..bb80b25825b6 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -60,8 +60,6 @@ #include #include #include -#include -#include #include #include #include @@ -103,39 +101,6 @@ static const char HELPID_PREFIX_TESTTOOL[] = ".HelpId:"; static const sal_uInt16 STARTID_CUSTOMIZE_POPUPMENU = 1000; -class ImageOrientationListener : public svt::FrameStatusListener -{ - public: - ImageOrientationListener( const Reference< XStatusListener >& rReceiver, - const Reference< XComponentContext >& rxContext, - const Reference< XFrame >& rFrame ); - virtual ~ImageOrientationListener(); - - virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override; - - private: - Reference< XStatusListener > m_xReceiver; -}; - -ImageOrientationListener::ImageOrientationListener( - const Reference< XStatusListener >& rReceiver, - const Reference< XComponentContext >& rxContext, - const Reference< XFrame >& rFrame ) : - FrameStatusListener( rxContext, rFrame ), - m_xReceiver( rReceiver ) -{ -} - -ImageOrientationListener::~ImageOrientationListener() -{ -} - -void SAL_CALL ImageOrientationListener::statusChanged( const FeatureStateEvent& Event ) -throw ( RuntimeException, std::exception ) -{ - if ( m_xReceiver.is() ) - m_xReceiver->statusChanged( Event ); -} static sal_Int16 getImageTypeFromBools( bool bBig ) { @@ -180,9 +145,6 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext, m_bAddedToTaskPaneList( true ), m_bFrameActionRegistered( false ), m_bUpdateControllers( false ), - m_bImageOrientationRegistered( false ), - m_bImageMirrored( false ), - m_lImageRotation( 0 ), m_pToolBar( pToolBar ), m_aResourceName( rResourceName ), m_xFrame( rFrame ), @@ -348,61 +310,6 @@ void ToolBarManager::RefreshImages() m_pToolBar->SetOutputSizePixel( aSize ); } -void ToolBarManager::UpdateImageOrientation() -{ - SolarMutexGuard g; - - if ( m_xUICommandLabels.is() ) - { - sal_Int32 i; - Sequence< OUString > aSeqMirrorCmd; - Sequence< OUString > aSeqRotateCmd; - m_xUICommandLabels->getByName( - UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST ) >>= aSeqMirrorCmd; - m_xUICommandLabels->getByName( - UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST ) >>= aSeqRotateCmd; - - CommandToInfoMap::iterator pIter; - for ( i = 0; i < aSeqMirrorCmd.getLength(); i++ ) - { - OUString aMirrorCmd = aSeqMirrorCmd[i]; - pIter = m_aCommandMap.find( aMirrorCmd ); - if ( pIter != m_aCommandMap.end() ) - pIter->second.bMirrored = true; - } - for ( i = 0; i < aSeqRotateCmd.getLength(); i++ ) - { - OUString aRotateCmd = aSeqRotateCmd[i]; - pIter = m_aCommandMap.find( aRotateCmd ); - if ( pIter != m_aCommandMap.end() ) - pIter->second.bRotated = true; - } - } - - for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ ) - { - sal_uInt16 nId = m_pToolBar->GetItemId( nPos ); - if ( nId > 0 ) - { - OUString aCmd = m_pToolBar->GetItemCommand( nId ); - - CommandToInfoMap::const_iterator pIter = m_aCommandMap.find( aCmd ); - if ( pIter != m_aCommandMap.end() ) - { - if ( pIter->second.bRotated ) - { - m_pToolBar->SetItemImageMirrorMode( nId, false ); - m_pToolBar->SetItemImageAngle( nId, m_lImageRotation ); - } - if ( pIter->second.bMirrored ) - { - m_pToolBar->SetItemImageMirrorMode( nId, m_bImageMirrored ); - } - } - } - } -} - void ToolBarManager::UpdateControllers() { @@ -479,24 +386,6 @@ throw ( RuntimeException, std::exception ) } } -void SAL_CALL ToolBarManager::statusChanged( const css::frame::FeatureStateEvent& Event ) -throw ( css::uno::RuntimeException, std::exception ) -{ - SolarMutexGuard g; - if ( m_bDisposed ) - return; - - if ( Event.FeatureURL.Complete == ".uno:ImageOrientation" ) - { - SfxImageItem aItem( 1, 0 ); - aItem.PutValue( Event.State, 0 ); - - m_lImageRotation = aItem.GetRotation(); - m_bImageMirrored = aItem.IsMirrored(); - UpdateImageOrientation(); - } -} - void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( RuntimeException, std::exception ) { { @@ -535,14 +424,6 @@ void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( Run } } - if ( m_xImageOrientationListener.is() ) - { - ImageOrientationListener* pImageOrientation = - static_cast(m_xImageOrientationListener.get()); - pImageOrientation->unbindListener(); - m_xImageOrientationListener.clear(); - } - m_xDocImageManager.clear(); m_xModuleImageManager.clear(); @@ -611,14 +492,6 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception } } - if ( m_xImageOrientationListener.is() ) - { - ImageOrientationListener* pImageOrientation = - static_cast(m_xImageOrientationListener.get()); - pImageOrientation->unbindListener(); - m_xImageOrientationListener.clear(); - } - m_xFrame.clear(); m_xContext.clear(); Reference< XComponent > xCompGAM( m_xGlobalAcceleratorManager, UNO_QUERY ); @@ -993,7 +866,6 @@ void ToolBarManager::CreateControllers() } AddFrameActionListener(); - AddImageOrientationListener(); } void ToolBarManager::AddFrameActionListener() @@ -1006,23 +878,6 @@ void ToolBarManager::AddFrameActionListener() } } -void ToolBarManager::AddImageOrientationListener() -{ - if ( !m_bImageOrientationRegistered && m_xFrame.is() ) - { - m_bImageOrientationRegistered = true; - ImageOrientationListener* pImageOrientation = new ImageOrientationListener( - Reference< XStatusListener >( static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ), - m_xContext, - m_xFrame ); - m_xImageOrientationListener.set( static_cast< ::cppu::OWeakObject *>( - pImageOrientation ), UNO_QUERY ); - pImageOrientation->addStatusListener( - ".uno:ImageOrientation"); - pImageOrientation->bindListener(); - } -} - ToolBoxItemBits ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle ) { ToolBoxItemBits nItemBits( ToolBoxItemBits::NONE ); diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx index 93d5b99e8b03..9665dfd10ea1 100644 --- a/include/vcl/button.hxx +++ b/include/vcl/button.hxx @@ -94,7 +94,7 @@ public: virtual bool set_property(const OString &rKey, const OString &rValue) override; /// Sets the button state according to the FeatureStateEvent emitted by an Uno state change. - virtual void SetStateUno(const css::frame::FeatureStateEvent& rEvent); + virtual void statusChanged(const css::frame::FeatureStateEvent& rEvent); protected: @@ -187,7 +187,7 @@ public: void SetState( TriState eState ); TriState GetState() const { return meState; } - virtual void SetStateUno(const css::frame::FeatureStateEvent& rEvent) override; + virtual void statusChanged(const css::frame::FeatureStateEvent& rEvent) override; void Check( bool bCheck = true ); bool IsChecked() const; diff --git a/include/vcl/buttonstatuslistener.hxx b/include/vcl/buttonstatuslistener.hxx deleted file mode 100644 index 772189591114..000000000000 --- a/include/vcl/buttonstatuslistener.hxx +++ /dev/null @@ -1,45 +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/. - */ - -#ifndef INCLUDED_VCL_BUTTONSTATUSLISTENER_HXX -#define INCLUDED_VCL_BUTTONSTATUSLISTENER_HXX - -#include -#include - -#include -#include -#include - - -class VCL_DLLPUBLIC ButtonStatusListener : public cppu::WeakImplHelper < css::frame::XStatusListener> -{ -public: - ButtonStatusListener(Button* button, const rtl::OUString& aCommand); - -private: - VclPtr