tdf#132518 - Group pivot date field values in dropdown filter

Change-Id: I636f6f28e3e2cfaed1e01a6d4ee3a1604cf5d16b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209534
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
This commit is contained in:
Andreas Heinisch
2026-08-24 13:08:48 +02:00
parent 5cfac95032
commit d43befdf16
8 changed files with 59 additions and 4 deletions
+2
View File
@@ -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<css::beans::XPropertySet>& xProp,
const OUString& rName, double fDefault = 0.0);
template<typename EnumT>
static EnumT GetEnumProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp,
const OUString& rName, EnumT nDefault )
+3
View File
@@ -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();
+2
View File
@@ -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;
+9
View File
@@ -1211,6 +1211,11 @@ bool ScDPObject::GetMembers( sal_Int32 nDim, sal_Int32 nHier, std::vector<ScDPLa
aMem.maLayoutName = ScUnoHelpFunctions::GetStringProperty(
xMemProp, SC_UNO_DP_LAYOUTNAME, OUString());
aMem.mbHasValue
= ScUnoHelpFunctions::GetBoolProperty(xMemProp, SC_UNO_DP_MEMBER_HAS_VALUE);
if (aMem.mbHasValue)
aMem.mfValue
= ScUnoHelpFunctions::GetDoubleProperty(xMemProp, SC_UNO_DP_MEMBER_VALUE);
}
aMembers.push_back(aMem);
@@ -2621,6 +2626,10 @@ void ScDPObject::FillLabelDataForDimension(
lcl_FillLabelData(rLabelData, xDimProp);
rLabelData.mnFlags = ScUnoHelpFunctions::GetLongProperty(
xDimProp, SC_UNO_DP_FLAGS );
// tdf#132518 - group pivot date field values in dropdown filter
ScDPTableData* pTableData = GetTableData();
rLabelData.mbIsDateDimension = pTableData && pTableData->IsDateDimension(nDim);
}
void ScDPObject::FillLabelData(sal_Int32 nDim, ScDPLabelData& rLabels)
+14
View File
@@ -2670,6 +2670,10 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPMember::getPropertySetInfo(
{ SC_UNO_DP_POSITION, 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
{ SC_UNO_DP_SHOWDETAILS, 0, cppu::UnoType<bool>::get(), 0, 0 },
{ SC_UNO_DP_LAYOUTNAME, 0, cppu::UnoType<OUString>::get(), 0, 0 },
{ SC_UNO_DP_MEMBER_VALUE, 0, cppu::UnoType<double>::get(),
beans::PropertyAttribute::READONLY, 0 },
{ SC_UNO_DP_MEMBER_HAS_VALUE, 0, cppu::UnoType<bool>::get(),
beans::PropertyAttribute::READONLY, 0 },
};
static uno::Reference<beans::XPropertySetInfo> 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");
+5 -2
View File
@@ -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
+18
View File
@@ -88,6 +88,24 @@ sal_Int32 ScUnoHelpFunctions::GetLongProperty( const uno::Reference<beans::XProp
return nRet;
}
double ScUnoHelpFunctions::GetDoubleProperty(const uno::Reference<beans::XPropertySet>& 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<beans::XPropertySet>& xProp,
const OUString& rName, sal_Int32 nDefault )
{
+6 -2
View File
@@ -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);