dbaccess/source/ui/control/opendoccontrols.cxx | 52 ------------------------- include/vcl/commandinfoprovider.hxx | 2 vcl/source/helper/commandinfoprovider.cxx | 33 +++++++++++++++ 3 files changed, 37 insertions(+), 50 deletions(-)
New commits: commit bf8f926acc8afd6a2dcd2b889d427c01e06dbf85 Author: Susobhan Ghosh <susobhan...@gmail.com> Date: Sat Mar 5 01:48:55 2016 +0530 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 <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx index caa0e1c..1e5db4b 100644 --- a/dbaccess/source/ui/control/opendoccontrols.cxx +++ b/dbaccess/source/ui/control/opendoccontrols.cxx @@ -32,6 +32,7 @@ #include <comphelper/processfactory.hxx> #include <vcl/graph.hxx> #include <vcl/help.hxx> +#include <vcl/commandinfoprovider.hxx> #include <unotools/historyoptions.hxx> #include <comphelper/sequenceashashmap.hxx> #include <tools/urlobj.hxx> @@ -59,55 +60,6 @@ namespace dbaui using ::com::sun::star::frame::theUICommandDescription; using ::com::sun::star::graphic::XGraphic; - OUString GetCommandText( const sal_Char* _pCommandURL, const OUString& _rModuleName ) - { - OUString sLabel; - if ( !_pCommandURL || !*_pCommandURL ) - return sLabel; - - Reference< XNameAccess > xUICommandLabels; - OUString sCommandURL = OUString::createFromAscii( _pCommandURL ); - - try - { - do - { - // Retrieve popup menu labels - Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - if ( !xContext.is() ) - break; - - Reference< XNameAccess> xNameAccess( theUICommandDescription::get(xContext) ); - - xNameAccess->getByName( _rModuleName ) >>= xUICommandLabels; - if ( !xUICommandLabels.is() ) - break; - - Sequence< PropertyValue > aProperties; - if ( !( xUICommandLabels->getByName(sCommandURL) >>= aProperties ) ) - break; - - sal_Int32 nCount( aProperties.getLength() ); - for ( sal_Int32 i=0; i<nCount; ++i ) - { - OUString sPropertyName( aProperties[i].Name ); - if ( sPropertyName == "Label" ) - { - aProperties[i].Value >>= sLabel; - break; - } - } - } - while ( false ); - } - catch( Exception& rException ) - { - (void)rException; - } - - return sLabel; - } - Image GetCommandIcon( const sal_Char* _pCommandURL, const OUString& _rModuleName ) { Image aIcon; @@ -170,7 +122,7 @@ namespace dbaui m_sModule = OUString::createFromAscii( _pAsciiModuleName ); // our label should equal the UI text of the "Open" command - OUString sLabel(GetCommandText(".uno:Open", m_sModule)); + OUString sLabel(vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(".uno:Open", m_sModule)); SetText(" " + sLabel.replaceAll("~", "")); // Place icon left of text and both centered in the button. diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx index 29a9bf8..67a7ab3 100644 --- a/include/vcl/commandinfoprovider.hxx +++ b/include/vcl/commandinfoprovider.hxx @@ -87,6 +87,8 @@ public: OUString GetRealCommandForCommand( const OUString& rCommandName, const css::uno::Reference<css::frame::XFrame>& rxFrame ); + OUString GetCommandPropertyFromModule( const sal_Char* pCommandURL, const OUString& rModuleName ); + Image GetImageForCommand( const OUString& rsCommandName, bool bLarge, diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 121aacf..c878a94 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 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits