[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - sw/qa sw/source writerfilter/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Sat Jul 13 22:18:26 UTC 2019


 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx    |    4 -
 sw/source/core/crsr/DateFormFieldButton.cxx  |   14 +---
 sw/source/core/text/itrform2.cxx             |   26 +++----
 sw/source/filter/ww8/docxattributeoutput.cxx |   89 +++++++++++++--------------
 sw/source/ui/fldui/DateFormFieldDialog.cxx   |    8 --
 writerfilter/source/dmapper/SdtHelper.cxx    |    5 +
 6 files changed, 70 insertions(+), 76 deletions(-)

New commits:
commit 1784522ef9c10b8d67c193b0ada2f09d4dc79ad3
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jul 3 14:43:54 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:17:59 2019 +0200

    MSForms: DOCX filter: handle date formats with quotation marks.
    
    Reviewed-on: https://gerrit.libreoffice.org/75454
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 9c2feb75a6104d4376cccb157244dd7f6e88968a)
    
    Change-Id: I61cc6d47200acdd55f147b4f1829330dec8562a0
    Reviewed-on: https://gerrit.libreoffice.org/75547
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index a951b61df1d8..f4f9c72a7f11 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -648,7 +648,7 @@ DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx")
     assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1);
 }
 
-/*DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
+DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
 {
     // check XML
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
@@ -658,7 +658,7 @@ DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy");
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES");
     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", u"mi\u00E9rcoles, 05 de marzo de 2014");
-}*/
+}
 
 DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx")
 {
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index fe64960bec2b..501302417305 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1673,8 +1673,11 @@ void DocxAttributeOutput::WriteFormDate(const OUString& sCurrentDate, const OUSt
     else
         m_pSerializer->startElementNS(XML_w, XML_date, FSEND);
 
+    OString sUTF8DateFormat = sDateFormat.toUtf8();
+    // Replace quotation mark used for marking static strings in date format
+    sUTF8DateFormat = sUTF8DateFormat.replaceAll("\"", "'");
     m_pSerializer->singleElementNS(XML_w, XML_dateFormat,
-                                   FSNS(XML_w, XML_val), sDateFormat.toUtf8(), FSEND);
+                                   FSNS(XML_w, XML_val), sUTF8DateFormat, FSEND);
     m_pSerializer->singleElementNS(XML_w, XML_lid,
                                    FSNS(XML_w, XML_val), sLang.toUtf8(), FSEND);
     m_pSerializer->singleElementNS(XML_w, XML_storeMappedDataAs,
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index 41706b616a03..7dd3c2d8a32d 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -114,7 +114,10 @@ void SdtHelper::createDateContentControl()
             uno::Reference<container::XNameContainer> xNameCont = xFormField->getParameters();
             if(xNameCont.is())
             {
-                xNameCont->insertByName(ODF_FORMDATE_DATEFORMAT, uno::makeAny(m_sDateFormat.makeStringAndClear()));
+                OUString sDateFormat = m_sDateFormat.makeStringAndClear();
+                // Replace quotation mark used for marking static strings in date format
+                sDateFormat = sDateFormat.replaceAll("'", "\"");
+                xNameCont->insertByName(ODF_FORMDATE_DATEFORMAT, uno::makeAny(sDateFormat));
                 xNameCont->insertByName(ODF_FORMDATE_DATEFORMAT_LANGUAGE, uno::makeAny(m_sLocale.makeStringAndClear()));
                 OUString sDate = m_sDate.makeStringAndClear();
                 if(!sDate.isEmpty())
commit 0b782ca56bddd95e0706da9d70e2bbb0cd2612de
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jul 3 14:43:12 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:17:49 2019 +0200

    MSForms: date format: better searching of date format entries
    
    * GetEntryKey and PutEntry methods are not consistent.
    * It can happen that GetEntryKey does not found the format
    we are searching for, however the PutEntry() method finds
    it among the entries and so returns with failure.
    * Let's check the nFormat instead, PutEntry returns the found
    entry key if the entry exists.
    
    Reviewed-on: https://gerrit.libreoffice.org/75453
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 9e007eb2b0ab44b436da9d00559150cc4fa37dc5)
    
    Change-Id: Ia7e8702b03999950adfa649d1adc3a839dc5a178
    Reviewed-on: https://gerrit.libreoffice.org/75546
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/source/core/crsr/DateFormFieldButton.cxx b/sw/source/core/crsr/DateFormFieldButton.cxx
index adb12d89286b..52a634e6158f 100644
--- a/sw/source/core/crsr/DateFormFieldButton.cxx
+++ b/sw/source/core/crsr/DateFormFieldButton.cxx
@@ -59,17 +59,16 @@ SwDatePickerDialog::SwDatePickerDialog(SwEditWin* parent, sw::mark::IFieldmark*
 
             sal_uInt32 nFormat = m_pNumberFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT,
                                                                  ODF_FORMDATE_CURRENTDATE_LANGUAGE);
-            bool bValidFormat = nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND;
             if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 sal_Int32 nCheckPos = 0;
                 short nType;
                 OUString sFormat = ODF_FORMDATE_CURRENTDATE_FORMAT;
-                bValidFormat = m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
-                                                            ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
+                                             ODF_FORMDATE_CURRENTDATE_LANGUAGE);
             }
 
-            if (bValidFormat)
+            if (nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 double dCurrentDate = 0;
                 m_pNumberFormatter->IsNumberFormat(sDateString, nFormat, dCurrentDate);
@@ -101,17 +100,16 @@ IMPL_LINK(SwDatePickerDialog, ImplSelectHdl, Calendar*, pCalendar, void)
         {
             sal_uInt32 nFormat = m_pNumberFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT,
                                                                  ODF_FORMDATE_CURRENTDATE_LANGUAGE);
-            bool bValidFormat = nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND;
             if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 sal_Int32 nCheckPos = 0;
                 short nType;
                 OUString sFormat = ODF_FORMDATE_CURRENTDATE_FORMAT;
-                bValidFormat = m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
-                                                            ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
+                                             ODF_FORMDATE_CURRENTDATE_LANGUAGE);
             }
 
-            if (bValidFormat)
+            if (nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 Color* pCol = nullptr;
                 OUString sOutput;
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index cddf9f51014c..988a14c18937 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -890,20 +890,19 @@ namespace sw { namespace mark {
             pResult->second >>= sFormattedDate;
 
             sal_uInt32 nFormat = pFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT, ODF_FORMDATE_CURRENTDATE_LANGUAGE);
-            bool bValidFormat = nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND;
             if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 sal_Int32 nCheckPos = 0;
                 short nType;
                 OUString sFormat = ODF_FORMDATE_CURRENTDATE_FORMAT;
-                bValidFormat = pFormatter->PutEntry(sFormat,
-                                                    nCheckPos,
-                                                    nType,
-                                                    nFormat,
-                                                    ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                pFormatter->PutEntry(sFormat,
+                                     nCheckPos,
+                                     nType,
+                                     nFormat,
+                                     ODF_FORMDATE_CURRENTDATE_LANGUAGE);
             }
 
-            if (bValidFormat)
+            if (nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 pFormatter->IsNumberFormat(sFormattedDate, nFormat, dCurrentDate);
                 bHasCurrentDate = true;
@@ -913,20 +912,19 @@ namespace sw { namespace mark {
         if (!sDateFormat.isEmpty() && !sLang.isEmpty() && bHasCurrentDate)
         {
             sal_uInt32 nFormat = pFormatter->GetEntryKey(sDateFormat, LanguageTag(sLang).getLanguageType());
-            bool bValidFormat = nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND;
             if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 sal_Int32 nCheckPos = 0;
                 short nType;
-                bValidFormat = pFormatter->PutEntry(sDateFormat,
-                                                    nCheckPos,
-                                                    nType,
-                                                    nFormat,
-                                                    LanguageTag(sLang).getLanguageType());
+                pFormatter->PutEntry(sDateFormat,
+                                     nCheckPos,
+                                     nType,
+                                     nFormat,
+                                     LanguageTag(sLang).getLanguageType());
             }
 
             OUString sOutput;
-            if (bValidFormat)
+            if (nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 Color* pCol = nullptr;
                 pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a6fe5ea3108e..fe64960bec2b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1688,57 +1688,51 @@ void DocxAttributeOutput::WriteFormDate(const OUString& sCurrentDate, const OUSt
     m_pSerializer->startElementNS(XML_w, XML_sdtContent, FSEND);
     m_pSerializer->startElementNS(XML_w, XML_r, FSEND);
 
+    // Convert the current date to the right format
     if (!sCurrentDate.isEmpty())
     {
-        // Convert the current date to the right format
-        if (!sCurrentDate.isEmpty())
+        SvNumberFormatter* pFormatter = m_rExport.m_pDoc->GetNumberFormatter();
+        double dCurrentDate = 0.0;
+        // First get the date internal double representation
+        sal_uInt32 nFormat = pFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT, ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+        if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
         {
-            SvNumberFormatter* pFormatter = m_rExport.m_pDoc->GetNumberFormatter();
-
-            double dCurrentDate = 0.0;
-            // First get the date internal double representation
-            sal_uInt32 nFormat = pFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT, ODF_FORMDATE_CURRENTDATE_LANGUAGE);
-            bool bValidFormat = nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND;
-            if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
-            {
-                sal_Int32 nCheckPos = 0;
-                short nType;
-                OUString sFormat = ODF_FORMDATE_CURRENTDATE_FORMAT;
-                bValidFormat = pFormatter->PutEntry(sFormat,
-                                                    nCheckPos,
-                                                    nType,
-                                                    nFormat,
-                                                    ODF_FORMDATE_CURRENTDATE_LANGUAGE);
-            }
-            if (bValidFormat)
-            {
-                pFormatter->IsNumberFormat(sCurrentDate, nFormat, dCurrentDate);
-            }
-
-            // Then convert the date to a fromatter string
-            nFormat = pFormatter->GetEntryKey(sDateFormat, LanguageTag(sLang).getLanguageType());
-            bValidFormat = nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND;
-            if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
-            {
-                sal_Int32 nCheckPos = 0;
-                short nType;
-                OUString sNonConstDateFormat = sDateFormat;
-                bValidFormat = pFormatter->PutEntry(sNonConstDateFormat,
-                                                    nCheckPos,
-                                                    nType,
-                                                    nFormat,
-                                                    LanguageTag(sLang).getLanguageType());
-            }
+            sal_Int32 nCheckPos = 0;
+            short nType;
+            OUString sFormat = ODF_FORMDATE_CURRENTDATE_FORMAT;
+            pFormatter->PutEntry(sFormat,
+                                 nCheckPos,
+                                 nType,
+                                 nFormat,
+                                 ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+        }
+        if (nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
+        {
+            pFormatter->IsNumberFormat(sCurrentDate, nFormat, dCurrentDate);
+        }
 
-            OUString sOutput;
-            if (bValidFormat)
-            {
-                Color* pCol = nullptr;
-                pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
-            }
+        // Then convert the date to a fromatter string
+        nFormat = pFormatter->GetEntryKey(sDateFormat, LanguageTag(sLang).getLanguageType());
+        if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
+        {
+            sal_Int32 nCheckPos = 0;
+            short nType;
+            OUString sNonConstDateFormat = sDateFormat;
+            pFormatter->PutEntry(sNonConstDateFormat,
+                                 nCheckPos,
+                                 nType,
+                                 nFormat,
+                                 LanguageTag(sLang).getLanguageType());
+        }
 
-            RunText(sOutput);
+        OUString sOutput;
+        if (nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
+        {
+            Color* pCol = nullptr;
+            pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
         }
+
+        RunText(sOutput);
     }
 
     m_pSerializer->endElementNS(XML_w, XML_r);
diff --git a/sw/source/ui/fldui/DateFormFieldDialog.cxx b/sw/source/ui/fldui/DateFormFieldDialog.cxx
index 4a80c313b637..45c607b0084c 100644
--- a/sw/source/ui/fldui/DateFormFieldDialog.cxx
+++ b/sw/source/ui/fldui/DateFormFieldDialog.cxx
@@ -79,17 +79,15 @@ void DateFormFieldDialog::InitControls()
         {
             LanguageType aLangType = LanguageTag(sLang).getLanguageType();
             sal_uInt32 nFormatKey = m_pNumberFormatter->GetEntryKey(sFormatString, aLangType);
-            bool bValidFormat = nFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND;
             if (nFormatKey == NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 sal_Int32 nCheckPos = 0;
                 short nType;
-                bValidFormat
-                    = m_pNumberFormatter->PutEntry(sFormatString, nCheckPos, nType, nFormatKey,
-                                                   LanguageTag(sLang).getLanguageType());
+                m_pNumberFormatter->PutEntry(sFormatString, nCheckPos, nType, nFormatKey,
+                                             LanguageTag(sLang).getLanguageType());
             }
 
-            if (aLangType != LANGUAGE_DONTKNOW && bValidFormat)
+            if (aLangType != LANGUAGE_DONTKNOW && nFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
                 if (m_xFormatLB->GetCurLanguage() == aLangType)
                 {


More information about the Libreoffice-commits mailing list