summaryrefslogtreecommitdiff
path: root/linguistic
diff options
context:
space:
mode:
authorThomas Lange <tl@openoffice.org>2001-07-25 09:09:50 +0000
committerThomas Lange <tl@openoffice.org>2001-07-25 09:09:50 +0000
commit0c5d6ef6f0599491179f0082ab12eede9ce3052c (patch)
tree8844a18701fa33a453c80bc0b1038dd178cf97cd /linguistic
parent897bb75c7de9ab60387e76e08c7601de6f83c8a0 (diff)
#90210# use correct text-encoding for non latin1 languages
Diffstat (limited to 'linguistic')
-rw-r--r--linguistic/inc/misc.hxx14
-rw-r--r--linguistic/source/dicimp.cxx12
-rw-r--r--linguistic/source/dlistimp.cxx30
-rw-r--r--linguistic/source/lngopt.cxx6
-rw-r--r--linguistic/source/misc.cxx56
5 files changed, 85 insertions, 33 deletions
diff --git a/linguistic/inc/misc.hxx b/linguistic/inc/misc.hxx
index e09dade4373a..183828350568 100644
--- a/linguistic/inc/misc.hxx
+++ b/linguistic/inc/misc.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: misc.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tl $ $Date: 2000-12-22 12:44:34 $
+ * last change: $Author: tl $ $Date: 2001-07-25 10:07:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -146,16 +146,16 @@ namespace linguistic
///////////////////////////////////////////////////////////////////////////
-inline rtl_TextEncoding GetTextEncoding() { return osl_getThreadTextEncoding(); }
+rtl_TextEncoding GetTextEncoding( INT16 nLanguage );
-inline ::rtl::OUString BS2OU(const ByteString &rText)
+inline ::rtl::OUString BS2OU(const ByteString &rText, rtl_TextEncoding nEnc)
{
- return ::rtl::OUString( rText.GetBuffer(), rText.Len(), GetTextEncoding() );
+ return ::rtl::OUString( rText.GetBuffer(), rText.Len(), nEnc );
}
-inline ByteString OU2BS(const ::rtl::OUString &rText)
+inline ByteString OU2BS(const ::rtl::OUString &rText, rtl_TextEncoding nEnc)
{
- return ByteString( rText.getStr(), GetTextEncoding() );
+ return ByteString( rText.getStr(), nEnc );
}
///////////////////////////////////////////////////////////////////////////
diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx
index d14e2d101740..0fa41556b943 100644
--- a/linguistic/source/dicimp.cxx
+++ b/linguistic/source/dicimp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dicimp.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: tl $ $Date: 2001-06-18 11:28:27 $
+ * last change: $Author: tl $ $Date: 2001-07-25 10:07:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -267,7 +267,7 @@ ULONG DictionaryNeo::loadEntries(const OUString &rMainURL)
nDicVersion = GetDicVersion( aWordBuf );
- rtl_TextEncoding eEnc = RTL_TEXTENCODING_MS_1252;
+ rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
if (6 == nDicVersion)
eEnc = RTL_TEXTENCODING_UTF8;
@@ -396,7 +396,7 @@ ULONG DictionaryNeo::saveEntries(const OUString &rURL)
if ((nErr = pStream->GetError()))
return nErr;
- rtl_TextEncoding eEnc = GetTextEncoding();
+ rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
if (6 == nDicVersion)
eEnc = RTL_TEXTENCODING_UTF8;
@@ -469,7 +469,7 @@ int DictionaryNeo::cmpDicEntry(const OUString& rWord1,
OUString aWord1( rWord1 ),
aWord2( rWord2 );
- xub_StrLen nLen1 = aWord1.getLength(),
+ INT32 nLen1 = aWord1.getLength(),
nLen2 = aWord2.getLength();
if (bSimilarOnly)
{
@@ -481,7 +481,7 @@ int DictionaryNeo::cmpDicEntry(const OUString& rWord1,
}
const sal_Unicode cIgnChar = '=';
- xub_StrLen nIdx1 = 0,
+ INT32 nIdx1 = 0,
nIdx2 = 0,
nNumIgnChar1 = 0,
nNumIgnChar2 = 0;
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index a84d41bfe079..8236cb534aa6 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlistimp.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: tl $ $Date: 2001-06-27 10:23:02 $
+ * last change: $Author: tl $ $Date: 2001-07-25 10:08:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -422,8 +422,8 @@ void DicList::searchForDictionaries( ActDicArray &rDicList,
if (STRING_NOTFOUND != nPos)
aTmp1 = aTmp1.Copy( nPos + 1 );
String aTmp2;
- INT32 j;
- INT32 nCount = rDicList.Count();
+ USHORT j;
+ USHORT nCount = rDicList.Count();
for(j = 0; j < nCount; j++)
{
aTmp2 = rDicList.GetObject( j ).xDic->getName().getStr();
@@ -456,8 +456,8 @@ INT32 DicList::getDicPos(const Reference< XDictionary > &xDic)
INT32 nPos = -1;
ActDicArray& rDicList = GetDicList();
- INT32 n = rDicList.Count();
- for (INT32 i = 0; i < n; i++)
+ USHORT n = rDicList.Count();
+ for (USHORT i = 0; i < n; i++)
{
if ( rDicList.GetObject(i).xDic == xDic )
return i;
@@ -491,8 +491,8 @@ uno::Sequence< Reference< XDictionary > > SAL_CALL
uno::Sequence< Reference< XDictionary > > aDics( rDicList.Count() );
Reference< XDictionary > *pDic = aDics.getArray();
- INT32 n = aDics.getLength();
- for (INT32 i = 0; i < n; i++)
+ USHORT n = (USHORT) aDics.getLength();
+ for (USHORT i = 0; i < n; i++)
pDic[i] = rDicList.GetObject(i).xDic;
return aDics;
@@ -506,8 +506,8 @@ Reference< XDictionary > SAL_CALL
Reference< XDictionary > xDic;
ActDicArray& rDicList = GetDicList();
- INT32 nCount = rDicList.Count();
- for (INT32 i = 0; i < nCount; i++)
+ USHORT nCount = rDicList.Count();
+ for (USHORT i = 0; i < nCount; i++)
{
const Reference< XDictionary > &rDic = rDicList.GetObject(i).xDic;
if (rDic.is() && rDic->getName() == aDictionaryName)
@@ -557,7 +557,7 @@ sal_Bool SAL_CALL
{
// remove dictionary list from the dictionaries listener lists
ActDicArray& rDicList = GetDicList();
- Reference< XDictionary > xDic( rDicList.GetObject( nPos ).xDic );
+ Reference< XDictionary > xDic( rDicList.GetObject( (USHORT) nPos ).xDic );
DBG_ASSERT(xDic.is(), "lng : empty reference");
if (xDic.is())
{
@@ -567,7 +567,7 @@ sal_Bool SAL_CALL
xDic->removeDictionaryEventListener( xDicEvtLstnrHelper );
}
- rDicList.Remove(nPos);
+ rDicList.Remove( (USHORT) nPos );
bRes = TRUE;
}
return bRes;
@@ -773,8 +773,8 @@ void DicList::SaveDics()
{
// save (modified) dictionaries
ActDicArray& rDicList = GetDicList();
- INT32 nCount = rDicList.Count();;
- for (INT32 i = 0; i < nCount; i++)
+ USHORT nCount = rDicList.Count();;
+ for (USHORT i = 0; i < nCount; i++)
{
// save (modified) dictionaries
Reference< frame::XStorable > xStor( rDicList.GetObject(i).xDic,
@@ -926,7 +926,7 @@ static void AddInternal(
static const char *pDefWordDelim =
"!\"#$%&'()*+,-./:;<=>?[]\\_^`{|}~\t \n";
ByteString aDummy( pDefWordDelim );
- String aDelim( aDummy , RTL_TEXTENCODING_MS_1252 );
+ String aDelim( aDummy, osl_getThreadTextEncoding() );
aDelim.EraseAllChars( '.' );
String aToken;
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx
index b683704274af..ffcfd4ca3111 100644
--- a/linguistic/source/lngopt.cxx
+++ b/linguistic/source/lngopt.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: lngopt.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tl $ $Date: 2001-05-08 12:46:16 $
+ * last change: $Author: tl $ $Date: 2001-07-25 10:09:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -607,7 +607,7 @@ Sequence< PropertyValue > SAL_CALL
Any aAny;
aOpt.GetValue( aAny, rItem.nWID );
- rVal.Name = OUString( rItem.pName, rItem.nNameLen, GetTextEncoding() );
+ rVal.Name = OUString( rItem.pName, rItem.nNameLen, RTL_TEXTENCODING_ASCII_US );
rVal.Handle = rItem.nWID;
rVal.Value = aAny;
rVal.State = PropertyState_DIRECT_VALUE ;
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 9b246ee1a94f..0115a18bcf55 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: misc.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tl $ $Date: 2001-07-04 13:33:43 $
+ * last change: $Author: tl $ $Date: 2001-07-25 10:09:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -133,6 +133,58 @@ osl::Mutex & GetLinguMutex()
///////////////////////////////////////////////////////////////////////////
+/**
+ returns text-encoding used for ByteString unicode String conversion
+ */
+rtl_TextEncoding GetTextEncoding( INT16 nLanguage )
+{
+ DBG_ASSERT( nLanguage != LANGUAGE_NONE, "invalid language argument" )
+ static INT16 nLastLanguage = LANGUAGE_NONE;
+
+ // set default value for unknown languages
+ static rtl_TextEncoding nEncoding = RTL_TEXTENCODING_DONTKNOW;
+
+ if (nLastLanguage != nLanguage)
+ {
+ nLastLanguage = nLanguage;
+ switch (nLanguage)
+ {
+ case LANGUAGE_GERMAN :
+ case LANGUAGE_GERMAN_SWISS :
+ case LANGUAGE_ENGLISH_US :
+ case LANGUAGE_ENGLISH_UK :
+ case LANGUAGE_FRENCH :
+ case LANGUAGE_ITALIAN :
+ case LANGUAGE_SPANISH :
+ case LANGUAGE_CATALAN :
+ case LANGUAGE_PORTUGUESE :
+ case LANGUAGE_PORTUGUESE_BRAZILIAN :
+ case LANGUAGE_DANISH :
+ case LANGUAGE_DUTCH :
+ case LANGUAGE_SWEDISH :
+ case LANGUAGE_FINNISH :
+ case LANGUAGE_NORWEGIAN_BOKMAL :
+ case LANGUAGE_NORWEGIAN_NYNORSK :
+ case LANGUAGE_AFRIKAANS :
+ nEncoding = RTL_TEXTENCODING_MS_1252; break;
+ case LANGUAGE_CZECH :
+ case LANGUAGE_HUNGARIAN :
+ case LANGUAGE_POLISH :
+ nEncoding = RTL_TEXTENCODING_MS_1250; break;
+ case LANGUAGE_RUSSIAN :
+ nEncoding = RTL_TEXTENCODING_MS_1251; break;
+ case LANGUAGE_GREEK :
+ nEncoding = RTL_TEXTENCODING_MS_1253; break;
+ default:
+ DBG_ERROR( "unexpected language" );
+ }
+ }
+
+ return nEncoding;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
BOOL IsUseDicList( const PropertyValues &rProperties,
const Reference< XPropertySet > &rxProp )
{