summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-04-12 20:01:06 +0200
committerEike Rathke <erack@redhat.com>2013-04-12 20:45:01 +0200
commitf3e70f0f9ced15917bb3d91f0653952031e250ba (patch)
treed0f777279be8fbd31fa606c6d0684df5ff2c7d9a /editeng
parentcabde84509d0644258b3d5ccb8c7022e28f505bf (diff)
make that a proper static method EditView::CheckLanguage()
Change-Id: I08c1af6813314b4881aafdd7f3f98a7629d5cf76
Diffstat (limited to 'editeng')
-rw-r--r--editeng/inc/editeng/editview.hxx27
-rw-r--r--editeng/source/editeng/editview.cxx29
2 files changed, 40 insertions, 16 deletions
diff --git a/editeng/inc/editeng/editview.hxx b/editeng/inc/editeng/editview.hxx
index f3cad0e4c99f..a2f5ce8a3d65 100644
--- a/editeng/inc/editeng/editview.hxx
+++ b/editeng/inc/editeng/editview.hxx
@@ -60,7 +60,12 @@ namespace sun {
namespace star {
namespace datatransfer {
class XTransferable;
-}}}}
+}
+namespace linguistic2 {
+ class XSpellChecker1;
+ class XLanguageGuessing;
+}
+}}}
class EDITENG_DLLPUBLIC EditView
{
@@ -215,6 +220,26 @@ public:
String GetSurroundingText() const;
Selection GetSurroundingTextSelection() const;
+
+ /** Tries to determine the language of 'rText', returning a matching known
+ locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
+ matched.
+
+ @param bIsParaText
+ If TRUE, rText is a paragraph and the language is obtained by
+ passing the text to xLangGuess.
+ IF FALSE, a language match is tried for, in order,
+ 1. the default document language (non-CTL, non-CJK, aka LATIN)
+ 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
+ 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
+ 4. en-US
+ If nothing matched, LANGUAGE_NONE is returned.
+ */
+ static LanguageType CheckLanguage(
+ const OUString &rText,
+ com::sun::star::uno::Reference< com::sun::star::linguistic2::XSpellChecker1 > xSpell,
+ com::sun::star::uno::Reference< com::sun::star::linguistic2::XLanguageGuessing > xLangGuess,
+ bool bIsParaText );
};
#endif // _MyEDITVIEW_HXX
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index b4d66527b528..f2433546023a 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -68,18 +68,17 @@
using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
-using namespace com::sun::star::linguistic2;
DBG_NAME( EditView )
-// From SW => Create common method
-static LanguageType lcl_CheckLanguage(
- const OUString &rText,
- Reference< XSpellChecker1 > xSpell,
- Reference< linguistic2::XLanguageGuessing > xLangGuess,
- sal_Bool bIsParaText )
+// static
+LanguageType EditView::CheckLanguage(
+ const OUString &rText,
+ Reference< linguistic2::XSpellChecker1 > xSpell,
+ Reference< linguistic2::XLanguageGuessing > xLangGuess,
+ bool bIsParaText )
{
LanguageType nLang = LANGUAGE_NONE;
if (bIsParaText) // check longer texts with language-guessing...
@@ -889,7 +888,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
Point aPos ( pImpEditView->GetWindow()->PixelToLogic( rPosPixel ) );
aPos = pImpEditView->GetDocPos( aPos );
EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
- Reference< XSpellChecker1 > xSpeller( PIMPEE->GetSpeller() );
+ Reference< linguistic2::XSpellChecker1 > xSpeller( PIMPEE->GetSpeller() );
ESelection aOldSel = GetSelection();
if ( xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, sal_True ) )
{
@@ -920,10 +919,10 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
rVal.Value <<= (sal_Int16) 7;
//
// Are there any replace suggestions?
- Reference< XSpellAlternatives > xSpellAlt =
+ Reference< linguistic2::XSpellAlternatives > xSpellAlt =
xSpeller->spell( aSelected, PIMPEE->GetLanguage( aPaM2 ), aPropVals );
- Reference< XLanguageGuessing > xLangGuesser( EE_DLL().GetGlobalData()->GetLanguageGuesser() );
+ Reference< linguistic2::XLanguageGuessing > xLangGuesser( EE_DLL().GetGlobalData()->GetLanguageGuesser() );
// check if text might belong to a different language...
LanguageType nGuessLangWord = LANGUAGE_NONE;
@@ -941,8 +940,8 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
OSL_FAIL( "content node is NULL" );
}
- nGuessLangWord = lcl_CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, sal_False );
- nGuessLangPara = lcl_CheckLanguage( aParaText, xSpeller, xLangGuesser, sal_True );
+ nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
+ nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
}
if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
{
@@ -993,11 +992,11 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
SvtLinguConfig aCfg;
- Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
- Sequence< Reference< XDictionary > > aDics;
+ Reference< linguistic2::XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
+ Sequence< Reference< linguistic2::XDictionary > > aDics;
if (xDicList.is())
{
- const Reference< XDictionary > *pDic = NULL;
+ const Reference< linguistic2::XDictionary > *pDic = NULL;
// add the default positive dictionary to dic-list (if not already done).
// This is to ensure that there is at least one dictionary to which
// words could be added.