LCOV - code coverage report
Current view: top level - svl/source/items - cenumitm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 81 54.3 %
Date: 2012-08-25 Functions: 18 41 43.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15 50 30.0 %

           Branch data     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 [ +  + ][ -  + ]:    1491192 : TYPEINIT1(SfxEnumItemInterface, SfxPoolItem)
      37                 :            : 
      38                 :            : //============================================================================
      39                 :            : // virtual
      40                 :    1909225 : int SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const
      41                 :            : {
      42                 :            :     SFX_ASSERT(SfxPoolItem::operator ==(rItem), Which(), "unequal type");
      43                 :    1909225 :     return GetEnumValue()
      44                 :            :                == static_cast< const SfxEnumItemInterface * >(&rItem)->
      45                 :    1909225 :                       GetEnumValue();
      46                 :            : }
      47                 :            : 
      48                 :            : //============================================================================
      49                 :            : // virtual
      50                 :            : SfxItemPresentation
      51                 :          0 : SfxEnumItemInterface::GetPresentation(SfxItemPresentation, SfxMapUnit,
      52                 :            :                                       SfxMapUnit, XubString & rText,
      53                 :            :                                       const IntlWrapper *) const
      54                 :            : {
      55         [ #  # ]:          0 :     rText = XubString::CreateFromInt32(GetEnumValue());
      56                 :          0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      57                 :            : }
      58                 :            : 
      59                 :            : //============================================================================
      60                 :            : // virtual
      61                 :       1767 : bool SfxEnumItemInterface::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8)
      62                 :            :     const
      63                 :            : {
      64         [ +  - ]:       1767 :     rVal <<= sal_Int32(GetEnumValue());
      65                 :       1767 :     return true;
      66                 :            : }
      67                 :            : 
      68                 :            : //============================================================================
      69                 :            : // virtual
      70                 :      19750 : bool SfxEnumItemInterface::PutValue(const com::sun::star::uno::Any& rVal,
      71                 :            :                                     sal_uInt8)
      72                 :            : {
      73                 :      19750 :     sal_Int32 nTheValue = 0;
      74                 :            : 
      75         [ +  - ]:      19750 :     if ( ::cppu::enum2int( nTheValue, rVal ) )
      76                 :            :     {
      77         [ +  - ]:      19750 :         SetEnumValue(sal_uInt16(nTheValue));
      78                 :      19750 :         return true;
      79                 :            :     }
      80                 :            :     OSL_FAIL("SfxEnumItemInterface::PutValue(): Wrong type");
      81                 :      19750 :     return false;
      82                 :            : }
      83                 :            : 
      84                 :            : //============================================================================
      85                 :          0 : rtl::OUString SfxEnumItemInterface::GetValueTextByPos(sal_uInt16) const
      86                 :            : {
      87                 :            :     DBG_WARNING("SfxEnumItemInterface::GetValueTextByPos(): Pure virtual");
      88                 :          0 :     return rtl::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                 :       1407 : int SfxEnumItemInterface::HasBoolValue() const
     117                 :            : {
     118                 :       1407 :     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 [ -  + ][ +  + ]:    1487640 : 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                 :    3836699 : sal_uInt16 CntEnumItem::GetEnumValue() const
     163                 :            : {
     164                 :    3836699 :     return GetValue();
     165                 :            : }
     166                 :            : 
     167                 :            : //============================================================================
     168                 :            : // virtual
     169                 :      19754 : void CntEnumItem::SetEnumValue(sal_uInt16 nTheValue)
     170                 :            : {
     171                 :      19754 :     SetValue(nTheValue);
     172                 :      19754 : }
     173                 :            : 
     174                 :            : //============================================================================
     175                 :            : //
     176                 :            : //  class CntBoolItem
     177                 :            : //
     178                 :            : //============================================================================
     179                 :            : 
     180                 :            : DBG_NAME(CntBoolItem)
     181                 :            : 
     182                 :            : //============================================================================
     183 [ -  + ][ +  + ]:    1377538 : 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                 :     646381 : int CntBoolItem::operator ==(const SfxPoolItem & rItem) const
     196                 :            : {
     197                 :            :     DBG_ASSERT(rItem.ISA(CntBoolItem),
     198                 :            :                "CntBoolItem::operator ==(): Bad type");
     199                 :     646381 :     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                 :            :     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                 :            :                                                  UniString & 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                 :      47752 : bool CntBoolItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     225                 :            : {
     226         [ +  - ]:      47752 :     rVal <<= sal_Bool(m_bValue);
     227                 :      47752 :     return true;
     228                 :            : }
     229                 :            : 
     230                 :            : //============================================================================
     231                 :            : // virtual
     232                 :     179835 : bool CntBoolItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
     233                 :            : {
     234                 :     179835 :     sal_Bool bTheValue = sal_Bool();
     235         [ +  - ]:     179835 :     if (rVal >>= bTheValue)
     236                 :            :     {
     237                 :     179835 :         m_bValue = bTheValue;
     238                 :     179835 :         return true;
     239                 :            :     }
     240                 :            :     OSL_FAIL("CntBoolItem::PutValue(): Wrong type");
     241                 :     179835 :     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                 :       2646 : SvStream & CntBoolItem::Store(SvStream & rStream, sal_uInt16) const
     254                 :            : {
     255                 :       2646 :     rStream << m_bValue;
     256                 :       2646 :     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 : rtl::OUString CntBoolItem::GetValueTextByVal(sal_Bool bTheValue) const
     276                 :            : {
     277 [ #  # ][ #  # ]:          0 :     return bTheValue ?  rtl::OUString("TRUE") : rtl::OUString("FALSE");
                 [ #  # ]
     278                 :            : }
     279                 :            : 
     280                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10