LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svl/source/items - rngitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 80 0.0 %
Date: 2013-07-09 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 : int 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 1;
      86           0 :     return 0;
      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 >> nVon;
     102           0 :     rStream >> 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 << nFrom;
     111           0 :     rStream << nTo;
     112           0 :     return rStream;
     113             : }
     114             : 
     115             : //=========================================================================
     116             : 
     117           0 : SfxUShortRangesItem::SfxUShortRangesItem()
     118           0 : :   _pRanges(0)
     119             : {
     120           0 : }
     121             : 
     122             : //-------------------------------------------------------------------------
     123             : 
     124           0 : SfxUShortRangesItem::SfxUShortRangesItem( sal_uInt16 nWID, SvStream &rStream )
     125           0 : :   SfxPoolItem( nWID )
     126             : {
     127           0 :     sal_uInt16 nCount(0);
     128           0 :     rStream >> nCount;
     129           0 :     _pRanges = new sal_uInt16[nCount + 1];
     130           0 :     for ( sal_uInt16 n = 0; n < nCount; ++n )
     131           0 :         rStream >> _pRanges[n];
     132           0 :     _pRanges[nCount] = 0;
     133           0 : }
     134             : 
     135             : //-------------------------------------------------------------------------
     136             : 
     137           0 : SfxUShortRangesItem::SfxUShortRangesItem( const SfxUShortRangesItem& rItem )
     138           0 : :   SfxPoolItem( rItem )
     139             : {
     140           0 :     sal_uInt16 nCount = Count_Impl(rItem._pRanges) + 1;
     141           0 :     _pRanges = new sal_uInt16[nCount];
     142           0 :     memcpy( _pRanges, rItem._pRanges, sizeof(sal_uInt16) * nCount );
     143           0 : }
     144             : 
     145             : //-------------------------------------------------------------------------
     146             : 
     147           0 : SfxUShortRangesItem::~SfxUShortRangesItem()
     148             : {
     149           0 :     delete _pRanges;
     150           0 : }
     151             : 
     152             : //-------------------------------------------------------------------------
     153             : 
     154           0 : int SfxUShortRangesItem::operator==( const SfxPoolItem &rItem ) const
     155             : {
     156           0 :     const SfxUShortRangesItem &rOther = (const SfxUShortRangesItem&) rItem;
     157           0 :     if ( !_pRanges && !rOther._pRanges )
     158           0 :         return sal_True;
     159           0 :     if ( _pRanges || rOther._pRanges )
     160           0 :         return sal_False;
     161             : 
     162             :     sal_uInt16 n;
     163           0 :     for ( n = 0; _pRanges[n] && rOther._pRanges[n]; ++n )
     164           0 :         if ( *_pRanges != rOther._pRanges[n] )
     165           0 :             return 0;
     166             : 
     167           0 :     return !_pRanges[n] && !rOther._pRanges[n];
     168             : }
     169             : 
     170             : //-------------------------------------------------------------------------
     171             : 
     172           0 : SfxItemPresentation SfxUShortRangesItem::GetPresentation( SfxItemPresentation /*ePres*/,
     173             :                                     SfxMapUnit /*eCoreMetric*/,
     174             :                                     SfxMapUnit /*ePresMetric*/,
     175             :                                     OUString & /*rText*/,
     176             :                                     const IntlWrapper * ) const
     177             : {
     178             :     // not implemented
     179           0 :     return SFX_ITEM_PRESENTATION_NONE;
     180             : }
     181             : 
     182             : //-------------------------------------------------------------------------
     183             : 
     184           0 : SfxPoolItem* SfxUShortRangesItem::Clone( SfxItemPool * ) const
     185             : {
     186           0 :     return new SfxUShortRangesItem( *this );
     187             : }
     188             : 
     189             : //-------------------------------------------------------------------------
     190             : 
     191           0 : SfxPoolItem* SfxUShortRangesItem::Create( SvStream &rStream, sal_uInt16 ) const
     192             : {
     193           0 :     return new SfxUShortRangesItem( Which(), rStream );
     194             : }
     195             : 
     196             : //-------------------------------------------------------------------------
     197             : 
     198           0 : SvStream& SfxUShortRangesItem::Store( SvStream &rStream, sal_uInt16 ) const
     199             : {
     200           0 :     sal_uInt16 nCount = Count_Impl( _pRanges );
     201           0 :     rStream >> nCount;
     202           0 :     for ( sal_uInt16 n = 0; _pRanges[n]; ++n )
     203           0 :         rStream >> _pRanges[n];
     204           0 :     return rStream;
     205             : }
     206             : 
     207             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10