2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-03-28 10:45:54 +00:00
|
|
|
#include <com/sun/star/linguistic2/XAvailableLocales.hpp>
|
2009-09-17 11:26:03 +00:00
|
|
|
#include <com/sun/star/i18n/ScriptType.hpp>
|
2001-03-22 07:28:26 +00:00
|
|
|
#include <linguistic/misc.hxx>
|
2009-09-17 11:26:03 +00:00
|
|
|
#include <rtl/ustring.hxx>
|
2001-06-12 12:04:36 +00:00
|
|
|
#include <unotools/localedatawrapper.hxx>
|
2009-12-11 11:15:06 +01:00
|
|
|
#include <tools/urlobj.hxx>
|
2007-11-23 15:38:18 +00:00
|
|
|
#include <svtools/langtab.hxx>
|
2000-11-24 09:22:55 +00:00
|
|
|
#include <tools/shl.hxx>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/mslangid.hxx>
|
|
|
|
#include <i18nlangtag/lang.h>
|
2010-01-07 18:52:36 +01:00
|
|
|
#include <editeng/scripttypeitem.hxx>
|
|
|
|
#include <editeng/unolingu.hxx>
|
2007-06-27 16:18:46 +00:00
|
|
|
#include <svx/langbox.hxx>
|
|
|
|
#include <svx/dialmgr.hxx>
|
|
|
|
#include <svx/dialogs.hrc>
|
2012-09-19 22:01:49 +01:00
|
|
|
#include <vcl/builder.hxx>
|
2000-11-24 09:22:55 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star::util;
|
2001-03-22 07:28:26 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::linguistic2;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
2009-12-11 11:15:06 +01:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2013-09-03 12:26:45 +02:00
|
|
|
OUString GetDicInfoStr( const OUString& rName, const sal_uInt16 nLang, bool bNeg )
|
2009-12-11 11:15:06 +01:00
|
|
|
{
|
|
|
|
INetURLObject aURLObj;
|
|
|
|
aURLObj.SetSmartProtocol( INET_PROT_FILE );
|
|
|
|
aURLObj.SetSmartURL( rName, INetURLObject::ENCODE_ALL );
|
2013-09-03 12:26:45 +02:00
|
|
|
OUString aTmp( aURLObj.GetBase() );
|
|
|
|
aTmp += " ";
|
2009-12-11 11:15:06 +01:00
|
|
|
|
|
|
|
if ( bNeg )
|
|
|
|
{
|
2013-09-03 12:26:45 +02:00
|
|
|
aTmp += " (-) ";
|
2009-12-11 11:15:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( LANGUAGE_NONE == nLang )
|
2012-04-29 23:36:57 +01:00
|
|
|
aTmp += SVX_RESSTR(RID_SVXSTR_LANGUAGE_ALL);
|
2009-12-11 11:15:06 +01:00
|
|
|
else
|
|
|
|
{
|
2013-09-03 12:26:45 +02:00
|
|
|
aTmp += " '[' ";
|
2009-12-11 11:15:06 +01:00
|
|
|
aTmp += SvtLanguageTable::GetLanguageString( (LanguageType)nLang );
|
2013-09-03 12:26:45 +02:00
|
|
|
aTmp += " ']' ";
|
2009-12-11 11:15:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return aTmp;
|
|
|
|
}
|
2001-03-22 07:28:26 +00:00
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// misc local helper functions
|
|
|
|
//========================================================================
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
static Sequence< sal_Int16 > lcl_LocaleSeqToLangSeq( Sequence< Locale > &rSeq )
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
|
|
|
const Locale *pLocale = rSeq.getConstArray();
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Int32 nCount = rSeq.getLength();
|
2001-03-22 07:28:26 +00:00
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
Sequence< sal_Int16 > aLangs( nCount );
|
|
|
|
sal_Int16 *pLang = aLangs.getArray();
|
|
|
|
for (sal_Int32 i = 0; i < nCount; ++i)
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
2013-07-13 02:54:05 +02:00
|
|
|
pLang[i] = LanguageTag::convertToLanguageType( pLocale[i] );
|
2001-03-22 07:28:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return aLangs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-19 14:11:15 +09:00
|
|
|
static bool lcl_SeqHasLang( const Sequence< sal_Int16 > & rLangSeq, sal_Int16 nLang )
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Int32 i = -1;
|
|
|
|
sal_Int32 nLen = rLangSeq.getLength();
|
2001-03-22 07:28:26 +00:00
|
|
|
if (nLen)
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
const sal_Int16 *pLang = rLangSeq.getConstArray();
|
2001-03-22 07:28:26 +00:00
|
|
|
for (i = 0; i < nLen; ++i)
|
|
|
|
{
|
|
|
|
if (nLang == pLang[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i >= 0 && i < nLen;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// class SvxLanguageBox
|
|
|
|
//========================================================================
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 TypeToPos_Impl( LanguageType eType, const ListBox& rLb )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
|
|
|
|
sal_uInt16 nCount = rLb.GetEntryCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
for ( sal_uInt16 i=0; nPos == LISTBOX_ENTRY_NOTFOUND && i<nCount; i++ )
|
|
|
|
if ( eType == LanguageType((sal_uIntPtr)rLb.GetEntryData(i)) )
|
2000-09-18 16:07:07 +00:00
|
|
|
nPos = i;
|
|
|
|
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
2012-09-19 22:01:49 +01:00
|
|
|
SvxLanguageBox::SvxLanguageBox( Window* pParent, WinBits nBits, sal_Bool bCheck )
|
|
|
|
: ListBox( pParent, nBits )
|
|
|
|
, m_pSpellUsedLang( NULL )
|
|
|
|
, m_bWithCheckmark( bCheck )
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2014-01-03 20:53:11 +00:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxLanguageBox(Window *pParent, VclBuilder::stringmap &rMap)
|
2012-09-19 22:01:49 +01:00
|
|
|
{
|
2014-01-03 20:53:11 +00:00
|
|
|
WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
|
|
|
|
bool bDropdown = VclBuilder::extractDropdown(rMap);
|
|
|
|
if (bDropdown)
|
|
|
|
nBits |= WB_DROPDOWN;
|
|
|
|
else
|
|
|
|
nBits |= WB_BORDER;
|
|
|
|
SvxLanguageBox *pListBox = new SvxLanguageBox(pParent, nBits);
|
2012-10-24 14:10:20 +01:00
|
|
|
pListBox->EnableAutoSize(true);
|
2012-09-19 22:01:49 +01:00
|
|
|
return pListBox;
|
|
|
|
}
|
|
|
|
|
2001-04-18 07:50:38 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void SvxLanguageBox::Init()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-23 15:38:18 +00:00
|
|
|
m_pLangTable = new SvtLanguageTable;
|
2000-11-24 09:22:55 +00:00
|
|
|
m_aNotCheckedImage = Image( SVX_RES( RID_SVXIMG_NOTCHECKED ) );
|
|
|
|
m_aCheckedImage = Image( SVX_RES( RID_SVXIMG_CHECKED ) );
|
2013-09-04 15:29:16 +02:00
|
|
|
m_aAllString = SVX_RESSTR( RID_SVXSTR_LANGUAGE_ALL );
|
2001-03-22 07:28:26 +00:00
|
|
|
m_nLangList = LANG_LIST_EMPTY;
|
2011-01-10 16:11:35 +01:00
|
|
|
m_bHasLangNone = sal_False;
|
|
|
|
m_bLangNoneIsLangAll = sal_False;
|
2001-03-22 07:28:26 +00:00
|
|
|
|
|
|
|
// display entries sorted
|
|
|
|
SetStyle( GetStyle() | WB_SORT );
|
2000-11-24 09:22:55 +00:00
|
|
|
|
|
|
|
if ( m_bWithCheckmark )
|
|
|
|
{
|
2007-11-23 15:38:18 +00:00
|
|
|
SvtLanguageTable aLangTable;
|
2006-10-12 11:17:14 +00:00
|
|
|
sal_uInt32 nCount = aLangTable.GetEntryCount();
|
|
|
|
for ( sal_uInt32 i = 0; i < nCount; i++ )
|
2000-11-24 09:22:55 +00:00
|
|
|
{
|
2001-03-22 07:28:26 +00:00
|
|
|
LanguageType nLangType = aLangTable.GetTypeAtIndex( i );
|
|
|
|
|
2013-03-19 14:11:15 +09:00
|
|
|
bool bInsert = true;
|
2001-03-22 07:28:26 +00:00
|
|
|
if ((LANGUAGE_DONTKNOW == nLangType) ||
|
2013-04-03 21:16:01 +02:00
|
|
|
(LANGUAGE_SYSTEM == nLangType))
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
2013-03-19 14:11:15 +09:00
|
|
|
bInsert = false;
|
2001-03-22 07:28:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bInsert )
|
|
|
|
InsertLanguage( nLangType );
|
2000-11-24 09:22:55 +00:00
|
|
|
}
|
2001-03-22 07:28:26 +00:00
|
|
|
m_nLangList = LANG_LIST_ALL;
|
2000-11-24 09:22:55 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-03-22 07:28:26 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SvxLanguageBox::~SvxLanguageBox()
|
|
|
|
{
|
2001-06-21 08:51:30 +00:00
|
|
|
delete m_pSpellUsedLang;
|
2000-11-24 09:22:55 +00:00
|
|
|
delete m_pLangTable;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2013-09-03 12:26:45 +02:00
|
|
|
sal_uInt16 SvxLanguageBox::ImplInsertImgEntry( const OUString& rEntry, sal_uInt16 nPos, bool bChecked )
|
2002-07-19 09:07:02 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nRet = 0;
|
2002-07-19 09:07:02 +00:00
|
|
|
if( !bChecked )
|
|
|
|
nRet = InsertEntry( rEntry, m_aNotCheckedImage, nPos );
|
|
|
|
else
|
|
|
|
nRet = InsertEntry( rEntry, m_aCheckedImage, nPos );
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
void SvxLanguageBox::SetLanguageList( sal_Int16 nLangList,
|
|
|
|
sal_Bool bHasLangNone, sal_Bool bLangNoneIsLangAll, sal_Bool bCheckSpellAvail )
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
m_nLangList = nLangList;
|
|
|
|
m_bHasLangNone = bHasLangNone;
|
|
|
|
m_bLangNoneIsLangAll = bLangNoneIsLangAll;
|
|
|
|
m_bWithCheckmark = bCheckSpellAvail;
|
|
|
|
|
|
|
|
if ( LANG_LIST_EMPTY != nLangList )
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
Sequence< sal_Int16 > aSpellAvailLang;
|
|
|
|
Sequence< sal_Int16 > aHyphAvailLang;
|
|
|
|
Sequence< sal_Int16 > aThesAvailLang;
|
|
|
|
Sequence< sal_Int16 > aSpellUsedLang;
|
|
|
|
Sequence< sal_Int16 > aHyphUsedLang;
|
|
|
|
Sequence< sal_Int16 > aThesUsedLang;
|
2001-03-28 10:45:54 +00:00
|
|
|
Reference< XAvailableLocales > xAvail( LinguMgr::GetLngSvcMgr(), UNO_QUERY );
|
|
|
|
if (xAvail.is())
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
|
|
|
Sequence< Locale > aTmp;
|
|
|
|
|
|
|
|
if (LANG_LIST_SPELL_AVAIL & nLangList)
|
|
|
|
{
|
2013-01-30 11:44:23 +01:00
|
|
|
aTmp = xAvail->getAvailableLocales( SN_SPELLCHECKER );
|
2001-03-22 07:28:26 +00:00
|
|
|
aSpellAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
|
|
|
|
}
|
|
|
|
if (LANG_LIST_HYPH_AVAIL & nLangList)
|
|
|
|
{
|
2013-01-30 11:44:23 +01:00
|
|
|
aTmp = xAvail->getAvailableLocales( SN_HYPHENATOR );
|
2001-03-22 07:28:26 +00:00
|
|
|
aHyphAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
|
|
|
|
}
|
|
|
|
if (LANG_LIST_THES_AVAIL & nLangList)
|
|
|
|
{
|
2013-01-30 11:44:23 +01:00
|
|
|
aTmp = xAvail->getAvailableLocales( SN_THESAURUS );
|
2001-03-22 07:28:26 +00:00
|
|
|
aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
|
|
|
|
}
|
|
|
|
}
|
2001-06-21 08:51:30 +00:00
|
|
|
if (LANG_LIST_SPELL_USED & nLangList)
|
|
|
|
{
|
|
|
|
Reference< XSpellChecker1 > xTmp1( SvxGetSpellChecker(), UNO_QUERY );
|
|
|
|
if (xTmp1.is())
|
|
|
|
aSpellUsedLang = xTmp1->getLanguages();
|
|
|
|
}
|
|
|
|
if (LANG_LIST_HYPH_USED & nLangList)
|
|
|
|
{
|
|
|
|
Reference< XHyphenator > xTmp( SvxGetHyphenator() );
|
2001-10-12 12:00:07 +00:00
|
|
|
if (xTmp.is()) {
|
|
|
|
Sequence < Locale > aLocaleSequence( xTmp->getLocales() );
|
|
|
|
aHyphUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
|
|
|
|
}
|
2001-06-21 08:51:30 +00:00
|
|
|
}
|
|
|
|
if (LANG_LIST_THES_USED & nLangList)
|
|
|
|
{
|
|
|
|
Reference< XThesaurus > xTmp( SvxGetThesaurus() );
|
2001-10-12 12:00:07 +00:00
|
|
|
if (xTmp.is()) {
|
|
|
|
Sequence < Locale > aLocaleSequence( xTmp->getLocales() );
|
|
|
|
aThesUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
|
|
|
|
}
|
2001-06-21 08:51:30 +00:00
|
|
|
}
|
2001-03-22 07:28:26 +00:00
|
|
|
|
2007-11-23 15:38:18 +00:00
|
|
|
SvtLanguageTable aLangTable;
|
2001-06-12 12:04:36 +00:00
|
|
|
::com::sun::star::uno::Sequence< sal_uInt16 > xKnown;
|
2001-06-12 14:06:00 +00:00
|
|
|
const sal_uInt16* pKnown;
|
2006-10-12 11:17:14 +00:00
|
|
|
sal_uInt32 nCount;
|
2001-06-12 12:04:36 +00:00
|
|
|
if ( nLangList & LANG_LIST_ONLY_KNOWN )
|
2001-06-12 14:06:00 +00:00
|
|
|
{
|
2001-06-12 12:04:36 +00:00
|
|
|
xKnown = LocaleDataWrapper::getInstalledLanguageTypes();
|
2001-06-12 14:06:00 +00:00
|
|
|
pKnown = xKnown.getConstArray();
|
2006-10-12 11:17:14 +00:00
|
|
|
nCount = xKnown.getLength();
|
2001-06-12 14:06:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCount = aLangTable.GetEntryCount();
|
|
|
|
pKnown = NULL;
|
|
|
|
}
|
2006-10-12 11:17:14 +00:00
|
|
|
for ( sal_uInt32 i = 0; i < nCount; i++ )
|
2001-03-22 07:28:26 +00:00
|
|
|
{
|
2001-06-12 14:06:00 +00:00
|
|
|
LanguageType nLangType;
|
|
|
|
if ( nLangList & LANG_LIST_ONLY_KNOWN )
|
|
|
|
nLangType = pKnown[i];
|
|
|
|
else
|
|
|
|
nLangType = aLangTable.GetTypeAtIndex( i );
|
2001-03-22 08:30:28 +00:00
|
|
|
if ( nLangType != LANGUAGE_DONTKNOW &&
|
2006-10-12 11:17:14 +00:00
|
|
|
nLangType != LANGUAGE_SYSTEM &&
|
|
|
|
nLangType != LANGUAGE_NONE &&
|
2009-01-06 12:54:16 +00:00
|
|
|
(MsLangId::getSubLanguage( nLangType) != 0 ||
|
|
|
|
(nLangList & LANG_LIST_ALSO_PRIMARY_ONLY)) &&
|
2006-10-12 11:17:14 +00:00
|
|
|
((nLangList & LANG_LIST_ALL) != 0 ||
|
|
|
|
((nLangList & LANG_LIST_WESTERN) != 0 &&
|
|
|
|
(SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
|
|
|
|
SCRIPTTYPE_LATIN)) ||
|
|
|
|
((nLangList & LANG_LIST_CTL) != 0 &&
|
|
|
|
(SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
|
|
|
|
SCRIPTTYPE_COMPLEX)) ||
|
|
|
|
((nLangList & LANG_LIST_CJK) != 0 &&
|
|
|
|
(SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
|
|
|
|
SCRIPTTYPE_ASIAN)) ||
|
|
|
|
((nLangList & LANG_LIST_FBD_CHARS) != 0 &&
|
|
|
|
MsLangId::hasForbiddenCharacters(nLangType)) ||
|
|
|
|
((nLangList & LANG_LIST_SPELL_AVAIL) != 0 &&
|
|
|
|
lcl_SeqHasLang(aSpellAvailLang, nLangType)) ||
|
|
|
|
((nLangList & LANG_LIST_HYPH_AVAIL) != 0 &&
|
|
|
|
lcl_SeqHasLang(aHyphAvailLang, nLangType)) ||
|
|
|
|
((nLangList & LANG_LIST_THES_AVAIL) != 0 &&
|
|
|
|
lcl_SeqHasLang(aThesAvailLang, nLangType)) ||
|
|
|
|
((nLangList & LANG_LIST_SPELL_USED) != 0 &&
|
|
|
|
lcl_SeqHasLang(aSpellUsedLang, nLangType)) ||
|
|
|
|
((nLangList & LANG_LIST_HYPH_USED) != 0 &&
|
|
|
|
lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
|
|
|
|
((nLangList & LANG_LIST_THES_USED) != 0 &&
|
|
|
|
lcl_SeqHasLang(aThesUsedLang, nLangType))) )
|
2001-03-22 07:28:26 +00:00
|
|
|
InsertLanguage( nLangType );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bHasLangNone)
|
|
|
|
InsertLanguage( LANGUAGE_NONE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType nLangType, sal_uInt16 nPos )
|
2009-09-17 11:26:03 +00:00
|
|
|
{
|
|
|
|
return ImplInsertLanguage( nLangType, nPos, ::com::sun::star::i18n::ScriptType::WEAK );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 SvxLanguageBox::ImplInsertLanguage( const LanguageType nLangType, sal_uInt16 nPos, sal_Int16 nType )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-01-06 12:54:16 +00:00
|
|
|
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
|
|
|
|
// For obsolete and to be replaced languages check whether an entry of the
|
|
|
|
// replacement already exists and if so don't add an entry with identical
|
|
|
|
// string as would be returned by SvtLanguageTable::GetString().
|
|
|
|
if (nLang != nLangType)
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
|
2009-01-06 12:54:16 +00:00
|
|
|
if ( nAt != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
return nAt;
|
|
|
|
}
|
|
|
|
|
2013-09-04 15:29:16 +02:00
|
|
|
OUString aStrEntry = m_pLangTable->GetString( nLang );
|
2009-01-06 12:54:16 +00:00
|
|
|
if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
|
2001-03-22 07:28:26 +00:00
|
|
|
aStrEntry = m_aAllString;
|
2009-09-17 11:26:03 +00:00
|
|
|
|
|
|
|
LanguageType nRealLang = nLang;
|
|
|
|
if (nRealLang == LANGUAGE_SYSTEM)
|
|
|
|
{
|
|
|
|
nRealLang = MsLangId::resolveSystemLanguageByScriptType(nRealLang, nType);
|
2013-09-04 15:29:16 +02:00
|
|
|
aStrEntry += " - ";
|
|
|
|
aStrEntry += m_pLangTable->GetString( nRealLang );
|
2012-07-08 20:51:13 +02:00
|
|
|
} else if (nRealLang == LANGUAGE_USER_SYSTEM_CONFIG) {
|
|
|
|
nRealLang = MsLangId::getSystemLanguage();
|
2013-09-04 15:29:16 +02:00
|
|
|
aStrEntry += " - ";
|
|
|
|
aStrEntry += m_pLangTable->GetString( nRealLang );
|
2009-09-17 11:26:03 +00:00
|
|
|
}
|
|
|
|
|
2009-02-17 10:33:03 +00:00
|
|
|
aStrEntry = ApplyLreOrRleEmbedding( aStrEntry );
|
2001-03-22 07:28:26 +00:00
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = 0;
|
2000-11-24 09:22:55 +00:00
|
|
|
if ( m_bWithCheckmark )
|
|
|
|
{
|
2013-03-19 14:11:15 +09:00
|
|
|
bool bFound = false;
|
2001-06-21 08:51:30 +00:00
|
|
|
|
|
|
|
if (!m_pSpellUsedLang)
|
2000-11-24 09:22:55 +00:00
|
|
|
{
|
2001-06-21 08:51:30 +00:00
|
|
|
Reference< XSpellChecker1 > xSpell( SvxGetSpellChecker(), UNO_QUERY );
|
|
|
|
if ( xSpell.is() )
|
2011-01-10 16:11:35 +01:00
|
|
|
m_pSpellUsedLang = new Sequence< sal_Int16 >( xSpell->getLanguages() );
|
2000-11-24 09:22:55 +00:00
|
|
|
}
|
2001-06-21 08:51:30 +00:00
|
|
|
bFound = m_pSpellUsedLang ?
|
2013-03-19 14:11:15 +09:00
|
|
|
lcl_SeqHasLang( *m_pSpellUsedLang, nRealLang ) : false;
|
2001-06-21 08:51:30 +00:00
|
|
|
|
2002-07-19 09:07:02 +00:00
|
|
|
nAt = ImplInsertImgEntry( aStrEntry, nPos, bFound );
|
2000-11-24 09:22:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nAt = InsertEntry( aStrEntry, nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SetEntryData( nAt, (void*)(sal_uIntPtr)nLangType );
|
2007-07-03 13:01:31 +00:00
|
|
|
return nAt;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 SvxLanguageBox::InsertDefaultLanguage( sal_Int16 nType, sal_uInt16 nPos )
|
2009-09-17 11:26:03 +00:00
|
|
|
{
|
|
|
|
return ImplInsertLanguage( LANGUAGE_SYSTEM, nPos, nType );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2012-07-08 20:51:13 +02:00
|
|
|
sal_uInt16 SvxLanguageBox::InsertSystemLanguage( sal_uInt16 nPos )
|
|
|
|
{
|
|
|
|
return ImplInsertLanguage( LANGUAGE_USER_SYSTEM_CONFIG, nPos, ::com::sun::star::i18n::ScriptType::WEAK );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType nLangType,
|
|
|
|
sal_Bool bCheckEntry, sal_uInt16 nPos )
|
2001-06-21 08:51:30 +00:00
|
|
|
{
|
2009-01-06 12:54:16 +00:00
|
|
|
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
|
|
|
|
// For obsolete and to be replaced languages check whether an entry of the
|
|
|
|
// replacement already exists and if so don't add an entry with identical
|
|
|
|
// string as would be returned by SvtLanguageTable::GetString().
|
|
|
|
if (nLang != nLangType)
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
|
2009-01-06 12:54:16 +00:00
|
|
|
if ( nAt != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
return nAt;
|
|
|
|
}
|
|
|
|
|
2013-09-04 15:29:16 +02:00
|
|
|
OUString aStrEntry = m_pLangTable->GetString( nLang );
|
2009-01-06 12:54:16 +00:00
|
|
|
if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
|
2001-06-21 08:51:30 +00:00
|
|
|
aStrEntry = m_aAllString;
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = ImplInsertImgEntry( aStrEntry, nPos, bCheckEntry );
|
|
|
|
SetEntryData( nAt, (void*)(sal_uIntPtr)nLang );
|
2001-06-21 08:51:30 +00:00
|
|
|
|
2007-07-03 13:01:31 +00:00
|
|
|
return nAt;
|
2001-06-21 08:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SvxLanguageBox::RemoveLanguage( const LanguageType eLangType )
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = TypeToPos_Impl( eLangType, *this );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nAt != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
RemoveEntry( nAt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
LanguageType SvxLanguageBox::GetSelectLanguage() const
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nPos = GetSelectEntryPos();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
|
2011-01-10 16:11:35 +01:00
|
|
|
return LanguageType( (sal_uIntPtr)GetEntryData(nPos) );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
return LanguageType( LANGUAGE_DONTKNOW );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
void SvxLanguageBox::SelectLanguage( const LanguageType eLangType, sal_Bool bSelect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-01-06 12:54:16 +00:00
|
|
|
// If the core uses a LangID of an imported MS document and wants to select
|
|
|
|
// a language that is replaced, we need to select the replacement instead.
|
|
|
|
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-09-22 02:53:10 +02:00
|
|
|
if ( nAt == LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
nAt = InsertLanguage( nLang ); // on-the-fly-ID
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nAt != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
SelectEntryPos( nAt, bSelect );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Bool SvxLanguageBox::IsLanguageSelected( const LanguageType eLangType ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-01-06 12:54:16 +00:00
|
|
|
// Same here, work on the replacement if applicable.
|
|
|
|
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nAt != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
return IsEntryPosSelected( nAt );
|
|
|
|
else
|
2011-01-10 16:11:35 +01:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|