LCOV - code coverage report
Current view: top level - svl/source/items - intitem.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 66 39.4 %
Date: 2015-06-13 12:38:46 Functions: 30 46 65.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 <osl/diagnose.h>
      24             : #include <tools/bigint.hxx>
      25             : #include <tools/stream.hxx>
      26             : #include <svl/metitem.hxx>
      27             : #include <libxml/xmlwriter.h>
      28             : 
      29             : 
      30             : //  class SfxByteItem
      31             : 
      32             : 
      33       29859 : TYPEINIT1_AUTOFACTORY(SfxByteItem, CntByteItem);
      34             : 
      35             : // virtual
      36           0 : SfxPoolItem * SfxByteItem::Create(SvStream & rStream, sal_uInt16) const
      37             : {
      38           0 :     short nValue = 0;
      39           0 :     rStream.ReadInt16( nValue );
      40           0 :     return new SfxByteItem(Which(), sal_uInt8(nValue));
      41             : }
      42             : 
      43     1538720 : TYPEINIT1_AUTOFACTORY(SfxInt16Item, SfxPoolItem);
      44             : 
      45           0 : SfxInt16Item::SfxInt16Item(sal_uInt16 which, SvStream & rStream):
      46           0 :     SfxPoolItem(which)
      47             : {
      48           0 :     short nTheValue = 0;
      49           0 :     rStream.ReadInt16( nTheValue );
      50           0 :     m_nValue = nTheValue;
      51           0 : }
      52             : 
      53             : // virtual
      54      849695 : bool SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
      55             : {
      56             :     DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
      57      849695 :     return m_nValue == (static_cast< const SfxInt16Item * >(&rItem))->
      58      849695 :                         m_nValue;
      59             : }
      60             : 
      61             : // virtual
      62           0 : int SfxInt16Item::Compare(const SfxPoolItem & rWith) const
      63             : {
      64             :     DBG_ASSERT(SfxPoolItem::operator ==(rWith), "unequal type");
      65             :     return (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
      66           0 :              < m_nValue ?
      67             :             -1 :
      68             :            (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
      69             :              == m_nValue ?
      70           0 :             0 : 1;
      71             : }
      72             : 
      73             : // virtual
      74           0 : bool SfxInt16Item::GetPresentation(SfxItemPresentation,
      75             :                                                   SfxMapUnit, SfxMapUnit,
      76             :                                                   OUString & rText,
      77             :                                                   const IntlWrapper *) const
      78             : {
      79           0 :     rText = OUString::number(m_nValue);
      80           0 :     return true;
      81             : }
      82             : 
      83             : 
      84             : // virtual
      85        1838 : bool SfxInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
      86             : {
      87        1838 :     sal_Int16 nValue = m_nValue;
      88        1838 :     rVal <<= nValue;
      89        1838 :     return true;
      90             : }
      91             : 
      92             : // virtual
      93        1303 : bool SfxInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 )
      94             : {
      95        1303 :     sal_Int16 nValue = sal_Int16();
      96        1303 :     if (rVal >>= nValue)
      97             :     {
      98        1303 :         m_nValue = nValue;
      99        1303 :         return true;
     100             :     }
     101             : 
     102             :     OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
     103           0 :     return false;
     104             : }
     105             : 
     106             : // virtual
     107           0 : SfxPoolItem * SfxInt16Item::Create(SvStream & rStream, sal_uInt16) const
     108             : {
     109           0 :     return new SfxInt16Item(Which(), rStream);
     110             : }
     111             : 
     112             : // virtual
     113           0 : SvStream & SfxInt16Item::Store(SvStream & rStream, sal_uInt16) const
     114             : {
     115           0 :     rStream.WriteInt16( short(m_nValue) );
     116           0 :     return rStream;
     117             : }
     118             : 
     119       13844 : SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
     120             : {
     121       13844 :     return new SfxInt16Item(*this);
     122             : }
     123             : 
     124             : //  class SfxUInt16Item
     125      918926 : TYPEINIT1_AUTOFACTORY(SfxUInt16Item, CntUInt16Item);
     126             : 
     127           0 : void SfxUInt16Item::dumpAsXml(xmlTextWriterPtr pWriter) const
     128             : {
     129           0 :     xmlTextWriterStartElement(pWriter, BAD_CAST("sfxUInt16Item"));
     130           0 :     xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
     131           0 :     xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
     132           0 :     xmlTextWriterEndElement(pWriter);
     133           0 : }
     134             : 
     135             : 
     136             : //  class SfxInt32Item
     137             : 
     138             : 
     139      686898 : TYPEINIT1_AUTOFACTORY(SfxInt32Item, CntInt32Item);
     140             : 
     141             : 
     142             : 
     143             : //  class SfxUInt32Item
     144             : 
     145             : 
     146      174672 : TYPEINIT1_AUTOFACTORY(SfxUInt32Item, CntUInt32Item);
     147             : 
     148       84294 : TYPEINIT1_AUTOFACTORY(SfxMetricItem, SfxInt32Item);
     149             : 
     150       46947 : SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_uInt32 nValue):
     151       46947 :     SfxInt32Item(which, nValue)
     152             : {
     153       46947 : }
     154             : 
     155           0 : SfxMetricItem::SfxMetricItem(sal_uInt16 which, SvStream & rStream):
     156           0 :     SfxInt32Item(which, rStream)
     157             : {
     158           0 : }
     159             : 
     160       79451 : SfxMetricItem::SfxMetricItem(const SfxMetricItem & rItem):
     161       79451 :     SfxInt32Item(rItem)
     162             : {
     163       79451 : }
     164             : 
     165             : // virtual
     166           0 : bool SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
     167             : {
     168           0 :     BigInt aTheValue(GetValue());
     169           0 :     aTheValue *= nMult;
     170           0 :     aTheValue += nDiv / 2;
     171           0 :     aTheValue /= nDiv;
     172           0 :     SetValue(aTheValue);
     173           0 :     return true;
     174             : }
     175             : 
     176             : // virtual
     177           0 : bool SfxMetricItem::HasMetrics() const
     178             : {
     179           0 :     return true;
     180             : }
     181             : 
     182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11