sw/qa/extras/mailmerge/data/mm-single-date.fodt | 25 ++++++++++++++++++++++++ sw/qa/extras/mailmerge/data/single-date.ods |binary sw/qa/extras/mailmerge/mailmerge2.cxx | 14 +++++++++++++ sw/source/core/fields/dbfld.cxx | 2 - sw/source/ui/dbui/dbinsdlg.cxx | 2 - 5 files changed, 41 insertions(+), 2 deletions(-)
New commits: commit 8eeb11aba618d6333b254b05749bba9d6235827f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Sep 10 15:43:18 2025 +0500 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Sep 11 09:23:22 2025 +0200 tdf#168252: fix "standard" date in SwDBField::FormatValue ... after commit 5b808448dc79e996efa7cb5082145d4e5803daa6 (Related: tdf#167591 Make STANDARD_DB_DATE more standard, 2025-07-21). Change-Id: I3bbe87c77aafb44cf53bc43613eeb3eb975b42f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190749 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 92f0eeef847bb8c980aef1760c3355df0e2e11ef) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190777 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/mailmerge/data/mm-single-date.fodt b/sw/qa/extras/mailmerge/data/mm-single-date.fodt new file mode 100644 index 000000000000..d8fcf2e27c1a --- /dev/null +++ b/sw/qa/extras/mailmerge/data/mm-single-date.fodt @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:settings> + <config:config-item-set config:name="ooo:configuration-settings"> + <config:config-item config:name="CurrentDatabaseDataSource" config:type="string">single-date</config:config-item> + <config:config-item config:name="CurrentDatabaseCommand" config:type="string">Sheet1</config:config-item> + <config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item> + </config:config-item-set> + </office:settings> + <office:automatic-styles> + <number:date-style style:name="ISO" number:language="en" number:country="US"> + <number:year number:style="long"/> + <number:text>-</number:text> + <number:month number:style="long"/> + <number:text>-</number:text> + <number:day number:style="long"/> + </number:date-style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p><text:database-display text:table-name="Sheet1" text:table-type="table" text:column-name="date" style:data-style-name="ISO" text:database-name="single-date"><date></text:database-display></text:p> + </office:text> + </office:body> +</office:document> \ No newline at end of file diff --git a/sw/qa/extras/mailmerge/data/single-date.ods b/sw/qa/extras/mailmerge/data/single-date.ods new file mode 100644 index 000000000000..6f3d36ddefa2 Binary files /dev/null and b/sw/qa/extras/mailmerge/data/single-date.ods differ diff --git a/sw/qa/extras/mailmerge/mailmerge2.cxx b/sw/qa/extras/mailmerge/mailmerge2.cxx index de3c8fb770c6..e1f21e2089ad 100644 --- a/sw/qa/extras/mailmerge/mailmerge2.cxx +++ b/sw/qa/extras/mailmerge/mailmerge2.cxx @@ -432,6 +432,20 @@ CPPUNIT_TEST_FIXTURE(MMTest2, testTdf156061) getXPath(pXmlDoc, "//txt[2]/infos/bounds", "height").toInt32()); } +// The document has a MM field referencing a date in the data source having a single record. +// The check ensures that the date arrives correctly to the merged document. +DECLARE_SHELL_MAILMERGE_TEST(testTdf168252, "mm-single-date.fodt", "single-date.ods", "Sheet1") +{ + executeMailMerge(); + CPPUNIT_ASSERT(mxSwTextDocument); + + // Without the fix, this would fail with + // - Expected: 2025-08-31 + // - Actual : 2025-09-02 + // because the DB filed code assumed obsolete null date. + CPPUNIT_ASSERT_EQUAL(u"2025-08-31"_ustr, mxSwTextDocument->getText()->getString()); +} + } // end of anonymous namespace namespace com::sun::star::table { diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index de9ca7208dad..b8ef92ff6e8e 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -264,7 +264,7 @@ bool SwDBField::FormatValue( SvNumberFormatter const * pDocFormatter, OUString c if( DataType::DATE == nColumnType || DataType::TIME == nColumnType || DataType::TIMESTAMP == nColumnType ) { - Date aStandard( 1, 1, 1900 ); + Date aStandard(30, 12, 1899); if( pDocFormatter->GetNullDate() != aStandard ) aNumber += (aStandard - pDocFormatter->GetNullDate()); } commit 40f481b9c4d3cdcb5621002064ac89578ed6dece Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Sep 10 16:52:34 2025 +0500 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Sep 11 09:23:11 2025 +0200 tdf#168347: fix "standard" date in SwInsertDBColAutoPilot::DataToDoc (1) This fixes DB_Column::Type::COL_TEXT case. Change-Id: I2b758000b49ae8d1729f3ce61b066f5d0eeb434b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190756 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit cda403f39b5db9074917819e60a2e16744136c11) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190778 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index bb97a6030bf1..e7b2a0dc7e39 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1312,7 +1312,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, const Color* pCol; if(rNumFormatr.GetType(pDBCol->nFormat) & SvNumFormatType::DATE) { - ::Date aStandard(1,1,1900); + ::Date aStandard(30, 12, 1899); if (rNumFormatr.GetNullDate() != aStandard) nValue += (aStandard - rNumFormatr.GetNullDate()); }