svl/source/numbers/zforlist.cxx |    3 ++-
 svl/source/numbers/zforscan.cxx |    5 +++--
 svl/source/numbers/zforscan.hxx |    3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 234cb2da3598837a60572dc8475bcb7d9503335f
Author:     Mateusz Wlazłowski <mateusz....@gmail.com>
AuthorDate: Sun Apr 27 11:44:49 2025 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Apr 30 17:42:40 2025 +0200

    tdf#166268 Initialize the correct null date in ImpSvNumberformatScan
    
    When forcibly recalculating the document from the bug report, multiple 
threads
    are spawned, each initializing its own SvNFLanguageData object from an 
already
    existing one.
    
    When initializing an SvNFLanguageData object from another one, the 
associated
    null date (maNullDate) is not passed to the newly created
    ImpSvNumberformatScan object, resulting in it always initializing with the
    default null date of 30/12/1899 in worker threads.
    However, the document has a base date set to 01/01/1904, causing displayed
    dates to appear from 1904, while functions like =YEAR() calculate dates
    based on 1899. This leads to a 4-year difference between displayed dates and
    the results of date functions.
    
    This commit updates the ImpSvNumberformatScan constructor to pass the 
original
    object's null date during initialization, while retaining 30/12/1899 as the
    default for cases where no explicit null date is provided.
    
    Regression from: b38974391e8d4bf0d450abfaa86bbccbe1022995
    (Related: tdf#160056 do calc NumberFormatting via ScInterpreterContext)
    
    Change-Id: I7b622717f2c245dccef22897c1a2cc88daf60ff6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184687
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 7fe1e337d5f3..83f678e4aebe 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -325,7 +325,8 @@ SvNFLanguageData::SvNFLanguageData(const SvNFLanguageData& 
rOther)
     xTransliteration.init(xContext, ActLnge);
 
     pStringScanner.reset(new ImpSvNumberInputScan(*this));
-    pFormatScanner.reset(new ImpSvNumberformatScan(*this, 
rOther.pFormatScanner->getColorCallback()));
+    pFormatScanner.reset(new ImpSvNumberformatScan(*this, 
rOther.pFormatScanner->getColorCallback(),
+                                                   
rOther.pFormatScanner->GetNullDate()));
 }
 
 SvNFLanguageData::~SvNFLanguageData()
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index d79f0bb9d35b..a63c91ee7716 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -122,8 +122,9 @@ static const std::u16string_view& GermanColorName(size_t i)
 }
 
 ImpSvNumberformatScan::ImpSvNumberformatScan(SvNFLanguageData& 
rCurrentLanguageData,
-                                             const SvNumberFormatter& 
rColorCallback)
-    : maNullDate( 30, 12, 1899)
+                                             const SvNumberFormatter& 
rColorCallback,
+                                             const Date& aNullDate)
+    : maNullDate(aNullDate)
     , mrCurrentLanguageData(rCurrentLanguageData)
     , mrColorCallback(rColorCallback)
     , eNewLnge(LANGUAGE_DONTKNOW)
diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx
index 2613fe02abc3..b35c48ce9d8e 100644
--- a/svl/source/numbers/zforscan.hxx
+++ b/svl/source/numbers/zforscan.hxx
@@ -51,7 +51,8 @@ public:
     };
 
     explicit ImpSvNumberformatScan(SvNFLanguageData& rCurrentLanguageData,
-                                   const SvNumberFormatter& rColorCallback);
+                                   const SvNumberFormatter& rColorCallback,
+                                   const Date& aNullDate = Date(30, 12, 1899));
     ~ImpSvNumberformatScan();
     void ChangeIntl( KeywordLocalization eKeywordLocalization = 
KeywordLocalization::AllowEnglish ); // Replaces Keywords
 

Reply via email to