From d8fc06d233f189341b3f9acc20253e371198e068 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 16 Nov 2015 15:41:27 +0100 Subject: Move functionality to retrieve command image to CommandInfoProvider Change-Id: I79c22e0507c5eba8b5e28721de3279131aececc9 --- vcl/source/window/builder.cxx | 74 +----------------------------------------- vcl/source/window/toolbox2.cxx | 12 +------ 2 files changed, 2 insertions(+), 84 deletions(-) (limited to 'vcl/source/window') diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 40036983126b..ad800893b75f 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -7,16 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include #include @@ -889,10 +880,6 @@ namespace if (aCommand.isEmpty()) return; - uno::Reference xContext(comphelper::getProcessComponentContext()); - uno::Reference xModuleManager(frame::ModuleManager::create(xContext)); - OUString aModuleId(xModuleManager->identify(rFrame)); - OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommand, rFrame)); if (!aLabel.isEmpty()) pButton->SetText(aLabel); @@ -901,7 +888,7 @@ namespace if (!aTooltip.isEmpty()) pButton->SetQuickHelpText(aTooltip); - Image aImage(VclBuilder::getCommandImage(aCommand, /* bLarge = */ false, xContext, rFrame, aModuleId)); + Image aImage(vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommand, /*bLarge=*/ false, rFrame)); pButton->SetModeImage(aImage); pButton->SetCommandHandler(aCommand); @@ -2169,65 +2156,6 @@ void VclBuilder::reorderWithinParent(std::vector& rChilds, bool bI } } -Image VclBuilder::getCommandImage(const OUString& rCommand, bool bLarge, - const uno::Reference& rContext, const uno::Reference& rFrame, - const OUString& rModuleId) -{ - if (rCommand.isEmpty()) - return Image(); - - sal_Int16 nImageType(ui::ImageType::COLOR_NORMAL | ui::ImageType::SIZE_DEFAULT); - if (bLarge) - nImageType |= ui::ImageType::SIZE_LARGE; - - try - { - uno::Reference xController(rFrame->getController()); - uno::Reference xModel(xController->getModel()); - - uno::Reference xSupplier(xModel, uno::UNO_QUERY); - if (xSupplier.is()) - { - uno::Reference xDocUICfgMgr(xSupplier->getUIConfigurationManager(), uno::UNO_QUERY); - uno::Reference xDocImgMgr(xDocUICfgMgr->getImageManager(), uno::UNO_QUERY); - - uno::Sequence< uno::Reference > aGraphicSeq; - uno::Sequence aImageCmdSeq { rCommand }; - - aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq ); - uno::Reference xGraphic = aGraphicSeq[0]; - Image aImage(xGraphic); - - if (!!aImage) - return aImage; - } - } - catch (uno::Exception&) - { - } - - try { - uno::Reference xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(rContext)); - uno::Reference xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(rModuleId)); - - uno::Sequence< uno::Reference > aGraphicSeq; - uno::Reference xModuleImageManager(xUICfgMgr->getImageManager(), uno::UNO_QUERY); - - uno::Sequence aImageCmdSeq { rCommand }; - - aGraphicSeq = xModuleImageManager->getImages(nImageType, aImageCmdSeq); - - uno::Reference xGraphic(aGraphicSeq[0]); - - return Image(xGraphic); - } - catch (uno::Exception&) - { - } - - return Image(); -} - void VclBuilder::collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap) { xmlreader::Span span; diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 5bb123aa4742..1de2f21de8d6 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -40,12 +40,6 @@ #include -#include -#include -#include -#include -#include - using namespace vcl; using namespace com::sun::star; @@ -603,13 +597,9 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, void ToolBox::InsertItem(const OUString& rCommand, const uno::Reference& rFrame, ToolBoxItemBits nBits, const Size& rRequestedSize, sal_uInt16 nPos) { - uno::Reference xContext(comphelper::getProcessComponentContext()); - uno::Reference xModuleManager(frame::ModuleManager::create(xContext)); - OUString aModuleId(xModuleManager->identify(rFrame)); - OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(rCommand, rFrame)); OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(rCommand, rFrame)); - Image aImage(VclBuilder::getCommandImage(rCommand, (GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE), xContext, rFrame, aModuleId)); + Image aImage(vcl::CommandInfoProvider::Instance().GetImageForCommand(rCommand, (GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE), rFrame)); // let's invent an ItemId const sal_uInt16 COMMAND_ITEMID_START = 30000; -- cgit v1.2.3