diff --git a/sc/inc/miscuno.hxx b/sc/inc/miscuno.hxx index 075bf0046185..c54cf4aba645 100644 --- a/sc/inc/miscuno.hxx +++ b/sc/inc/miscuno.hxx @@ -143,6 +143,8 @@ public: const OUString& rName, sal_Int16 nDefault ); static sal_Int32 GetLongProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, const OUString& rName ); + static double GetDoubleProperty(const css::uno::Reference& xProp, + const OUString& rName, double fDefault = 0.0); template static EnumT GetEnumProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, const OUString& rName, EnumT nDefault ) diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx index 8d3edba969fc..f06c4165dde0 100644 --- a/sc/inc/pivot.hxx +++ b/sc/inc/pivot.hxx @@ -84,6 +84,7 @@ struct ScDPLabelData bool mbDataLayout:1; bool mbRepeatItemLabels:1; bool mbCalculatedField:1; + bool mbIsDateDimension:1; ///< true = Source values are dates/times. struct Member { @@ -91,6 +92,8 @@ struct ScDPLabelData OUString maLayoutName; bool mbVisible; bool mbShowDetails; + double mfValue; ///< raw value (e.g. date serial), only meaningful when mbHasValue is true. + bool mbHasValue; Member(); diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 2412a0d2b448..dc322f34d687 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -644,6 +644,8 @@ inline constexpr OUString SC_UNO_DP_LAYOUTNAME = u"LayoutName"_ustr; inline constexpr OUString SC_UNO_DP_FIELD_SUBTOTALNAME = u"FieldSubtotalName"_ustr; inline constexpr OUString SC_UNO_DP_GRANDTOTAL_NAME = u"GrandTotalName"_ustr; inline constexpr OUString SC_UNO_DP_HAS_HIDDEN_MEMBER = u"HasHiddenMember"_ustr; +inline constexpr OUString SC_UNO_DP_MEMBER_VALUE = u"MemberValue"_ustr; +inline constexpr OUString SC_UNO_DP_MEMBER_HAS_VALUE = u"MemberHasValue"_ustr; #define SC_UNO_DP_CALCULATEDFIELD SC_UNONAME_CALCULATEDFIELD #define SC_UNO_DP_CALCULATION SC_UNONAME_CALCULATION inline constexpr OUString SC_UNO_DP_FLAGS = u"Flags"_ustr; diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index bc8d743acd4a..ab2b0f16509e 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1211,6 +1211,11 @@ bool ScDPObject::GetMembers( sal_Int32 nDim, sal_Int32 nHier, std::vectorIsDateDimension(nDim); } void ScDPObject::FillLabelData(sal_Int32 nDim, ScDPLabelData& rLabels) diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 697a2ce23ff3..268f038747f5 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -2670,6 +2670,10 @@ uno::Reference SAL_CALL ScDPMember::getPropertySetInfo( { SC_UNO_DP_POSITION, 0, cppu::UnoType::get(), 0, 0 }, { SC_UNO_DP_SHOWDETAILS, 0, cppu::UnoType::get(), 0, 0 }, { SC_UNO_DP_LAYOUTNAME, 0, cppu::UnoType::get(), 0, 0 }, + { SC_UNO_DP_MEMBER_VALUE, 0, cppu::UnoType::get(), + beans::PropertyAttribute::READONLY, 0 }, + { SC_UNO_DP_MEMBER_HAS_VALUE, 0, cppu::UnoType::get(), + beans::PropertyAttribute::READONLY, 0 }, }; static uno::Reference aRef = new SfxItemPropertySetInfo( aDPMemberMap_Impl ); @@ -2707,6 +2711,16 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const OUString& aPropertyName ) aRet <<= nPosition; else if (aPropertyName == SC_UNO_DP_LAYOUTNAME) aRet <<= mpLayoutName ? *mpLayoutName : OUString(); + else if (aPropertyName == SC_UNO_DP_MEMBER_VALUE) + { + const ScDPItemData* pData = GetItemData(); + aRet <<= pData ? pData->GetValue() : 0.0; + } + else if (aPropertyName == SC_UNO_DP_MEMBER_HAS_VALUE) + { + const ScDPItemData* pData = GetItemData(); + aRet <<= pData && pData->IsValue(); + } else { OSL_FAIL("unknown property"); diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx index 3fc96837cd3c..e64a10127318 100644 --- a/sc/source/core/data/pivot2.cxx +++ b/sc/source/core/data/pivot2.cxx @@ -33,7 +33,9 @@ ScDPName::ScDPName(OUString aName, OUString aLayoutName, sal_uInt8 nDupCount) : ScDPLabelData::Member::Member() : mbVisible(true), - mbShowDetails(true) + mbShowDetails(true), + mfValue(0.0), + mbHasValue(false) {} OUString const & ScDPLabelData::Member::getDisplayName() const @@ -55,7 +57,8 @@ ScDPLabelData::ScDPLabelData() : mbIsValue(false), mbDataLayout(false), mbRepeatItemLabels(false), - mbCalculatedField(false) + mbCalculatedField(false), + mbIsDateDimension(false) {} OUString const & ScDPLabelData::getDisplayName() const diff --git a/sc/source/ui/unoobj/miscuno.cxx b/sc/source/ui/unoobj/miscuno.cxx index c0eba32bcd21..fa5f9cf91e28 100644 --- a/sc/source/ui/unoobj/miscuno.cxx +++ b/sc/source/ui/unoobj/miscuno.cxx @@ -88,6 +88,24 @@ sal_Int32 ScUnoHelpFunctions::GetLongProperty( const uno::Reference& xProp, + const OUString& rName, double fDefault) +{ + double fRet = fDefault; + if (xProp.is()) + { + try + { + xProp->getPropertyValue(rName) >>= fRet; + } + catch (uno::Exception&) + { + // keep default + } + } + return fRet; +} + sal_Int32 ScUnoHelpFunctions::GetEnumPropertyImpl( const uno::Reference& xProp, const OUString& rName, sal_Int32 nDefault ) { diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index e8282b3e33b8..36f90971dd90 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -651,8 +651,11 @@ void ScGridWindow::DPPopulateFieldMembers(const ScDPLabelData& rLabelData) if (aName.isEmpty()) // Use special string for an empty name. mpDPFieldPopup->addMember(ScResId(STR_EMPTYDATA), 0.0, rMem.mbVisible, false); + else if (rLabelData.mbIsDateDimension && rMem.mbHasValue) + // tdf#132518 - group pivot date field values in dropdown filter + mpDPFieldPopup->addDateMember(aName, rMem.mfValue, rMem.mbVisible, false); else - mpDPFieldPopup->addMember(rMem.getDisplayName(), 0.0, rMem.mbVisible, false); + mpDPFieldPopup->addMember(aName, 0.0, rMem.mbVisible, false); } } @@ -732,8 +735,9 @@ void ScGridWindow::DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScr mpDPFieldPopup.reset(); weld::Window* pPopupParent = GetFrameWeld(); + // tdf#132518 - group pivot date field values in dropdown filter mpDPFieldPopup.reset(new ScCheckListMenuControl(pPopupParent, mrViewData, - false, -1)); + pDPData->maLabels.mbIsDateDimension, -1)); DPSetupFieldPopup(std::move(pDPData), bDimOrientNotPage, pDPObj);