summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-07-12 21:11:17 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2015-07-13 12:09:52 +0000
commit2aea9e37d697ce51efc5fb37ba50f1bf177e0445 (patch)
treec6564f6cc7a61c497be13b146ed00615652b85dc /chart2
parent9c2a8065add0da1e649633efa0795beddfa68eed (diff)
Introduce generic sub toolbar controller
Currently many toolbar controllers are basically doing the same thing - show some docked toolbar. So the idea here is to have one generic controller that will handle all these cases in a unified way. It will get the name of the toolbar that it's supposed to show from the configuration, based on the command it was registered for. Right now it can handle both simple (i.e. with DROPDOWNONLY bits) and split (i.e. with DROPDOWN bits) scenarios, where for split kind it replaces the function (and the image) of the main part of the button, with the last selected function, for easy reusing. A button is considered to be a split one, if the name of the initial default command was passed along with the sub toolbar name, otherwise it will be a simple button. The core change is in framework/. Other parts are a usage example, in form of converting the custom shapes buttons to this new controller. Change-Id: I087cc58c3db1889ca69a26546d4f00fe07e2a58d Reviewed-on: https://gerrit.libreoffice.org/16967 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/Library_chartcontroller.mk1
-rw-r--r--chart2/inc/pch/precompiled_chartcontroller.hxx1
-rw-r--r--chart2/source/controller/chartcontroller.component4
-rw-r--r--chart2/source/controller/main/ShapeToolbarController.cxx290
-rw-r--r--chart2/source/controller/main/ShapeToolbarController.hxx94
5 files changed, 0 insertions, 390 deletions
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk
index 884404edd750..1b2b46dbe300 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -183,7 +183,6 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
chart2/source/controller/main/PositionAndSizeHelper \
chart2/source/controller/main/SelectionHelper \
chart2/source/controller/main/ShapeController \
- chart2/source/controller/main/ShapeToolbarController \
chart2/source/controller/main/StatusBarCommandDispatch \
chart2/source/controller/main/UndoActions \
chart2/source/controller/main/UndoCommandDispatch \
diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx
index 12b3613f56bb..f6ebf367020e 100644
--- a/chart2/inc/pch/precompiled_chartcontroller.hxx
+++ b/chart2/inc/pch/precompiled_chartcontroller.hxx
@@ -270,7 +270,6 @@
#include <svx/svxdlg.hxx>
#include <svx/svxgrahicitem.hxx>
#include <svx/tabline.hxx>
-#include <svx/tbxcustomshapes.hxx>
#include <svx/unoapi.hxx>
#include <svx/unofill.hxx>
#include <svx/unomodel.hxx>
diff --git a/chart2/source/controller/chartcontroller.component b/chart2/source/controller/chartcontroller.component
index 045d61f244dc..23269baf25fa 100644
--- a/chart2/source/controller/chartcontroller.component
+++ b/chart2/source/controller/chartcontroller.component
@@ -43,10 +43,6 @@
constructor="com_sun_star_comp_chart2_ChartTypeDialog_get_implementation">
<service name="com.sun.star.chart2.ChartTypeDialog"/>
</implementation>
- <implementation name="com.sun.star.comp.chart2.ShapeToolbarController"
- constructor="com_sun_star_comp_chart2_ShapeToolbarController_get_implementation">
- <service name="com.sun.star.chart2.ShapeToolbarController"/>
- </implementation>
<implementation name="com.sun.star.comp.chart2.WizardDialog"
constructor="com_sun_star_comp_chart2_WizardDialog_get_implementation">
<service name="com.sun.star.chart2.WizardDialog"/>
diff --git a/chart2/source/controller/main/ShapeToolbarController.cxx b/chart2/source/controller/main/ShapeToolbarController.cxx
deleted file mode 100644
index 999c9bacdd5c..000000000000
--- a/chart2/source/controller/main/ShapeToolbarController.cxx
+++ /dev/null
@@ -1,290 +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 "ShapeToolbarController.hxx"
-
-#include <osl/mutex.hxx>
-#include <cppuhelper/supportsservice.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/toolbox.hxx>
-#include <toolkit/helper/vclunohelper.hxx>
-#include <svx/svxids.hrc>
-#include <svx/tbxcustomshapes.hxx>
-#include <comphelper/propertysequence.hxx>
-
-using namespace com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-
-namespace chart
-{
-
-OUString ShapeToolbarController::getImplementationName() throw (uno::RuntimeException, std::exception)
-{
- return getImplementationName_Static();
-}
-
-OUString ShapeToolbarController::getImplementationName_Static() throw (uno::RuntimeException)
-{
- return OUString( "com.sun.star.comp.chart2.ShapeToolbarController" );
-}
-
-Sequence< OUString > ShapeToolbarController::getSupportedServiceNames_Static() throw (uno::RuntimeException)
-{
- Sequence< OUString > aSupported(1);
- aSupported.getArray()[0] = "com.sun.star.chart2.ShapeToolbarController";
- return aSupported;
-}
-
-sal_Bool ShapeToolbarController::supportsService( const OUString& ServiceName ) throw (uno::RuntimeException, std::exception)
-{
- return cppu::supportsService( this, ServiceName );
-}
-
-Sequence< OUString > ShapeToolbarController::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
-{
- return getSupportedServiceNames_Static();
-}
-
-ShapeToolbarController::ShapeToolbarController( const Reference< uno::XComponentContext >& xContext )
- :m_pToolbarController( NULL )
- ,m_nToolBoxId( 1 )
- ,m_nSlotId( 0 )
-{
- osl_atomic_increment( &m_refCount );
- m_xContext = xContext;
- osl_atomic_decrement( &m_refCount );
-}
-
-ShapeToolbarController::~ShapeToolbarController()
-{
-}
-
-// ::com::sun::star::uno::XInterface
-uno::Any ShapeToolbarController::queryInterface( const uno::Type& rType ) throw (uno::RuntimeException, std::exception)
-{
- uno::Any aReturn = ToolboxController::queryInterface( rType );
- if ( !aReturn.hasValue() )
- {
- aReturn = ShapeToolbarController_Base::queryInterface( rType );
- }
- return aReturn;
-}
-
-void ShapeToolbarController::acquire() throw ()
-{
- ToolboxController::acquire();
-}
-
-void ShapeToolbarController::release() throw ()
-{
- ToolboxController::release();
-}
-
-// ::com::sun::star::lang::XInitialization
-void ShapeToolbarController::initialize( const Sequence< uno::Any >& rArguments ) throw (uno::Exception, uno::RuntimeException, std::exception)
-{
- ToolboxController::initialize( rArguments );
- SolarMutexGuard aSolarMutexGuard;
- ::osl::MutexGuard aGuard( m_aMutex );
-
- VclPtr< ToolBox > pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
- if ( pToolBox )
- {
- const sal_uInt16 nCount = pToolBox->GetItemCount();
- for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
- {
- const sal_uInt16 nItemId = pToolBox->GetItemId( nPos );
- if ( pToolBox->GetItemCommand( nItemId ) == m_aCommandURL )
- {
- m_nToolBoxId = nItemId;
- break;
- }
- }
- if ( m_aCommandURL == ".uno:BasicShapes" )
- {
- m_aStates.insert( TCommandState::value_type( ".uno:BasicShapes", sal_True ) );
- m_nSlotId = SID_DRAWTBX_CS_BASIC;
- m_pToolbarController = new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox );
- }
- else if ( m_aCommandURL == ".uno:SymbolShapes" )
- {
- m_aStates.insert( TCommandState::value_type( ".uno:SymbolShapes", sal_True ) );
- m_nSlotId = SID_DRAWTBX_CS_SYMBOL;
- m_pToolbarController = new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox );
- }
- else if ( m_aCommandURL == ".uno:ArrowShapes" )
- {
- m_aStates.insert( TCommandState::value_type( ".uno:ArrowShapes", sal_True ) );
- m_nSlotId = SID_DRAWTBX_CS_ARROW;
- m_pToolbarController = new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox);
- }
- else if ( m_aCommandURL == ".uno:FlowChartShapes" )
- {
- m_aStates.insert( TCommandState::value_type( ".uno:FlowChartShapes", sal_True ) );
- m_nSlotId = SID_DRAWTBX_CS_FLOWCHART;
- m_pToolbarController = new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox );
- }
- else if ( m_aCommandURL == ".uno:CalloutShapes" )
- {
- m_aStates.insert( TCommandState::value_type( ".uno:CalloutShapes", sal_True ) );
- m_nSlotId = SID_DRAWTBX_CS_CALLOUT;
- m_pToolbarController = new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox );
- }
- else if ( m_aCommandURL == ".uno:StarShapes" )
- {
- m_aStates.insert( TCommandState::value_type( ".uno:StarShapes" , sal_True ) );
- m_nSlotId = SID_DRAWTBX_CS_STAR;
- m_pToolbarController = new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox );
- }
-
- for ( TCommandState::iterator aIter( m_aStates.begin() ); aIter != m_aStates.end(); ++aIter )
- {
- addStatusListener( aIter->first );
- }
-
- if ( m_pToolbarController.is() )
- {
- m_pToolbarController->initialize( rArguments );
- }
-
- // check if paste special is allowed, when not don't add DROPDOWN
- pToolBox->SetItemBits( m_nToolBoxId, pToolBox->GetItemBits( m_nToolBoxId ) | ToolBoxItemBits::DROPDOWN );
- }
-}
-
-// ::com::sun::star::frame::XStatusListener
-void ShapeToolbarController::statusChanged( const frame::FeatureStateEvent& Event ) throw ( uno::RuntimeException, std::exception )
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete );
- if ( aFind != m_aStates.end() )
- {
- aFind->second = Event.IsEnabled;
- if ( m_pToolbarController.is() )
- {
- bool bCheckmark = false;
- ToolBox& rTb = m_pToolbarController->GetToolBox();
-
- for ( sal_uInt16 i = 0; i < rTb.GetItemCount(); ++i )
- {
- sal_uInt16 nId = rTb.GetItemId( i );
- if ( nId == 0 )
- {
- continue;
- }
- OUString aCmd = rTb.GetItemCommand( nId );
- if ( aCmd == Event.FeatureURL.Complete )
- {
- rTb.EnableItem( nId, Event.IsEnabled );
- if ( Event.State >>= bCheckmark )
- {
- rTb.CheckItem( nId, bCheckmark );
- }
- else
- {
- OUString aItemText;
- if ( Event.State >>= aItemText )
- {
- rTb.SetItemText( nId, aItemText );
- }
- }
- }
- }
- }
- }
-}
-
-// ::com::sun::star::frame::XToolbarController
-Reference< awt::XWindow > ShapeToolbarController::createPopupWindow() throw (uno::RuntimeException, std::exception)
-{
- SolarMutexGuard aSolarMutexGuard;
- ::osl::MutexGuard aGuard( m_aMutex );
-
- Reference< awt::XWindow > xRet;
- if ( m_pToolbarController.is() )
- {
- xRet = m_pToolbarController->createPopupWindow();
- }
-
- return xRet;
-}
-
-void ShapeToolbarController::execute( sal_Int16 KeyModifier ) throw (uno::RuntimeException, std::exception)
-{
- auto aArgs(::comphelper::InitPropertySequence({
- { "KeyModifier", uno::makeAny(KeyModifier) }
- }));
- dispatchCommand( m_aCommandURL, aArgs );
-}
-
-// ::com::sun::star::frame::XSubToolbarController
-sal_Bool ShapeToolbarController::opensSubToolbar() throw (uno::RuntimeException, std::exception)
-{
- return ( m_nSlotId == SID_DRAWTBX_CS_BASIC ||
- m_nSlotId == SID_DRAWTBX_CS_SYMBOL ||
- m_nSlotId == SID_DRAWTBX_CS_ARROW ||
- m_nSlotId == SID_DRAWTBX_CS_FLOWCHART ||
- m_nSlotId == SID_DRAWTBX_CS_CALLOUT ||
- m_nSlotId == SID_DRAWTBX_CS_STAR );
-}
-
-OUString ShapeToolbarController::getSubToolbarName() throw (uno::RuntimeException, std::exception)
-{
- SolarMutexGuard aSolarMutexGuard;
- ::osl::MutexGuard aGuard(m_aMutex);
- if ( m_pToolbarController.is() )
- {
- return m_pToolbarController->getSubToolbarName();
- }
- return OUString();
-}
-
-void ShapeToolbarController::functionSelected( const OUString& rCommand ) throw (uno::RuntimeException, std::exception)
-{
- SolarMutexGuard aSolarMutexGuard;
- ::osl::MutexGuard aGuard( m_aMutex );
- if ( m_pToolbarController.is() )
- {
- m_aCommandURL = rCommand;
- m_pToolbarController->functionSelected( rCommand );
- }
-}
-
-void ShapeToolbarController::updateImage() throw (uno::RuntimeException, std::exception)
-{
- SolarMutexGuard aSolarMutexGuard;
- ::osl::MutexGuard aGuard( m_aMutex );
- if ( m_pToolbarController.is() )
- {
- m_pToolbarController->updateImage();
- }
-}
-
-} // namespace chart
-
-extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
-com_sun_star_comp_chart2_ShapeToolbarController_get_implementation(css::uno::XComponentContext *context,
- css::uno::Sequence<css::uno::Any> const &)
-{
- return cppu::acquire(new ::chart::ShapeToolbarController(context));
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/main/ShapeToolbarController.hxx b/chart2/source/controller/main/ShapeToolbarController.hxx
deleted file mode 100644
index f067e401ccb0..000000000000
--- a/chart2/source/controller/main/ShapeToolbarController.hxx
+++ /dev/null
@@ -1,94 +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_CHART2_SOURCE_CONTROLLER_MAIN_SHAPETOOLBARCONTROLLER_HXX
-#define INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_SHAPETOOLBARCONTROLLER_HXX
-
-#include <sal/config.h>
-
-#include <map>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/frame/XSubToolbarController.hpp>
-
-#include <cppuhelper/implbase2.hxx>
-#include <rtl/ref.hxx>
-#include <svtools/toolboxcontroller.hxx>
-
-class SfxToolBoxControl;
-
-namespace chart
-{
-
-typedef ::cppu::ImplHelper2 < ::com::sun::star::lang::XServiceInfo,
- ::com::sun::star::frame::XSubToolbarController> ShapeToolbarController_Base;
-
-typedef rtl::Reference<SfxToolBoxControl> TToolbarHelper;
-
-class ShapeToolbarController : public ::svt::ToolboxController
- ,public ShapeToolbarController_Base
-{
- typedef std::map<OUString, sal_Bool> TCommandState;
- TCommandState m_aStates;
- TToolbarHelper m_pToolbarController;
- sal_uInt16 m_nToolBoxId;
- sal_uInt16 m_nSlotId;
- ShapeToolbarController( const ShapeToolbarController& ) SAL_DELETED_FUNCTION;
- void operator =( const ShapeToolbarController& ) SAL_DELETED_FUNCTION;
-
-public:
- explicit ShapeToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
- virtual ~ShapeToolbarController();
-
- // ::com::sun::star::uno::XInterface
- virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
- virtual void SAL_CALL release() throw () SAL_OVERRIDE;
-
- // ::com::sun::star::lang::XServiceInfo
- virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // needed by registration
- static OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
- static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // ::com::sun::star::lang::XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // ::com::sun::star::frame::XStatusListener
- virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // ::com::sun::star::frame::XToolbarController
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // ::com::sun::star::frame::XSubToolbarController
- virtual sal_Bool SAL_CALL opensSubToolbar() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual OUString SAL_CALL getSubToolbarName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL functionSelected( const OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL updateImage() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-};
-
-} // namespace chart
-
-#endif // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_SHAPETOOLBARCONTROLLER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */