chart2/source/controller/itemsetwrapper/ItemConverter.cxx |   23 ++++++++++++++
 1 file changed, 23 insertions(+)

New commits:
commit ec65a00298ffbb30869dec222887f42f3ca4533e
Author:     Armin Le Grand (Collabora) <armin.le.gr...@me.com>
AuthorDate: Mon Mar 10 15:20:17 2025 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Mon Mar 10 17:12:37 2025 +0100

    tdf#165491 ITEM regression: Chart needs order of events
    
    The Item with WhichID SCHATTR_STAT_KIND_ERROR *has* to be
    handled 1st since it sets additional information about the
    ErrorBarStyle at beans::XPropertySet xErrorBarProp that the
    processing of the *other* Items already need access to, see
    'case SCHATTR_STAT_KIND_ERROR' in
    StatisticsItemConverter::ApplySpecialItem. This worked before
    the change of SfxItemSet to use a std::unordered_set since
    the order of Items was fix and - since SCHATTR_STAT_KIND_ERROR
    had the lowest WhichID - was handled 1st. Not sure if that was
    by purpose and it was known that this was necessary - there
    are no comments hinting to that, so it might have worked by
    coincidence before. In general it is bad style to rely on the
    'order' of Items in an ItemSet - there is no order defined in
    general.
    
    Change-Id: I93e2c8e30f762e1bb83adb2b43459bbfb263a151
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182742
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>
    Tested-by: Jenkins

diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
index 3d4cf2abc309..1a4eebf91127 100644
--- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
@@ -28,6 +28,7 @@
 #include <comphelper/diagnose_ex.hxx>
 #include <sal/log.hxx>
 #include <utility>
+#include <chartview/ChartSfxItemIds.hxx>
 
 using namespace ::com::sun::star;
 
@@ -156,8 +157,30 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & 
rItemSet )
     tPropertyNameWithMemberId aProperty;
     uno::Any aValue;
 
+    // tdf#165491 the Item with WhichID SCHATTR_STAT_KIND_ERROR *has* to
+    // be handled 1st since it sets additional information about the
+    // ErrorBarStyle at uno::Reference< beans::XPropertySet > xErrorBarProp
+    // that the processing of the *other* Items already need access to,
+    // see 'case SCHATTR_STAT_KIND_ERROR' in
+    // StatisticsItemConverter::ApplySpecialItem. This worked before the
+    // change of SfxItemSet to use a std::unordered_set since the order
+    // of Items was fix and - since SCHATTR_STAT_KIND_ERROR had the
+    // lowest WhichID - was handled 1st. Not sure if that was by purpose
+    // and it was known that this was necessary - there are no comments
+    // hinting to that. In general it is bad style to rely on the 'order'
+    // of Items being processed - there is no order defined in general.
+    {
+        const SfxPoolItem* pItem(nullptr);
+        if (SfxItemState::SET == 
rItemSet.GetItemState(SCHATTR_STAT_KIND_ERROR, false, &pItem))
+            if(!GetItemProperty(pItem->Which(), aProperty))
+                bItemsChanged = ApplySpecialItem(pItem->Which(), rItemSet);
+    }
+
     for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
     {
+        if (SCHATTR_STAT_KIND_ERROR == pItem->Which())
+            continue;
+
         if( aIter.GetItemState( false ) == SfxItemState::SET )
         {
             if( GetItemProperty( pItem->Which(), aProperty ))

Reply via email to