diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2017-04-23 15:04:36 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2017-04-23 19:50:15 +0300 |
commit | fb698d5e81c8b4149c092305506d40e2f7ef7f5d (patch) | |
tree | 7d4cc743d6fe75f628e974a1144379a7f6c563c9 /sfx2 | |
parent | 94490fdf76ff9aec05774a6dbbb0b42d87812969 (diff) |
Replace GetImage with CommandInfoProvider::GetImageForCommand
And move ToolBoxButtonSize->ImageType mapping code to a
common place.
Change-Id: If158f4b6f2750054fcf64491c2941706e7d3a329
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/inc/pch/precompiled_sfx.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/appl/app.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/appl/imagemgr.cxx | 202 | ||||
-rw-r--r-- | sfx2/source/dialog/recfloat.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControllerItem.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarPanelBase.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarToolBox.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/sidebar/Tools.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/toolbox/tbxitem.cxx | 6 |
10 files changed, 3 insertions, 224 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 2ad775dcc162..5b0ca8cccd85 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -105,7 +105,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/appl/fwkhelper \ sfx2/source/appl/helpdispatch \ sfx2/source/appl/helpinterceptor \ - sfx2/source/appl/imagemgr \ sfx2/source/appl/imestatuswindow \ sfx2/source/appl/impldde \ sfx2/source/appl/linkmgr2 \ diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx index 570c23b28def..7a3e57ac264d 100644 --- a/sfx2/inc/pch/precompiled_sfx.hxx +++ b/sfx2/inc/pch/precompiled_sfx.hxx @@ -460,7 +460,6 @@ #include <sfx2/frame.hxx> #include <sfx2/frmdescr.hxx> #include <sfx2/hintpost.hxx> -#include <sfx2/imagemgr.hxx> #include <sfx2/infobar.hxx> #include <sfx2/ipclient.hxx> #include <sfx2/linkmgr.hxx> diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 0b14446a7098..234fa72c0f95 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -100,7 +100,6 @@ #include <rtl/strbuf.hxx> #include <memory> #include <framework/sfxhelperfunctions.hxx> -#include <sfx2/imagemgr.hxx> #include "fwkhelper.hxx" using namespace ::com::sun::star; diff --git a/sfx2/source/appl/imagemgr.cxx b/sfx2/source/appl/imagemgr.cxx deleted file mode 100644 index ad59dccc7a3a..000000000000 --- a/sfx2/source/appl/imagemgr.cxx +++ /dev/null @@ -1,202 +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 <sfx2/imagemgr.hxx> -#include <com/sun/star/frame/XController.hpp> -#include <com/sun/star/ui/XImageManager.hpp> -#include <com/sun/star/frame/ModuleManager.hpp> -#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> -#include <com/sun/star/ui/ImageType.hpp> -#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> - -#include <tools/globname.hxx> -#include <tools/urlobj.hxx> -#include <svtools/imagemgr.hxx> -#include <comphelper/processfactory.hxx> -#include <rtl/ustring.hxx> - -#include <sfx2/app.hxx> -#include <sfx2/unoctitm.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/msg.hxx> -#include <sfx2/msgpool.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/module.hxx> -#include <sfx2/objsh.hxx> -#include <sfx2/docfac.hxx> - -#include <unordered_map> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::ui; - -typedef std::unordered_map< OUString, - WeakReference< XImageManager >, - OUStringHash > ModuleIdToImagegMgr; - - -Image SAL_CALL GetImage( - const css::uno::Reference< css::frame::XFrame >& rFrame, - const OUString& aURL, - bool bBig -) -{ - // TODO/LATeR: shouldn't this become a method at SfxViewFrame?! That would save the UnoTunnel - if ( !rFrame.is() ) - return Image(); - - INetURLObject aObj( aURL ); - INetProtocol nProtocol = aObj.GetProtocol(); - - Reference < XController > xController; - Reference < XModel > xModel; - if ( rFrame.is() ) - xController = rFrame->getController(); - if ( xController.is() ) - xModel = xController->getModel(); - - OUString aCommandURL( aURL ); - if ( nProtocol == INetProtocol::Slot ) - { - sal_uInt16 nId = ( sal_uInt16 ) aURL.copy(5).toInt32(); - const SfxSlot* pSlot = nullptr; - if ( xModel.is() ) - { - Reference < XUnoTunnel > xObj( xModel, UNO_QUERY ); - Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() ); - sal_Int64 nHandle = xObj.is() ? xObj->getSomething( aSeq ) : 0; - if ( nHandle ) - { - SfxObjectShell* pDoc = reinterpret_cast<SfxObjectShell*>(sal::static_int_cast<sal_IntPtr>( nHandle )); - SfxModule* pModule = pDoc->GetFactory().GetModule(); - pSlot = pModule->GetSlotPool()->GetSlot( nId ); - } - } - else - pSlot = SfxSlotPool::GetSlotPool().GetSlot( nId ); - - if ( pSlot ) - { - aCommandURL = ".uno:"; - aCommandURL += OUString::createFromAscii( pSlot->GetUnoName() ); - } - else - aCommandURL.clear(); - } - - Reference< XImageManager > xDocImgMgr; - if ( xModel.is() ) - { - Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY ); - if ( xSupplier.is() ) - { - Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY ); - xDocImgMgr.set( xDocUICfgMgr->getImageManager(), UNO_QUERY ); - } - } - - sal_Int16 nImageType( css::ui::ImageType::COLOR_NORMAL| css::ui::ImageType::SIZE_DEFAULT ); - if ( bBig ) - nImageType |= css::ui::ImageType::SIZE_LARGE; - - if ( xDocImgMgr.is() ) - { - Sequence< Reference< css::graphic::XGraphic > > aGraphicSeq; - Sequence<OUString> aImageCmdSeq { aCommandURL }; - - try - { - aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq ); - Reference< css::graphic::XGraphic > xGraphic = aGraphicSeq[0]; - Image aImage( xGraphic ); - - if ( !!aImage ) - return aImage; - } - catch (const Exception&) - { - } - } - - static WeakReference< XModuleManager2 > s_xModuleManager; - - Reference< XModuleManager2 > xModuleManager = s_xModuleManager; - - if ( !xModuleManager.is() ) - { - xModuleManager = ModuleManager::create(::comphelper::getProcessComponentContext()); - s_xModuleManager = xModuleManager; - } - - try - { - if ( !aCommandURL.isEmpty() ) - { - Reference< XImageManager > xModuleImageManager; - OUString aModuleId = xModuleManager->identify( rFrame ); - - static ModuleIdToImagegMgr s_aModuleIdToImageMgrMap; - - ModuleIdToImagegMgr::iterator pIter = s_aModuleIdToImageMgrMap.find( aModuleId ); - if ( pIter != s_aModuleIdToImageMgrMap.end() ) - xModuleImageManager = pIter->second; - else - { - static WeakReference< XModuleUIConfigurationManagerSupplier > s_xModuleCfgMgrSupplier; - - Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier = s_xModuleCfgMgrSupplier; - - if ( !xModuleCfgMgrSupplier.is() ) - { - xModuleCfgMgrSupplier = theModuleUIConfigurationManagerSupplier::get( - ::comphelper::getProcessComponentContext() ); - - s_xModuleCfgMgrSupplier = xModuleCfgMgrSupplier; - } - - Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleId ); - xModuleImageManager.set( xUICfgMgr->getImageManager(), UNO_QUERY ); - s_aModuleIdToImageMgrMap.insert( ModuleIdToImagegMgr::value_type( aModuleId, xModuleImageManager )); - } - - Sequence< Reference< css::graphic::XGraphic > > aGraphicSeq; - Sequence<OUString> aImageCmdSeq { aCommandURL }; - - aGraphicSeq = xModuleImageManager->getImages( nImageType, aImageCmdSeq ); - - Reference< css::graphic::XGraphic > xGraphic = aGraphicSeq[0]; - Image aImage( xGraphic ); - - if ( !!aImage ) - return aImage; - else if ( nProtocol != INetProtocol::Uno && nProtocol != INetProtocol::Slot ) - return SvFileInformationManager::GetImageNoDefault( aObj, bBig ); - } - } - catch (const Exception&) - { - } - - return Image(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx index aebfd9c9fe1f..d80d89f965a1 100644 --- a/sfx2/source/dialog/recfloat.cxx +++ b/sfx2/source/dialog/recfloat.cxx @@ -30,7 +30,6 @@ #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/viewsh.hxx> -#include <sfx2/imagemgr.hxx> SFX_IMPL_FLOATINGWINDOW( SfxRecordingFloatWrapper_Impl, SID_RECORDING_FLOATWINDOW ); diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx index 2ebff3df3a8c..5bc39b3e664d 100644 --- a/sfx2/source/sidebar/ControllerItem.cxx +++ b/sfx2/source/sidebar/ControllerItem.cxx @@ -20,7 +20,6 @@ #include <sfx2/msgpool.hxx> #include <sfx2/viewsh.hxx> -#include <sfx2/imagemgr.hxx> #include <sfx2/bindings.hxx> #include <unotools/cmdoptions.hxx> #include <vcl/commandinfoprovider.hxx> diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx index 8c8db52d0731..e0d72cff36d2 100644 --- a/sfx2/source/sidebar/SidebarPanelBase.cxx +++ b/sfx2/source/sidebar/SidebarPanelBase.cxx @@ -21,7 +21,6 @@ #include <sfx2/sidebar/ILayoutableWindow.hxx> #include <sfx2/sidebar/IContextChangeReceiver.hxx> #include <sfx2/sidebar/SidebarModelUpdate.hxx> -#include <sfx2/imagemgr.hxx> #include <vcl/ctrl.hxx> #include <vcl/layout.hxx> #include <comphelper/processfactory.hxx> diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx index 968366eab8f9..2dc0c5910c62 100644 --- a/sfx2/source/sidebar/SidebarToolBox.cxx +++ b/sfx2/source/sidebar/SidebarToolBox.cxx @@ -255,13 +255,6 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void) if (mbUseDefaultButtonSize) SetToolboxButtonSize(GetDefaultButtonSize()); - vcl::ImageType eImageType = vcl::ImageType::Size16; - ToolBoxButtonSize eSize = GetToolboxButtonSize(); - if (eSize == ToolBoxButtonSize::Large) - eImageType = vcl::ImageType::Size26; - else if (eSize == ToolBoxButtonSize::Size32) - eImageType = vcl::ImageType::Size32; - for (auto const& it : maControllers) { Reference<frame::XSubToolbarController> xController(it.second, UNO_QUERY); @@ -275,7 +268,7 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void) { OUString aCommandURL = GetItemCommand(it.first); css::uno::Reference<frame::XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, xFrame, eImageType); + Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, xFrame, GetImageSize()); SetItemImage(it.first, aImage); } } diff --git a/sfx2/source/sidebar/Tools.cxx b/sfx2/source/sidebar/Tools.cxx index b809f7ad96f5..e246599fd9c0 100644 --- a/sfx2/source/sidebar/Tools.cxx +++ b/sfx2/source/sidebar/Tools.cxx @@ -21,9 +21,9 @@ #include <sfx2/sidebar/Theme.hxx> -#include <sfx2/imagemgr.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/namedvaluecollection.hxx> +#include <vcl/commandinfoprovider.hxx> #include <vcl/gradient.hxx> #include <com/sun/star/frame/XDispatchProvider.hpp> @@ -57,7 +57,7 @@ Image Tools::GetImage ( { if (rsURL.startsWith(".uno:")) { - const Image aPanelImage (::GetImage(rxFrame, rsURL, false)); + const Image aPanelImage(vcl::CommandInfoProvider::GetImageForCommand(rsURL, rxFrame)); return aPanelImage; } else diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index b908b6f932f6..5aed453f2392 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -87,7 +87,6 @@ #include <sfx2/unoctitm.hxx> #include "helpid.hrc" #include "workwin.hxx" -#include <sfx2/imagemgr.hxx> #include <ctrlfactoryimpl.hxx> using namespace ::com::sun::star; @@ -572,11 +571,6 @@ Reference< css::awt::XWindow > SAL_CALL SfxToolBoxControl::createItemWindow( con return VCLUnoHelper::GetInterface( CreateItemWindow( VCLUnoHelper::GetWindow( rParent ))); } -bool SfxToolBoxControl::hasBigImages() const -{ - return (GetToolBox().GetToolboxButtonSize() == ToolBoxButtonSize::Large); -} - void SfxToolBoxControl::SetPopupWindow( SfxPopupWindow* pWindow ) { pImpl->mpPopupWindow = pWindow; |