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

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


 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |    4 +-
 sw/source/core/crsr/DateFormFieldButton.cxx   |   39 ++++++++++++++----------
 sw/source/core/text/itrform2.cxx              |   42 ++++++++++++++++----------
 sw/source/filter/ww8/docxattributeoutput.cxx  |   39 ++++++++++++++----------
 sw/source/ui/fldui/DateFormFieldDialog.cxx    |   32 +++++++++++++------
 5 files changed, 98 insertions(+), 58 deletions(-)

New commits:
commit 4adc32e25474eb0a1279eca602d71e257a34ee4c
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jul 1 14:24:08 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:17:10 2019 +0200

    MSForms: date form field dialog: create the format entry if it does not exist
    
    Reviewed-on: https://gerrit.libreoffice.org/75450
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 9b4e0e65e38b21b9af7314732d6839e8bfd671c2)
    
    Change-Id: I62da736efeabc2da634d9a7a38512d7e908b03fc
    Reviewed-on: https://gerrit.libreoffice.org/75543
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/source/ui/fldui/DateFormFieldDialog.cxx b/sw/source/ui/fldui/DateFormFieldDialog.cxx
index 715a17369aa6..4a80c313b637 100644
--- a/sw/source/ui/fldui/DateFormFieldDialog.cxx
+++ b/sw/source/ui/fldui/DateFormFieldDialog.cxx
@@ -79,8 +79,17 @@ 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());
+            }
 
-            if (aLangType != LANGUAGE_DONTKNOW && nFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
+            if (aLangType != LANGUAGE_DONTKNOW && bValidFormat)
             {
                 if (m_xFormatLB->GetCurLanguage() == aLangType)
                 {
commit 08d40ab10c5ca54177898f34c5e5e3e581f58875
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jul 1 13:45:09 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:16:59 2019 +0200

    MSForms: date field converions: better error handling
    
    Reviewed-on: https://gerrit.libreoffice.org/75449
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 1e6b8e5c2a42b2ca35c963bbbe83f3e2e817ff50)
    
    Change-Id: Ia518c7c50079e443ddf135f1c32c5c39d2c85552
    Reviewed-on: https://gerrit.libreoffice.org/75542
    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 cd309ae7ab69..adb12d89286b 100644
--- a/sw/source/core/crsr/DateFormFieldButton.cxx
+++ b/sw/source/core/crsr/DateFormFieldButton.cxx
@@ -57,22 +57,26 @@ SwDatePickerDialog::SwDatePickerDialog(SwEditWin* parent, sw::mark::IFieldmark*
             OUString sDateString;
             pResult->second >>= sDateString;
 
-            double dCurrentDate = 0;
             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;
-                m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
-                                             ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                bValidFormat = m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
+                                                            ODF_FORMDATE_CURRENTDATE_LANGUAGE);
             }
 
-            m_pNumberFormatter->IsNumberFormat(sDateString, nFormat, dCurrentDate);
+            if (bValidFormat)
+            {
+                double dCurrentDate = 0;
+                m_pNumberFormatter->IsNumberFormat(sDateString, nFormat, dCurrentDate);
 
-            const Date& rNullDate = m_pNumberFormatter->GetNullDate();
-            m_pCalendar->SetCurDate(rNullDate + sal_Int32(dCurrentDate));
+                const Date& rNullDate = m_pNumberFormatter->GetNullDate();
+                m_pCalendar->SetCurDate(rNullDate + sal_Int32(dCurrentDate));
+            }
         }
     }
     m_pCalendar->SetSelectHdl(LINK(this, SwDatePickerDialog, ImplSelectHdl));
@@ -95,26 +99,31 @@ IMPL_LINK(SwDatePickerDialog, ImplSelectHdl, Calendar*, pCalendar, void)
     {
         if (m_pFieldmark != nullptr)
         {
-            Color* pCol = nullptr;
-            OUString sOutput;
             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;
-                m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
-                                             ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                bValidFormat = m_pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat,
+                                                            ODF_FORMDATE_CURRENTDATE_LANGUAGE);
             }
 
-            const Date& rNullDate = m_pNumberFormatter->GetNullDate();
-            double dDate = pCalendar->GetFirstSelectedDate() - rNullDate;
+            if (bValidFormat)
+            {
+                Color* pCol = nullptr;
+                OUString sOutput;
 
-            m_pNumberFormatter->GetOutputString(dDate, nFormat, sOutput, &pCol, false);
+                const Date& rNullDate = m_pNumberFormatter->GetNullDate();
+                double dDate = pCalendar->GetFirstSelectedDate() - rNullDate;
 
-            sw::mark::IFieldmark::parameter_map_t* pParameters = m_pFieldmark->GetParameters();
-            (*pParameters)[ODF_FORMDATE_CURRENTDATE] <<= sOutput;
+                m_pNumberFormatter->GetOutputString(dDate, nFormat, sOutput, &pCol, false);
+
+                sw::mark::IFieldmark::parameter_map_t* pParameters = m_pFieldmark->GetParameters();
+                (*pParameters)[ODF_FORMDATE_CURRENTDATE] <<= sOutput;
+            }
         }
         EndPopupMode();
     }
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index ce8302a1c8ad..cddf9f51014c 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -889,38 +889,48 @@ namespace sw { namespace mark {
             OUString sFormattedDate;
             pResult->second >>= sFormattedDate;
 
-            sal_uInt32 nFormat = pFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT, ODF_FORMDATE_CURRENTDATE_LANGUAGE);            if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
+            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;
-                pFormatter->PutEntry(sFormat,
-                                     nCheckPos,
-                                     nType,
-                                     nFormat,
-                                     ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                bValidFormat = pFormatter->PutEntry(sFormat,
+                                                    nCheckPos,
+                                                    nType,
+                                                    nFormat,
+                                                    ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+            }
+
+            if (bValidFormat)
+            {
+                pFormatter->IsNumberFormat(sFormattedDate, nFormat, dCurrentDate);
+                bHasCurrentDate = true;
             }
-            pFormatter->IsNumberFormat(sFormattedDate, nFormat, dCurrentDate);
-            bHasCurrentDate = true;
         }
 
-        Color* pCol = nullptr;
         if (!sDateFormat.isEmpty() && !sLang.isEmpty() && bHasCurrentDate)
         {
-            OUString sOutput;
             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;
-                pFormatter->PutEntry(sDateFormat,
-                                     nCheckPos,
-                                     nType,
-                                     nFormat,
-                                     LanguageTag(sLang).getLanguageType());
+                bValidFormat = pFormatter->PutEntry(sDateFormat,
+                                                    nCheckPos,
+                                                    nType,
+                                                    nFormat,
+                                                    LanguageTag(sLang).getLanguageType());
+            }
+
+            OUString sOutput;
+            if (bValidFormat)
+            {
+                Color* pCol = nullptr;
+                pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
             }
-            pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
             return sOutput;
         }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 76a5c27ba677..a6fe5ea3108e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1697,36 +1697,45 @@ void DocxAttributeOutput::WriteFormDate(const OUString& sCurrentDate, const OUSt
 
             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)
+            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;
-                pFormatter->PutEntry(sFormat,
-                                     nCheckPos,
-                                     nType,
-                                     nFormat,
-                                     ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+                bValidFormat = pFormatter->PutEntry(sFormat,
+                                                    nCheckPos,
+                                                    nType,
+                                                    nFormat,
+                                                    ODF_FORMDATE_CURRENTDATE_LANGUAGE);
+            }
+            if (bValidFormat)
+            {
+                pFormatter->IsNumberFormat(sCurrentDate, nFormat, dCurrentDate);
             }
-            pFormatter->IsNumberFormat(sCurrentDate, nFormat, dCurrentDate);
 
             // Then convert the date to a fromatter string
-            OUString sOutput;
-            Color* pCol = nullptr;
             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;
-                pFormatter->PutEntry(sNonConstDateFormat,
-                                     nCheckPos,
-                                     nType,
-                                     nFormat,
-                                     LanguageTag(sLang).getLanguageType());
+                bValidFormat = pFormatter->PutEntry(sNonConstDateFormat,
+                                                    nCheckPos,
+                                                    nType,
+                                                    nFormat,
+                                                    LanguageTag(sLang).getLanguageType());
+            }
+
+            OUString sOutput;
+            if (bValidFormat)
+            {
+                Color* pCol = nullptr;
+                pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
             }
-            pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, &pCol, false);
 
             RunText(sOutput);
         }
diff --git a/sw/source/ui/fldui/DateFormFieldDialog.cxx b/sw/source/ui/fldui/DateFormFieldDialog.cxx
index 8321acd24875..715a17369aa6 100644
--- a/sw/source/ui/fldui/DateFormFieldDialog.cxx
+++ b/sw/source/ui/fldui/DateFormFieldDialog.cxx
@@ -80,20 +80,23 @@ void DateFormFieldDialog::InitControls()
             LanguageType aLangType = LanguageTag(sLang).getLanguageType();
             sal_uInt32 nFormatKey = m_pNumberFormatter->GetEntryKey(sFormatString, aLangType);
 
-            if (m_xFormatLB->GetCurLanguage() == aLangType)
+            if (aLangType != LANGUAGE_DONTKNOW && nFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
             {
-                m_xFormatLB->SetAutomaticLanguage(true);
-            }
-            else
-            {
-                m_xFormatLB->SetAutomaticLanguage(false);
-                m_xFormatLB->SetLanguage(aLangType);
+                if (m_xFormatLB->GetCurLanguage() == aLangType)
+                {
+                    m_xFormatLB->SetAutomaticLanguage(true);
+                }
+                else
+                {
+                    m_xFormatLB->SetAutomaticLanguage(false);
+                    m_xFormatLB->SetLanguage(aLangType);
 
-                // Change format and change back for regenerating the list
-                m_xFormatLB->SetFormatType(css::util::NumberFormat::ALL);
-                m_xFormatLB->SetFormatType(css::util::NumberFormat::DATE);
+                    // Change format and change back for regenerating the list
+                    m_xFormatLB->SetFormatType(css::util::NumberFormat::ALL);
+                    m_xFormatLB->SetFormatType(css::util::NumberFormat::DATE);
+                }
+                m_xFormatLB->SetDefFormat(nFormatKey);
             }
-            m_xFormatLB->SetDefFormat(nFormatKey);
         }
     }
 }
commit fdba499719cf8cedde691db04409664980aaef0b
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jul 1 13:27:31 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:16:50 2019 +0200

    MSForms: DOCX filter: reenable passing test
    
    Change-Id: Ic82e2edddce7e46740f74f7b20bb849b6735a3b8
    Reviewed-on: https://gerrit.libreoffice.org/75448
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 70ae581d103b599a321f513baba1158eeb2887f2)
    Reviewed-on: https://gerrit.libreoffice.org/75541
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 922d6e85ef59..d997c8b13435 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -551,14 +551,14 @@ DECLARE_OOXMLEXPORT_TEST(testTableStart2Sdt, "table-start-2-sdt.docx")
     }
 }
 
-/*DECLARE_OOXMLEXPORT_TEST(testSdtDateDuplicate, "sdt-date-duplicate.docx")
+DECLARE_OOXMLEXPORT_TEST(testSdtDateDuplicate, "sdt-date-duplicate.docx")
 {
     if (xmlDocPtr pXmlDoc = parseExport())
     {
         // Single <w:sdt> was exported as 2 <w:sdt> elements.
         assertXPath(pXmlDoc, "//w:sdt", 1);
     }
-}*/
+}
 
 DECLARE_OOXMLEXPORT_TEST(testFdo81492, "fdo81492.docx")
 {


More information about the Libreoffice-commits mailing list