summaryrefslogtreecommitdiff
path: root/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/itemsetwrapper/ItemConverter.cxx')
-rw-r--r--chart2/source/controller/itemsetwrapper/ItemConverter.cxx51
1 files changed, 37 insertions, 14 deletions
diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
index a99d848d0c8c..1a4eebf91127 100644
--- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
@@ -25,17 +25,19 @@
#include <svl/itemiter.hxx>
#include <svl/whiter.hxx>
#include <svx/svxids.hrc>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
+#include <utility>
+#include <chartview/ChartSfxItemIds.hxx>
using namespace ::com::sun::star;
namespace chart::wrapper {
ItemConverter::ItemConverter(
- const uno::Reference< beans::XPropertySet > & rPropertySet,
+ uno::Reference< beans::XPropertySet > xPropertySet,
SfxItemPool& rItemPool ) :
- m_xPropertySet( rPropertySet ),
+ m_xPropertySet(std::move( xPropertySet )),
m_rItemPool( rItemPool )
{
resetPropertySet( m_xPropertySet );
@@ -75,20 +77,18 @@ void ItemConverter::_disposing( const lang::EventObject& )
void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
{
- const sal_uInt16 * pRanges = rOutItemSet.GetRanges();
+ const WhichRangesContainer& pRanges = rOutItemSet.GetRanges();
tPropertyNameWithMemberId aProperty;
SfxItemPool & rPool = GetItemPool();
- assert(pRanges != nullptr);
+ assert(!pRanges.empty());
OSL_ASSERT( m_xPropertySetInfo.is());
OSL_ASSERT( m_xPropertySet.is());
- while( (*pRanges) != 0)
+ for(const auto& rPair : pRanges)
{
- sal_uInt16 nBeg = *pRanges;
- ++pRanges;
- sal_uInt16 nEnd = *pRanges;
- ++pRanges;
+ sal_uInt16 nBeg = rPair.first;
+ sal_uInt16 nEnd = rPair.second;
OSL_ASSERT( nBeg <= nEnd );
for( sal_uInt16 nWhich = nBeg; nWhich <= nEnd; ++nWhich )
@@ -96,7 +96,7 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
if( GetItemProperty( nWhich, aProperty ))
{
// put the Property into the itemset
- std::unique_ptr<SfxPoolItem> pItem(rPool.GetDefaultItem( nWhich ).Clone());
+ std::unique_ptr<SfxPoolItem> pItem(rPool.GetUserOrPoolDefaultItem( nWhich ).Clone());
if( pItem )
{
@@ -157,9 +157,31 @@ 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( rItemSet.GetItemState( pItem->Which(), false ) == SfxItemState::SET )
+ if (SCHATTR_STAT_KIND_ERROR == pItem->Which())
+ continue;
+
+ if( aIter.GetItemState( false ) == SfxItemState::SET )
{
if( GetItemProperty( pItem->Which(), aProperty ))
{
@@ -200,7 +222,8 @@ void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItem
while (nWhich)
{
- if ((rSourceSet.GetItemState(nWhich, true, &pPoolItem) == SfxItemState::SET) &&
+ SfxItemState nSourceItemState = aIter.GetItemState(true, &pPoolItem);
+ if ((nSourceItemState == SfxItemState::SET) &&
(rDestSet.GetItemState(nWhich, true, &pPoolItem) == SfxItemState::SET))
{
if (rSourceSet.Get(nWhich) != rDestSet.Get(nWhich))
@@ -211,7 +234,7 @@ void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItem
}
}
}
- else if( rSourceSet.GetItemState(nWhich, true, &pPoolItem) == SfxItemState::DONTCARE )
+ else if( nSourceItemState == SfxItemState::INVALID )
rDestSet.InvalidateItem(nWhich);
nWhich = aIter.NextWhich ();