From 96f2a6d16e6a6bf070e6875776b6153a70e75a7a Mon Sep 17 00:00:00 2001
From: Eike Rathke <erack@redhat.com>
Date: Sat, 3 Jul 2021 11:46:49 +0200
Subject: Resolves: tdf#125035 Use number formatter for long date in
 DateFormatter fields

Change-Id: Ib0cd55d9ad4e3abb4839d70c0086063a3f1a90f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118344
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 2cc8ec691cc37b07e4f134bf379164f375b8a481)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118310
---
 include/vcl/formatter.hxx     | 4 ++--
 include/vcl/toolkit/field.hxx | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

(limited to 'include')

diff --git a/include/vcl/formatter.hxx b/include/vcl/formatter.hxx
index e2879dc36076..2049d1e12a6f 100644
--- a/include/vcl/formatter.hxx
+++ b/include/vcl/formatter.hxx
@@ -85,7 +85,7 @@ enum class FORMAT_CHANGE_TYPE
 
 class VCL_DLLPUBLIC Formatter
 {
-private:
+public:
     // A SvNumberFormatter is very expensive (regarding time and space), it is a Singleton
     class StaticFormatter
     {
@@ -95,7 +95,7 @@ private:
         StaticFormatter();
         ~StaticFormatter();
 
-        operator SvNumberFormatter* () { return GetFormatter(); }
+        operator SvNumberFormatter* () const { return GetFormatter(); }
         UNLESS_MERGELIBS(VCL_DLLPUBLIC) static SvNumberFormatter* GetFormatter();
     };
 
diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx
index e30d16e55edc..d6ae05f51fc5 100644
--- a/include/vcl/toolkit/field.hxx
+++ b/include/vcl/toolkit/field.hxx
@@ -29,6 +29,7 @@
 #include <tools/time.hxx>
 #include <vcl/toolkit/combobox.hxx>
 #include <vcl/toolkit/spinfld.hxx>
+#include <vcl/formatter.hxx>
 
 namespace com::sun::star::lang { struct Locale; }
 
@@ -391,6 +392,7 @@ public:
 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DateFormatter : public FormatterBase
 {
 private:
+    Formatter::StaticFormatter maStaticFormatter;
     std::unique_ptr<CalendarWrapper> mxCalendarWrapper;
     Date                    maFieldDate;
     Date                    maLastDate;
@@ -415,7 +417,7 @@ protected:
     SAL_DLLPRIVATE bool     ImplAllowMalformedInput() const;
 
 public:
-    static OUString         FormatDate(const Date& rNewDate, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleData, CalendarWrapper& rCalendarWrapper);
+    static OUString         FormatDate(const Date& rNewDate, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleData, CalendarWrapper& rCalendarWrapper, const Formatter::StaticFormatter* pStaticFormatter = nullptr);
     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);
 
-- 
cgit