Kaydet (Commit) c8e32709 authored tarafından Michael Stahl's avatar Michael Stahl

SfxEnumItem: cut out the middle man here too

CntEnumItem, we hardly knew you existed.

Change-Id: I54b489f22662f9a3305478d18438b13850444316
üst 69f68677
......@@ -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: */
......@@ -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;
};
//============================================================================
......
......@@ -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 \
......
......@@ -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
//
......
/* -*- 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: */
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