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 <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 0335a319c5662f0b849a2231e48338dfeb6aa845)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118427
diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx
index d6ae05f..1eb55fa 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 6034156..6ed04e3 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)