LCOV - code coverage report
Current view: top level - svl/source/items - rngitem.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 81 0.0 %
Date: 2014-11-03 Functions: 0 29 0.0 %
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 <tools/stream.hxx>
      21             : #include <svl/rngitem.hxx>
      22             : 
      23           0 : static inline sal_uInt16 Count_Impl(const sal_uInt16 * pRanges)
      24             : {
      25           0 :     sal_uInt16 nCount = 0;
      26           0 :     for (; *pRanges; pRanges += 2) nCount += 2;
      27           0 :     return nCount;
      28             : }
      29             : 
      30             : 
      31             : 
      32           0 : TYPEINIT1_AUTOFACTORY(SfxRangeItem, SfxPoolItem);
      33           0 : TYPEINIT1_AUTOFACTORY(SfxUShortRangesItem, SfxPoolItem);
      34             : 
      35           0 : SfxRangeItem::SfxRangeItem()
      36             : {
      37           0 :     nFrom = 0;
      38           0 :     nTo = 0;
      39           0 : }
      40             : 
      41             : 
      42             : 
      43           0 : SfxRangeItem::SfxRangeItem( sal_uInt16 which, sal_uInt16 from, sal_uInt16 to ):
      44             :     SfxPoolItem( which ),
      45             :     nFrom( from ),
      46           0 :     nTo( to )
      47             : {
      48           0 : }
      49             : 
      50             : 
      51             : 
      52           0 : SfxRangeItem::SfxRangeItem( const SfxRangeItem& rItem ) :
      53           0 :     SfxPoolItem( rItem )
      54             : {
      55           0 :     nFrom = rItem.nFrom;
      56           0 :     nTo = rItem.nTo;
      57           0 : }
      58             : 
      59             : 
      60             : 
      61           0 : bool SfxRangeItem::GetPresentation
      62             : (
      63             :     SfxItemPresentation     /*ePresentation*/,
      64             :     SfxMapUnit              /*eCoreMetric*/,
      65             :     SfxMapUnit              /*ePresentationMetric*/,
      66             :     OUString&               rText,
      67             :     const IntlWrapper *
      68             : )   const
      69             : {
      70           0 :     rText = OUString::number(nFrom) + ":" + OUString::number(nTo);
      71           0 :     return true;
      72             : }
      73             : 
      74             : 
      75             : 
      76           0 : bool SfxRangeItem::operator==( const SfxPoolItem& rItem ) const
      77             : {
      78             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      79           0 :     const SfxRangeItem& rT = static_cast<const SfxRangeItem&>(rItem);
      80           0 :     return nFrom==rT.nFrom && nTo==rT.nTo;
      81             : }
      82             : 
      83             : 
      84             : 
      85           0 : SfxPoolItem* SfxRangeItem::Clone(SfxItemPool *) const
      86             : {
      87           0 :     return new SfxRangeItem( Which(), nFrom, nTo );
      88             : }
      89             : 
      90             : 
      91             : 
      92           0 : SfxPoolItem* SfxRangeItem::Create(SvStream &rStream, sal_uInt16) const
      93             : {
      94           0 :     sal_uInt16 nVon(0), nBis(0);
      95           0 :     rStream.ReadUInt16( nVon );
      96           0 :     rStream.ReadUInt16( nBis );
      97           0 :     return new SfxRangeItem( Which(), nVon, nBis );
      98             : }
      99             : 
     100             : 
     101             : 
     102           0 : SvStream& SfxRangeItem::Store(SvStream &rStream, sal_uInt16) const
     103             : {
     104           0 :     rStream.WriteUInt16( nFrom );
     105           0 :     rStream.WriteUInt16( nTo );
     106           0 :     return rStream;
     107             : }
     108             : 
     109           0 : SfxUShortRangesItem::SfxUShortRangesItem()
     110           0 : :   _pRanges(0)
     111             : {
     112           0 : }
     113             : 
     114           0 : SfxUShortRangesItem::SfxUShortRangesItem( sal_uInt16 nWID, SvStream &rStream )
     115           0 : :   SfxPoolItem( nWID )
     116             : {
     117           0 :     sal_uInt16 nCount(0);
     118           0 :     rStream.ReadUInt16(nCount);
     119           0 :     const size_t nMaxEntries = rStream.remainingSize() / sizeof(sal_uInt16);
     120           0 :     if (nCount > nMaxEntries)
     121             :     {
     122           0 :         nCount = nMaxEntries;
     123             :         SAL_WARN("svl.items", "SfxUShortRangesItem: truncated Stream");
     124             :     }
     125           0 :     _pRanges = new sal_uInt16[nCount + 1];
     126           0 :     for ( sal_uInt16 n = 0; n < nCount; ++n )
     127           0 :         rStream.ReadUInt16( _pRanges[n] );
     128           0 :     _pRanges[nCount] = 0;
     129           0 : }
     130             : 
     131           0 : SfxUShortRangesItem::SfxUShortRangesItem( const SfxUShortRangesItem& rItem )
     132           0 : :   SfxPoolItem( rItem )
     133             : {
     134           0 :     sal_uInt16 nCount = Count_Impl(rItem._pRanges) + 1;
     135           0 :     _pRanges = new sal_uInt16[nCount];
     136           0 :     memcpy( _pRanges, rItem._pRanges, sizeof(sal_uInt16) * nCount );
     137           0 : }
     138             : 
     139           0 : SfxUShortRangesItem::~SfxUShortRangesItem()
     140             : {
     141           0 :     delete _pRanges;
     142           0 : }
     143             : 
     144             : 
     145           0 : bool SfxUShortRangesItem::operator==( const SfxPoolItem &rItem ) const
     146             : {
     147           0 :     const SfxUShortRangesItem &rOther = static_cast<const SfxUShortRangesItem&>(rItem);
     148           0 :     if ( !_pRanges && !rOther._pRanges )
     149           0 :         return true;
     150           0 :     if ( _pRanges || rOther._pRanges )
     151           0 :         return false;
     152             : 
     153             :     sal_uInt16 n;
     154           0 :     for ( n = 0; _pRanges[n] && rOther._pRanges[n]; ++n )
     155           0 :         if ( *_pRanges != rOther._pRanges[n] )
     156           0 :             return false;
     157             : 
     158           0 :     return !_pRanges[n] && !rOther._pRanges[n];
     159             : }
     160             : 
     161             : 
     162           0 : bool SfxUShortRangesItem::GetPresentation( SfxItemPresentation /*ePres*/,
     163             :                                     SfxMapUnit /*eCoreMetric*/,
     164             :                                     SfxMapUnit /*ePresMetric*/,
     165             :                                     OUString & /*rText*/,
     166             :                                     const IntlWrapper * ) const
     167             : {
     168             :     // not implemented
     169           0 :     return false;
     170             : }
     171             : 
     172             : 
     173           0 : SfxPoolItem* SfxUShortRangesItem::Clone( SfxItemPool * ) const
     174             : {
     175           0 :     return new SfxUShortRangesItem( *this );
     176             : }
     177             : 
     178             : 
     179           0 : SfxPoolItem* SfxUShortRangesItem::Create( SvStream &rStream, sal_uInt16 ) const
     180             : {
     181           0 :     return new SfxUShortRangesItem( Which(), rStream );
     182             : }
     183             : 
     184             : 
     185           0 : SvStream& SfxUShortRangesItem::Store( SvStream &rStream, sal_uInt16 ) const
     186             : {
     187           0 :     sal_uInt16 nCount = Count_Impl( _pRanges );
     188           0 :     rStream.ReadUInt16( nCount );
     189           0 :     for ( sal_uInt16 n = 0; _pRanges[n]; ++n )
     190           0 :         rStream.ReadUInt16( _pRanges[n] );
     191           0 :     return rStream;
     192             : }
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10