sc/source/filter/excel/xlroot.cxx         |    8 ++++----
 sc/source/filter/inc/pivotcachebuffer.hxx |    4 ++--
 sc/source/filter/inc/xlroot.hxx           |    3 ++-
 sc/source/filter/oox/pivotcachebuffer.cxx |    4 ++--
 sc/source/filter/oox/pivottablebuffer.cxx |    4 ++--
 5 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 553c128e3fdc4b9612c1150b30d7b89df2ae6fdd
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Jul 18 17:42:50 2024 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sat Jul 20 00:35:57 2024 +0200

    Eliminate unnecessary DateTime conversions
    
    Change-Id: I7bda80e01d37ecd8c2d7e3f8b9ad6fac1e74f3a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170698
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/filter/excel/xlroot.cxx 
b/sc/source/filter/excel/xlroot.cxx
index 417a8e8858d7..06c1299afe91 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -323,9 +323,9 @@ SvNumberFormatter& XclRoot::GetFormatter() const
     return *GetDoc().GetFormatTable();
 }
 
-DateTime XclRoot::GetNullDate() const
+Date XclRoot::GetNullDate() const
 {
-    return DateTime( GetFormatter().GetNullDate() );
+    return GetFormatter().GetNullDate();
 }
 
 sal_uInt16 XclRoot::GetBaseYear() const
@@ -339,7 +339,7 @@ const DateTime theExcelCutOverDate( Date( 1, 3, 1900 ));
 
 double XclRoot::GetDoubleFromDateTime( const DateTime& rDateTime ) const
 {
-    double fValue = DateTime::Sub( rDateTime, GetNullDate());
+    double fValue = DateTime::Sub( rDateTime, DateTime( GetNullDate()));
     // adjust dates before 1900-03-01 to get correct time values in the range 
[0.0,1.0)
     /* XXX: this is only used when reading BIFF, otherwise we'd have to check
      * for dateCompatibility==true as mentioned below. */
@@ -350,7 +350,7 @@ double XclRoot::GetDoubleFromDateTime( const DateTime& 
rDateTime ) const
 
 DateTime XclRoot::GetDateTimeFromDouble( double fValue ) const
 {
-    DateTime aDateTime = GetNullDate() + fValue;
+    DateTime aDateTime = DateTime( GetNullDate()) + fValue;
     // adjust dates before 1900-03-01 to get correct time values
     /* FIXME: correction should only be done when writing BIFF or OOXML
      * transitional with dateCompatibility==true (or absent for default true),
diff --git a/sc/source/filter/inc/pivotcachebuffer.hxx 
b/sc/source/filter/inc/pivotcachebuffer.hxx
index e255c79eae15..35f266cb9068 100644
--- a/sc/source/filter/inc/pivotcachebuffer.hxx
+++ b/sc/source/filter/inc/pivotcachebuffer.hxx
@@ -35,7 +35,7 @@ namespace oox::core { class Relations; }
 
 class ScDPSaveDimension;
 class ScDPObject;
-class DateTime;
+class Date;
 
 namespace oox::xls {
 
@@ -83,7 +83,7 @@ public:
     OUString     getName() const;
 
     /** Returns the string representation of the item, using the actual 
formatting. */
-    OUString     getFormattedName(const ScDPSaveDimension& rSaveDim, 
ScDPObject* pObj, const DateTime& rNullDate) const;
+    OUString     getFormattedName(const ScDPSaveDimension& rSaveDim, 
ScDPObject* pObj, const Date& rNullDate) const;
     /** Returns true if the item is unused. */
     bool         isUnused() const { return mbUnused; }
 
diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx
index 603307fb3476..380a6b49403b 100644
--- a/sc/source/filter/inc/xlroot.hxx
+++ b/sc/source/filter/inc/xlroot.hxx
@@ -30,6 +30,7 @@ namespace comphelper { class IDocPasswordVerifier; }
 
 // Forward declarations of objects in public use ==============================
 
+class Date;
 class DateTime;
 class SotStorage;
 class SotStorageStream;
@@ -216,7 +217,7 @@ public:
     /** Returns the number formatter of the Calc document. */
     SvNumberFormatter&  GetFormatter() const;
     /** Returns the null date of the current number formatter. */
-    DateTime            GetNullDate() const;
+    Date                GetNullDate() const;
     /** Returns the base year depending on the current null date (1900 or 
1904). */
     sal_uInt16          GetBaseYear() const;
     /** Converts a date/time value to a floating-point value. */
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx 
b/sc/source/filter/oox/pivotcachebuffer.cxx
index 929e7b3bdea6..3af082b3c10e 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -236,7 +236,7 @@ OUString PivotCacheItem::getName() const
     return OUString();
 }
 
-OUString PivotCacheItem::getFormattedName(const ScDPSaveDimension& rSaveDim, 
ScDPObject* pObj, const DateTime& rNullDate) const
+OUString PivotCacheItem::getFormattedName(const ScDPSaveDimension& rSaveDim, 
ScDPObject* pObj, const Date& rNullDate) const
 {
     switch( mnType )
     {
@@ -253,7 +253,7 @@ OUString PivotCacheItem::getFormattedName(const 
ScDPSaveDimension& rSaveDim, ScD
                 SAL_WARN("sc", "PivotCacheField::getFormattedName - invalid 
date");
                 return OUString();
             }
-            return pObj->GetFormattedString(rSaveDim.GetName(), 
DateTime::Sub(DateTime(aDateTime), rNullDate));
+            return pObj->GetFormattedString(rSaveDim.GetName(), 
DateTime::Sub(DateTime(aDateTime), DateTime(rNullDate)));
         }
         case XML_e: return maValue.get< OUString >();
     }
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index 920432c1e2f9..5439b1d58357 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -581,7 +581,7 @@ void PivotTableField::convertPageField( const 
PTPageFieldModel& rPageField )
             ScDPObject* pDPObj = mrPivotTable.getDPObject();
             ScDPSaveData* pSaveData = pDPObj->GetSaveData();
             ScDPSaveDimension* pDim = 
pSaveData->GetDimensionByName(pCacheField->getName());
-            OUString aSelectedPage = pSharedItem->getFormattedName(*pDim, 
pDPObj, ::DateTime(::Date(getWorkbookSettings().getNullDate())));
+            OUString aSelectedPage = pSharedItem->getFormattedName(*pDim, 
pDPObj, Date( getWorkbookSettings().getNullDate()));
             aPropSet.setProperty( PROP_SelectedPage, aSelectedPage );
         }
     }
@@ -798,7 +798,7 @@ Reference< XDataPilotField > 
PivotTableField::convertRowColPageField( sal_Int32
 
                         try
                         {
-                            ScDPSaveMember* pMem = 
pDim->GetMemberByName(pSharedItem->getFormattedName(*pDim, pDPObj, 
::DateTime(::Date(getWorkbookSettings().getNullDate()))));
+                            ScDPSaveMember* pMem = 
pDim->GetMemberByName(pSharedItem->getFormattedName(*pDim, pDPObj, Date( 
getWorkbookSettings().getNullDate())));
                             pMem->SetShowDetails(rItem.mbShowDetails);
                             pMem->SetIsVisible(!rItem.mbHidden);
                         }

Reply via email to