LCOV - code coverage report
Current view: top level - svl/source/items - cintitem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 59 149 39.6 %
Date: 2014-04-11 Functions: 22 67 32.8 %
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/cintitem.hxx>
      23             : 
      24       16698 : TYPEINIT1_AUTOFACTORY(CntByteItem, SfxPoolItem);
      25             : 
      26             : // virtual
      27       28148 : bool CntByteItem::operator ==(const SfxPoolItem & rItem) const
      28             : {
      29             :     DBG_ASSERT(rItem.ISA(CntByteItem),
      30             :                "CntByteItem::operator ==(): Bad type");
      31       28148 :     return m_nValue == (static_cast< const CntByteItem * >(&rItem))->m_nValue;
      32             : }
      33             : 
      34             : // virtual
      35           0 : int CntByteItem::Compare(const SfxPoolItem & rWith) const
      36             : {
      37             :     DBG_ASSERT(rWith.ISA(CntByteItem), "CntByteItem::Compare(): Bad type");
      38           0 :     return (static_cast< const CntByteItem * >(&rWith))->m_nValue < m_nValue ?
      39             :             -1 :
      40             :            (static_cast< const CntByteItem * >(&rWith))->m_nValue
      41             :              == m_nValue ?
      42           0 :             0 : 1;
      43             : }
      44             : 
      45             : // virtual
      46           0 : SfxItemPresentation CntByteItem::GetPresentation(SfxItemPresentation,
      47             :                                                  SfxMapUnit, SfxMapUnit,
      48             :                                                  OUString & rText,
      49             :                                                  const IntlWrapper *) const
      50             : {
      51           0 :     rText = OUString::number( m_nValue );
      52           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      53             : }
      54             : 
      55             : // virtual
      56          53 : bool CntByteItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
      57             : {
      58          53 :     sal_Int8 nValue = m_nValue;
      59          53 :     rVal <<= nValue;
      60          53 :     return true;
      61             : }
      62             : 
      63             : // virtual
      64        7820 : bool CntByteItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
      65             : {
      66        7820 :     sal_Int8 nValue = sal_Int8();
      67        7820 :     if (rVal >>= nValue)
      68             :     {
      69        7820 :         m_nValue = nValue;
      70        7820 :         return true;
      71             :     }
      72             : 
      73             :     OSL_FAIL( "CntByteItem::PutValue - Wrong type!" );
      74           0 :     return false;
      75             : }
      76             : 
      77             : // virtual
      78           0 : SfxPoolItem * CntByteItem::Create(SvStream & rStream, sal_uInt16) const
      79             : {
      80           0 :     short nTheValue = 0;
      81           0 :     rStream.ReadInt16( nTheValue );
      82           0 :     return new CntByteItem(Which(), sal_uInt8(nTheValue));
      83             : }
      84             : 
      85             : // virtual
      86           0 : SvStream & CntByteItem::Store(SvStream & rStream, sal_uInt16) const
      87             : {
      88           0 :     rStream.WriteInt16( short(m_nValue) );
      89           0 :     return rStream;
      90             : }
      91             : 
      92             : // virtual
      93           0 : SfxPoolItem * CntByteItem::Clone(SfxItemPool *) const
      94             : {
      95           0 :     return new CntByteItem(*this);
      96             : }
      97             : 
      98             : // virtual
      99           0 : sal_uInt8 CntByteItem::GetMin() const
     100             : {
     101           0 :     return 0;
     102             : }
     103             : 
     104             : // virtual
     105           0 : sal_uInt8 CntByteItem::GetMax() const
     106             : {
     107           0 :     return 255;
     108             : }
     109             : 
     110             : // virtual
     111           0 : SfxFieldUnit CntByteItem::GetUnit() const
     112             : {
     113           0 :     return SFX_FUNIT_NONE;
     114             : }
     115             : 
     116      401914 : TYPEINIT1_AUTOFACTORY(CntUInt16Item, SfxPoolItem);
     117             : 
     118           0 : CntUInt16Item::CntUInt16Item(sal_uInt16 which, SvStream & rStream) :
     119           0 :     SfxPoolItem(which)
     120             : {
     121           0 :     sal_uInt16 nTheValue = 0;
     122           0 :     rStream.ReadUInt16( nTheValue );
     123           0 :     m_nValue = nTheValue;
     124           0 : }
     125             : 
     126             : // virtual
     127      208612 : bool CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
     128             : {
     129             :     DBG_ASSERT(rItem.ISA(CntUInt16Item),
     130             :                "CntUInt16Item::operator ==(): Bad type");
     131      208612 :     return m_nValue == (static_cast< const CntUInt16Item * >(&rItem))->
     132      208612 :                         m_nValue;
     133             : }
     134             : 
     135             : // virtual
     136           0 : int CntUInt16Item::Compare(const SfxPoolItem & rWith) const
     137             : {
     138             :     DBG_ASSERT(rWith.ISA(CntUInt16Item),
     139             :                "CntUInt16Item::Compare(): Bad type");
     140             :     return (static_cast< const CntUInt16Item * >(&rWith))->m_nValue
     141           0 :              < m_nValue ?
     142             :             -1 :
     143             :            (static_cast< const CntUInt16Item * >(&rWith))->m_nValue
     144             :              == m_nValue ?
     145           0 :             0 : 1;
     146             : }
     147             : 
     148             : // virtual
     149           0 : SfxItemPresentation CntUInt16Item::GetPresentation(SfxItemPresentation,
     150             :                                                    SfxMapUnit, SfxMapUnit,
     151             :                                                    OUString & rText,
     152             :                                                    const IntlWrapper *)
     153             :     const
     154             : {
     155           0 :     rText = OUString::number( m_nValue );
     156           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
     157             : }
     158             : 
     159             : // virtual
     160        6008 : bool CntUInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     161             : {
     162        6008 :     sal_Int32 nValue = m_nValue;
     163        6008 :     rVal <<= nValue;
     164        6008 :     return true;
     165             : }
     166             : 
     167             : // virtual
     168       76025 : bool CntUInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
     169             : {
     170       76025 :     sal_Int32 nValue = 0;
     171       76025 :     if (rVal >>= nValue)
     172             :     {
     173             :         DBG_ASSERT( nValue <= USHRT_MAX, "Overflow in UInt16 value!");
     174       76025 :         m_nValue = (sal_uInt16)nValue;
     175       76025 :         return true;
     176             :     }
     177             : 
     178             :     OSL_FAIL( "CntUInt16Item::PutValue - Wrong type!" );
     179           0 :     return false;
     180             : }
     181             : 
     182             : // virtual
     183           0 : SfxPoolItem * CntUInt16Item::Create(SvStream & rStream, sal_uInt16) const
     184             : {
     185           0 :     return new CntUInt16Item(Which(), rStream);
     186             : }
     187             : 
     188             : // virtual
     189           0 : SvStream & CntUInt16Item::Store(SvStream &rStream, sal_uInt16) const
     190             : {
     191           0 :     rStream.WriteUInt16( sal_uInt16(m_nValue) );
     192           0 :     return rStream;
     193             : }
     194             : 
     195             : // virtual
     196           0 : SfxPoolItem * CntUInt16Item::Clone(SfxItemPool *) const
     197             : {
     198           0 :     return new CntUInt16Item(*this);
     199             : }
     200             : 
     201             : // virtual
     202           0 : sal_uInt16 CntUInt16Item::GetMin() const
     203             : {
     204           0 :     return 0;
     205             : }
     206             : 
     207             : // virtual
     208           0 : sal_uInt16 CntUInt16Item::GetMax() const
     209             : {
     210           0 :     return 65535;
     211             : }
     212             : 
     213             : // virtual
     214           0 : SfxFieldUnit CntUInt16Item::GetUnit() const
     215             : {
     216           0 :     return SFX_FUNIT_NONE;
     217             : }
     218             : 
     219      364008 : TYPEINIT1_AUTOFACTORY(CntInt32Item, SfxPoolItem);
     220             : 
     221         256 : CntInt32Item::CntInt32Item(sal_uInt16 which, SvStream & rStream)
     222             :     : SfxPoolItem(which)
     223         256 :     , m_nValue(0)
     224             : {
     225             :     //fdo#39428 SvStream no longer supports operator>>(long&)
     226         256 :     rStream.ReadInt32( m_nValue );
     227         256 : }
     228             : 
     229             : // virtual
     230      430344 : bool CntInt32Item::operator ==(const SfxPoolItem & rItem) const
     231             : {
     232             :     DBG_ASSERT(rItem.ISA(CntInt32Item),
     233             :                "CntInt32Item::operator ==(): Bad type");
     234      430344 :     return m_nValue == (static_cast< const CntInt32Item * >(&rItem))->
     235      430344 :                         m_nValue;
     236             : }
     237             : 
     238             : // virtual
     239           0 : int CntInt32Item::Compare(const SfxPoolItem & rWith) const
     240             : {
     241             :     DBG_ASSERT(rWith.ISA(CntInt32Item), "CntInt32Item::Compare(): Bad type");
     242             :     return (static_cast< const CntInt32Item * >(&rWith))->m_nValue
     243           0 :              < m_nValue ?
     244             :             -1 :
     245             :            (static_cast< const CntInt32Item * >(&rWith))->m_nValue
     246             :              == m_nValue ?
     247           0 :             0 : 1;
     248             : }
     249             : 
     250             : // virtual
     251           0 : SfxItemPresentation CntInt32Item::GetPresentation(SfxItemPresentation,
     252             :                                                   SfxMapUnit, SfxMapUnit,
     253             :                                                   OUString & rText,
     254             :                                                   const IntlWrapper *) const
     255             : {
     256           0 :     rText = OUString::number( m_nValue );
     257           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
     258             : }
     259             : 
     260             : // virtual
     261        5130 : bool CntInt32Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     262             : {
     263        5130 :     sal_Int32 nValue = m_nValue;
     264        5130 :     rVal <<= nValue;
     265        5130 :     return true;
     266             : }
     267             : 
     268             : // virtual
     269       41540 : bool CntInt32Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
     270             : {
     271       41540 :     sal_Int32 nValue = 0;
     272       41540 :     if (rVal >>= nValue)
     273             :     {
     274       41489 :         m_nValue = nValue;
     275       41489 :         return true;
     276             :     }
     277             : 
     278             :     OSL_FAIL( "CntInt32Item::PutValue - Wrong type!" );
     279          51 :     return false;
     280             : }
     281             : 
     282             : // virtual
     283           0 : SfxPoolItem * CntInt32Item::Create(SvStream & rStream, sal_uInt16) const
     284             : {
     285           0 :     return new CntInt32Item(Which(), rStream);
     286             : }
     287             : 
     288             : // virtual
     289         528 : SvStream & CntInt32Item::Store(SvStream &rStream, sal_uInt16) const
     290             : {
     291             :     //fdo#39428 SvStream no longer supports operator<<(long)
     292         528 :     rStream.WriteInt32( m_nValue );
     293         528 :     return rStream;
     294             : }
     295             : 
     296             : // virtual
     297           0 : SfxPoolItem * CntInt32Item::Clone(SfxItemPool *) const
     298             : {
     299           0 :     return new CntInt32Item(*this);
     300             : }
     301             : 
     302             : // virtual
     303           0 : sal_Int32 CntInt32Item::GetMin() const
     304             : {
     305           0 :     return sal_Int32(0x80000000);
     306             : }
     307             : 
     308             : // virtual
     309           0 : sal_Int32 CntInt32Item::GetMax() const
     310             : {
     311           0 :     return 0x7FFFFFFF;
     312             : }
     313             : 
     314             : // virtual
     315           0 : SfxFieldUnit CntInt32Item::GetUnit() const
     316             : {
     317           0 :     return SFX_FUNIT_NONE;
     318             : }
     319             : 
     320       51682 : TYPEINIT1_AUTOFACTORY(CntUInt32Item, SfxPoolItem);
     321             : 
     322           0 : CntUInt32Item::CntUInt32Item(sal_uInt16 which, SvStream & rStream) :
     323           0 :     SfxPoolItem(which)
     324             : {
     325           0 :     sal_uInt32 nTheValue = 0;
     326           0 :     rStream.ReadUInt32( nTheValue );
     327           0 :     m_nValue = nTheValue;
     328           0 : }
     329             : 
     330             : // virtual
     331       18050 : bool CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
     332             : {
     333             :     DBG_ASSERT(rItem.ISA(CntUInt32Item),
     334             :                "CntUInt32Item::operator ==(): Bad type");
     335       18050 :     return m_nValue == (static_cast< const CntUInt32Item * >(&rItem))->
     336       18050 :                         m_nValue;
     337             : }
     338             : 
     339             : // virtual
     340           0 : int CntUInt32Item::Compare(const SfxPoolItem & rWith) const
     341             : {
     342             :     DBG_ASSERT(rWith.ISA(CntUInt32Item),
     343             :                "CntUInt32Item::operator ==(): Bad type");
     344             :     return (static_cast< const CntUInt32Item * >(&rWith))->m_nValue
     345           0 :              < m_nValue ?
     346             :             -1 :
     347             :            (static_cast< const CntUInt32Item * >(&rWith))->m_nValue
     348             :              == m_nValue ?
     349           0 :             0 : 1;
     350             : }
     351             : 
     352             : // virtual
     353           0 : SfxItemPresentation CntUInt32Item::GetPresentation(SfxItemPresentation,
     354             :                                                    SfxMapUnit, SfxMapUnit,
     355             :                                                    OUString & rText,
     356             :                                                    const IntlWrapper *)
     357             :     const
     358             : {
     359           0 :     rText = OUString::number(m_nValue);
     360           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
     361             : }
     362             : 
     363             : // virtual
     364          16 : bool CntUInt32Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
     365             : {
     366          16 :     sal_Int32 nValue = m_nValue;
     367             :     DBG_ASSERT( nValue>=0, "Overflow in UInt32 value!");
     368          16 :     rVal <<= nValue;
     369          16 :     return true;
     370             : }
     371             : 
     372             : // virtual
     373        1041 : bool CntUInt32Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
     374             : {
     375        1041 :     sal_Int32 nValue = 0;
     376        1041 :     if (rVal >>= nValue)
     377             :     {
     378             :         DBG_ASSERT( nValue>=0, "Overflow in UInt32 value!");
     379        1041 :         m_nValue = nValue;
     380        1041 :         return true;
     381             :     }
     382             : 
     383             :     OSL_FAIL( "CntUInt32Item::PutValue - Wrong type!" );
     384           0 :     return false;
     385             : }
     386             : 
     387             : // virtual
     388           0 : SfxPoolItem * CntUInt32Item::Create(SvStream & rStream, sal_uInt16) const
     389             : {
     390           0 :     return new CntUInt32Item(Which(), rStream);
     391             : }
     392             : 
     393             : // virtual
     394           0 : SvStream & CntUInt32Item::Store(SvStream &rStream, sal_uInt16) const
     395             : {
     396           0 :     rStream.WriteUInt32( static_cast<sal_uInt32>(m_nValue) );
     397           0 :     return rStream;
     398             : }
     399             : 
     400             : // virtual
     401           0 : SfxPoolItem * CntUInt32Item::Clone(SfxItemPool *) const
     402             : {
     403           0 :     return new CntUInt32Item(*this);
     404             : }
     405             : 
     406             : // virtual
     407           0 : sal_uInt32 CntUInt32Item::GetMin() const
     408             : {
     409           0 :     return 0;
     410             : }
     411             : 
     412             : // virtual
     413           0 : sal_uInt32 CntUInt32Item::GetMax() const
     414             : {
     415           0 :     return 0xFFFFFFFF;
     416             : }
     417             : 
     418             : // virtual
     419           0 : SfxFieldUnit CntUInt32Item::GetUnit() const
     420             : {
     421           0 :     return SFX_FUNIT_NONE;
     422             : }
     423             : 
     424             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10