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

Generated by: LCOV version 1.11