From 26999baa19f28e4916df28bc8c2eca2f88b70cbd Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 25 Nov 2009 16:50:53 +0000 Subject: #i51258# thesaurus for right click context menu --- sd/sdi/drtxtob.sdi | 6 ++++++ sd/source/ui/view/drtxtob.cxx | 29 +++++++++++++++++++++++++++++ sd/source/ui/view/drtxtob1.cxx | 16 ++++++++++++++++ sd/uiconfig/sdraw/menubar/menubar.xml | 2 +- sd/uiconfig/simpress/menubar/menubar.xml | 2 +- 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/sd/sdi/drtxtob.sdi b/sd/sdi/drtxtob.sdi index 4e2ca49c0b82..f4133f0f4643 100644 --- a/sd/sdi/drtxtob.sdi +++ b/sd/sdi/drtxtob.sdi @@ -202,5 +202,11 @@ shell TextObjectBar ExecMethod = Execute; StateMethod = GetAttrState; ] + SID_THES + [ + ExecMethod = Execute ; + StateMethod = GetAttrState ; + ] + } diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index 55980ff02050..7e3e48b7a59d 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -33,14 +33,21 @@ #include "TextObjectBar.hxx" +#include +#include #include #include #include +#include +#include +#include +#include #include #include #include #include +#include #include #include #include @@ -73,6 +80,8 @@ using namespace sd; +using namespace ::com::sun::star; + #define TextObjectBar #include "sdslots.hxx" @@ -373,6 +382,26 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) } break; + case SID_THES: + { + EditView & rEditView = mpView->GetTextEditOutlinerView()->GetEditView();; + String aStatusVal; + LanguageType nLang = LANGUAGE_NONE; + bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); + + // disable "Thesaurus" context menu entry if there is nothing to look up + lang::Locale aLocale( SvxCreateLocale( nLang ) ); + uno::Reference< linguistic2::XThesaurus > xThes( LinguMgr::GetThesaurus() ); + if (!bIsLookUpWord || + !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) + rSet.DisableItem( SID_THES ); + + //! avoid puting the same item as SfxBoolItem at the end of this function + nSlotId = 0; + } + break; + default: break; } diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 9c2733c933dd..b128472ac61c 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -33,6 +33,12 @@ #include "TextObjectBar.hxx" +#include + +//#include +#include +#include +#include #include #ifndef _ULSPITEM_HXX @@ -341,6 +347,16 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } break; + case SID_THES: + { + String aReplaceText; + SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); + if (pItem2) + aReplaceText = pItem2->GetValue(); + if (aReplaceText.Len() > 0) + ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText ); + } + break; default: { diff --git a/sd/uiconfig/sdraw/menubar/menubar.xml b/sd/uiconfig/sdraw/menubar/menubar.xml index 04e085c6050f..a7ce6d3f76cb 100644 --- a/sd/uiconfig/sdraw/menubar/menubar.xml +++ b/sd/uiconfig/sdraw/menubar/menubar.xml @@ -214,7 +214,7 @@ - + diff --git a/sd/uiconfig/simpress/menubar/menubar.xml b/sd/uiconfig/simpress/menubar/menubar.xml index 2483b61bd01e..fd565d5d7c8c 100644 --- a/sd/uiconfig/simpress/menubar/menubar.xml +++ b/sd/uiconfig/simpress/menubar/menubar.xml @@ -242,7 +242,7 @@ - + -- cgit