2013-06-16 02:48:58 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2013-04-19 08:51:45 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
|
|
|
|
2015-11-16 12:23:25 +01:00
|
|
|
#include <vcl/commandinfoprovider.hxx>
|
2017-02-17 11:11:44 +02:00
|
|
|
#include <vcl/keycod.hxx>
|
2016-07-13 15:52:26 +02:00
|
|
|
#include <vcl/mnemonic.hxx>
|
|
|
|
#include <comphelper/string.hxx>
|
2019-06-15 17:13:48 +03:00
|
|
|
#include <comphelper/sequence.hxx>
|
2015-11-13 17:00:03 +01:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2017-02-20 13:01:46 +02:00
|
|
|
#include <cppuhelper/weakref.hxx>
|
2013-04-19 08:51:45 +00:00
|
|
|
|
2018-11-15 22:04:54 +01:00
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
2013-05-27 14:52:39 +02:00
|
|
|
#include <com/sun/star/frame/ModuleManager.hpp>
|
2014-01-28 15:27:32 +01:00
|
|
|
#include <com/sun/star/frame/theUICommandDescription.hpp>
|
2013-05-27 14:52:39 +02:00
|
|
|
#include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
|
2013-04-19 08:51:45 +00:00
|
|
|
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
|
2014-01-29 18:58:18 +01:00
|
|
|
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
|
2015-11-16 15:41:27 +01:00
|
|
|
#include <com/sun/star/ui/ImageType.hpp>
|
|
|
|
#include <com/sun/star/ui/XImageManager.hpp>
|
2015-11-16 12:23:25 +01:00
|
|
|
#include <com/sun/star/awt/KeyModifier.hpp>
|
|
|
|
|
2013-04-19 08:51:45 +00:00
|
|
|
using namespace css;
|
2014-09-02 17:38:00 +00:00
|
|
|
using namespace css::uno;
|
2013-04-19 08:51:45 +00:00
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
namespace vcl { namespace CommandInfoProvider {
|
|
|
|
|
2019-08-22 16:33:14 +02:00
|
|
|
static Reference<container::XNameAccess> GetCommandDescription()
|
2017-02-20 13:01:46 +02:00
|
|
|
{
|
|
|
|
static WeakReference<container::XNameAccess> xWeakRef;
|
|
|
|
css::uno::Reference<container::XNameAccess> xRef(xWeakRef);
|
|
|
|
|
|
|
|
if (!xRef.is())
|
|
|
|
{
|
|
|
|
xRef = frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
|
|
|
|
xWeakRef = xRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2019-08-22 16:33:14 +02:00
|
|
|
static Reference<ui::XModuleUIConfigurationManagerSupplier> GetModuleConfigurationSupplier()
|
2017-02-20 13:01:46 +02:00
|
|
|
{
|
|
|
|
static WeakReference<ui::XModuleUIConfigurationManagerSupplier> xWeakRef;
|
|
|
|
css::uno::Reference<ui::XModuleUIConfigurationManagerSupplier> xRef(xWeakRef);
|
|
|
|
|
|
|
|
if (!xRef.is())
|
|
|
|
{
|
|
|
|
xRef = ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext());
|
|
|
|
xWeakRef = xRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2019-08-22 16:33:14 +02:00
|
|
|
static Reference<ui::XAcceleratorConfiguration> GetGlobalAcceleratorConfiguration()
|
2017-02-20 13:01:46 +02:00
|
|
|
{
|
|
|
|
static WeakReference<ui::XAcceleratorConfiguration> xWeakRef;
|
|
|
|
css::uno::Reference<ui::XAcceleratorConfiguration> xRef(xWeakRef);
|
|
|
|
|
|
|
|
if (!xRef.is())
|
|
|
|
{
|
|
|
|
xRef = ui::GlobalAcceleratorConfiguration::create(comphelper::getProcessComponentContext());
|
|
|
|
xWeakRef = xRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2019-08-22 16:33:14 +02:00
|
|
|
static Reference<ui::XAcceleratorConfiguration> GetDocumentAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
|
|
|
Reference<frame::XController> xController = rxFrame->getController();
|
|
|
|
if (xController.is())
|
|
|
|
{
|
2017-02-23 09:43:24 +02:00
|
|
|
Reference<ui::XUIConfigurationManagerSupplier> xSupplier(xController->getModel(), UNO_QUERY);
|
|
|
|
if (xSupplier.is())
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
2017-02-23 09:43:24 +02:00
|
|
|
Reference<ui::XUIConfigurationManager> xConfigurationManager(
|
|
|
|
xSupplier->getUIConfigurationManager());
|
|
|
|
if (xConfigurationManager.is())
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
2017-02-23 09:43:24 +02:00
|
|
|
return xConfigurationManager->getShortCutManager();
|
2017-02-17 11:11:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-08-22 16:33:14 +02:00
|
|
|
static Reference<ui::XAcceleratorConfiguration> GetModuleAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
|
|
|
css::uno::Reference<css::ui::XAcceleratorConfiguration> curModuleAcceleratorConfiguration;
|
|
|
|
try
|
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
Reference<ui::XModuleUIConfigurationManagerSupplier> xSupplier(GetModuleConfigurationSupplier());
|
2017-02-17 11:11:44 +02:00
|
|
|
Reference<ui::XUIConfigurationManager> xManager (
|
|
|
|
xSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame)));
|
|
|
|
if (xManager.is())
|
|
|
|
{
|
|
|
|
curModuleAcceleratorConfiguration = xManager->getShortCutManager();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return curModuleAcceleratorConfiguration;
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static vcl::KeyCode AWTKey2VCLKey(const awt::KeyEvent& aAWTKey)
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
|
|
|
bool bShift = ((aAWTKey.Modifiers & awt::KeyModifier::SHIFT) == awt::KeyModifier::SHIFT );
|
|
|
|
bool bMod1 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD1 ) == awt::KeyModifier::MOD1 );
|
|
|
|
bool bMod2 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD2 ) == awt::KeyModifier::MOD2 );
|
|
|
|
bool bMod3 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD3 ) == awt::KeyModifier::MOD3 );
|
2018-01-12 20:10:40 +01:00
|
|
|
sal_uInt16 nKey = static_cast<sal_uInt16>(aAWTKey.KeyCode);
|
2017-02-17 11:11:44 +02:00
|
|
|
|
|
|
|
return vcl::KeyCode(nKey, bShift, bMod1, bMod2, bMod3);
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static OUString RetrieveShortcutsFromConfiguration(
|
2017-02-17 11:11:44 +02:00
|
|
|
const Reference<ui::XAcceleratorConfiguration>& rxConfiguration,
|
|
|
|
const OUString& rsCommandName)
|
|
|
|
{
|
|
|
|
if (rxConfiguration.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Sequence<OUString> aCommands { rsCommandName };
|
|
|
|
|
|
|
|
Sequence<Any> aKeyCodes (rxConfiguration->getPreferredKeyEventsForCommandList(aCommands));
|
|
|
|
if (aCommands.getLength() == 1)
|
|
|
|
{
|
|
|
|
awt::KeyEvent aKeyEvent;
|
|
|
|
if (aKeyCodes[0] >>= aKeyEvent)
|
|
|
|
{
|
|
|
|
return AWTKey2VCLKey(aKeyEvent).GetName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (css::lang::IllegalArgumentException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OUString();
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName, const OUString& rsModuleName)
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
|
|
|
Sequence< OUString > aSequence;
|
|
|
|
try
|
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
if (!rsModuleName.isEmpty())
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
Reference<container::XNameAccess> xNameAccess(GetCommandDescription());
|
2017-02-17 11:11:44 +02:00
|
|
|
Reference<container::XNameAccess> xUICommandLabels;
|
2017-02-19 14:38:32 +02:00
|
|
|
if (xNameAccess->getByName(rsModuleName) >>= xUICommandLabels)
|
|
|
|
{
|
2017-02-17 11:11:44 +02:00
|
|
|
xUICommandLabels->getByName(rsResourceName) >>= aSequence;
|
2019-06-15 17:13:48 +03:00
|
|
|
if (comphelper::findValue(aSequence, rsCommandName) != -1)
|
|
|
|
return true;
|
2017-02-17 11:11:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-19 08:51:45 +00:00
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static Sequence<beans::PropertyValue> GetCommandProperties(const OUString& rsCommandName, const OUString& rsModuleName)
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
|
|
|
Sequence<beans::PropertyValue> aProperties;
|
2013-04-19 08:51:45 +00:00
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
try
|
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
if (!rsModuleName.isEmpty())
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
Reference<container::XNameAccess> xNameAccess(GetCommandDescription());
|
2017-02-17 11:11:44 +02:00
|
|
|
Reference<container::XNameAccess> xUICommandLabels;
|
2018-12-07 23:27:51 +01:00
|
|
|
if ((xNameAccess->getByName(rsModuleName) >>= xUICommandLabels) && xUICommandLabels->hasByName(rsCommandName))
|
2017-02-17 11:11:44 +02:00
|
|
|
xUICommandLabels->getByName(rsCommandName) >>= aProperties;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
}
|
2015-11-26 11:32:40 +00:00
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
return aProperties;
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName, const OUString& rsModuleName)
|
2015-11-26 11:32:40 +00:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName, rsModuleName));
|
2019-06-15 17:13:48 +03:00
|
|
|
auto pProp = std::find_if(aProperties.begin(), aProperties.end(),
|
|
|
|
[&rsProperty](const beans::PropertyValue& rProp) { return rProp.Name == rsProperty; });
|
|
|
|
if (pProp != aProperties.end())
|
2017-02-17 11:11:44 +02:00
|
|
|
{
|
2019-06-15 17:13:48 +03:00
|
|
|
OUString sLabel;
|
|
|
|
pProp->Value >>= sLabel;
|
|
|
|
return sLabel;
|
2017-02-17 11:11:44 +02:00
|
|
|
}
|
|
|
|
return OUString();
|
2013-04-19 08:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
OUString GetLabelForCommand (
|
2013-04-19 08:51:45 +00:00
|
|
|
const OUString& rsCommandName,
|
2017-02-19 14:38:32 +02:00
|
|
|
const OUString& rsModuleName)
|
2013-04-19 08:51:45 +00:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
return GetCommandProperty("Name", rsCommandName, rsModuleName);
|
2015-11-13 17:00:03 +01:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
OUString GetMenuLabelForCommand (
|
2015-11-17 12:08:30 +01:00
|
|
|
const OUString& rsCommandName,
|
2017-02-19 14:38:32 +02:00
|
|
|
const OUString& rsModuleName)
|
2015-11-17 12:08:30 +01:00
|
|
|
{
|
|
|
|
// Here we want to use "Label", not "Name". "Name" is a stripped-down version of "Label" without accelerators
|
|
|
|
// and ellipsis. In the menu, we want to have those accelerators and ellipsis.
|
2017-02-19 14:38:32 +02:00
|
|
|
return GetCommandProperty("Label", rsCommandName, rsModuleName);
|
2015-11-17 12:08:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
OUString GetPopupLabelForCommand (
|
2015-11-17 12:08:30 +01:00
|
|
|
const OUString& rsCommandName,
|
2017-02-19 14:38:32 +02:00
|
|
|
const OUString& rsModuleName)
|
2015-11-17 12:08:30 +01:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
OUString sPopupLabel(GetCommandProperty("PopupLabel", rsCommandName, rsModuleName));
|
2015-11-17 12:08:30 +01:00
|
|
|
if (!sPopupLabel.isEmpty())
|
|
|
|
return sPopupLabel;
|
2017-02-19 14:38:32 +02:00
|
|
|
return GetCommandProperty("Label", rsCommandName, rsModuleName);
|
2015-11-17 12:08:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
OUString GetTooltipForCommand (
|
2015-11-13 17:00:03 +01:00
|
|
|
const OUString& rsCommandName,
|
2016-02-26 10:36:34 +02:00
|
|
|
const Reference<frame::XFrame>& rxFrame)
|
2015-11-13 17:00:03 +01:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
OUString sModuleName(GetModuleIdentifier(rxFrame));
|
|
|
|
OUString sLabel (GetCommandProperty("TooltipLabel", rsCommandName, sModuleName));
|
2016-07-13 15:52:26 +02:00
|
|
|
if (sLabel.isEmpty()) {
|
2017-02-19 14:38:32 +02:00
|
|
|
sLabel = GetPopupLabelForCommand(rsCommandName, sModuleName);
|
2016-07-13 15:52:26 +02:00
|
|
|
// Remove '...' at the end and mnemonics (we don't want those in tooltips)
|
|
|
|
sLabel = comphelper::string::stripEnd(sLabel, '.');
|
|
|
|
sLabel = MnemonicGenerator::EraseAllMnemonicChars(sLabel);
|
|
|
|
}
|
2015-11-13 17:00:03 +01:00
|
|
|
|
2016-03-21 12:05:30 +02:00
|
|
|
// Command can be just an alias to another command,
|
|
|
|
// so need to get the shortcut of the "real" command.
|
2017-02-19 14:38:32 +02:00
|
|
|
const OUString sRealCommand(GetRealCommandForCommand(rsCommandName, sModuleName));
|
2016-03-21 12:05:30 +02:00
|
|
|
const OUString sShortCut(GetCommandShortcut(!sRealCommand.isEmpty() ? sRealCommand : rsCommandName, rxFrame));
|
2016-02-26 10:36:34 +02:00
|
|
|
if (!sShortCut.isEmpty())
|
|
|
|
return sLabel + " (" + sShortCut + ")";
|
2015-11-13 17:00:03 +01:00
|
|
|
return sLabel;
|
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
OUString GetCommandShortcut (const OUString& rsCommandName,
|
2017-02-20 14:05:09 +02:00
|
|
|
const Reference<frame::XFrame>& rxFrame)
|
2015-11-13 17:00:03 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
OUString sShortcut;
|
|
|
|
|
2017-01-24 21:18:00 +05:30
|
|
|
sShortcut = RetrieveShortcutsFromConfiguration(GetDocumentAcceleratorConfiguration(rxFrame), rsCommandName);
|
2015-11-13 17:00:03 +01:00
|
|
|
if (sShortcut.getLength() > 0)
|
|
|
|
return sShortcut;
|
|
|
|
|
2017-01-24 21:18:00 +05:30
|
|
|
sShortcut = RetrieveShortcutsFromConfiguration(GetModuleAcceleratorConfiguration(rxFrame), rsCommandName);
|
2015-11-13 17:00:03 +01:00
|
|
|
if (sShortcut.getLength() > 0)
|
|
|
|
return sShortcut;
|
|
|
|
|
|
|
|
sShortcut = RetrieveShortcutsFromConfiguration(GetGlobalAcceleratorConfiguration(), rsCommandName);
|
|
|
|
if (sShortcut.getLength() > 0)
|
|
|
|
return sShortcut;
|
|
|
|
|
|
|
|
return OUString();
|
2013-04-19 08:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
OUString GetRealCommandForCommand(const OUString& rCommandName,
|
2017-02-19 14:38:32 +02:00
|
|
|
const OUString& rsModuleName)
|
2016-02-26 12:47:43 +02:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
return GetCommandProperty("TargetURL", rCommandName, rsModuleName);
|
2016-02-26 12:47:43 +02:00
|
|
|
}
|
|
|
|
|
2019-04-17 16:10:24 +01:00
|
|
|
Reference<graphic::XGraphic> GetXGraphicForCommand(const OUString& rsCommandName,
|
|
|
|
const Reference<frame::XFrame>& rxFrame,
|
|
|
|
vcl::ImageType eImageType)
|
2015-11-16 15:41:27 +01:00
|
|
|
{
|
|
|
|
if (rsCommandName.isEmpty())
|
2019-04-17 16:10:24 +01:00
|
|
|
return nullptr;
|
2015-11-16 15:41:27 +01:00
|
|
|
|
|
|
|
sal_Int16 nImageType(ui::ImageType::COLOR_NORMAL | ui::ImageType::SIZE_DEFAULT);
|
2016-10-30 16:24:37 +01:00
|
|
|
|
|
|
|
if (eImageType == vcl::ImageType::Size26)
|
2015-11-16 15:41:27 +01:00
|
|
|
nImageType |= ui::ImageType::SIZE_LARGE;
|
2016-10-30 16:24:37 +01:00
|
|
|
else if (eImageType == vcl::ImageType::Size32)
|
|
|
|
nImageType |= ui::ImageType::SIZE_32;
|
2015-11-16 15:41:27 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2017-02-23 09:43:24 +02:00
|
|
|
Reference<frame::XController> xController(rxFrame->getController(), UNO_SET_THROW);
|
|
|
|
Reference<ui::XUIConfigurationManagerSupplier> xSupplier(xController->getModel(), UNO_QUERY);
|
2015-11-16 15:41:27 +01:00
|
|
|
if (xSupplier.is())
|
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
Reference<ui::XUIConfigurationManager> xDocUICfgMgr(xSupplier->getUIConfigurationManager());
|
2015-11-16 15:41:27 +01:00
|
|
|
Reference<ui::XImageManager> xDocImgMgr(xDocUICfgMgr->getImageManager(), UNO_QUERY);
|
|
|
|
|
|
|
|
Sequence< Reference<graphic::XGraphic> > aGraphicSeq;
|
|
|
|
Sequence<OUString> aImageCmdSeq { rsCommandName };
|
|
|
|
|
|
|
|
aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq );
|
|
|
|
Reference<graphic::XGraphic> xGraphic = aGraphicSeq[0];
|
2019-04-17 16:10:24 +01:00
|
|
|
if (xGraphic.is())
|
|
|
|
return xGraphic;
|
2015-11-16 15:41:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2017-02-20 13:01:46 +02:00
|
|
|
Reference<ui::XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(GetModuleConfigurationSupplier());
|
2017-01-24 21:18:00 +05:30
|
|
|
Reference<ui::XUIConfigurationManager> xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame)));
|
2015-11-16 15:41:27 +01:00
|
|
|
|
|
|
|
Sequence< Reference<graphic::XGraphic> > aGraphicSeq;
|
|
|
|
Reference<ui::XImageManager> xModuleImageManager(xUICfgMgr->getImageManager(), UNO_QUERY);
|
|
|
|
|
|
|
|
Sequence<OUString> aImageCmdSeq { rsCommandName };
|
|
|
|
|
|
|
|
aGraphicSeq = xModuleImageManager->getImages(nImageType, aImageCmdSeq);
|
|
|
|
|
|
|
|
Reference<graphic::XGraphic> xGraphic(aGraphicSeq[0]);
|
|
|
|
|
2019-04-17 16:10:24 +01:00
|
|
|
return xGraphic;
|
2015-11-16 15:41:27 +01:00
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-17 16:10:24 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
Image GetImageForCommand(const OUString& rsCommandName,
|
2017-02-20 14:05:09 +02:00
|
|
|
const Reference<frame::XFrame>& rxFrame,
|
|
|
|
vcl::ImageType eImageType)
|
2017-01-20 16:46:14 +00:00
|
|
|
{
|
2018-11-26 16:59:42 +00:00
|
|
|
return Image(GetXGraphicForCommand(rsCommandName, rxFrame, eImageType));
|
2015-11-16 15:41:27 +01:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
sal_Int32 GetPropertiesForCommand (
|
2015-11-17 11:08:46 +01:00
|
|
|
const OUString& rsCommandName,
|
2017-02-19 14:38:32 +02:00
|
|
|
const OUString& rsModuleName)
|
2015-11-17 11:08:46 +01:00
|
|
|
{
|
2015-11-17 15:47:25 +01:00
|
|
|
sal_Int32 nValue = 0;
|
2017-02-19 14:38:32 +02:00
|
|
|
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName, rsModuleName));
|
2019-06-15 17:13:48 +03:00
|
|
|
|
|
|
|
auto pProp = std::find_if(aProperties.begin(), aProperties.end(),
|
|
|
|
[](const beans::PropertyValue& rProp) { return rProp.Name == "Properties"; });
|
|
|
|
if (pProp != aProperties.end())
|
|
|
|
pProp->Value >>= nValue;
|
|
|
|
|
2015-11-17 15:47:25 +01:00
|
|
|
return nValue;
|
2015-11-17 11:08:46 +01:00
|
|
|
}
|
|
|
|
|
2017-02-19 14:38:32 +02:00
|
|
|
bool IsRotated(const OUString& rsCommandName, const OUString& rsModuleName)
|
2015-12-04 17:05:11 +01:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
return ResourceHasKey("private:resource/image/commandrotateimagelist", rsCommandName, rsModuleName);
|
2015-12-04 17:05:11 +01:00
|
|
|
}
|
|
|
|
|
2017-02-19 14:38:32 +02:00
|
|
|
bool IsMirrored(const OUString& rsCommandName, const OUString& rsModuleName)
|
2015-12-04 17:05:11 +01:00
|
|
|
{
|
2017-02-19 14:38:32 +02:00
|
|
|
return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName, rsModuleName);
|
2015-12-04 17:05:11 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 14:05:09 +02:00
|
|
|
bool IsExperimental(const OUString& rsCommandName, const OUString& rModuleName)
|
2016-10-13 21:20:36 +02:00
|
|
|
{
|
|
|
|
Sequence<beans::PropertyValue> aProperties;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if( rModuleName.getLength() > 0)
|
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
Reference<container::XNameAccess> xNameAccess(GetCommandDescription());
|
2016-10-13 21:20:36 +02:00
|
|
|
Reference<container::XNameAccess> xUICommandLabels;
|
|
|
|
if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels )
|
|
|
|
xUICommandLabels->getByName(rsCommandName) >>= aProperties;
|
|
|
|
|
2019-06-15 17:13:48 +03:00
|
|
|
auto pProp = std::find_if(aProperties.begin(), aProperties.end(),
|
|
|
|
[](const beans::PropertyValue& rProp) { return rProp.Name == "IsExperimental"; });
|
|
|
|
if (pProp != aProperties.end())
|
2016-10-13 21:20:36 +02:00
|
|
|
{
|
2019-06-15 17:13:48 +03:00
|
|
|
bool bValue;
|
|
|
|
return (pProp->Value >>= bValue) && bValue;
|
2016-10-13 21:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-22 16:33:14 +02:00
|
|
|
OUString GetModuleIdentifier(const Reference<frame::XFrame>& rxFrame)
|
2013-04-19 08:51:45 +00:00
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
static WeakReference<frame::XModuleManager2> xWeakRef;
|
|
|
|
css::uno::Reference<frame::XModuleManager2> xRef(xWeakRef);
|
|
|
|
|
|
|
|
if (!xRef.is())
|
|
|
|
{
|
|
|
|
xRef = frame::ModuleManager::create(comphelper::getProcessComponentContext());
|
|
|
|
xWeakRef = xRef;
|
|
|
|
}
|
2017-02-20 12:31:17 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2017-02-20 13:01:46 +02:00
|
|
|
return xRef->identify(rxFrame);
|
2017-02-20 12:31:17 +02:00
|
|
|
}
|
|
|
|
catch (const Exception&)
|
|
|
|
{}
|
|
|
|
|
|
|
|
return OUString();
|
2013-04-19 08:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 11:11:44 +02:00
|
|
|
} }
|
2013-06-16 02:48:58 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|