LCOV - code coverage report
Current view: top level - sw/inc - ndindex.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 52 52 100.0 %
Date: 2014-04-11 Functions: 25 25 100.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             : #ifndef INCLUDED_SW_INC_NDINDEX_HXX
      20             : #define INCLUDED_SW_INC_NDINDEX_HXX
      21             : 
      22             : #include <limits.h>
      23             : 
      24             : #include <tools/solar.h>
      25             : 
      26             : #include <node.hxx>
      27             : 
      28             : class SwNode;
      29             : class SwNodes;
      30             : 
      31             : /// Marks a node in the document model.
      32             : class SW_DLLPUBLIC SwNodeIndex
      33             : {
      34             :     friend void SwNodes::RegisterIndex( SwNodeIndex& );
      35             :     friend void SwNodes::DeRegisterIndex( SwNodeIndex& );
      36             :     friend void SwNodes::RemoveNode( sal_uLong, sal_uLong, sal_Bool );
      37             : 
      38             :     SwNode* pNd;
      39             :     SwNodeIndex *pNext, *pPrev;
      40             : 
      41             :     void Remove();
      42             : 
      43             :     // These are not allowed!
      44             :     SwNodeIndex( SwNodes& rNds, sal_uInt16 nIdx );
      45             :     SwNodeIndex( SwNodes& rNds, int nIdx );
      46             : 
      47             : public:
      48             :     SwNodeIndex( SwNodes& rNds, sal_uLong nIdx = 0 );
      49             :     SwNodeIndex( const SwNodeIndex &, long nDiff = 0 );
      50             :     SwNodeIndex( const SwNode&, long nDiff = 0 );
      51     4384833 :     ~SwNodeIndex() { Remove(); }
      52             : 
      53             :     inline sal_uLong operator++();
      54             :     inline sal_uLong operator--();
      55             :     inline sal_uLong operator++(int);
      56             :     inline sal_uLong operator--(int);
      57             : 
      58             :     inline sal_uLong operator+=( sal_uLong );
      59             :     inline sal_uLong operator-=( sal_uLong );
      60             :     inline sal_uLong operator+=( const  SwNodeIndex& );
      61             :     inline sal_uLong operator-=( const SwNodeIndex& );
      62             : 
      63             :     inline sal_Bool operator< ( const SwNodeIndex& ) const;
      64             :     inline sal_Bool operator<=( const SwNodeIndex& ) const;
      65             :     inline sal_Bool operator> ( const SwNodeIndex& ) const;
      66             :     inline sal_Bool operator>=( const SwNodeIndex& ) const;
      67             :     inline sal_Bool operator==( const SwNodeIndex& ) const;
      68             :     inline sal_Bool operator!=( const SwNodeIndex& ) const;
      69             : 
      70             :     inline sal_Bool operator< ( sal_uLong nWert ) const;
      71             :     inline sal_Bool operator<=( sal_uLong nWert ) const;
      72             :     inline sal_Bool operator> ( sal_uLong nWert ) const;
      73             :     inline sal_Bool operator>=( sal_uLong nWert ) const;
      74             :     inline sal_Bool operator==( sal_uLong nWert ) const;
      75             :     inline sal_Bool operator!=( sal_uLong nWert ) const;
      76             : 
      77             :     inline SwNodeIndex& operator=( sal_uLong );
      78             :            SwNodeIndex& operator=( const SwNodeIndex& );
      79             :            SwNodeIndex& operator=( const SwNode& );
      80             : 
      81             :     // Return value of index as sal_uLong.
      82             :     inline sal_uLong GetIndex() const;
      83             : 
      84             :     // Enables assignments without creation of a temporary object.
      85             :     SwNodeIndex& Assign( SwNodes& rNds, sal_uLong );
      86             :     SwNodeIndex& Assign( const SwNode& rNd, long nOffset = 0 );
      87             : 
      88             :     // Gets pointer on NodesArray.
      89             :     inline const SwNodes& GetNodes() const;
      90             :     inline       SwNodes& GetNodes();
      91             : 
      92    12708200 :     SwNode& GetNode() const { return *pNd; }
      93             : };
      94             : 
      95             : // SwRange
      96             : 
      97       45779 : class SW_DLLPUBLIC SwNodeRange
      98             : {
      99             : public:
     100             :     SwNodeIndex aStart;
     101             :     SwNodeIndex aEnd;
     102             : 
     103             :     SwNodeRange( const SwNodeIndex &rS, const SwNodeIndex &rE );
     104             :     SwNodeRange( const SwNodeRange &rRange );
     105             : 
     106             :     SwNodeRange( SwNodes& rArr, sal_uLong nSttIdx = 0, sal_uLong nEndIdx = 0 );
     107             :     SwNodeRange( const SwNodeIndex& rS, long nSttDiff,
     108             :                  const SwNodeIndex& rE, long nEndDiff = 0 );
     109             :     SwNodeRange( const SwNode& rS, long nSttDiff,
     110             :                  const SwNode& rE, long nEndDiff = 0 );
     111             : };
     112             : 
     113             : // For inlines node.hxx is needed which in turn needs this one.
     114             : // Therefore all inlines accessing pNd are implemented here.
     115             : 
     116   100877645 : inline sal_uLong SwNodeIndex::GetIndex() const
     117             : {
     118   100877645 :     return pNd->GetIndex();
     119             : }
     120      594900 : inline const SwNodes& SwNodeIndex::GetNodes() const
     121             : {
     122      594900 :     return pNd->GetNodes();
     123             : }
     124      689611 : inline SwNodes& SwNodeIndex::GetNodes()
     125             : {
     126      689611 :     return pNd->GetNodes();
     127             : }
     128      305514 : inline sal_Bool SwNodeIndex::operator< ( sal_uLong nWert ) const
     129             : {
     130      305514 :     return pNd->GetIndex() < nWert;
     131             : }
     132        1974 : inline sal_Bool SwNodeIndex::operator<=( sal_uLong nWert ) const
     133             : {
     134        1974 :     return pNd->GetIndex() <= nWert;
     135             : }
     136        3183 : inline sal_Bool SwNodeIndex::operator> ( sal_uLong nWert ) const
     137             : {
     138        3183 :     return pNd->GetIndex() > nWert;
     139             : }
     140        1453 : inline sal_Bool SwNodeIndex::operator>=( sal_uLong nWert ) const
     141             : {
     142        1453 :     return pNd->GetIndex() >= nWert;
     143             : }
     144      765669 : inline sal_Bool SwNodeIndex::operator==( sal_uLong nWert ) const
     145             : {
     146      765669 :     return pNd->GetIndex() == nWert;
     147             : }
     148        2744 : inline sal_Bool SwNodeIndex::operator!=( sal_uLong nWert ) const
     149             : {
     150        2744 :     return pNd->GetIndex() != nWert;
     151             : }
     152    89961967 : inline sal_Bool SwNodeIndex::operator<( const SwNodeIndex& rIndex ) const
     153             : {
     154    89961967 :     return pNd->GetIndex() < rIndex.GetIndex();
     155             : }
     156       75059 : inline sal_Bool SwNodeIndex::operator<=( const SwNodeIndex& rIndex ) const
     157             : {
     158       75059 :     return pNd->GetIndex() <= rIndex.GetIndex();
     159             : }
     160     4737454 : inline sal_Bool SwNodeIndex::operator>( const SwNodeIndex& rIndex ) const
     161             : {
     162     4737454 :     return pNd->GetIndex() > rIndex.GetIndex();
     163             : }
     164       90076 : inline sal_Bool SwNodeIndex::operator>=( const SwNodeIndex& rIndex ) const
     165             : {
     166       90076 :     return pNd->GetIndex() >= rIndex.GetIndex();
     167             : }
     168    77411358 : inline sal_Bool SwNodeIndex::operator==( const SwNodeIndex& rIdx ) const
     169             : {
     170    77411358 :     return pNd == rIdx.pNd;
     171             : }
     172      359739 : inline sal_Bool SwNodeIndex::operator!=( const SwNodeIndex& rIdx ) const
     173             : {
     174      359739 :     return pNd != rIdx.pNd;
     175             : }
     176             : 
     177      220498 : inline sal_uLong SwNodeIndex::operator++()
     178             : {
     179      220498 :     return ( pNd = GetNodes()[ pNd->GetIndex()+1 ] )->GetIndex();
     180             : }
     181          58 : inline sal_uLong SwNodeIndex::operator--()
     182             : {
     183          58 :     return ( pNd = GetNodes()[ pNd->GetIndex()-1 ] )->GetIndex();
     184             : }
     185       73327 : inline sal_uLong SwNodeIndex::operator++(int)
     186             : {
     187       73327 :     sal_uLong nOldIndex = pNd->GetIndex();
     188       73327 :     pNd = GetNodes()[ nOldIndex + 1 ];
     189       73327 :     return nOldIndex;
     190             : }
     191       24102 : inline sal_uLong SwNodeIndex::operator--(int)
     192             : {
     193       24102 :     sal_uLong nOldIndex = pNd->GetIndex();
     194       24102 :     pNd = GetNodes()[ nOldIndex - 1 ];
     195       24102 :     return nOldIndex;
     196             : }
     197             : 
     198        1159 : inline sal_uLong SwNodeIndex::operator+=( sal_uLong nWert )
     199             : {
     200        1159 :     return ( pNd = GetNodes()[ pNd->GetIndex() + nWert ] )->GetIndex();
     201             : }
     202         302 : inline sal_uLong SwNodeIndex::operator-=( sal_uLong nWert )
     203             : {
     204         302 :     return ( pNd = GetNodes()[ pNd->GetIndex() - nWert ] )->GetIndex();
     205             : }
     206             : inline sal_uLong SwNodeIndex::operator+=( const  SwNodeIndex& rIndex )
     207             : {
     208             :     return ( pNd = GetNodes()[ pNd->GetIndex() + rIndex.GetIndex() ] )->GetIndex();
     209             : }
     210             : inline sal_uLong SwNodeIndex::operator-=( const SwNodeIndex& rIndex )
     211             : {
     212             :     return ( pNd = GetNodes()[ pNd->GetIndex() - rIndex.GetIndex() ] )->GetIndex();
     213             : }
     214             : 
     215       50657 : inline SwNodeIndex& SwNodeIndex::operator=( sal_uLong nWert )
     216             : {
     217       50657 :     pNd = GetNodes()[ nWert ];
     218       50657 :     return *this;
     219             : }
     220             : 
     221             : #endif
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10