ubsan: fix downcast

/svx/source/sidebar/area/AreaPropertyPanelBase.cxx:820:42: runtime error: downcast of address 0x5030003750d0 which does not point to an object of type 'const SfxUInt16Item'
0x5030003750d0: note: object is of type 'XFillTransparenceItem'
 00 00 00 00  d0 74 21 ac 12 7f 00 00  00 00 00 00 fb 03 be be  15 00 00 00 89 be 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'XFillTransparenceItem'
    #0 0x7f12b02722cf in svx::sidebar::AreaPropertyPanel

after
  commit 953219b811
  Author: Noel Grandin <noelgrandin@gmail.com>
  Date:   Wed Dec 3 21:34:19 2025 +0200
  make XFillTransparenceItem extend SfxPoolItem

Change-Id: Iaee48c5f5522cab8ec48cffd621cc866151429af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195235
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
(cherry picked from commit a608afdb68)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195284
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Noel Grandin
2025-12-09 14:35:29 +01:00
committed by Xisco Fauli
parent 1cf5e10ad9
commit 98cc40cc57
4 changed files with 8 additions and 9 deletions
@@ -454,7 +454,7 @@ void ChartAreaPanel::updateData()
{
sal_uInt16 nFillTransparence = 0;
xPropSet->getPropertyValue(u"FillTransparence"_ustr) >>= nFillTransparence;
SfxUInt16Item aTransparenceItem(0, nFillTransparence);
XFillTransparenceItem aTransparenceItem(nFillTransparence);
updateFillTransparence(false, true, &aTransparenceItem);
}
+2 -2
View File
@@ -245,11 +245,11 @@ std::unique_ptr<SfxTabPage> SvxTransparenceTabPage::Create(weld::Container* pPag
bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs)
{
const SfxPoolItem* pGradientItem = nullptr;
const SfxPoolItem* pLinearItem = nullptr;
const XFillTransparenceItem* pLinearItem = nullptr;
SfxItemState eStateGradient(rOutAttrs.GetItemState(XATTR_FILLFLOATTRANSPARENCE, true, &pGradientItem));
SfxItemState eStateLinear(rOutAttrs.GetItemState(XATTR_FILLTRANSPARENCE, true, &pLinearItem));
bool bGradActive = (eStateGradient == SfxItemState::SET && static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->IsEnabled());
bool bLinearActive = (eStateLinear == SfxItemState::SET && static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue() != 0);
bool bLinearActive = (eStateLinear == SfxItemState::SET && pLinearItem->GetValue() != 0);
bool bGradUsed = (eStateGradient == SfxItemState::INVALID);
bool bLinearUsed = (eStateLinear == SfxItemState::INVALID);
@@ -91,7 +91,7 @@ public:
virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& aHatchItem) = 0;
virtual void setFillUseBackground(const XFillStyleItem* pStyleItem, const XFillUseSlideBackgroundItem& rItem) = 0;
void updateFillTransparence(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState);
void updateFillTransparence(bool bDisabled, bool bDefaultOrSet, const XFillTransparenceItem* pState);
void updateFillFloatTransparence(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState);
void updateFillStyle(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState);
void updateFillGradient(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState);
@@ -154,7 +154,7 @@ protected:
OUString maImgLinear;
std::unique_ptr< XFillFloatTransparenceItem > mpFloatTransparenceItem;
std::unique_ptr< SfxUInt16Item > mpTransparenceItem;
std::unique_ptr< XFillTransparenceItem > mpTransparenceItem;
// MCGR: Preserve ColorStops until we have a UI to edit these
basegfx::BColorStops maColorStops;
@@ -806,7 +806,7 @@ void AreaPropertyPanelBase::ImpUpdateTransparencies()
}
}
void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefaultOrSet, const XFillTransparenceItem* pState)
{
if (bDisabled)
{
@@ -817,8 +817,7 @@ void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefault
{
if (pState)
{
const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
mpTransparenceItem.reset(pItem->Clone());
mpTransparenceItem.reset(pState->Clone());
}
else
{
@@ -1089,7 +1088,7 @@ void AreaPropertyPanelBase::NotifyItemUpdate(
switch(nSID)
{
case SID_ATTR_FILL_TRANSPARENCE:
updateFillTransparence(bDisabled, bDefaultOrSet, pState);
updateFillTransparence(bDisabled, bDefaultOrSet, static_cast<const XFillTransparenceItem*>(pState));
break;
case SID_ATTR_FILL_FLOATTRANSPARENCE:
updateFillFloatTransparence(bDisabled, bDefaultOrSet, pState);