[Libreoffice-commits] core.git: 2 commits - include/svl svl/Library_svl.mk svl/source
Michael Stahl
mstahl at redhat.com
Fri Aug 16 02:26:29 PDT 2013
include/svl/cenumitm.hxx | 90 +----------------------------------------
include/svl/eitem.hxx | 92 ++++++++++++++++++++++++++++++++++--------
svl/Library_svl.mk | 1
svl/source/items/cenumitm.cxx | 78 +++++++++++++++++++----------------
svl/source/items/eitem.cxx | 34 ---------------
5 files changed, 122 insertions(+), 173 deletions(-)
New commits:
commit c8e327092a8419636ae447b3b82052e6aeb724a0
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Aug 15 23:26:58 2013 +0200
SfxEnumItem: cut out the middle man here too
CntEnumItem, we hardly knew you existed.
Change-Id: I54b489f22662f9a3305478d18438b13850444316
diff --git a/include/svl/cenumitm.hxx b/include/svl/cenumitm.hxx
index dc61d30..c8fb8bb 100644
--- a/include/svl/cenumitm.hxx
+++ b/include/svl/cenumitm.hxx
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _SVTOOLS_CENUMITM_HXX
-#define _SVTOOLS_CENUMITM_HXX
+#ifndef SVTOOLS_CENUMITM_HXX
+#define SVTOOLS_CENUMITM_HXX
#include "svl/svldllapi.h"
#include <tools/debug.hxx>
@@ -81,42 +81,6 @@ public:
virtual void SetBoolValue(sal_Bool bValue);
};
-//============================================================================
-DBG_NAMEEX(CntEnumItem)
-
-class SVL_DLLPUBLIC CntEnumItem: public SfxEnumItemInterface
-{
- sal_uInt16 m_nValue;
-
-protected:
- explicit CntEnumItem(sal_uInt16 which = 0, sal_uInt16 nTheValue = 0):
- SfxEnumItemInterface(which), m_nValue(nTheValue) {}
-
- CntEnumItem(sal_uInt16 which, SvStream & rStream);
-
- CntEnumItem(const CntEnumItem & rItem):
- SfxEnumItemInterface(rItem), m_nValue(rItem.m_nValue) {}
-
-public:
- TYPEINFO();
-
- virtual SvStream & Store(SvStream & rStream, sal_uInt16) const;
-
- virtual sal_uInt16 GetEnumValue() const;
-
- virtual void SetEnumValue(sal_uInt16 nTheValue);
-
- sal_uInt16 GetValue() const { return m_nValue; }
-
- inline void SetValue(sal_uInt16 nTheValue);
-};
-
-inline void CntEnumItem::SetValue(sal_uInt16 nTheValue)
-{
- DBG_ASSERT(GetRefCount() == 0, "CntEnumItem::SetValue(): Pooled item");
- m_nValue = nTheValue;
-}
-
-#endif // _SVTOOLS_CENUMITM_HXX
+#endif // SVTOOLS_CENUMITM_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx
index e035c61..65938e2 100644
--- a/include/svl/eitem.hxx
+++ b/include/svl/eitem.hxx
@@ -24,18 +24,39 @@
#include <svl/cenumitm.hxx>
//============================================================================
-class SVL_DLLPUBLIC SfxEnumItem: public CntEnumItem
+
+class SVL_DLLPUBLIC SfxEnumItem
+ : public SfxEnumItemInterface
{
+ sal_uInt16 m_nValue;
+
protected:
- explicit SfxEnumItem(sal_uInt16 which = 0, sal_uInt16 nValue = 0):
- CntEnumItem(which, nValue) {}
+ explicit SfxEnumItem(sal_uInt16 const nWhich =0, sal_uInt16 const nValue =0)
+ : SfxEnumItemInterface(nWhich)
+ , m_nValue(nValue)
+ { }
- SfxEnumItem(sal_uInt16 which, SvStream & rStream):
- CntEnumItem(which, rStream) {}
+ SfxEnumItem(const SfxEnumItem & rItem)
+ : SfxEnumItemInterface(rItem)
+ , m_nValue(rItem.m_nValue)
+ { }
+
+ SfxEnumItem(sal_uInt16 const nWhich, SvStream & rStream);
public:
TYPEINFO();
+ sal_uInt16 GetValue() const { return m_nValue; }
+
+ void SetValue(sal_uInt16 nTheValue);
+
+ // SfxPoolItem
+ virtual SvStream & Store(SvStream & rStream, sal_uInt16) const SAL_OVERRIDE;
+
+ virtual sal_uInt16 GetEnumValue() const SAL_OVERRIDE;
+
+ virtual void SetEnumValue(sal_uInt16 nTheValue) SAL_OVERRIDE;
+
};
//============================================================================
diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index fd28a7a..fbca266 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -70,7 +70,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
svl/source/items/ctypeitm \
svl/source/items/custritm \
svl/source/items/dateitem \
- svl/source/items/eitem \
svl/source/items/flagitem \
svl/source/items/globalnameitem \
svl/source/items/grabbagitem \
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index 42923ff..9e11d71 100644
--- a/svl/source/items/cenumitm.cxx
+++ b/svl/source/items/cenumitm.cxx
@@ -119,39 +119,45 @@ void SfxEnumItemInterface::SetBoolValue(sal_Bool)
{}
//
-// class CntEnumItem
+// class SfxEnumItem
//
-DBG_NAME(CntEnumItem)
+DBG_NAME(SfxEnumItem)
-CntEnumItem::CntEnumItem(sal_uInt16 which, SvStream & rStream):
- SfxEnumItemInterface(which)
+SfxEnumItem::SfxEnumItem(sal_uInt16 const nWhich, SvStream & rStream)
+ : SfxEnumItemInterface(nWhich)
{
m_nValue = 0;
rStream >> m_nValue;
}
-TYPEINIT1(CntEnumItem, SfxEnumItemInterface)
+TYPEINIT1(SfxEnumItem, SfxEnumItemInterface)
// virtual
-SvStream & CntEnumItem::Store(SvStream & rStream, sal_uInt16) const
+SvStream & SfxEnumItem::Store(SvStream & rStream, sal_uInt16) const
{
rStream << m_nValue;
return rStream;
}
// virtual
-sal_uInt16 CntEnumItem::GetEnumValue() const
+sal_uInt16 SfxEnumItem::GetEnumValue() const
{
return GetValue();
}
// virtual
-void CntEnumItem::SetEnumValue(sal_uInt16 nTheValue)
+void SfxEnumItem::SetEnumValue(sal_uInt16 const nTheValue)
{
SetValue(nTheValue);
}
+void SfxEnumItem::SetValue(sal_uInt16 const nTheValue)
+{
+ DBG_ASSERT(GetRefCount() == 0, "SfxEnumItem::SetValue(): Pooled item");
+ m_nValue = nTheValue;
+}
+
//
// class SfxBoolItem
//
diff --git a/svl/source/items/eitem.cxx b/svl/source/items/eitem.cxx
deleted file mode 100644
index 0b37d07..0000000
--- a/svl/source/items/eitem.cxx
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <svl/eitem.hxx>
-//
-// class SfxEnumItem
-//
-
-TYPEINIT1(SfxEnumItem, CntEnumItem);
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 69f686774cfeb803fdd63ed1ef07ff70550930de
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Aug 15 23:12:54 2013 +0200
SfxBoolItem: cut out the middle man
CntBoolItem adds no value at all.
Change-Id: I41a22fc11cca270e792f2a2f81e3638b54dc1d24
diff --git a/include/svl/cenumitm.hxx b/include/svl/cenumitm.hxx
index 35024c3..dc61d30 100644
--- a/include/svl/cenumitm.hxx
+++ b/include/svl/cenumitm.hxx
@@ -117,54 +117,6 @@ inline void CntEnumItem::SetValue(sal_uInt16 nTheValue)
m_nValue = nTheValue;
}
-//============================================================================
-DBG_NAMEEX(CntBoolItem)
-
-class SVL_DLLPUBLIC CntBoolItem: public SfxPoolItem
-{
- sal_Bool m_bValue;
-
-public:
- TYPEINFO();
-
- explicit CntBoolItem(sal_uInt16 which = 0, sal_Bool bTheValue = sal_False):
- SfxPoolItem(which), m_bValue(bTheValue) {}
-
- CntBoolItem(sal_uInt16 nWhich, SvStream & rStream);
-
- CntBoolItem(const CntBoolItem & rItem):
- SfxPoolItem(rItem), m_bValue(rItem.m_bValue) {}
-
- virtual int operator ==(const SfxPoolItem & rItem) const;
-
- using SfxPoolItem::Compare;
- virtual int Compare(const SfxPoolItem & rWith) const;
-
- virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
- SfxMapUnit, SfxMapUnit,
- OUString & rText,
- const IntlWrapper * = 0)
- const;
-
- virtual bool QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8 = 0) const;
-
- virtual bool PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 = 0);
-
- virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const;
-
- virtual SvStream & Store(SvStream & rStream, sal_uInt16) const;
-
- virtual SfxPoolItem * Clone(SfxItemPool * = 0) const;
-
- virtual sal_uInt16 GetValueCount() const;
-
- virtual OUString GetValueTextByVal(sal_Bool bTheValue) const;
-
- sal_Bool GetValue() const { return m_bValue; }
-
- void SetValue(sal_Bool bTheValue) { m_bValue = bTheValue; }
-};
-
#endif // _SVTOOLS_CENUMITM_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx
index c9c5e38..e035c61 100644
--- a/include/svl/eitem.hxx
+++ b/include/svl/eitem.hxx
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _SFXENUMITEM_HXX
-#define _SFXENUMITEM_HXX
+#ifndef SFXENUMITEM_HXX
+#define SFXENUMITEM_HXX
#include "svl/svldllapi.h"
#include <svl/cenumitm.hxx>
@@ -39,24 +39,63 @@ public:
};
//============================================================================
-class SVL_DLLPUBLIC SfxBoolItem: public CntBoolItem
+
+class SVL_DLLPUBLIC SfxBoolItem
+ : public SfxPoolItem
{
+ bool m_bValue;
+
public:
TYPEINFO();
- explicit SfxBoolItem(sal_uInt16 which = 0, sal_Bool bValue = sal_False):
- CntBoolItem(which, bValue) {}
+ explicit SfxBoolItem(sal_uInt16 const nWhich = 0, bool const bValue = false)
+ : SfxPoolItem(nWhich)
+ , m_bValue(bValue)
+ { }
+
+ SfxBoolItem(SfxBoolItem const& rItem)
+ : SfxPoolItem(rItem)
+ , m_bValue(rItem.m_bValue)
+ { }
+
+ SfxBoolItem(sal_uInt16 nWhich, SvStream & rStream);
+
+ bool GetValue() const { return m_bValue; }
+
+ void SetValue(bool const bTheValue) { m_bValue = bTheValue; }
+
+ // SfxPoolItem
+ virtual int operator ==(const SfxPoolItem & rItem) const SAL_OVERRIDE;
+
+ using SfxPoolItem::Compare;
+ virtual int Compare(const SfxPoolItem & rWith) const SAL_OVERRIDE;
+
+ virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ OUString & rText,
+ const IntlWrapper * = 0)
+ const SAL_OVERRIDE;
+
+ virtual bool QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8 = 0)
+ const SAL_OVERRIDE;
+
+ virtual bool PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 = 0)
+ SAL_OVERRIDE;
- SfxBoolItem(sal_uInt16 which, SvStream & rStream):
- CntBoolItem(which, rStream) {}
virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const
- { return new SfxBoolItem(Which(), rStream); }
+ SAL_OVERRIDE;
+
+ virtual SvStream & Store(SvStream & rStream, sal_uInt16) const SAL_OVERRIDE;
+
+ virtual SfxPoolItem * Clone(SfxItemPool * = 0) const SAL_OVERRIDE;
+
+ virtual sal_uInt16 GetValueCount() const;
+
+ virtual OUString GetValueTextByVal(sal_Bool bTheValue) const;
- virtual SfxPoolItem * Clone(SfxItemPool * = 0) const
- { return new SfxBoolItem(*this); }
};
-#endif // _SFXENUMITEM_HXX
+#endif // SFXENUMITEM_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index c476a14..42923ff 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 0f84b67..0b37d07 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: */
More information about the Libreoffice-commits
mailing list