sw/qa/extras/uiwriter/uiwriter.cxx | 14 ++++++++++++++ sw/source/uibase/shells/textfld.cxx | 11 +++++++++++ 2 files changed, 25 insertions(+)
New commits: commit 97835320bfe7a2fa61f10f102feb961f81057118 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Jun 11 07:37:49 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Jun 18 11:37:59 2020 +0200 tdf#134035 sw: insert long date format for Hungarian in Writer using Insert->Field->Date or the similar toolbar function. Note: the previously used short date format YYYY-MM-DD is rare in Hungarian text documents, and it is no longer mentioned in the last Hungarian orthographic standard (But it's still default in Calc, as standardized by (MSZ) ISO 8601.) Change-Id: I09f2f3314356e84c73a42be9f06ceaa6769e7338 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96112 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 1fff27fff064..774bfbab8092 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -372,6 +372,7 @@ public: void testTdf128860(); void testTdf133589(); void testInconsistentBookmark(); + void testInsertLongDateFormat(); #if HAVE_FEATURE_PDFIUM void testInsertPdf(); #endif @@ -588,6 +589,7 @@ public: CPPUNIT_TEST(testTdf133524); CPPUNIT_TEST(testTdf128860); CPPUNIT_TEST(testTdf133589); + CPPUNIT_TEST(testInsertLongDateFormat); #if HAVE_FEATURE_PDFIUM CPPUNIT_TEST(testInsertPdf); #endif @@ -7308,6 +7310,18 @@ void SwUiWriterTest::testTdf133589() CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText()); } +void SwUiWriterTest::testInsertLongDateFormat() +{ + // only for Hungarian, yet + createDoc("tdf133524.fodt"); + dispatchCommand(mxComponent, ".uno:InsertDateField", {}); + // Make sure that the document starts with a field now, and its expanded string value contains space + const uno::Reference< text::XTextRange > xField = getRun(getParagraph(1), 1); + CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xField, "TextPortionType")); + // the date format was "YYYY-MM-DD", but now "YYYY. MMM DD." + CPPUNIT_ASSERT(xField->getString().indexOf(" ") > -1); +} + #if HAVE_FEATURE_PDFIUM void SwUiWriterTest::testInsertPdf() { diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 929b731e6856..9b7d3b10a4fd 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -60,6 +60,7 @@ #include <svl/zformat.hxx> #include <IMark.hxx> #include <officecfg/Office/Compatibility.hxx> +#include <ndtxt.hxx> using namespace nsSwDocInfoSubType; @@ -605,9 +606,19 @@ void SwTextShell::ExecField(SfxRequest &rReq) break; case FN_INSERT_FLD_DATE : + { nInsertType = SwFieldTypesEnum::Date; bIsText = false; + // use long date format for Hungarian + SwPaM* pCursorPos = rSh.GetCursor(); + if( pCursorPos ) + { + LanguageType nLang = pCursorPos->GetPoint()->nNode.GetNode().GetTextNode()->GetLang(pCursorPos->GetPoint()->nContent.GetIndex()); + if (nLang == LANGUAGE_HUNGARIAN) + nInsertFormat = rSh.GetNumberFormatter()->GetFormatIndex(NF_DATE_SYSTEM_LONG, nLang); + } goto FIELD_INSERT; + } case FN_INSERT_FLD_TIME : nInsertType = SwFieldTypesEnum::Time; bIsText = false; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits