diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-12-12 20:33:26 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-12-13 10:01:45 +0100 |
commit | cf3bbe3a753ae9246f0ac98f5a8554aa76216eaf (patch) | |
tree | 0723ea99156e99c5cbe9b95e9c50d89f13602a5e /framework | |
parent | 604c3140d1efe58177468e96d69e8a1d09d94da5 (diff) |
only use css::awt::XPopupMenu methods
Change-Id: Ib8e14af038fccd43e79f12b6a5f9371be6a29c43
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126706
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/uielement/thesaurusmenucontroller.cxx | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/framework/source/uielement/thesaurusmenucontroller.cxx b/framework/source/uielement/thesaurusmenucontroller.cxx index 0826d1c1582a..efc7f76204f6 100644 --- a/framework/source/uielement/thesaurusmenucontroller.cxx +++ b/framework/source/uielement/thesaurusmenucontroller.cxx @@ -17,16 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <i18nlangtag/languagetag.hxx> +#include <sal/log.hxx> #include <svl/lngmisc.hxx> #include <svtools/popupmenucontrollerbase.hxx> -#include <unotools/lingucfg.hxx> #include <toolkit/awt/vclxmenu.hxx> +#include <unotools/lingucfg.hxx> #include <vcl/commandinfoprovider.hxx> -#include <vcl/image.hxx> -#include <vcl/menu.hxx> -#include <sal/log.hxx> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/linguistic2/LinguServiceManager.hpp> namespace { @@ -86,11 +87,22 @@ void ThesaurusMenuController::fillPopupMenu() return; SvtLinguConfig aCfg; - Image aImage; + css::uno::Reference<css::graphic::XGraphic> xGraphic; OUString aThesImplName( getThesImplName( aLocale ) ); OUString aSynonymsImageUrl( aCfg.GetSynonymsContextImage( aThesImplName ) ); - if ( !aThesImplName.isEmpty() && !aSynonymsImageUrl.isEmpty() ) - aImage = Image( aSynonymsImageUrl ); + if (!aThesImplName.isEmpty() && !aSynonymsImageUrl.isEmpty()) + { + try + { + css::uno::Reference<css::uno::XComponentContext> xContext(::comphelper::getProcessComponentContext()); + css::uno::Reference<css::graphic::XGraphicProvider> xProvider(css::graphic::GraphicProvider::create(xContext)); + xGraphic = xProvider->queryGraphic({ comphelper::makePropertyValue("URL", aSynonymsImageUrl) }); + } + catch (const css::uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("fwk"); + } + } sal_uInt16 nId = 1; for ( const auto& aSynonym : aSynonyms ) @@ -99,12 +111,9 @@ void ThesaurusMenuController::fillPopupMenu() m_xPopupMenu->insertItem(nId, aItemText, 0, -1); m_xPopupMenu->setCommand(nId, ".uno:ThesaurusFromContext?WordReplace:string=" + aItemText); - if (!aSynonymsImageUrl.isEmpty()) - { - VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>(m_xPopupMenu); - Menu* pVCLMenu = pAwtMenu->GetMenu(); - pVCLMenu->SetItemImage( nId, aImage ); - } + if (xGraphic.is()) + m_xPopupMenu->setItemImage(nId, xGraphic, false); + nId++; } |