kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0005-fdo-72774-Generate-correct-group-items-for-the-year-.patch

f0633d
From 584b8621afec7a77ceab2e2f029687a7dd1a18c3 Mon Sep 17 00:00:00 2001
f0633d
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f0633d
Date: Tue, 7 Jan 2014 22:13:07 -0500
f0633d
Subject: [PATCH 5/9] fdo#72774: Generate correct group items for the year
f0633d
 group.
f0633d
f0633d
This changes bring it back to the same algorithm used in 3.5.
f0633d
f0633d
Change-Id: I16855cef1de133a1f886baa823d5b0d2b148e781
f0633d
(cherry picked from commit c2e88a32314012afb799e321ec1d658f99f71781)
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7306
f0633d
Reviewed-by: Eike Rathke <erack@redhat.com>
f0633d
Tested-by: Eike Rathke <erack@redhat.com>
f0633d
---
f0633d
 sc/inc/dputil.hxx                 |  2 +-
f0633d
 sc/source/core/data/dpdimsave.cxx |  4 ++--
f0633d
 sc/source/core/data/dpgroup.cxx   |  2 +-
f0633d
 sc/source/core/data/dputil.cxx    | 13 ++++++++-----
f0633d
 4 files changed, 12 insertions(+), 9 deletions(-)
f0633d
f0633d
diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx
f0633d
index e4ed831..9568e95 100644
f0633d
--- a/sc/inc/dputil.hxx
f0633d
+++ b/sc/inc/dputil.hxx
f0633d
@@ -45,7 +45,7 @@ public:
f0633d
         SvNumberFormatter* pFormatter);
f0633d
 
f0633d
     static sal_Int32 getDatePartValue(
f0633d
-        double fValue, const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart,
f0633d
+        double fValue, const ScDPNumGroupInfo* pInfo, sal_Int32 nDatePart,
f0633d
         SvNumberFormatter* pFormatter);
f0633d
 
f0633d
     static OUString getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc);
f0633d
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx
f0633d
index 16f68b8..2db4023 100644
f0633d
--- a/sc/source/core/data/dpdimsave.cxx
f0633d
+++ b/sc/source/core/data/dpdimsave.cxx
f0633d
@@ -338,8 +338,8 @@ void fillDateGroupDimension(
f0633d
     {
f0633d
         case sheet::DataPilotFieldGroupBy::YEARS:
f0633d
             nStart = ScDPUtil::getDatePartValue(
f0633d
-                fSourceMin, rDateInfo, sheet::DataPilotFieldGroupBy::YEARS, pFormatter);
f0633d
-            nEnd = ScDPUtil::getDatePartValue(fSourceMax, rDateInfo, sheet::DataPilotFieldGroupBy::YEARS, pFormatter);
f0633d
+                fSourceMin, NULL, sheet::DataPilotFieldGroupBy::YEARS, pFormatter);
f0633d
+            nEnd = ScDPUtil::getDatePartValue(fSourceMax, NULL, sheet::DataPilotFieldGroupBy::YEARS, pFormatter);
f0633d
             break;
f0633d
         case sheet::DataPilotFieldGroupBy::QUARTERS: nStart = 1; nEnd = 4;   break;
f0633d
         case sheet::DataPilotFieldGroupBy::MONTHS:   nStart = 1; nEnd = 12;  break;
f0633d
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
f0633d
index 1e8059a..6a9f824 100644
f0633d
--- a/sc/source/core/data/dpgroup.cxx
f0633d
+++ b/sc/source/core/data/dpgroup.cxx
f0633d
@@ -911,7 +911,7 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector
f0633d
             {
f0633d
                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
f0633d
                 sal_Int32 nPartValue = ScDPUtil::getDatePartValue(
f0633d
-                    pData->GetValue(), *pNumInfo, nDatePart, pFormatter);
f0633d
+                    pData->GetValue(), pNumInfo, nDatePart, pFormatter);
f0633d
 
f0633d
                 ScDPItemData aItem(nDatePart, nPartValue);
f0633d
                 rItems[i] = pCache->GetIdByItemData(nColumn, aItem);
f0633d
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
f0633d
index e34bc79..558e189 100644
f0633d
--- a/sc/source/core/data/dputil.cxx
f0633d
+++ b/sc/source/core/data/dputil.cxx
f0633d
@@ -294,16 +294,19 @@ OUString ScDPUtil::getNumGroupName(
f0633d
 }
f0633d
 
f0633d
 sal_Int32 ScDPUtil::getDatePartValue(
f0633d
-    double fValue, const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart,
f0633d
+    double fValue, const ScDPNumGroupInfo* pInfo, sal_Int32 nDatePart,
f0633d
     SvNumberFormatter* pFormatter)
f0633d
 {
f0633d
     // Start and end are inclusive
f0633d
     // (End date without a time value is included, with a time value it's not)
f0633d
 
f0633d
-    if (fValue < rInfo.mfStart && !rtl::math::approxEqual(fValue, rInfo.mfStart))
f0633d
-        return ScDPItemData::DateFirst;
f0633d
-    if (fValue > rInfo.mfEnd && !rtl::math::approxEqual(fValue, rInfo.mfEnd))
f0633d
-        return ScDPItemData::DateLast;
f0633d
+    if (pInfo)
f0633d
+    {
f0633d
+        if (fValue < pInfo->mfStart && !rtl::math::approxEqual(fValue, pInfo->mfStart))
f0633d
+            return ScDPItemData::DateFirst;
f0633d
+        if (fValue > pInfo->mfEnd && !rtl::math::approxEqual(fValue, pInfo->mfEnd))
f0633d
+            return ScDPItemData::DateLast;
f0633d
+    }
f0633d
 
f0633d
     sal_Int32 nResult = 0;
f0633d
 
f0633d
-- 
f0633d
1.8.4.2
f0633d