LCOV - code coverage report
Current view: top level - svl/source/items - intitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 3 66 4.5 %
Date: 2014-04-14 Functions: 3 48 6.2 %
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             : //  class SfxByteItem
      29             : 
      30             : 
      31           0 : TYPEINIT1_AUTOFACTORY(SfxByteItem, CntByteItem);
      32             : 
      33             : // virtual
      34           0 : SfxPoolItem * SfxByteItem::Create(SvStream & rStream, sal_uInt16) const
      35             : {
      36           0 :     short nValue = 0;
      37           0 :     rStream.ReadInt16( nValue );
      38           0 :     return new SfxByteItem(Which(), sal_uInt8(nValue));
      39             : }
      40             : 
      41           1 : TYPEINIT1_AUTOFACTORY(SfxInt16Item, SfxPoolItem);
      42             : 
      43           0 : SfxInt16Item::SfxInt16Item(sal_uInt16 which, SvStream & rStream):
      44           0 :     SfxPoolItem(which)
      45             : {
      46           0 :     short nTheValue = 0;
      47           0 :     rStream.ReadInt16( nTheValue );
      48           0 :     m_nValue = nTheValue;
      49           0 : }
      50             : 
      51             : // virtual
      52           0 : bool SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
      53             : {
      54             :     DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
      55           0 :     return m_nValue == (static_cast< const SfxInt16Item * >(&rItem))->
      56           0 :                         m_nValue;
      57             : }
      58             : 
      59             : // virtual
      60           0 : int SfxInt16Item::Compare(const SfxPoolItem & rWith) const
      61             : {
      62             :     DBG_ASSERT(SfxPoolItem::operator ==(rWith), "unequal type");
      63             :     return (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
      64           0 :              < m_nValue ?
      65             :             -1 :
      66             :            (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
      67             :              == m_nValue ?
      68           0 :             0 : 1;
      69             : }
      70             : 
      71             : // virtual
      72           0 : SfxItemPresentation SfxInt16Item::GetPresentation(SfxItemPresentation,
      73             :                                                   SfxMapUnit, SfxMapUnit,
      74             :                                                   OUString & rText,
      75             :                                                   const IntlWrapper *) const
      76             : {
      77           0 :     rText = OUString::number(m_nValue);
      78           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      79             : }
      80             : 
      81             : 
      82             : // virtual
      83           0 : bool SfxInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
      84             : {
      85           0 :     sal_Int16 nValue = m_nValue;
      86           0 :     rVal <<= nValue;
      87           0 :     return true;
      88             : }
      89             : 
      90             : // virtual
      91           0 : bool SfxInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 )
      92             : {
      93           0 :     sal_Int16 nValue = sal_Int16();
      94           0 :     if (rVal >>= nValue)
      95             :     {
      96           0 :         m_nValue = nValue;
      97           0 :         return true;
      98             :     }
      99             : 
     100             :     OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
     101           0 :     return false;
     102             : }
     103             : 
     104             : // virtual
     105           0 : SfxPoolItem * SfxInt16Item::Create(SvStream & rStream, sal_uInt16) const
     106             : {
     107           0 :     return new SfxInt16Item(Which(), rStream);
     108             : }
     109             : 
     110             : // virtual
     111           0 : SvStream & SfxInt16Item::Store(SvStream & rStream, sal_uInt16) const
     112             : {
     113           0 :     rStream.WriteInt16( short(m_nValue) );
     114           0 :     return rStream;
     115             : }
     116             : 
     117           0 : SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
     118             : {
     119           0 :     return new SfxInt16Item(*this);
     120             : }
     121             : 
     122           0 : sal_Int16 SfxInt16Item::GetMin() const
     123             : {
     124           0 :     return -32768;
     125             : }
     126             : 
     127           0 : sal_Int16 SfxInt16Item::GetMax() const
     128             : {
     129           0 :     return 32767;
     130             : }
     131             : 
     132           0 : SfxFieldUnit SfxInt16Item::GetUnit() const
     133             : {
     134           0 :     return SFX_FUNIT_NONE;
     135             : }
     136             : 
     137             : 
     138             : //  class SfxUInt16Item
     139             : 
     140             : 
     141           1 : TYPEINIT1_AUTOFACTORY(SfxUInt16Item, CntUInt16Item);
     142             : 
     143             : 
     144             : 
     145             : //  class SfxInt32Item
     146             : 
     147             : 
     148           0 : TYPEINIT1_AUTOFACTORY(SfxInt32Item, CntInt32Item);
     149             : 
     150             : 
     151             : 
     152             : //  class SfxUInt32Item
     153             : 
     154             : 
     155           1 : TYPEINIT1_AUTOFACTORY(SfxUInt32Item, CntUInt32Item);
     156             : 
     157           0 : TYPEINIT1_AUTOFACTORY(SfxMetricItem, SfxInt32Item);
     158             : 
     159           0 : SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_uInt32 nValue):
     160           0 :     SfxInt32Item(which, nValue)
     161             : {
     162           0 : }
     163             : 
     164           0 : SfxMetricItem::SfxMetricItem(sal_uInt16 which, SvStream & rStream):
     165           0 :     SfxInt32Item(which, rStream)
     166             : {
     167           0 : }
     168             : 
     169           0 : SfxMetricItem::SfxMetricItem(const SfxMetricItem & rItem):
     170           0 :     SfxInt32Item(rItem)
     171             : {
     172           0 : }
     173             : 
     174             : // virtual
     175           0 : bool SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
     176             : {
     177           0 :     BigInt aTheValue(GetValue());
     178           0 :     aTheValue *= nMult;
     179           0 :     aTheValue += nDiv / 2;
     180           0 :     aTheValue /= nDiv;
     181           0 :     SetValue(aTheValue);
     182           0 :     return true;
     183             : }
     184             : 
     185             : // virtual
     186           0 : bool SfxMetricItem::HasMetrics() const
     187             : {
     188           0 :     return true;
     189             : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10