From 40fa83871e18bf7ff54f853e6b665f207ee8fb78 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 16 Nov 2015 12:23:25 +0100 Subject: Move CommandInfoProvider to vcl and use it from there Change-Id: If7e3ef81cad8974bc54f359096e3ecc700fa62d6 Reviewed-on: https://gerrit.libreoffice.org/19984 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- vcl/source/window/builder.cxx | 40 +++------------------------------------- vcl/source/window/toolbox2.cxx | 5 +++-- 2 files changed, 6 insertions(+), 39 deletions(-) (limited to 'vcl/source/window') diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 09ed49e6fa64..40036983126b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -892,11 +893,11 @@ namespace uno::Reference xModuleManager(frame::ModuleManager::create(xContext)); OUString aModuleId(xModuleManager->identify(rFrame)); - OUString aLabel(VclBuilder::getCommandProperty("Label", aCommand, xContext, aModuleId)); + OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommand, rFrame)); if (!aLabel.isEmpty()) pButton->SetText(aLabel); - OUString aTooltip(VclBuilder::getCommandProperty("Tooltip", aCommand, xContext, aModuleId)); + OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(aCommand, rFrame)); if (!aTooltip.isEmpty()) pButton->SetQuickHelpText(aTooltip); @@ -2168,41 +2169,6 @@ void VclBuilder::reorderWithinParent(std::vector& rChilds, bool bI } } -OUString VclBuilder::getCommandProperty(const OUString& rProperty, const OUString& rCommand, - const uno::Reference& rContext, const OUString& rModuleId) -{ - if (rCommand.isEmpty()) - return OUString(); - - try - { - uno::Reference xUICommandLabels; - uno::Reference xUICommandDescription(frame::theUICommandDescription::get(rContext)); - - if ((xUICommandDescription->getByName(rModuleId) >>= xUICommandLabels) && xUICommandLabels.is()) - { - uno::Sequence aProperties; - if (xUICommandLabels->getByName(rCommand) >>= aProperties) - { - for ( sal_Int32 i = 0; i < aProperties.getLength(); i++ ) - { - if (aProperties[i].Name == rProperty) - { - OUString aLabel; - if (aProperties[i].Value >>= aLabel) - return aLabel; - } - } - } - } - } - catch (uno::Exception&) - { - } - - return OUString(); -} - Image VclBuilder::getCommandImage(const OUString& rCommand, bool bLarge, const uno::Reference& rContext, const uno::Reference& rFrame, const OUString& rModuleId) diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 0efb1f8cfa85..5bb123aa4742 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -606,8 +607,8 @@ void ToolBox::InsertItem(const OUString& rCommand, const uno::Reference xModuleManager(frame::ModuleManager::create(xContext)); OUString aModuleId(xModuleManager->identify(rFrame)); - OUString aLabel(VclBuilder::getCommandProperty("Label", rCommand, xContext, aModuleId)); - OUString aTooltip(VclBuilder::getCommandProperty("TooltipLabel", rCommand, xContext, aModuleId)); + 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)); // let's invent an ItemId -- cgit