summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2015-11-16 15:41:27 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2015-11-16 15:49:46 +0100
commitd8fc06d233f189341b3f9acc20253e371198e068 (patch)
tree763854ea14d181cd82244a7917849fee416e6ec8 /vcl/source/window
parent40fa83871e18bf7ff54f853e6b665f207ee8fb78 (diff)
Move functionality to retrieve command image to CommandInfoProvider
Change-Id: I79c22e0507c5eba8b5e28721de3279131aececc9
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/builder.cxx74
-rw-r--r--vcl/source/window/toolbox2.cxx12
2 files changed, 2 insertions, 84 deletions
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 <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/XModuleManager2.hpp>
-#include <com/sun/star/frame/theUICommandDescription.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
-#include <com/sun/star/ui/ImageType.hpp>
-#include <com/sun/star/ui/XImageManager.hpp>
-#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/ui/XUIConfigurationManager.hpp>
-#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <comphelper/processfactory.hxx>
#include <osl/module.hxx>
@@ -889,10 +880,6 @@ namespace
if (aCommand.isEmpty())
return;
- uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
- uno::Reference<frame::XModuleManager2> 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<vcl::Window*>& rChilds, bool bI
}
}
-Image VclBuilder::getCommandImage(const OUString& rCommand, bool bLarge,
- const uno::Reference<uno::XComponentContext>& rContext, const uno::Reference<frame::XFrame>& 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<frame::XController> xController(rFrame->getController());
- uno::Reference<frame::XModel> xModel(xController->getModel());
-
- uno::Reference<ui::XUIConfigurationManagerSupplier> xSupplier(xModel, uno::UNO_QUERY);
- if (xSupplier.is())
- {
- uno::Reference<ui::XUIConfigurationManager> xDocUICfgMgr(xSupplier->getUIConfigurationManager(), uno::UNO_QUERY);
- uno::Reference<ui::XImageManager> xDocImgMgr(xDocUICfgMgr->getImageManager(), uno::UNO_QUERY);
-
- uno::Sequence< uno::Reference<graphic::XGraphic> > aGraphicSeq;
- uno::Sequence<OUString> aImageCmdSeq { rCommand };
-
- aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq );
- uno::Reference<graphic::XGraphic> xGraphic = aGraphicSeq[0];
- Image aImage(xGraphic);
-
- if (!!aImage)
- return aImage;
- }
- }
- catch (uno::Exception&)
- {
- }
-
- try {
- uno::Reference<ui::XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(rContext));
- uno::Reference<ui::XUIConfigurationManager> xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(rModuleId));
-
- uno::Sequence< uno::Reference<graphic::XGraphic> > aGraphicSeq;
- uno::Reference<ui::XImageManager> xModuleImageManager(xUICfgMgr->getImageManager(), uno::UNO_QUERY);
-
- uno::Sequence<OUString> aImageCmdSeq { rCommand };
-
- aGraphicSeq = xModuleImageManager->getImages(nImageType, aImageCmdSeq);
-
- uno::Reference<graphic::XGraphic> 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 <unotools/confignode.hxx>
-#include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/XController.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/XModuleManager2.hpp>
-#include <com/sun/star/lang/IllegalArgumentException.hpp>
-
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<frame::XFrame>& rFrame, ToolBoxItemBits nBits, const Size& rRequestedSize, sal_uInt16 nPos)
{
- uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
- uno::Reference<frame::XModuleManager2> 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;