summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/tools/DiagramHelper.cxx2
-rw-r--r--include/svl/numformat.hxx11
-rw-r--r--sc/source/core/data/column3.cxx4
-rw-r--r--svl/source/numbers/zforlist.cxx40
4 files changed, 34 insertions, 23 deletions
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index f1021442f617..51bcd4cf9f0c 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -1061,7 +1061,7 @@ sal_Int32 DiagramHelper::getDateTimeInputNumberFormat( const Reference< util::XN
// Obtain best matching date, time or datetime format.
nRet = pNumFormatter->GuessDateTimeFormat( nType, fNumber, LANGUAGE_SYSTEM);
// Obtain the corresponding edit format.
- nRet = pNumFormatter->GetEditFormat( fNumber, nRet, nType, LANGUAGE_SYSTEM, nullptr);
+ nRet = pNumFormatter->GetEditFormat( fNumber, nRet, nType, nullptr);
}
return nRet;
}
diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index e002349b2dad..9cdb414346c5 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -306,9 +306,16 @@ public:
should not be used otherwise. */
sal_uInt32 GuessDateTimeFormat(SvNumFormatType& rType, double fNumber, LanguageType eLnge);
- /** Return the corresponding edit format of a format. */
+ /** Return the corresponding edit format of a format.
+
+ nFIndex, eType and pFormat (if not nullptr) are assumed to match each
+ other / be of one format. The locale to use is obtained from pFormat,
+ if nullptr then LANGUAGE_SYSTEM is used. This can be overriden by
+ specifying eForLocale other than LANGUAGE_DONTKNOW.
+ */
sal_uInt32 GetEditFormat(double fNumber, sal_uInt32 nFIndex, SvNumFormatType eType,
- LanguageType eLnge, SvNumberformat const* pFormat);
+ SvNumberformat const* pFormat,
+ LanguageType eForLocale = LANGUAGE_DONTKNOW);
/// Return the reference date
const Date& GetNullDate() const;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 56aff45386b5..8d5a9363a02a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2064,8 +2064,8 @@ bool ScColumn::ParseString(
bForceFormatDate = false;
else
{
- nIndex = aParam.mpNumFormatter->GetEditFormat( aCell.getValue(), nOldIndex, eNumFormatType,
- pOldFormat->GetLanguage(), pOldFormat);
+ nIndex = aParam.mpNumFormatter->GetEditFormat(
+ aCell.getValue(), nOldIndex, eNumFormatType, pOldFormat);
eEvalDateFormat = aParam.mpNumFormatter->GetEvalDateFormat();
aParam.mpNumFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL);
}
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 8606a4a24226..1ea60fc81784 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1594,10 +1594,14 @@ sal_uInt32 SvNumberFormatter::GuessDateTimeFormat( SvNumFormatType& rType, doubl
}
sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex,
- SvNumFormatType eType, LanguageType eLang,
- SvNumberformat const * pFormat )
+ SvNumFormatType eType,
+ SvNumberformat const * pFormat,
+ LanguageType eForLocale )
{
::osl::MutexGuard aGuard( GetInstanceMutex() );
+ const LanguageType eLang = (pFormat ? pFormat->GetLanguage() : LANGUAGE_SYSTEM);
+ if (eForLocale == LANGUAGE_DONTKNOW)
+ eForLocale = eLang;
sal_uInt32 nKey = nFIndex;
switch ( eType )
{
@@ -1615,16 +1619,16 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex,
// fdo#34977 preserve time when editing even if only date was
// displayed.
if (bIsoDate)
- nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang);
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eForLocale);
else
- nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eForLocale );
}
else
{
if (bIsoDate)
- nKey = GetFormatIndex( NF_DATE_ISO_YYYYMMDD, eLang);
+ nKey = GetFormatIndex( NF_DATE_ISO_YYYYMMDD, eForLocale);
else
- nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
+ nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eForLocale );
}
}
break;
@@ -1635,36 +1639,36 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex,
* of a signed 16-bit. 32k hours are 3.7 years ... or
* 1903-09-26 if date. */
if (fabs( fNumber) * 24 < 0x7fff)
- nKey = GetTimeFormat( fNumber, eLang, true);
+ nKey = GetTimeFormat( fNumber, eForLocale, true);
// Preserve duration, use [HH]:MM:SS instead of time.
else
- nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eForLocale );
// Assume that a large value is a datetime with only time
// displayed.
}
else
- nKey = GetStandardFormat( fNumber, nFIndex, eType, eLang );
+ nKey = GetStandardFormat( fNumber, nFIndex, eType, eForLocale );
break;
case SvNumFormatType::DURATION :
- nKey = GetTimeFormat( fNumber, eLang, true);
+ nKey = GetTimeFormat( fNumber, eForLocale, true);
break;
case SvNumFormatType::DATETIME :
if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang))
- nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eForLocale );
else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, eLang))
- nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, eForLocale );
else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, eLang))
- nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, eForLocale );
else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang) || (pFormat && pFormat->IsIso8601( 0 )))
- nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eForLocale );
else
- nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eForLocale );
break;
case SvNumFormatType::NUMBER:
- nKey = GetStandardFormat( eType, eLang );
+ nKey = GetStandardFormat( eType, eForLocale );
break;
default:
- nKey = GetStandardFormat( fNumber, nFIndex, eType, eLang );
+ nKey = GetStandardFormat( fNumber, nFIndex, eType, eForLocale );
}
return nKey;
}
@@ -1712,7 +1716,7 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
bPrecChanged = true;
}
- sal_uInt32 nKey = GetEditFormat( fOutNumber, nRealKey, eType, eLang, pFormat);
+ sal_uInt32 nKey = GetEditFormat( fOutNumber, nRealKey, eType, pFormat);
// if bFiltering true keep the nRealKey format
if ( nKey != nRealKey && !bFiltering )
{