LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svl/source/items - intitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 66 39.4 %
Date: 2013-07-09 Functions: 30 48 62.5 %
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             : 
      21             : #include <svl/intitem.hxx>
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : #include <tools/bigint.hxx>
      24             : #include <tools/stream.hxx>
      25             : #include <svl/metitem.hxx>
      26             : 
      27             : //============================================================================
      28             : //
      29             : //  class SfxByteItem
      30             : //
      31             : //============================================================================
      32             : 
      33        9387 : TYPEINIT1_AUTOFACTORY(SfxByteItem, CntByteItem);
      34             : 
      35             : //============================================================================
      36             : // virtual
      37           0 : SfxPoolItem * SfxByteItem::Create(SvStream & rStream, sal_uInt16) const
      38             : {
      39           0 :     short nValue = 0;
      40           0 :     rStream >> nValue;
      41           0 :     return new SfxByteItem(Which(), sal_uInt8(nValue));
      42             : }
      43             : 
      44             : //============================================================================
      45             : //
      46             : //  class SfxInt16Item
      47             : //
      48             : //============================================================================
      49             : 
      50             : DBG_NAME(SfxInt16Item);
      51             : 
      52             : //============================================================================
      53      826965 : TYPEINIT1_AUTOFACTORY(SfxInt16Item, SfxPoolItem);
      54             : 
      55             : //============================================================================
      56           0 : SfxInt16Item::SfxInt16Item(sal_uInt16 which, SvStream & rStream):
      57           0 :     SfxPoolItem(which)
      58             : {
      59             :     DBG_CTOR(SfxInt16Item, 0);
      60           0 :     short nTheValue = 0;
      61           0 :     rStream >> nTheValue;
      62           0 :     m_nValue = nTheValue;
      63           0 : }
      64             : 
      65             : //============================================================================
      66             : // virtual
      67      612642 : int SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
      68             : {
      69             :     DBG_CHKTHIS(SfxInt16Item, 0);
      70             :     DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
      71      612642 :     return m_nValue == (static_cast< const SfxInt16Item * >(&rItem))->
      72      612642 :                         m_nValue;
      73             : }
      74             : 
      75             : //============================================================================
      76             : // virtual
      77           0 : int SfxInt16Item::Compare(const SfxPoolItem & rWith) const
      78             : {
      79             :     DBG_CHKTHIS(SfxInt16Item, 0);
      80             :     DBG_ASSERT(SfxPoolItem::operator ==(rWith), "unequal type");
      81             :     return (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
      82           0 :              < m_nValue ?
      83             :             -1 :
      84             :            (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
      85             :              == m_nValue ?
      86           0 :             0 : 1;
      87             : }
      88             : 
      89             : //============================================================================
      90             : // virtual
      91           0 : SfxItemPresentation SfxInt16Item::GetPresentation(SfxItemPresentation,
      92             :                                                   SfxMapUnit, SfxMapUnit,
      93             :                                                   OUString & rText,
      94             :                                                   const IntlWrapper *) const
      95             : {
      96             :     DBG_CHKTHIS(SfxInt16Item, 0);
      97           0 :     rText = OUString::number(m_nValue);
      98           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      99             : }
     100             : 
     101             : 
     102             : //============================================================================
     103             : // virtual
     104         167 : bool SfxInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     105             : {
     106         167 :     sal_Int16 nValue = m_nValue;
     107         167 :     rVal <<= nValue;
     108         167 :     return true;
     109             : }
     110             : 
     111             : //============================================================================
     112             : // virtual
     113          89 : bool SfxInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 )
     114             : {
     115          89 :     sal_Int16 nValue = sal_Int16();
     116          89 :     if (rVal >>= nValue)
     117             :     {
     118          89 :         m_nValue = nValue;
     119          89 :         return true;
     120             :     }
     121             : 
     122             :     OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
     123           0 :     return false;
     124             : }
     125             : 
     126             : //============================================================================
     127             : // virtual
     128           0 : SfxPoolItem * SfxInt16Item::Create(SvStream & rStream, sal_uInt16) const
     129             : {
     130             :     DBG_CHKTHIS(SfxInt16Item, 0);
     131           0 :     return new SfxInt16Item(Which(), rStream);
     132             : }
     133             : 
     134             : //============================================================================
     135             : // virtual
     136           0 : SvStream & SfxInt16Item::Store(SvStream & rStream, sal_uInt16) const
     137             : {
     138             :     DBG_CHKTHIS(SfxInt16Item, 0);
     139           0 :     rStream << short(m_nValue);
     140           0 :     return rStream;
     141             : }
     142             : 
     143             : //============================================================================
     144        3650 : SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
     145             : {
     146             :     DBG_CHKTHIS(SfxInt16Item, 0);
     147        3650 :     return new SfxInt16Item(*this);
     148             : }
     149             : 
     150             : //============================================================================
     151           0 : sal_Int16 SfxInt16Item::GetMin() const
     152             : {
     153             :     DBG_CHKTHIS(SfxInt16Item, 0);
     154           0 :     return -32768;
     155             : }
     156             : 
     157             : //============================================================================
     158           0 : sal_Int16 SfxInt16Item::GetMax() const
     159             : {
     160             :     DBG_CHKTHIS(SfxInt16Item, 0);
     161           0 :     return 32767;
     162             : }
     163             : 
     164             : //============================================================================
     165           0 : SfxFieldUnit SfxInt16Item::GetUnit() const
     166             : {
     167             :     DBG_CHKTHIS(SfxInt16Item, 0);
     168           0 :     return SFX_FUNIT_NONE;
     169             : }
     170             : 
     171             : //============================================================================
     172             : //
     173             : //  class SfxUInt16Item
     174             : //
     175             : //============================================================================
     176             : 
     177      355063 : TYPEINIT1_AUTOFACTORY(SfxUInt16Item, CntUInt16Item);
     178             : 
     179             : 
     180             : //============================================================================
     181             : //
     182             : //  class SfxInt32Item
     183             : //
     184             : //============================================================================
     185             : 
     186      221229 : TYPEINIT1_AUTOFACTORY(SfxInt32Item, CntInt32Item);
     187             : 
     188             : 
     189             : //============================================================================
     190             : //
     191             : //  class SfxUInt32Item
     192             : //
     193             : //============================================================================
     194             : 
     195       65684 : TYPEINIT1_AUTOFACTORY(SfxUInt32Item, CntUInt32Item);
     196             : 
     197             : 
     198             : //============================================================================
     199             : //
     200             : //  class SfxMetricItem
     201             : //
     202             : //============================================================================
     203             : 
     204             : DBG_NAME(SfxMetricItem);
     205             : 
     206             : //============================================================================
     207       24344 : TYPEINIT1_AUTOFACTORY(SfxMetricItem, SfxInt32Item);
     208             : 
     209             : //============================================================================
     210       14396 : SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_uInt32 nValue):
     211       14396 :     SfxInt32Item(which, nValue)
     212             : {
     213             :     DBG_CTOR(SfxMetricItem, 0);
     214       14396 : }
     215             : 
     216             : //============================================================================
     217           0 : SfxMetricItem::SfxMetricItem(sal_uInt16 which, SvStream & rStream):
     218           0 :     SfxInt32Item(which, rStream)
     219             : {
     220             :     DBG_CTOR(SfxMetricItem, 0);
     221           0 : }
     222             : 
     223             : //============================================================================
     224       37520 : SfxMetricItem::SfxMetricItem(const SfxMetricItem & rItem):
     225       37520 :     SfxInt32Item(rItem)
     226             : {
     227             :     DBG_CTOR(SfxMetricItem, 0);
     228       37520 : }
     229             : 
     230             : //============================================================================
     231             : // virtual
     232           0 : bool SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
     233             : {
     234           0 :     BigInt aTheValue(GetValue());
     235           0 :     aTheValue *= nMult;
     236           0 :     aTheValue += nDiv / 2;
     237           0 :     aTheValue /= nDiv;
     238           0 :     SetValue(aTheValue);
     239           0 :     return true;
     240             : }
     241             : 
     242             : //============================================================================
     243             : // virtual
     244           0 : bool SfxMetricItem::HasMetrics() const
     245             : {
     246           0 :     return true;
     247             : }
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10