LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svl/source/items - cenumitm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 83 53.0 %
Date: 2013-07-09 Functions: 18 41 43.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/uno/Any.hxx>
      21             : #include <tools/stream.hxx>
      22             : #include <svl/cenumitm.hxx>
      23             : #include <whassert.hxx>
      24             : 
      25             : #include <comphelper/extract.hxx>
      26             : 
      27             : //============================================================================
      28             : //
      29             : //  class SfxEnumItemInterface
      30             : //
      31             : //============================================================================
      32             : 
      33             : DBG_NAME(SfxEnumItemInterface)
      34             : 
      35             : //============================================================================
      36      877958 : TYPEINIT1(SfxEnumItemInterface, SfxPoolItem)
      37             : 
      38             : //============================================================================
      39             : // virtual
      40     1028279 : int SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const
      41             : {
      42             :     SFX_ASSERT(SfxPoolItem::operator ==(rItem), Which(), "unequal type");
      43     1028279 :     return GetEnumValue()
      44     1028279 :                == static_cast< const SfxEnumItemInterface * >(&rItem)->
      45     2056558 :                       GetEnumValue();
      46             : }
      47             : 
      48             : //============================================================================
      49             : // virtual
      50             : SfxItemPresentation
      51           0 : SfxEnumItemInterface::GetPresentation(SfxItemPresentation, SfxMapUnit,
      52             :                                       SfxMapUnit, OUString & rText,
      53             :                                       const IntlWrapper *) const
      54             : {
      55           0 :     rText = OUString::number( GetEnumValue() );
      56           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      57             : }
      58             : 
      59             : //============================================================================
      60             : // virtual
      61         890 : bool SfxEnumItemInterface::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8)
      62             :     const
      63             : {
      64         890 :     rVal <<= sal_Int32(GetEnumValue());
      65         890 :     return true;
      66             : }
      67             : 
      68             : //============================================================================
      69             : // virtual
      70       10755 : bool SfxEnumItemInterface::PutValue(const com::sun::star::uno::Any& rVal,
      71             :                                     sal_uInt8)
      72             : {
      73       10755 :     sal_Int32 nTheValue = 0;
      74             : 
      75       10755 :     if ( ::cppu::enum2int( nTheValue, rVal ) )
      76             :     {
      77       10755 :         SetEnumValue(sal_uInt16(nTheValue));
      78       10755 :         return true;
      79             :     }
      80             :     OSL_FAIL("SfxEnumItemInterface::PutValue(): Wrong type");
      81           0 :     return false;
      82             : }
      83             : 
      84             : //============================================================================
      85           0 : OUString SfxEnumItemInterface::GetValueTextByPos(sal_uInt16) const
      86             : {
      87             :     DBG_WARNING("SfxEnumItemInterface::GetValueTextByPos(): Pure virtual");
      88           0 :     return OUString();
      89             : }
      90             : 
      91             : //============================================================================
      92             : // virtual
      93           0 : sal_uInt16 SfxEnumItemInterface::GetValueByPos(sal_uInt16 nPos) const
      94             : {
      95           0 :     return nPos;
      96             : }
      97             : 
      98             : //============================================================================
      99             : // virtual
     100           0 : sal_uInt16 SfxEnumItemInterface::GetPosByValue(sal_uInt16 nValue) const
     101             : {
     102           0 :     sal_uInt16 nCount = GetValueCount();
     103           0 :     for (sal_uInt16 i = 0; i < nCount; ++i)
     104           0 :         if (GetValueByPos(i) == nValue)
     105           0 :             return i;
     106           0 :     return USHRT_MAX;
     107             : }
     108             : 
     109           0 : sal_Bool SfxEnumItemInterface::IsEnabled(sal_uInt16) const
     110             : {
     111           0 :     return sal_True;
     112             : }
     113             : 
     114             : //============================================================================
     115             : // virtual
     116         752 : int SfxEnumItemInterface::HasBoolValue() const
     117             : {
     118         752 :     return false;
     119             : }
     120             : 
     121             : //============================================================================
     122             : // virtual
     123           0 : sal_Bool SfxEnumItemInterface::GetBoolValue() const
     124             : {
     125           0 :     return false;
     126             : }
     127             : 
     128             : //============================================================================
     129             : // virtual
     130           0 : void SfxEnumItemInterface::SetBoolValue(sal_Bool)
     131           0 : {}
     132             : 
     133             : //============================================================================
     134             : //
     135             : //  class CntEnumItem
     136             : //
     137             : //============================================================================
     138             : 
     139             : DBG_NAME(CntEnumItem)
     140             : 
     141             : //============================================================================
     142           0 : CntEnumItem::CntEnumItem(sal_uInt16 which, SvStream & rStream):
     143           0 :     SfxEnumItemInterface(which)
     144             : {
     145           0 :     m_nValue = 0;
     146           0 :     rStream >> m_nValue;
     147           0 : }
     148             : 
     149             : //============================================================================
     150      876070 : TYPEINIT1(CntEnumItem, SfxEnumItemInterface)
     151             : 
     152             : //============================================================================
     153             : // virtual
     154        2112 : SvStream & CntEnumItem::Store(SvStream & rStream, sal_uInt16) const
     155             : {
     156        2112 :     rStream << m_nValue;
     157        2112 :     return rStream;
     158             : }
     159             : 
     160             : //============================================================================
     161             : // virtual
     162     2068010 : sal_uInt16 CntEnumItem::GetEnumValue() const
     163             : {
     164     2068010 :     return GetValue();
     165             : }
     166             : 
     167             : //============================================================================
     168             : // virtual
     169       10757 : void CntEnumItem::SetEnumValue(sal_uInt16 nTheValue)
     170             : {
     171       10757 :     SetValue(nTheValue);
     172       10757 : }
     173             : 
     174             : //============================================================================
     175             : //
     176             : //  class CntBoolItem
     177             : //
     178             : //============================================================================
     179             : 
     180             : DBG_NAME(CntBoolItem)
     181             : 
     182             : //============================================================================
     183      738526 : TYPEINIT1_AUTOFACTORY(CntBoolItem, SfxPoolItem)
     184             : 
     185             : //============================================================================
     186         256 : CntBoolItem::CntBoolItem(sal_uInt16 which, SvStream & rStream):
     187         256 :     SfxPoolItem(which)
     188             : {
     189         256 :     m_bValue = false;
     190         256 :     rStream >> m_bValue;
     191         256 : }
     192             : 
     193             : //============================================================================
     194             : // virtual
     195      358597 : int CntBoolItem::operator ==(const SfxPoolItem & rItem) const
     196             : {
     197             :     DBG_ASSERT(rItem.ISA(CntBoolItem),
     198             :                "CntBoolItem::operator ==(): Bad type");
     199      358597 :     return m_bValue == static_cast< CntBoolItem const * >(&rItem)->m_bValue;
     200             : }
     201             : 
     202             : //============================================================================
     203             : // virtual
     204           0 : int CntBoolItem::Compare(const SfxPoolItem & rWith) const
     205             : {
     206             :     DBG_ASSERT(rWith.ISA(CntBoolItem), "CntBoolItem::Compare(): Bad type");
     207           0 :     return m_bValue == static_cast< CntBoolItem const * >(&rWith)->m_bValue ?
     208           0 :                0 : m_bValue ? -1 : 1;
     209             : }
     210             : 
     211             : //============================================================================
     212             : // virtual
     213           0 : SfxItemPresentation CntBoolItem::GetPresentation(SfxItemPresentation,
     214             :                                                  SfxMapUnit, SfxMapUnit,
     215             :                                                  OUString & rText,
     216             :                                                  const IntlWrapper *) const
     217             : {
     218           0 :     rText = GetValueTextByVal(m_bValue);
     219           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
     220             : }
     221             : 
     222             : //============================================================================
     223             : // virtual
     224       26026 : bool CntBoolItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     225             : {
     226       26026 :     rVal <<= sal_Bool(m_bValue);
     227       26026 :     return true;
     228             : }
     229             : 
     230             : //============================================================================
     231             : // virtual
     232       95986 : bool CntBoolItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
     233             : {
     234       95986 :     sal_Bool bTheValue = sal_Bool();
     235       95986 :     if (rVal >>= bTheValue)
     236             :     {
     237       95984 :         m_bValue = bTheValue;
     238       95984 :         return true;
     239             :     }
     240             :     OSL_FAIL("CntBoolItem::PutValue(): Wrong type");
     241           2 :     return false;
     242             : }
     243             : 
     244             : //============================================================================
     245             : // virtual
     246           0 : SfxPoolItem * CntBoolItem::Create(SvStream & rStream, sal_uInt16) const
     247             : {
     248           0 :     return new CntBoolItem(Which(), rStream);
     249             : }
     250             : 
     251             : //============================================================================
     252             : // virtual
     253        1086 : SvStream & CntBoolItem::Store(SvStream & rStream, sal_uInt16) const
     254             : {
     255        1086 :     rStream << m_bValue;
     256        1086 :     return rStream;
     257             : }
     258             : 
     259             : //============================================================================
     260             : // virtual
     261           0 : SfxPoolItem * CntBoolItem::Clone(SfxItemPool *) const
     262             : {
     263           0 :     return new CntBoolItem(*this);
     264             : }
     265             : 
     266             : //============================================================================
     267             : // virtual
     268           0 : sal_uInt16 CntBoolItem::GetValueCount() const
     269             : {
     270           0 :     return 2;
     271             : }
     272             : 
     273             : //============================================================================
     274             : // virtual
     275           0 : OUString CntBoolItem::GetValueTextByVal(sal_Bool bTheValue) const
     276             : {
     277           0 :     return bTheValue ?  OUString("TRUE") : OUString("FALSE");
     278             : }
     279             : 
     280             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10