LibreOffice Module chart2 (master) 1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
chart::wrapper::ItemConverter Class Referenceabstract

This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets. More...

#include <ItemConverter.hxx>

Inheritance diagram for chart::wrapper::ItemConverter:
[legend]
Collaboration diagram for chart::wrapper::ItemConverter:
[legend]

Public Types

typedef sal_uInt16 tWhichIdType
 
typedef OUString tPropertyNameType
 
typedef sal_uInt8 tMemberIdType
 
typedef std::pair< tPropertyNameType, tMemberIdTypetPropertyNameWithMemberId
 

Public Member Functions

 ItemConverter (css::uno::Reference< css::beans::XPropertySet > xPropertySet, SfxItemPool &rItemPool)
 Construct an item converter that uses the given property set for reading/writing converted items. More...
 
virtual ~ItemConverter () override
 
virtual void FillItemSet (SfxItemSet &rOutItemSet) const
 applies all properties that can be mapped to items into the given item set. More...
 
virtual bool ApplyItemSet (const SfxItemSet &rItemSet)
 applies all properties that are results of a conversion from all items in rItemSet to the internal XPropertySet. More...
 
SfxItemSet CreateEmptyItemSet () const
 creates an empty item set using the given pool or a common pool if empty (see GetItemPool) and allowing all items given in the ranges returned by GetWhichPairs. More...
 

Static Public Member Functions

static void InvalidateUnequalItems (SfxItemSet &rDestSet, const SfxItemSet &rSourceSet)
 Invalidates all items in rDestSet, that are set (state SfxItemState::SET) in both item sets (rDestSet and rSourceSet) and have differing content. More...
 

Protected Member Functions

virtual const WhichRangesContainerGetWhichPairs () const =0
 implement this method to provide an array of which-ranges More...
 
virtual bool GetItemProperty (tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const =0
 implement this method to return a Property object for a given which id. More...
 
virtual void FillSpecialItem (sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const
 for items that can not be mapped directly to a property. More...
 
virtual bool ApplySpecialItem (sal_uInt16 nWhichId, const SfxItemSet &rItemSet)
 for items that can not be mapped directly to a property. More...
 
SfxItemPoolGetItemPool () const
 Returns the pool. More...
 
const css::uno::Reference< css::beans::XPropertySet > & GetPropertySet () const
 Returns the XPropertySet that was given in the CTOR and is used to apply items in ApplyItemSet(). More...
 
virtual void _disposing (const css::lang::EventObject &rSource) override
 
void resetPropertySet (const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
 sets a new property set, that you get with GetPropertySet(). More...
 
- Protected Member Functions inherited from utl::OEventListenerAdapter
 OEventListenerAdapter ()
 
virtual ~OEventListenerAdapter ()
 
void startComponentListening (const css::uno::Reference< css::lang::XComponent > &_rxComp)
 
void stopComponentListening (const css::uno::Reference< css::lang::XComponent > &_rxComp)
 
void stopAllComponentListening ()
 
virtual void _disposing (const css::lang::EventObject &_rSource)=0
 

Private Attributes

css::uno::Reference< css::beans::XPropertySetm_xPropertySet
 
css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertySetInfo
 
SfxItemPoolm_rItemPool
 

Detailed Description

This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.

With this helper classes, you can feed dialogs with XPropertySets and let those modify by the dialogs.

You must implement GetWhichPairs() such that an SfxItemSet created with CreateEmptyItemSet() is able to hold all items that may be mapped.

You also have to implement GetItemProperty(), in order to return the property name for a given which-id together with the corresponding member-id that has to be used for conversion in QueryValue/PutValue.

FillSpecialItem and ApplySpecialItem may be used for special handling of individual item, e.g. if you need member-ids in QueryValue/PutValue

A typical use could be the following:

::comphelper::ChartTypeItemConverter aItemConverter( xPropertySet, GetItemPool() ); SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); aItemConverter.FillItemSet( aItemSet ); bool bChanged = false;

MyDialog aDlg( aItemSet ); if( aDlg.Execute() == RET_OK ) { const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); if( pOutItemSet ) bChanged = aItemConverter.ApplyItemSet( *pOutItemSet ); }

if( bChanged ) { [ apply model changes to view ] }

Definition at line 68 of file ItemConverter.hxx.

Member Typedef Documentation

◆ tMemberIdType

Definition at line 82 of file ItemConverter.hxx.

◆ tPropertyNameType

Definition at line 81 of file ItemConverter.hxx.

◆ tPropertyNameWithMemberId

Definition at line 84 of file ItemConverter.hxx.

◆ tWhichIdType

Definition at line 80 of file ItemConverter.hxx.

Constructor & Destructor Documentation

◆ ItemConverter()

chart::wrapper::ItemConverter::ItemConverter ( css::uno::Reference< css::beans::XPropertySet xPropertySet,
SfxItemPool rItemPool 
)

Construct an item converter that uses the given property set for reading/writing converted items.

Definition at line 36 of file ItemConverter.cxx.

References m_xPropertySet, and resetPropertySet().

◆ ~ItemConverter()

chart::wrapper::ItemConverter::~ItemConverter ( )
overridevirtual

Member Function Documentation

◆ _disposing()

void chart::wrapper::ItemConverter::_disposing ( const css::lang::EventObject &  rSource)
overrideprotectedvirtual

Implements utl::OEventListenerAdapter.

Definition at line 73 of file ItemConverter.cxx.

◆ ApplyItemSet()

bool chart::wrapper::ItemConverter::ApplyItemSet ( const SfxItemSet rItemSet)
virtual

◆ ApplySpecialItem()

bool chart::wrapper::ItemConverter::ApplySpecialItem ( sal_uInt16  nWhichId,
const SfxItemSet rItemSet 
)
protectedvirtual

◆ CreateEmptyItemSet()

SfxItemSet chart::wrapper::ItemConverter::CreateEmptyItemSet ( ) const

creates an empty item set using the given pool or a common pool if empty (see GetItemPool) and allowing all items given in the ranges returned by GetWhichPairs.

Definition at line 68 of file ItemConverter.cxx.

References GetItemPool(), and GetWhichPairs().

Referenced by chart::ChartController::executeDispatch_InsertErrorBars(), chart::ChartController::executeDispatch_InsertMenu_DataLabels(), chart::ChartController::executeDispatch_InsertTrendline(), chart::ChartController::executeDlg_ObjectProperties_withoutUndoGuard(), and chart::wrapper::MultipleItemConverter::FillItemSet().

◆ FillItemSet()

void chart::wrapper::ItemConverter::FillItemSet ( SfxItemSet rOutItemSet) const
virtual

applies all properties that can be mapped to items into the given item set.

Call this method before opening a dialog.

Parameters
rOutItemSetthe SfxItemSet is filled with all items that are a result of a conversion from a property of the internal XPropertySet.

Reimplemented in chart::wrapper::AxisItemConverter, chart::wrapper::DataPointItemConverter, chart::wrapper::DataTableItemConverter, chart::wrapper::ErrorBarItemConverter, chart::wrapper::LegendItemConverter, chart::wrapper::MultipleItemConverter, chart::wrapper::RegressionCurveItemConverter, chart::wrapper::RegressionEquationItemConverter, chart::wrapper::TextLabelItemConverter, and chart::wrapper::TitleItemConverter.

Definition at line 77 of file ItemConverter.cxx.

References SfxPoolItem::Clone(), DBG_UNHANDLED_EXCEPTION, WhichRangesContainer::empty(), FillSpecialItem(), SfxItemPool::GetDefaultItem(), GetItemPool(), GetItemProperty(), SfxItemSet::GetRanges(), m_xPropertySet, m_xPropertySetInfo, SfxItemSet::Put(), and TOOLS_WARN_EXCEPTION.

Referenced by chart::wrapper::AxisItemConverter::FillItemSet(), chart::wrapper::DataPointItemConverter::FillItemSet(), chart::wrapper::DataTableItemConverter::FillItemSet(), chart::wrapper::ErrorBarItemConverter::FillItemSet(), chart::wrapper::LegendItemConverter::FillItemSet(), chart::wrapper::RegressionCurveItemConverter::FillItemSet(), chart::wrapper::RegressionEquationItemConverter::FillItemSet(), chart::wrapper::TextLabelItemConverter::FillItemSet(), and chart::wrapper::TitleItemConverter::FillItemSet().

◆ FillSpecialItem()

void chart::wrapper::ItemConverter::FillSpecialItem ( sal_uInt16  nWhichId,
SfxItemSet rOutItemSet 
) const
protectedvirtual

◆ GetItemPool()

SfxItemPool & chart::wrapper::ItemConverter::GetItemPool ( ) const
inlineprotected

Returns the pool.

Definition at line 158 of file ItemConverter.hxx.

References m_rItemPool.

Referenced by CreateEmptyItemSet(), and FillItemSet().

◆ GetItemProperty()

virtual bool chart::wrapper::ItemConverter::GetItemProperty ( tWhichIdType  nWhichId,
tPropertyNameWithMemberId rOutProperty 
) const
protectedpure virtual

◆ GetPropertySet()

const css::uno::Reference< css::beans::XPropertySet > & chart::wrapper::ItemConverter::GetPropertySet ( ) const
inlineprotected

◆ GetWhichPairs()

virtual const WhichRangesContainer & chart::wrapper::ItemConverter::GetWhichPairs ( ) const
protectedpure virtual

◆ InvalidateUnequalItems()

void chart::wrapper::ItemConverter::InvalidateUnequalItems ( SfxItemSet rDestSet,
const SfxItemSet rSourceSet 
)
static

Invalidates all items in rDestSet, that are set (state SfxItemState::SET) in both item sets (rDestSet and rSourceSet) and have differing content.

Definition at line 194 of file ItemConverter.cxx.

References SfxWhichIter::FirstWhich(), SfxItemSet::Get(), SfxWhichIter::GetItemState(), SfxItemSet::GetItemState(), SfxItemSet::InvalidateItem(), and SfxWhichIter::NextWhich().

Referenced by chart::wrapper::MultipleItemConverter::FillItemSet().

◆ resetPropertySet()

void chart::wrapper::ItemConverter::resetPropertySet ( const css::uno::Reference< css::beans::XPropertySet > &  xPropSet)
protected

sets a new property set, that you get with GetPropertySet().

It should not be necessary to use this method. It is introduced to allow changing the regression type of a regression curve which changes the object identity.

Definition at line 50 of file ItemConverter.cxx.

References m_xPropertySet, m_xPropertySetInfo, utl::OEventListenerAdapter::startComponentListening(), and utl::OEventListenerAdapter::stopAllComponentListening().

Referenced by chart::wrapper::RegressionCurveItemConverter::ApplySpecialItem(), chart::wrapper::StatisticsItemConverter::ApplySpecialItem(), and ItemConverter().

Member Data Documentation

◆ m_rItemPool

SfxItemPool& chart::wrapper::ItemConverter::m_rItemPool
private

Definition at line 180 of file ItemConverter.hxx.

Referenced by GetItemPool().

◆ m_xPropertySet

css::uno::Reference< css::beans::XPropertySet > chart::wrapper::ItemConverter::m_xPropertySet
private

◆ m_xPropertySetInfo

css::uno::Reference< css::beans::XPropertySetInfo > chart::wrapper::ItemConverter::m_xPropertySetInfo
private

Definition at line 178 of file ItemConverter.hxx.

Referenced by FillItemSet(), and resetPropertySet().


The documentation for this class was generated from the following files: