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

Generated by: LCOV version 1.10