oox/source/drawingml/textfield.cxx |   23 ++++++++++++-----------
 oox/source/export/drawingml.cxx    |    4 +++-
 sd/qa/unit/data/odp/numfmt.odp     |binary
 sd/qa/unit/data/pptx/numfmt.pptx   |binary
 sd/qa/unit/export-tests-ooxml2.cxx |   32 ++++++++++++++++++++------------
 5 files changed, 35 insertions(+), 24 deletions(-)

New commits:
commit 7ec4a0872d16eb20d790eb8079ba538898fd2ff6
Author:     Sarper Akdemir <sarper.akde...@collabora.com>
AuthorDate: Tue Jun 29 13:33:52 2021 +0300
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Mon Jul 19 16:47:10 2021 +0200

    tdf#59323 tdf#142221: fix pptx datetime import export format
    
    fixed some problems from the original implementation of
    pptx datetime field formatting
    (2b0669eec0d86e973a7d8def8744c522bbf8af8b)
    
    also the comments on tests seemed to be based on en-IN which
    seems to differ a lot for SvxDateFormat::StdBig. So converted
    them to en-US's StdBig.
    
    expanded the tests, so it covers previously poorly imported
    types. Also made them use the SvxDateFormat and SvxTimeFormat
    
    Change-Id: I675c482d3095b5373975abb2e6e7eca2d353243d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118135
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/oox/source/drawingml/textfield.cxx 
b/oox/source/drawingml/textfield.cxx
index e590c5c7a2cb..0d33da71266d 100644
--- a/oox/source/drawingml/textfield.cxx
+++ b/oox/source/drawingml/textfield.cxx
@@ -218,21 +218,22 @@ SvxDateFormat 
TextField::getLODateFormat(std::u16string_view rDateTimeType)
     switch( nDateTimeNum )
     {
     case 1: // Date dd/mm/yyyy
-    case 2: // Date Day, Month dd, yyyy
-    case 5: // Date dd-Mon-yy
-    case 6: // Date Month yy
-    case 7: // Date Mon-yy
     case 8: // DateTime dd/mm/yyyy H:MM PM
     case 9: // DateTime dd/mm/yyyy H:MM:SS PM
         return SvxDateFormat::B;
-    case 3: // Date dd Month yyyy
+    case 2: // Date Day, Month dd, yyyy
         return SvxDateFormat::StdBig;
-    case 4: // Date Month dd, yyyy
-        return SvxDateFormat::StdSmall;
-    case 10: // Time H:MM
-    case 11: // Time H:MM:SS
-    case 12: // Time H:MM PM
-    case 13: // Time H:MM:SS PM
+    case 3: // Date dd Month yyyy
+    case 4: // Date Month dd, yyyy - no exact map
+    case 6: // Date Month yy - no exact map
+        return SvxDateFormat::D;
+    case 5: // Date dd-Mon-yy - no exact map
+    case 7: // Date Mon-yy - no exact map
+        return SvxDateFormat::C;
+    case 10: // Time H:MM - not a date format
+    case 11: // Time H:MM:SS - not a date format
+    case 12: // Time H:MM PM - not a date format
+    case 13: // Time H:MM:SS PM - not a date format
     default:
         return SvxDateFormat::AppDefault;
     }
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 7c6754a35f6d..e45c5c52e8c5 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2355,11 +2355,13 @@ OUString 
DrawingML::GetDatetimeTypeFromDateTime(SvxDateFormat eDate, SvxTimeForm
         case SvxDateFormat::B:
             aDateField = "datetime1"; // 13/02/1996
             break;
-        case SvxDateFormat::StdBig:
         case SvxDateFormat::C:
+            aDateField = "datetime5";
+            break;
         case SvxDateFormat::D:
             aDateField = "datetime3"; // 13 February 1996
             break;
+        case SvxDateFormat::StdBig:
         case SvxDateFormat::E:
         case SvxDateFormat::F:
             aDateField = "datetime2";
diff --git a/sd/qa/unit/data/odp/numfmt.odp b/sd/qa/unit/data/odp/numfmt.odp
index 6fd32ce0a66d..51227ea091d9 100644
Binary files a/sd/qa/unit/data/odp/numfmt.odp and 
b/sd/qa/unit/data/odp/numfmt.odp differ
diff --git a/sd/qa/unit/data/pptx/numfmt.pptx b/sd/qa/unit/data/pptx/numfmt.pptx
index e5f0f5cf151a..f855fbbeb12c 100644
Binary files a/sd/qa/unit/data/pptx/numfmt.pptx and 
b/sd/qa/unit/data/pptx/numfmt.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index e2cdef3d76f6..b7d6e0ca5554 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -12,6 +12,7 @@
 #include <comphelper/sequence.hxx>
 #include <editeng/eeitem.hxx>
 #include <editeng/editobj.hxx>
+#include <editeng/flditem.hxx>
 #include <editeng/outlobj.hxx>
 #include <editeng/numitem.hxx>
 #include <editeng/unoprnms.hxx>
@@ -787,26 +788,33 @@ void matchNumberFormat( int nPage, uno::Reference< 
text::XTextField > const & xF
     xPropSet->getPropertyValue("NumberFormat") >>= nNumFmt;
     switch( nPage )
     {
-        case 0:     // 13/02/96
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(2), nNumFmt);
+        case 0:     // 13/02/96 (StdSmall)
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(SvxDateFormat::StdSmall), nNumFmt);
                     break;
         case 1:     // 13/02/1996
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(5), nNumFmt);
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(SvxDateFormat::B), nNumFmt);
                     break;
-        case 2:     // 13 February 1996
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(3), nNumFmt);
+        case 2:     // Tuesday, June 29, 2021 (StdBig)
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(SvxDateFormat::StdBig), nNumFmt);
                     break;
-        case 3:     // 13:49:38
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(2), nNumFmt);
+        case 3:     // 13:49:38 (Standard)
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(SvxTimeFormat::Standard), nNumFmt);
                     break;
         case 4:     // 13:49
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(3), nNumFmt);
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(SvxTimeFormat::HH24_MM), nNumFmt);
                     break;
         case 5:     // 01:49 PM
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(6), nNumFmt);
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(SvxTimeFormat::HH12_MM), nNumFmt);
                     break;
         case 6:     // 01:49:38 PM
-                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(7), nNumFmt);
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time 
fields don't match", sal_Int32(SvxTimeFormat::HH12_MM_SS), nNumFmt);
+                    break;
+        case 7:     // June 29, 2021
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(SvxDateFormat::D), nNumFmt);
+                    break;
+        case 8:     // Jun 29, 2021
+                    CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date 
fields don't match", sal_Int32(SvxDateFormat::C), nNumFmt);
+                    break;
     }
 }
 
@@ -818,7 +826,7 @@ void SdOOXMLExportTest2::testDatetimeFieldNumberFormat()
 
     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
 
-    for(sal_uInt16 i = 0; i <= 6; ++i)
+    for(sal_uInt16 i = 0; i <= 8; ++i)
     {
         matchNumberFormat( i, getTextFieldFromPage(0, 0, 0, i, xDocShRef) );
     }
@@ -832,7 +840,7 @@ void SdOOXMLExportTest2::testDatetimeFieldNumberFormatPPTX()
 
     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
 
-    for(sal_uInt16 i = 0; i <= 6; ++i)
+    for(sal_uInt16 i = 0; i <= 8; ++i)
     {
         matchNumberFormat( i, getTextFieldFromPage(0, 0, 0, i, xDocShRef) );
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to