LCOV - code coverage report
Current view: top level - svl/source/items - cenumitm.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 51 86 59.3 %
Date: 2014-11-03 Functions: 26 42 61.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 <svl/eitem.hxx>
      24             : #include "whassert.hxx"
      25             : 
      26             : #include <comphelper/extract.hxx>
      27             : 
      28     3558377 : TYPEINIT1(SfxEnumItemInterface, SfxPoolItem)
      29             : 
      30             : // virtual
      31     2183257 : bool SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const
      32             : {
      33             :     SFX_ASSERT(SfxPoolItem::operator ==(rItem), Which(), "unequal type");
      34     2183257 :     return GetEnumValue()
      35             :                == static_cast< const SfxEnumItemInterface * >(&rItem)->
      36     2183257 :                       GetEnumValue();
      37             : }
      38             : 
      39             : // virtual
      40           0 : bool SfxEnumItemInterface::GetPresentation(SfxItemPresentation, SfxMapUnit,
      41             :                                       SfxMapUnit, OUString & rText,
      42             :                                       const IntlWrapper *) const
      43             : {
      44           0 :     rText = OUString::number( GetEnumValue() );
      45           0 :     return true;
      46             : }
      47             : 
      48             : // virtual
      49        2186 : bool SfxEnumItemInterface::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8)
      50             :     const
      51             : {
      52        2186 :     rVal <<= sal_Int32(GetEnumValue());
      53        2186 :     return true;
      54             : }
      55             : 
      56             : // virtual
      57       10940 : bool SfxEnumItemInterface::PutValue(const com::sun::star::uno::Any& rVal,
      58             :                                     sal_uInt8)
      59             : {
      60       10940 :     sal_Int32 nTheValue = 0;
      61             : 
      62       10940 :     if ( ::cppu::enum2int( nTheValue, rVal ) )
      63             :     {
      64       10940 :         SetEnumValue(sal_uInt16(nTheValue));
      65       10940 :         return true;
      66             :     }
      67             :     OSL_FAIL("SfxEnumItemInterface::PutValue(): Wrong type");
      68           0 :     return false;
      69             : }
      70             : 
      71           0 : OUString SfxEnumItemInterface::GetValueTextByPos(sal_uInt16) const
      72             : {
      73             :     DBG_WARNING("SfxEnumItemInterface::GetValueTextByPos(): Pure virtual");
      74           0 :     return OUString();
      75             : }
      76             : 
      77             : // virtual
      78           0 : sal_uInt16 SfxEnumItemInterface::GetValueByPos(sal_uInt16 nPos) const
      79             : {
      80           0 :     return nPos;
      81             : }
      82             : 
      83             : // virtual
      84           0 : sal_uInt16 SfxEnumItemInterface::GetPosByValue(sal_uInt16 nValue) const
      85             : {
      86           0 :     sal_uInt16 nCount = GetValueCount();
      87           0 :     for (sal_uInt16 i = 0; i < nCount; ++i)
      88           0 :         if (GetValueByPos(i) == nValue)
      89           0 :             return i;
      90           0 :     return USHRT_MAX;
      91             : }
      92             : 
      93           0 : bool SfxEnumItemInterface::IsEnabled(sal_uInt16) const
      94             : {
      95           0 :     return true;
      96             : }
      97             : 
      98             : // virtual
      99        1130 : bool SfxEnumItemInterface::HasBoolValue() const
     100             : {
     101        1130 :     return false;
     102             : }
     103             : 
     104             : // virtual
     105           0 : bool SfxEnumItemInterface::GetBoolValue() const
     106             : {
     107           0 :     return false;
     108             : }
     109             : 
     110             : // virtual
     111           0 : void SfxEnumItemInterface::SetBoolValue(bool)
     112           0 : {}
     113             : 
     114           0 : SfxEnumItem::SfxEnumItem(sal_uInt16 const nWhich, SvStream & rStream)
     115           0 :     : SfxEnumItemInterface(nWhich)
     116             : {
     117           0 :     m_nValue = 0;
     118           0 :     rStream.ReadUInt16( m_nValue );
     119           0 : }
     120             : 
     121     3698418 : TYPEINIT1(SfxEnumItem, SfxEnumItemInterface)
     122             : 
     123             : // virtual
     124        5248 : SvStream & SfxEnumItem::Store(SvStream & rStream, sal_uInt16) const
     125             : {
     126        5248 :     rStream.WriteUInt16( m_nValue );
     127        5248 :     return rStream;
     128             : }
     129             : 
     130             : // virtual
     131     4388199 : sal_uInt16 SfxEnumItem::GetEnumValue() const
     132             : {
     133     4388199 :     return GetValue();
     134             : }
     135             : 
     136             : // virtual
     137       10986 : void SfxEnumItem::SetEnumValue(sal_uInt16 const nTheValue)
     138             : {
     139       10986 :     SetValue(nTheValue);
     140       10986 : }
     141             : 
     142      547476 : void SfxEnumItem::SetValue(sal_uInt16 const nTheValue)
     143             : {
     144             :     DBG_ASSERT(GetRefCount() == 0, "SfxEnumItem::SetValue(): Pooled item");
     145      547476 :     m_nValue = nTheValue;
     146      547476 : }
     147             : 
     148     5144007 : TYPEINIT1_AUTOFACTORY(SfxBoolItem, SfxPoolItem);
     149             : 
     150         512 : SfxBoolItem::SfxBoolItem(sal_uInt16 const nWhich, SvStream & rStream)
     151         512 :     : SfxPoolItem(nWhich)
     152             : {
     153         512 :     bool tmp = false;
     154         512 :     rStream.ReadCharAsBool( tmp );
     155         512 :     m_bValue = tmp;
     156         512 : }
     157             : 
     158             : // virtual
     159      689833 : bool SfxBoolItem::operator ==(const SfxPoolItem & rItem) const
     160             : {
     161             :     DBG_ASSERT(rItem.ISA(SfxBoolItem),
     162             :                "SfxBoolItem::operator ==(): Bad type");
     163      689833 :     return m_bValue == static_cast< SfxBoolItem const * >(&rItem)->m_bValue;
     164             : }
     165             : 
     166             : // virtual
     167           0 : int SfxBoolItem::Compare(const SfxPoolItem & rWith) const
     168             : {
     169             :     DBG_ASSERT(rWith.ISA(SfxBoolItem), "SfxBoolItem::Compare(): Bad type");
     170           0 :     return (m_bValue == static_cast<SfxBoolItem const*>(&rWith)->m_bValue) ?
     171           0 :                0 : m_bValue ? -1 : 1;
     172             : }
     173             : 
     174             : // virtual
     175           0 : bool SfxBoolItem::GetPresentation(SfxItemPresentation,
     176             :                                                  SfxMapUnit, SfxMapUnit,
     177             :                                                  OUString & rText,
     178             :                                                  const IntlWrapper *) const
     179             : {
     180           0 :     rText = GetValueTextByVal(m_bValue);
     181           0 :     return true;
     182             : }
     183             : 
     184             : // virtual
     185       67730 : bool SfxBoolItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     186             : {
     187       67730 :     rVal <<= m_bValue;
     188       67730 :     return true;
     189             : }
     190             : 
     191             : // virtual
     192      161657 : bool SfxBoolItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
     193             : {
     194      161657 :     bool bTheValue = bool();
     195      161657 :     if (rVal >>= bTheValue)
     196             :     {
     197      161653 :         m_bValue = bTheValue;
     198      161653 :         return true;
     199             :     }
     200             :     OSL_FAIL("SfxBoolItem::PutValue(): Wrong type");
     201           4 :     return false;
     202             : }
     203             : 
     204             : // virtual
     205         512 : SfxPoolItem * SfxBoolItem::Create(SvStream & rStream, sal_uInt16) const
     206             : {
     207         512 :     return new SfxBoolItem(Which(), rStream);
     208             : }
     209             : 
     210             : // virtual
     211        3232 : SvStream & SfxBoolItem::Store(SvStream & rStream, sal_uInt16) const
     212             : {
     213        3232 :     rStream.WriteUChar( m_bValue ); // not bool for serialization!
     214        3232 :     return rStream;
     215             : }
     216             : 
     217             : // virtual
     218     1347529 : SfxPoolItem * SfxBoolItem::Clone(SfxItemPool *) const
     219             : {
     220     1347529 :     return new SfxBoolItem(*this);
     221             : }
     222             : 
     223             : // virtual
     224           0 : sal_uInt16 SfxBoolItem::GetValueCount() const
     225             : {
     226           0 :     return 2;
     227             : }
     228             : 
     229             : // virtual
     230           0 : OUString SfxBoolItem::GetValueTextByVal(bool bTheValue) const
     231             : {
     232           0 :     return bTheValue ?  OUString("TRUE") : OUString("FALSE");
     233             : }
     234             : 
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10