[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 25 11:49:31 UTC 2020


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

New commits:
commit 86ed93261137e24c679baed137cc4559eb5376e4
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Thu Jun 11 07:37:49 2020 +0200
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Thu Jun 25 13:48:58 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
    
    Change-Id: I09f2f3314356e84c73a42be9f06ceaa6769e7338
    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>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index bb0d12aa7804..66137c9af662 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -375,6 +375,7 @@ public:
     void testTdf133589();
 #endif
     void testInconsistentBookmark();
+    void testInsertLongDateFormat();
 #if HAVE_FEATURE_PDFIUM
     void testInsertPdf();
 #endif
@@ -593,6 +594,7 @@ public:
 #if ENABLE_LIBNUMBERTEXT
     CPPUNIT_TEST(testTdf133589);
 #endif
+    CPPUNIT_TEST(testInsertLongDateFormat);
 #if HAVE_FEATURE_PDFIUM
     CPPUNIT_TEST(testInsertPdf);
 #endif
@@ -7319,6 +7321,18 @@ void SwUiWriterTest::testTdf133589()
 }
 #endif
 
+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;


More information about the Libreoffice-commits mailing list