diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-08-15 23:12:54 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-08-16 11:23:28 +0200 |
commit | 69f686774cfeb803fdd63ed1ef07ff70550930de (patch) | |
tree | 3b45125258a2d6ebfc41782a317378e8f3457f67 /svl | |
parent | 35223e5f19dc1f4e59c3694e98103444c82082b8 (diff) |
SfxBoolItem: cut out the middle man
CntBoolItem adds no value at all.
Change-Id: I41a22fc11cca270e792f2a2f81e3638b54dc1d24
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/cenumitm.cxx | 56 | ||||
-rw-r--r-- | svl/source/items/eitem.cxx | 7 |
2 files changed, 29 insertions, 34 deletions
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx index c476a146acaa..42923fff766b 100644 --- a/svl/source/items/cenumitm.cxx +++ b/svl/source/items/cenumitm.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/uno/Any.hxx> #include <tools/stream.hxx> #include <svl/cenumitm.hxx> +#include <svl/eitem.hxx> #include <whassert.hxx> #include <comphelper/extract.hxx> @@ -152,38 +153,39 @@ void CntEnumItem::SetEnumValue(sal_uInt16 nTheValue) } // -// class CntBoolItem +// class SfxBoolItem // -DBG_NAME(CntBoolItem) +DBG_NAME(SfxBoolItem) -TYPEINIT1_AUTOFACTORY(CntBoolItem, SfxPoolItem) +TYPEINIT1_AUTOFACTORY(SfxBoolItem, SfxPoolItem); -CntBoolItem::CntBoolItem(sal_uInt16 which, SvStream & rStream): - SfxPoolItem(which) +SfxBoolItem::SfxBoolItem(sal_uInt16 const nWhich, SvStream & rStream) + : SfxPoolItem(nWhich) { - m_bValue = false; - rStream >> m_bValue; + sal_Bool tmp = false; + rStream >> tmp; + m_bValue = tmp; } // virtual -int CntBoolItem::operator ==(const SfxPoolItem & rItem) const +int SfxBoolItem::operator ==(const SfxPoolItem & rItem) const { - DBG_ASSERT(rItem.ISA(CntBoolItem), - "CntBoolItem::operator ==(): Bad type"); - return m_bValue == static_cast< CntBoolItem const * >(&rItem)->m_bValue; + DBG_ASSERT(rItem.ISA(SfxBoolItem), + "SfxBoolItem::operator ==(): Bad type"); + return m_bValue == static_cast< SfxBoolItem const * >(&rItem)->m_bValue; } // virtual -int CntBoolItem::Compare(const SfxPoolItem & rWith) const +int SfxBoolItem::Compare(const SfxPoolItem & rWith) const { - DBG_ASSERT(rWith.ISA(CntBoolItem), "CntBoolItem::Compare(): Bad type"); - return m_bValue == static_cast< CntBoolItem const * >(&rWith)->m_bValue ? + DBG_ASSERT(rWith.ISA(SfxBoolItem), "SfxBoolItem::Compare(): Bad type"); + return (m_bValue == static_cast<SfxBoolItem const*>(&rWith)->m_bValue) ? 0 : m_bValue ? -1 : 1; } // virtual -SfxItemPresentation CntBoolItem::GetPresentation(SfxItemPresentation, +SfxItemPresentation SfxBoolItem::GetPresentation(SfxItemPresentation, SfxMapUnit, SfxMapUnit, OUString & rText, const IntlWrapper *) const @@ -193,14 +195,14 @@ SfxItemPresentation CntBoolItem::GetPresentation(SfxItemPresentation, } // virtual -bool CntBoolItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const +bool SfxBoolItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const { - rVal <<= sal_Bool(m_bValue); + rVal <<= m_bValue; return true; } // virtual -bool CntBoolItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8) +bool SfxBoolItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8) { sal_Bool bTheValue = sal_Bool(); if (rVal >>= bTheValue) @@ -208,37 +210,37 @@ bool CntBoolItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8) m_bValue = bTheValue; return true; } - OSL_FAIL("CntBoolItem::PutValue(): Wrong type"); + OSL_FAIL("SfxBoolItem::PutValue(): Wrong type"); return false; } // virtual -SfxPoolItem * CntBoolItem::Create(SvStream & rStream, sal_uInt16) const +SfxPoolItem * SfxBoolItem::Create(SvStream & rStream, sal_uInt16) const { - return new CntBoolItem(Which(), rStream); + return new SfxBoolItem(Which(), rStream); } // virtual -SvStream & CntBoolItem::Store(SvStream & rStream, sal_uInt16) const +SvStream & SfxBoolItem::Store(SvStream & rStream, sal_uInt16) const { - rStream << m_bValue; + rStream << static_cast<sal_Bool>(m_bValue); // not bool for serialization! return rStream; } // virtual -SfxPoolItem * CntBoolItem::Clone(SfxItemPool *) const +SfxPoolItem * SfxBoolItem::Clone(SfxItemPool *) const { - return new CntBoolItem(*this); + return new SfxBoolItem(*this); } // virtual -sal_uInt16 CntBoolItem::GetValueCount() const +sal_uInt16 SfxBoolItem::GetValueCount() const { return 2; } // virtual -OUString CntBoolItem::GetValueTextByVal(sal_Bool bTheValue) const +OUString SfxBoolItem::GetValueTextByVal(sal_Bool bTheValue) const { return bTheValue ? OUString("TRUE") : OUString("FALSE"); } diff --git a/svl/source/items/eitem.cxx b/svl/source/items/eitem.cxx index 0f84b67ef69d..0b37d072731e 100644 --- a/svl/source/items/eitem.cxx +++ b/svl/source/items/eitem.cxx @@ -24,11 +24,4 @@ TYPEINIT1(SfxEnumItem, CntEnumItem); -// -// class SfxBoolItem -// - -TYPEINIT1_AUTOFACTORY(SfxBoolItem, CntBoolItem); - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |