summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorPelin Kuran <pelinrkuran@gmail.com>2020-02-15 16:01:28 +0300
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-02-24 23:42:31 +0100
commit3593d6931e0fa5484c34fa722eaf18c658bbf0a9 (patch)
treef9936aabfb1e1794af020375552543a1b5bacdd2 /desktop
parent254db7f4e8a8648b5dbcf6565b61b003dff634ff (diff)
tdf#95845: Use CommandInfoProvider to receive UNO command labels
Change-Id: Id8fb7304ca5f8cc8c5b94504fb891b56769a57c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88756 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/migration/migration.cxx42
1 files changed, 3 insertions, 39 deletions
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index 262251d1fba8..4987adf3feb0 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -54,6 +54,7 @@
#include <com/sun/star/frame/theUICommandDescription.hpp>
#include <com/sun/star/ui/UIConfigurationManager.hpp>
#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
+#include <vcl/commandinfoprovider.hxx>
using namespace osl;
using namespace std;
@@ -73,44 +74,6 @@ static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
-static OUString retrieveLabelFromCommand(const OUString& sCommand, const OUString& sModuleIdentifier)
-{
- OUString sLabel;
-
- uno::Reference< container::XNameAccess > xUICommands;
- uno::Reference< container::XNameAccess > const xNameAccess(
- frame::theUICommandDescription::get(
- ::comphelper::getProcessComponentContext()) );
- xNameAccess->getByName( sModuleIdentifier ) >>= xUICommands;
- if (xUICommands.is()) {
- if ( !sCommand.isEmpty() ) {
- OUString aStr;
- ::uno::Sequence< beans::PropertyValue > aPropSeq;
- try {
- uno::Any a( xUICommands->getByName( sCommand ));
- if ( a >>= aPropSeq ) {
- for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) {
- if ( aPropSeq[i].Name == "Label" ) {
- aPropSeq[i].Value >>= aStr;
- break;
- }
- }
- }
-
- sLabel = aStr;
- } catch (const container::NoSuchElementException&) {
- sLabel = sCommand;
- sal_Int32 nIndex = sLabel.indexOf(':');
- if (nIndex>=0 && nIndex <= sLabel.getLength()-1)
- sLabel = sLabel.copy(nIndex+1);
- }
-
- }
- }
-
- return sLabel;
-}
-
static OUString mapModuleShortNameToIdentifier(const OUString& sShortName)
{
OUString sIdentifier;
@@ -1020,9 +983,10 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat
} while (nIndex >= 0);
if (nIndex == -1) {
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(elem.m_sCommandURL, sModuleIdentifier);
uno::Sequence< beans::PropertyValue > aPropSeq {
beans::PropertyValue(ITEM_DESCRIPTOR_COMMANDURL, 0, uno::makeAny(elem.m_sCommandURL), beans::PropertyState_DIRECT_VALUE),
- beans::PropertyValue(ITEM_DESCRIPTOR_LABEL, 0, uno::makeAny(retrieveLabelFromCommand(elem.m_sCommandURL, sModuleIdentifier)), beans::PropertyState_DIRECT_VALUE),
+ beans::PropertyValue(ITEM_DESCRIPTOR_LABEL, 0, uno::makeAny(vcl::CommandInfoProvider::GetLabelForCommand(aProperties)), beans::PropertyState_DIRECT_VALUE),
beans::PropertyValue(ITEM_DESCRIPTOR_CONTAINER, 0, uno::makeAny(elem.m_xPopupMenu), beans::PropertyState_DIRECT_VALUE)
};