Kaydet (Commit) 82c37453 authored tarafından Noel Grandin's avatar Noel Grandin

SfxItemHandle is only used in one place, so inline it

Change-Id: Ie54e0699312b6c072d2b162a068cffdf960be4d0
üst d26052bd
...@@ -45,7 +45,7 @@ namespace frm ...@@ -45,7 +45,7 @@ namespace frm
struct AttributeState struct AttributeState
{ {
private: private:
SfxItemHandle* pItemHandle; SfxPoolItem *pItemHandleItem;
public: public:
AttributeCheckState eSimpleState; AttributeCheckState eSimpleState;
...@@ -64,19 +64,19 @@ namespace frm ...@@ -64,19 +64,19 @@ namespace frm
}; };
inline AttributeState::AttributeState( ) inline AttributeState::AttributeState( )
:pItemHandle( NULL ) :pItemHandleItem ( NULL )
,eSimpleState( eIndetermined ) ,eSimpleState( eIndetermined )
{ {
} }
inline AttributeState::AttributeState( AttributeCheckState _eCheckState ) inline AttributeState::AttributeState( AttributeCheckState _eCheckState )
:pItemHandle( NULL ) :pItemHandleItem ( NULL )
,eSimpleState( _eCheckState ) ,eSimpleState( _eCheckState )
{ {
} }
inline AttributeState::AttributeState( const AttributeState& _rSource ) inline AttributeState::AttributeState( const AttributeState& _rSource )
:pItemHandle( NULL ) :pItemHandleItem ( NULL )
,eSimpleState( eIndetermined ) ,eSimpleState( eIndetermined )
{ {
operator=( _rSource ); operator=( _rSource );
...@@ -84,7 +84,7 @@ namespace frm ...@@ -84,7 +84,7 @@ namespace frm
inline AttributeState::~AttributeState( ) inline AttributeState::~AttributeState( )
{ {
delete(pItemHandle); // delete(pItemHandle);
} }
inline AttributeState& AttributeState::operator=( const AttributeState& _rSource ) inline AttributeState& AttributeState::operator=( const AttributeState& _rSource )
...@@ -99,17 +99,17 @@ namespace frm ...@@ -99,17 +99,17 @@ namespace frm
inline const SfxPoolItem* AttributeState::getItem() const inline const SfxPoolItem* AttributeState::getItem() const
{ {
return pItemHandle ? &pItemHandle->GetItem() : NULL; return pItemHandleItem;
} }
inline void AttributeState::setItem( const SfxPoolItem* _pItem ) inline void AttributeState::setItem( const SfxPoolItem* _pItem )
{ {
if ( pItemHandle ) if ( pItemHandleItem )
delete pItemHandle; delete pItemHandleItem;
if ( _pItem ) if ( _pItem )
pItemHandle = new SfxItemHandle( *const_cast< SfxPoolItem* >( _pItem ) ); pItemHandleItem = _pItem->Clone();
else else
pItemHandle = NULL; pItemHandleItem = NULL;
} }
inline bool AttributeState::operator==( const AttributeState& _rRHS ) inline bool AttributeState::operator==( const AttributeState& _rRHS )
...@@ -117,16 +117,16 @@ namespace frm ...@@ -117,16 +117,16 @@ namespace frm
if ( eSimpleState != _rRHS.eSimpleState ) if ( eSimpleState != _rRHS.eSimpleState )
return false; return false;
if ( pItemHandle && !_rRHS.pItemHandle ) if ( pItemHandleItem && !_rRHS.pItemHandleItem )
return false; return false;
if ( !pItemHandle && _rRHS.pItemHandle ) if ( !pItemHandleItem && _rRHS.pItemHandleItem )
return false; return false;
if ( !pItemHandle && !_rRHS.pItemHandle ) if ( !pItemHandleItem && !_rRHS.pItemHandleItem )
return true; return true;
return ( pItemHandle->GetItem() == _rRHS.pItemHandle->GetItem() ); return pItemHandleItem == _rRHS.pItemHandleItem;
} }
class IMultiAttributeDispatcher class IMultiAttributeDispatcher
......
...@@ -339,23 +339,6 @@ public: ...@@ -339,23 +339,6 @@ public:
}; };
// Handle class for PoolItems
class SVL_DLLPUBLIC SfxItemHandle
{
sal_uInt16 *pRef;
SfxPoolItem *pItem;
public:
explicit SfxItemHandle( SfxPoolItem& );
SfxItemHandle( const SfxItemHandle& );
~SfxItemHandle();
const SfxItemHandle &operator=(const SfxItemHandle &);
const SfxPoolItem &GetItem() const { return *pItem; }
};
DECL_PTRHINT(SVL_DLLPUBLIC, SfxPoolItemHint, SfxPoolItem); DECL_PTRHINT(SVL_DLLPUBLIC, SfxPoolItemHint, SfxPoolItem);
......
...@@ -256,50 +256,6 @@ SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const ...@@ -256,50 +256,6 @@ SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const
return new SfxVoidItem(*this); return new SfxVoidItem(*this);
} }
// SfxInvalidItem
SfxItemHandle::SfxItemHandle(SfxPoolItem &rItem):
pRef(new sal_uInt16(1)),
pItem(rItem.Clone())
{
}
SfxItemHandle::SfxItemHandle(const SfxItemHandle &rCopy):
pRef(rCopy.pRef),
pItem(rCopy.pItem)
{
++(*pRef);
}
const SfxItemHandle &SfxItemHandle::operator=(const SfxItemHandle &rCopy)
{
if(&rCopy == this || pItem == rCopy.pItem)
return *this;
--(*pRef);
if(!(*pRef))
{
delete pItem;
pItem = 0;
}
pRef = rCopy.pRef;
++(*pRef);
pItem = rCopy.pItem;
return *this;
}
SfxItemHandle::~SfxItemHandle()
{
--(*pRef);
if(!(*pRef)) {
delete pRef; pRef = 0;
delete pItem; pItem = 0;
}
}
bool SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ ) bool SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
{ {
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment