include/vcl/toolkit/field.hxx | 2 +- vcl/source/control/field2.cxx | 35 ++++++++++++++--------------------- 2 files changed, 15 insertions(+), 22 deletions(-)
New commits: commit 0335a319c5662f0b849a2231e48338dfeb6aa845 Author: Eike Rathke <er...@redhat.com> AuthorDate: Mon Jul 5 14:24:27 2021 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Mon Jul 5 17:24:09 2021 +0200 Pass Formatter::StaticFormatter also from weld:DateFormatter, tdf#125035 Change-Id: I8e6b0e581b9522fb04225fc945e579406a4be208 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118438 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx index 5217922ae20f..9ac458f0dc00 100644 --- a/include/vcl/toolkit/field.hxx +++ b/include/vcl/toolkit/field.hxx @@ -417,7 +417,7 @@ protected: SAL_DLLPRIVATE bool ImplAllowMalformedInput() const; public: - static OUString FormatDate(const Date& rNewDate, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleData, CalendarWrapper& rCalendarWrapper, const Formatter::StaticFormatter* pStaticFormatter = nullptr); + static OUString FormatDate(const Date& rNewDate, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleData, const Formatter::StaticFormatter& rStaticFormatter); static bool TextToDate(const OUString& rStr, Date& rTime, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleDataWrapper, const CalendarWrapper& rCalendarWrapper); static int GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 603415672f38..6ed04e3a16ee 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -1388,8 +1388,8 @@ namespace } OUString DateFormatter::FormatDate(const Date& rDate, ExtDateFieldFormat eExtFormat, - const LocaleDataWrapper& rLocaleData, CalendarWrapper& rCalendarWrapper, - const Formatter::StaticFormatter* pStaticFormatter) + const LocaleDataWrapper& rLocaleData, + const Formatter::StaticFormatter& rStaticFormatter) { bool bShowCentury = false; switch (eExtFormat) @@ -1439,22 +1439,16 @@ OUString DateFormatter::FormatDate(const Date& rDate, ExtDateFieldFormat eExtFor { case ExtDateFieldFormat::SystemLong: { - /* TODO: adapt all callers to pass a StaticFormatter. */ - if (!pStaticFormatter) - return rLocaleData.getLongDate( rDate, rCalendarWrapper, !bShowCentury ); - else - { - SvNumberFormatter* pFormatter = *pStaticFormatter; - const LanguageTag aFormatterLang( pFormatter->GetLanguageTag()); - const sal_uInt32 nIndex = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_LONG, - rLocaleData.getLanguageTag().getLanguageType(false)); - OUString aStr; - const Color* pCol; - pFormatter->GetOutputString( rDate - pFormatter->GetNullDate(), nIndex, aStr, &pCol); - // Reset to what other uses may expect. - pFormatter->ChangeIntl( aFormatterLang.getLanguageType(false)); - return aStr; - } + SvNumberFormatter* pFormatter = rStaticFormatter; + const LanguageTag aFormatterLang( pFormatter->GetLanguageTag()); + const sal_uInt32 nIndex = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_LONG, + rLocaleData.getLanguageTag().getLanguageType(false)); + OUString aStr; + const Color* pCol; + pFormatter->GetOutputString( rDate - pFormatter->GetNullDate(), nIndex, aStr, &pCol); + // Reset to what other uses may expect. + pFormatter->ChangeIntl( aFormatterLang.getLanguageType(false)); + return aStr; } case ExtDateFieldFormat::ShortDDMMYY: case ExtDateFieldFormat::ShortDDMMYYYY: @@ -1499,8 +1493,7 @@ OUString DateFormatter::FormatDate(const Date& rDate, ExtDateFieldFormat eExtFor OUString DateFormatter::ImplGetDateAsText( const Date& rDate ) const { - return DateFormatter::FormatDate(rDate, GetExtDateFormat(), ImplGetLocaleDataWrapper(), - GetCalendarWrapper(), &maStaticFormatter); + return DateFormatter::FormatDate(rDate, GetExtDateFormat(), ImplGetLocaleDataWrapper(), maStaticFormatter); } static void ImplDateIncrementDay( Date& rDate, bool bUp ) @@ -2219,7 +2212,7 @@ namespace weld OUString DateFormatter::FormatNumber(int nValue) const { const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - return ::DateFormatter::FormatDate(Date(nValue), m_eFormat, rLocaleData, GetCalendarWrapper()); + return ::DateFormatter::FormatDate(Date(nValue), m_eFormat, rLocaleData, m_aStaticFormatter); } IMPL_LINK_NOARG(DateFormatter, FormatOutputHdl, LinkParamNone*, bool) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits