[Libreoffice-commits] core.git: 4 commits - include/tools sc/source

Eike Rathke erack at redhat.com
Fri May 5 13:37:12 UTC 2017


 include/tools/date.hxx           |    9 +++++++++
 sc/source/core/data/dbdocutl.cxx |   15 +++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit ba11b28cae3b161bcea5a65709f3c3e222a3c082
Author: Eike Rathke <erack at redhat.com>
Date:   Fri May 5 15:35:55 2017 +0200

    Use Date(css::util::Date) ctor
    
    Change-Id: I99fa34fe3177bced41b16660ef1c3548b55ec60d

diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx
index e5838a7eb78f..4f8f2bba8f45 100644
--- a/sc/source/core/data/dbdocutl.cxx
+++ b/sc/source/core/data/dbdocutl.cxx
@@ -95,9 +95,7 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
                         SvNumberFormatter* pFormTable = pDoc->GetFormatTable();
                         nFormatIndex = pFormTable->GetStandardFormat(
                                 css::util::NumberFormat::DATE, ScGlobal::eLnge );
-
-                        nVal = Date( aDate.Day, aDate.Month, aDate.Year ) -
-                            *pFormTable->GetNullDate();
+                        nVal = Date( aDate ) - *pFormTable->GetNullDate();
                     }
                     bValue = true;
                 }
commit 45a1a762147058e3ec6807f6b7f1f7b0a15f3e59
Author: Eike Rathke <erack at redhat.com>
Date:   Fri May 5 15:28:10 2017 +0200

    ScDatabaseDocUtil::PutData: do not create an empty date if row wasNull
    
    Didn't harm because bEmptyFlag is evaluated later, but now Date asserts
    on various occasions. Also, the calculations are completely unnecessary
    in this case and were wrong anyway.
    
    Change-Id: I03ad7204668fbd6bcfa243e6a7c778be66f92c43

diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx
index 60a7610e478d..e5838a7eb78f 100644
--- a/sc/source/core/data/dbdocutl.cxx
+++ b/sc/source/core/data/dbdocutl.cxx
@@ -86,14 +86,19 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
 
             case sdbc::DataType::DATE:
                 {
-                    SvNumberFormatter* pFormTable = pDoc->GetFormatTable();
-                    nFormatIndex = pFormTable->GetStandardFormat(
-                                        css::util::NumberFormat::DATE, ScGlobal::eLnge );
-
                     util::Date aDate = xRow->getDate(nRowPos);
-                    nVal = Date( aDate.Day, aDate.Month, aDate.Year ) -
-                                                *pFormTable->GetNullDate();
                     bEmptyFlag = xRow->wasNull();
+                    if (bEmptyFlag)
+                        nVal = 0.0;
+                    else
+                    {
+                        SvNumberFormatter* pFormTable = pDoc->GetFormatTable();
+                        nFormatIndex = pFormTable->GetStandardFormat(
+                                css::util::NumberFormat::DATE, ScGlobal::eLnge );
+
+                        nVal = Date( aDate.Day, aDate.Month, aDate.Year ) -
+                            *pFormTable->GetNullDate();
+                    }
                     bValue = true;
                 }
                 break;
commit cf2c51307aaff7f68e149fd443975c44a132cc39
Author: Eike Rathke <erack at redhat.com>
Date:   Fri May 5 15:15:20 2017 +0200

    Introduce Date::IsEmpty()
    
    Change-Id: I4199b1da723c93b369c84bf664ef2d6e6e6dabb7

diff --git a/include/tools/date.hxx b/include/tools/date.hxx
index 97a6adec925d..7ea3998314fb 100644
--- a/include/tools/date.hxx
+++ b/include/tools/date.hxx
@@ -80,6 +80,8 @@ public:
                     }
                     Date( const css::util::DateTime& _rDateTime );
 
+    bool            IsEmpty() const { return mnDate == 0; }
+
     void            SetDate( sal_Int32 nNewDate );
     sal_Int32       GetDate() const { return mnDate; }
     /** Type safe access for values that are guaranteed to be unsigned, like Date::SYSTEM. */
commit d50fc27e760ffe74d1f676dbfe7cae5e9add5df7
Author: Eike Rathke <erack at redhat.com>
Date:   Fri May 5 15:11:33 2017 +0200

    Comment that day and month must be <100 and year != 0
    
    Change-Id: Ibfb003f4ce108b401e3102fecd0843dc75fcb41e

diff --git a/include/tools/date.hxx b/include/tools/date.hxx
index 600c4f90a562..97a6adec925d 100644
--- a/include/tools/date.hxx
+++ b/include/tools/date.hxx
@@ -69,8 +69,11 @@ public:
                     explicit Date( DateInitSystem );
                     explicit Date( sal_Int32 nDate ) : mnDate(nDate) {}
                     Date( const Date& rDate ) : mnDate(rDate.mnDate) {}
+
+                    /** nDay and nMonth both must be <100, nYear must be != 0 */
                     Date( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear )
                         { setDateFromDMY(nDay, nMonth, nYear); }
+
                     Date( const css::util::Date& rUDate )
                     {
                         setDateFromDMY(rUDate.Day, rUDate.Month, rUDate.Year);
@@ -83,9 +86,13 @@ public:
     sal_uInt32      GetDateUnsigned() const { return static_cast<sal_uInt32>(mnDate < 0 ? -mnDate : mnDate); }
     css::util::Date GetUNODate() const { return css::util::Date(GetDay(), GetMonth(), GetYear()); }
 
+                    /** nNewDay must be <100 */
     void            SetDay( sal_uInt16 nNewDay );
+                    /** nNewMonth must be <100 */
     void            SetMonth( sal_uInt16 nNewMonth );
+                    /** nNewYear must be != 0 */
     void            SetYear( sal_Int16 nNewYear );
+
     sal_uInt16      GetDay() const
                     {
                         return mnDate < 0 ?


More information about the Libreoffice-commits mailing list