[Libreoffice-commits] core.git: 5 commits - formula/inc formula/source i18npool/source sal/osl sc/source unotools/source
Eike Rathke
erack at redhat.com
Fri Feb 15 04:57:49 PST 2013
formula/inc/formula/tokenarray.hxx | 10 +++----
formula/source/core/api/FormulaCompiler.cxx | 15 +++++-----
formula/source/core/api/token.cxx | 6 ++--
i18npool/source/isolang/inunx.cxx | 5 ---
sal/osl/w32/nlsupport.c | 39 +++++++++++++++++++---------
sc/source/core/data/cell.cxx | 4 +-
sc/source/core/tool/interpr2.cxx | 2 -
sc/source/core/tool/interpr4.cxx | 4 +-
sc/source/filter/excel/excform.cxx | 2 -
unotools/source/misc/syslocale.cxx | 18 ++++++++++--
10 files changed, 65 insertions(+), 40 deletions(-)
New commits:
commit a60712be0e05ec2c2e3d48ec77511412151988ea
Author: Eike Rathke <erack at redhat.com>
Date: Fri Feb 15 13:49:43 2013 +0100
renamed SetRecalcMode...() to SetExclusiveRecalcMode...()
To emphasize exclusiveness of the four basic recalc modes renamed the
corresponding methods.
Change-Id: If6f99d2c84e4a042a3a3e3640cf416d306a2d0c5
diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx
index e9041ac..32d8710 100644
--- a/formula/inc/formula/tokenarray.hxx
+++ b/formula/inc/formula/tokenarray.hxx
@@ -84,7 +84,7 @@ protected:
inline ScRecalcMode GetCombinedBitsRecalcMode() const
{ return nMode & ~RECALCMODE_EMASK; }
/** Exclusive bits already set in nMode are
- zero'ed, nVal may contain combined bits, but
+ zero'ed, nBits may contain combined bits, but
only one exclusive bit may be set! */
inline void SetMaskedRecalcMode( ScRecalcMode nBits )
{ nMode = GetCombinedBitsRecalcMode() | nBits; }
@@ -142,13 +142,13 @@ public:
void AddRecalcMode( ScRecalcMode nBits );
inline void ClearRecalcMode() { nMode = RECALCMODE_NORMAL; }
- inline void SetRecalcModeNormal()
+ inline void SetExclusiveRecalcModeNormal()
{ SetMaskedRecalcMode( RECALCMODE_NORMAL ); }
- inline void SetRecalcModeAlways()
+ inline void SetExclusiveRecalcModeAlways()
{ SetMaskedRecalcMode( RECALCMODE_ALWAYS ); }
- inline void SetRecalcModeOnLoad()
+ inline void SetExclusiveRecalcModeOnLoad()
{ SetMaskedRecalcMode( RECALCMODE_ONLOAD ); }
- inline void SetRecalcModeOnLoadOnce()
+ inline void SetExclusiveRecalcModeOnLoadOnce()
{ SetMaskedRecalcMode( RECALCMODE_ONLOAD_ONCE ); }
inline void SetRecalcModeForced()
{ nMode |= RECALCMODE_FORCED; }
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index a8bfcbd..21f8e97 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1052,14 +1052,15 @@ void FormulaCompiler::Factor()
nNumFmt = lcl_GetRetFormat( eOp );
if ( IsOpCodeVolatile(eOp) )
- pArr->SetRecalcModeAlways();
+ pArr->SetExclusiveRecalcModeAlways();
else
{
switch( eOp )
{
// Functions recalculated on every document load.
- // Don't use SetRecalcModeOnLoad() which would override
- // ModeAlways.
+ // Don't use SetExclusiveRecalcModeOnLoad() which would
+ // override ModeAlways, use
+ // AddRecalcMode(RECALCMODE_ONLOAD) instead.
case ocConvert :
pArr->AddRecalcMode( RECALCMODE_ONLOAD );
break;
@@ -1599,7 +1600,7 @@ void FormulaCompiler::PopTokenArray()
p->pArr->nRefs = sal::static_int_cast<short>( p->pArr->nRefs + pArr->nRefs );
// obtain special RecalcMode from SharedFormula
if ( pArr->IsRecalcModeAlways() )
- p->pArr->SetRecalcModeAlways();
+ p->pArr->SetExclusiveRecalcModeAlways();
else if ( !pArr->IsRecalcModeNormal() && p->pArr->IsRecalcModeNormal() )
p->pArr->SetMaskedRecalcMode( pArr->GetRecalcMode() );
p->pArr->SetCombinedBitsRecalcMode( pArr->GetRecalcMode() );
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index f6110e7c..150be29 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -783,13 +783,13 @@ void FormulaTokenArray::AddRecalcMode( ScRecalcMode nBits )
{
//! Reihenfolge ist wichtig
if ( nBits & RECALCMODE_ALWAYS )
- SetRecalcModeAlways();
+ SetExclusiveRecalcModeAlways();
else if ( !IsRecalcModeAlways() )
{
if ( nBits & RECALCMODE_ONLOAD )
- SetRecalcModeOnLoad();
+ SetExclusiveRecalcModeOnLoad();
else if ( nBits & RECALCMODE_ONLOAD_ONCE && !IsRecalcModeOnLoad() )
- SetRecalcModeOnLoadOnce();
+ SetExclusiveRecalcModeOnLoadOnce();
}
SetCombinedBitsRecalcMode( nBits );
}
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 0967e81..75d1ced 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1698,7 +1698,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
break;
case ScInterpreter::VOLATILE_MACRO:
// The formula contains a volatile macro.
- pCode->SetRecalcModeAlways();
+ pCode->SetExclusiveRecalcModeAlways();
pDocument->PutInFormulaTree(this);
StartListeningTo(pDocument);
break;
@@ -1707,7 +1707,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
{
// The formula was previously volatile, but no more.
EndListeningTo(pDocument);
- pCode->SetRecalcModeNormal();
+ pCode->SetExclusiveRecalcModeNormal();
}
else
{
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index dc37e08..7326497 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2272,7 +2272,7 @@ void ScInterpreter::ScDde()
// Nach dem Laden muss neu interpretiert werden (Verknuepfungen aufbauen)
if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
- pMyFormulaCell->GetCode()->SetRecalcModeOnLoad();
+ pMyFormulaCell->GetCode()->SetExclusiveRecalcModeOnLoad();
// solange der Link nicht ausgewertet ist, Idle abklemmen
// (um zirkulaere Referenzen zu vermeiden)
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index d6f59f7..04cd1b58 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2676,7 +2676,7 @@ void ScInterpreter::ScExternal()
{
// nach dem Laden Asyncs wieder anwerfen
if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
- pMyFormulaCell->GetCode()->SetRecalcModeOnLoad();
+ pMyFormulaCell->GetCode()->SetExclusiveRecalcModeOnLoad();
// garantiert identischer Handle bei identischem Aufruf?!?
// sonst schei*e ...
double nErg = 0.0;
@@ -3047,7 +3047,7 @@ void ScInterpreter::ScExternal()
{
if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
{
- pMyFormulaCell->GetCode()->SetRecalcModeOnLoad();
+ pMyFormulaCell->GetCode()->SetExclusiveRecalcModeOnLoad();
}
uno::Reference<sheet::XVolatileResult> xRes = aCall.GetVarRes();
ScAddInListener* pLis = ScAddInListener::Get( xRes );
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index b819ab0..07d22f8 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -1684,7 +1684,7 @@ const ScTokenArray* ExcelToSc::GetBoolErr( XclBoolError eType )
if( nError )
( ( ScTokenArray* ) pErgebnis )->SetCodeError( nError );
- ( ( ScTokenArray* ) pErgebnis )->SetRecalcModeNormal();
+ ( ( ScTokenArray* ) pErgebnis )->SetExclusiveRecalcModeNormal();
return pErgebnis;
}
commit ff319d052659974d1aa5d6ac8c468a7259a46cc4
Author: Eike Rathke <erack at redhat.com>
Date: Fri Feb 15 13:07:00 2013 +0100
use AddRecalcMode(RECALCMODE_ONLOAD), fdo#60645 related
Instead of SetRecalcModeOnLoad() which sets the exclusive bit overriding
RECALCMODE_ALWAYS use AddRecalcMode() that handles these cases.
Change-Id: Ieeeff67d4dda1493e8c48f231b870513f655839a
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index c4e6cb1..a8bfcbd 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1070,16 +1070,16 @@ void FormulaCompiler::Factor()
// and recalc mode on load, fdo#60646
case ocCell :
pArr->SetRecalcModeOnRefMove();
- pArr->SetRecalcModeOnLoad();
+ pArr->AddRecalcMode( RECALCMODE_ONLOAD );
break;
case ocHyperLink :
// cell with hyperlink needs to be calculated on load to
// get its matrix result generated.
- pArr->SetRecalcModeOnLoad();
+ pArr->AddRecalcMode( RECALCMODE_ONLOAD );
pArr->SetHyperLink(true);
break;
case ocDde:
- pArr->SetRecalcModeOnLoad();
+ pArr->AddRecalcMode( RECALCMODE_ONLOAD );
break;
default:
; // nothing
commit cf8318429e3177574f9d60042c402401f484bf17
Author: Eike Rathke <erack at redhat.com>
Date: Wed Feb 13 21:49:52 2013 +0100
prevent out-of-bounds buffer writes in EnumLocalesParams
osl_getTextEncodingFromLocale()
In case of the Language code being longer than 2 characters the string
written to the struct EnumLocalesParams member was not 0-terminated if a
Country code was also given (consecutive fields in the struct) unless
the struct was packed in 4-byte alignment and luckily contained a 0 as
the 4th byte. The locale could not had been matched in these cases. In
case of a sufficiently long language or country argument the entire
EnumLocalesParams struct could had been overflown.
Change-Id: I1ec67ad0b3d12b0fa944d7e759bb5cb701842e39
diff --git a/sal/osl/w32/nlsupport.c b/sal/osl/w32/nlsupport.c
index 19e2a3f..e05e584 100644
--- a/sal/osl/w32/nlsupport.c
+++ b/sal/osl/w32/nlsupport.c
@@ -33,10 +33,24 @@
#include <osl/process.h>
#include <rtl/tencinfo.h>
+
+/* XXX NOTE:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/dd373848.aspx
+ * (retrieved 2013-02-13) has some weird description for the LOCALE_SISO*
+ * constants: "The maximum number of characters allowed for this string is
+ * nine, including a terminating null character." NINE?!? In ISO 639 and ISO
+ * 3166?
+ */
+#define ELP_LANGUAGE_FIELD_LENGTH 4
+#define ELP_COUNTRY_FIELD_LENGTH 3
+
+/** Struct used in EnumLocalesProcA() called via EnumSystemLocalesA() to obtain
+ available locales.
+*/
struct EnumLocalesParams
{
- WCHAR Language[3];
- WCHAR Country[3];
+ WCHAR Language[ELP_LANGUAGE_FIELD_LENGTH];
+ WCHAR Country[ELP_COUNTRY_FIELD_LENGTH];
LCID Locale;
};
@@ -58,7 +72,7 @@ BOOL CALLBACK EnumLocalesProcA( LPSTR lpLocaleStringA )
LCID localeId;
LPSTR pszEndA;
- WCHAR langCode[4];
+ WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
/* convert hex-string to LCID */
localeId = strtol( lpLocaleStringA, &pszEndA, 16 );
@@ -76,16 +90,17 @@ BOOL CALLBACK EnumLocalesProcA( LPSTR lpLocaleStringA )
an error under WinNT/2000 when called with an
unicode only lcid
*/
- if( GetLocaleInfo( localeId, LOCALE_SISO639LANGNAME , langCode, 4 ) )
+ if( GetLocaleInfo( localeId, LOCALE_SISO639LANGNAME , langCode, ELP_LANGUAGE_FIELD_LENGTH ) )
{
- WCHAR ctryCode[4];
+ WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
/* continue if language code does not match */
if( 0 != wcscmp( langCode, params->Language ) )
return TRUE;
/* check if country code is set and equals the current locale */
- if( '\0' != params->Country[0] && GetLocaleInfo( localeId, LOCALE_SISO3166CTRYNAME , ctryCode, 4 ) )
+ if( '\0' != params->Country[0] && GetLocaleInfo( localeId,
+ LOCALE_SISO3166CTRYNAME , ctryCode, ELP_COUNTRY_FIELD_LENGTH ) )
{
/* save return value in TLS and break if found desired locale */
if( 0 == wcscmp( ctryCode, params->Country ) )
@@ -173,11 +188,11 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
osl_getProcessLocale( &pLocale );
/* copy in parameters to structure */
- if( pLocale && pLocale->Language )
+ if( pLocale && pLocale->Language && pLocale->Language->length < ELP_LANGUAGE_FIELD_LENGTH )
{
wcscpy( params.Language, pLocale->Language->buffer );
- if( pLocale->Country )
+ if( pLocale->Country && pLocale->Country->length < ELP_COUNTRY_FIELD_LENGTH )
wcscpy( params.Country, pLocale->Country->buffer );
/* save pointer to local structure in TLS */
@@ -199,8 +214,8 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
void _imp_getProcessLocale( rtl_Locale ** ppLocale )
{
- WCHAR langCode[4];
- WCHAR ctryCode[4];
+ WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
+ WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
LCID localeId;
OSL_ASSERT( ppLocale );
@@ -209,8 +224,8 @@ void _imp_getProcessLocale( rtl_Locale ** ppLocale )
localeId = GetUserDefaultLCID();
/* call GetLocaleInfo to retrieve the iso codes */
- if( GetLocaleInfo( localeId, LOCALE_SISO639LANGNAME , langCode, 4 ) &&
- GetLocaleInfo( localeId, LOCALE_SISO3166CTRYNAME , ctryCode, 4 ) )
+ if( GetLocaleInfo( localeId, LOCALE_SISO639LANGNAME , langCode, ELP_LANGUAGE_FIELD_LENGTH ) &&
+ GetLocaleInfo( localeId, LOCALE_SISO3166CTRYNAME , ctryCode, ELP_COUNTRY_FIELD_LENGTH ) )
{
*ppLocale = rtl_locale_register( langCode, ctryCode, L"" );
}
commit 8a07032d01aa59fd94c393669d8ac4b8443acb2b
Author: Eike Rathke <erack at redhat.com>
Date: Wed Feb 13 20:16:42 2013 +0100
do not use the raw locale for osl_getTextEncodingFromLocale()
Change-Id: Iab7402721b5fbf20a05c9ff2725e52b012df2940
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index d850dd7..bf67a4d 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -204,9 +204,21 @@ rtl_TextEncoding SvtSysLocale::GetBestMimeEncoding()
{
// If the system locale is unknown to us, e.g. LC_ALL=xx, match the UI
// language if possible.
- ::com::sun::star::lang::Locale aLocale( SvtSysLocale().GetUILanguageTag().getLocale() );
- rtl_Locale * pLocale = rtl_locale_register( aLocale.Language.getStr(),
- aLocale.Country.getStr(), aLocale.Variant.getStr() );
+ SvtSysLocale aSysLocale;
+ const LanguageTag& rLanguageTag = aSysLocale.GetUILanguageTag();
+ // Converting blindly to Locale and then to rtl_Locale may feed the
+ // 'qlt' to rtl_locale_register() and the underlying system locale
+ // stuff, which doesn't know about it nor about BCP47 in the Variant
+ // field. So use the real language and for non-pure ISO cases hope for
+ // the best.. the fallback to UTF-8 should solve these cases nowadays.
+ /* FIXME-BCP47: the script needs to go in here as well, so actually
+ * we'd need some variant fiddling or glibc locale string and tweak
+ * rtl_locale_register() to know about it! But then again the Windows
+ * implementation still wouldn't know anything about it ... */
+ SAL_WARN_IF( !rLanguageTag.isIsoLocale(), "unotools.i18n",
+ "SvtSysLocale::GetBestMimeEncoding - non-ISO UI locale");
+ rtl_Locale * pLocale = rtl_locale_register( rLanguageTag.getLanguage().getStr(),
+ rLanguageTag.getCountry().getStr(), OUString().getStr() );
rtl_TextEncoding nEnc = osl_getTextEncodingFromLocale( pLocale );
pCharSet = rtl_getBestMimeCharsetFromTextEncoding( nEnc );
}
commit 5918c7c84c18042baba42e5899f00d69254e3586
Author: Eike Rathke <erack at redhat.com>
Date: Wed Feb 13 18:12:51 2013 +0100
use LanguageTag(rtl_Locale) ctor
Change-Id: Ie668d40b815ae1cbcdb321649d8e52513cad1aec
diff --git a/i18npool/source/isolang/inunx.cxx b/i18npool/source/isolang/inunx.cxx
index 778446a..005421c 100644
--- a/i18npool/source/isolang/inunx.cxx
+++ b/i18npool/source/isolang/inunx.cxx
@@ -99,10 +99,7 @@ static void getPlatformSystemLanguageImpl( LanguageType& rSystemLanguage,
if ( osl_getProcessLocale(&procLocale) == osl_Process_E_None )
{
- rtl::OUString rLang( procLocale->Language );
- rtl::OUString rCountry( procLocale->Country );
-
- nLang = LanguageTag( rLang, rCountry ).getLanguageType();
+ nLang = LanguageTag( *procLocale ).getLanguageType();
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
rSystemLanguage = nLang;
#ifdef DEBUG
More information about the Libreoffice-commits
mailing list