[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 26 19:38:01 UTC 2020


 sw/qa/extras/uiwriter/uiwriter.cxx  |   14 ++++++++++++++
 sw/source/uibase/shells/textfld.cxx |   11 +++++++++++
 2 files changed, 25 insertions(+)

New commits:
commit efe25ca0706541f7d0144e5b650a19f8d2f1a1ac
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Thu Jun 11 07:37:49 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Sun Jul 26 21:37:31 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.)
    
    Conflicts:
            sw/qa/extras/uiwriter/uiwriter.cxx
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96112
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 64641e9aa8f5399bae7846830176bc4444bfaf9d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96584
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    (cherry picked from commit 86ed93261137e24c679baed137cc4559eb5376e4)
    
    Change-Id: I09f2f3314356e84c73a42be9f06ceaa6769e7338
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99401
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 22c64cf844d6..33a5563c505e 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -368,6 +368,7 @@ public:
     void testTdf59666();
     void testTdf133524();
     void testInconsistentBookmark();
+    void testInsertLongDateFormat();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -577,6 +578,7 @@ public:
     CPPUNIT_TEST(testTdf38394);
     CPPUNIT_TEST(testTdf59666);
     CPPUNIT_TEST(testTdf133524);
+    CPPUNIT_TEST(testInsertLongDateFormat);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -7144,6 +7146,18 @@ void SwUiWriterTest::testTdf133524()
     CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
+void SwUiWriterTest::testInsertLongDateFormat()
+{
+    // only for Hungarian, yet
+    createDoc("tdf133524.fodt");
+    lcl_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);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index c65d5d65da6a..b5644784f8ac 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -82,6 +82,7 @@
 #include <svl/zformat.hxx>
 #include <IMark.hxx>
 #include <officecfg/Office/Compatibility.hxx>
+#include <ndtxt.hxx>
 
 
 using namespace nsSwDocInfoSubType;
@@ -636,9 +637,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;


More information about the Libreoffice-commits mailing list