summaryrefslogtreecommitdiff
path: root/vcl/source/helper
diff options
context:
space:
mode:
authorSusobhan Ghosh <susobhang70@gmail.com>2016-03-05 01:48:55 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-03-14 13:48:26 +0000
commitbf8f926acc8afd6a2dcd2b889d427c01e06dbf85 (patch)
tree693384f87178cbe142b7fe8df3bdfc72a162293d /vcl/source/helper
parent0ee0e8010f986b67d696111ff4ea269ccf904aba (diff)
tdf#95845 Use CommandInfoProvider to receive UNO command labels
Added GetCommandPropertyFromModule to CommandInfoProvider. Removed GetCommandText. Change-Id: Ie987984b6465d540029196df371c0c0467999a59 Reviewed-on: https://gerrit.libreoffice.org/22918 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'vcl/source/helper')
-rw-r--r--vcl/source/helper/commandinfoprovider.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx
index 121aacfeda17..c878a94323bc 100644
--- a/vcl/source/helper/commandinfoprovider.cxx
+++ b/vcl/source/helper/commandinfoprovider.cxx
@@ -477,6 +477,39 @@ OUString CommandInfoProvider::GetCommandProperty(const OUString& rsProperty, con
return OUString();
}
+OUString CommandInfoProvider::GetCommandPropertyFromModule( const sal_Char* pCommandURL, const OUString& rModuleName )
+{
+ OUString sLabel;
+ if ( !pCommandURL || !*pCommandURL )
+ return sLabel;
+
+ Sequence<beans::PropertyValue> aProperties;
+ OUString sCommandURL = OUString::createFromAscii( pCommandURL );
+ try
+ {
+ if( rModuleName.getLength() > 0)
+ {
+ Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(mxContext);
+ Reference<container::XNameAccess> xUICommandLabels;
+ if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels )
+ xUICommandLabels->getByName(sCommandURL) >>= aProperties;
+
+ for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex)
+ {
+ if(aProperties[nIndex].Name == "Label")
+ {
+ aProperties[nIndex].Value >>= sLabel;
+ return sLabel;
+ }
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ }
+ return OUString();
+}
+
vcl::KeyCode CommandInfoProvider::AWTKey2VCLKey(const awt::KeyEvent& aAWTKey)
{
bool bShift = ((aAWTKey.Modifiers & awt::KeyModifier::SHIFT) == awt::KeyModifier::SHIFT );