summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat@free.fr>2011-11-18 16:35:31 +0100
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2011-11-21 14:27:48 +0100
commit68f1b7dac7e77f68050f73c8692b8180f6e7cc65 (patch)
tree17cc4c7f76ac708346232c60c465628175384fde
parent96d01c8f07478f4241f014145a64c57b041f0d44 (diff)
sw: added explanations entry to grammar checking popup menu
-rw-r--r--sw/source/ui/inc/olmenu.hxx1
-rw-r--r--sw/source/ui/lingu/olmenu.cxx45
-rw-r--r--sw/source/ui/lingu/olmenu.hrc2
-rw-r--r--sw/source/ui/lingu/olmenu.src5
4 files changed, 52 insertions, 1 deletions
diff --git a/sw/source/ui/inc/olmenu.hxx b/sw/source/ui/inc/olmenu.hxx
index bc2c7a1e8973..d0d45b7a1784 100644
--- a/sw/source/ui/inc/olmenu.hxx
+++ b/sw/source/ui/inc/olmenu.hxx
@@ -52,6 +52,7 @@ class SwSpellPopup : public PopupMenu
::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt;
::com::sun::star::uno::Sequence< rtl::OUString > aSuggestions;
+ rtl::OUString sExplanationLink;
LanguageType nCheckedLanguage;
LanguageType nGuessLangWord;
diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx
index 0bb8f5921183..7133237583c1 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -59,7 +59,9 @@
#include <svl/svstdarr.hxx>
#endif
+#include <comphelper/anytostring.hxx>
#include <comphelper/processfactory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
#include <editeng/acorrcfg.hxx>
#include <editeng/svxacorr.hxx>
#include <editeng/langitem.hxx>
@@ -102,6 +104,8 @@
#include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
using namespace ::com::sun::star;
@@ -571,6 +575,7 @@ SwSpellPopup::SwSpellPopup(
PopupMenu( SW_RES(MN_SPELL_POPUP) ),
pSh( pWrtSh ),
aSuggestions( rSuggestions ),
+sExplanationLink( ),
bGrammarResults( true ),
aInfo16( SW_RES(IMG_INFO_16) )
{
@@ -582,6 +587,26 @@ aInfo16( SW_RES(IMG_INFO_16) )
InsertItem( MN_SHORT_COMMENT, aMessageText, MIB_NOSELECT, nPos++ );
SetItemImage( MN_SHORT_COMMENT, aInfo16 );
+ // Add an item to show detailled infos if the FullCommentURL property is defined
+ beans::PropertyValues aProperties = rResult.aErrors[ nErrorInResult ].aProperties;
+ {
+ sal_Int32 i = 0;
+ while ( !sExplanationLink.isEmpty() && i < aProperties.getLength() )
+ {
+ if ( aProperties[i].Name.equalsAscii( "FullCommentURL" ) )
+ {
+ uno::Any aValue = aProperties[i].Value;
+ aValue >>= sExplanationLink;
+ }
+ ++i;
+ }
+ }
+
+ if ( !sExplanationLink.isEmpty( ) )
+ {
+ InsertItem( MN_EXPLANATION_LINK, String( SW_RES( STR_EXPLANATION_LINK ) ), MIB_TEXT | MIB_HELP, nPos++ );
+ }
+
SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
InsertSeparator( nPos++ );
@@ -818,6 +843,26 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
}
}
+ else if ( nId == MN_EXPLANATION_LINK && !sExplanationLink.isEmpty() )
+ {
+ try
+ {
+ uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") ), uno::UNO_QUERY_THROW );
+ xSystemShellExecute->execute( sExplanationLink, rtl::OUString(),
+ com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
+ }
+ catch ( uno::Exception& )
+ {
+ uno::Any exc( ::cppu::getCaughtException() );
+ rtl::OUString msg( ::comphelper::anyToString( exc ) );
+ const SolarMutexGuard guard;
+ ErrorBox aErrorBox( NULL, WB_OK, msg );
+ aErrorBox.SetText( rtl::OUString::createFromAscii( "Explanations" ) );
+ aErrorBox.Execute();
+ }
+ }
else
{
// Set language for selection or for paragraph...
diff --git a/sw/source/ui/lingu/olmenu.hrc b/sw/source/ui/lingu/olmenu.hrc
index 887f8a2ad3af..1d65bbfa0ff7 100644
--- a/sw/source/ui/lingu/olmenu.hrc
+++ b/sw/source/ui/lingu/olmenu.hrc
@@ -39,6 +39,7 @@
#define STR_LANGSTATUS_MORE (RC_LINGU_BEGIN + 7)
#define STR_IGNORE_SELECTION (RC_LINGU_BEGIN + 8)
#define STR_RESET_TO_DEFAULT_LANGUAGE (RC_LINGU_BEGIN + 9)
+#define STR_EXPLANATION_LINK (RC_LINGU_BEGIN + 10)
#define IMG_INFO_16 (RC_LINGU_BEGIN + 100)
@@ -52,6 +53,7 @@
#define MN_SET_LANGUAGE_PARAGRAPH 206
#define MN_SET_LANGUAGE_ALL_TEXT 207
#define MN_SHORT_COMMENT 208
+#define MN_EXPLANATION_LINK 209
// id range for dictionaries sub menu
#define MN_DICTIONARIES_START 300
diff --git a/sw/source/ui/lingu/olmenu.src b/sw/source/ui/lingu/olmenu.src
index 0f9b77e36ee9..5b2d8b79460a 100644
--- a/sw/source/ui/lingu/olmenu.src
+++ b/sw/source/ui/lingu/olmenu.src
@@ -127,7 +127,10 @@ String STR_IGNORE_SELECTION
{
Text [ en-US ] = "Ignore" ;
};
-
+String STR_EXPLANATION_LINK
+{
+ Text [ en-US ] = "Explanations..." ;
+};
Image IMG_INFO_16
{
ImageBitmap = Bitmap { File = "info_16.png" ; };