LCOV - code coverage report
Current view: top level - sw/inc - ndindex.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 52 52 100.0 %
Date: 2014-11-03 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, 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    11582832 :     ~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 bool operator< ( const SwNodeIndex& ) const;
      64             :     inline bool operator<=( const SwNodeIndex& ) const;
      65             :     inline bool operator> ( const SwNodeIndex& ) const;
      66             :     inline bool operator>=( const SwNodeIndex& ) const;
      67             :     inline bool operator==( const SwNodeIndex& ) const;
      68             :     inline bool operator!=( const SwNodeIndex& ) const;
      69             : 
      70             :     inline bool operator< ( sal_uLong nWert ) const;
      71             :     inline bool operator<=( sal_uLong nWert ) const;
      72             :     inline bool operator> ( sal_uLong nWert ) const;
      73             :     inline bool operator>=( sal_uLong nWert ) const;
      74             :     inline bool operator==( sal_uLong nWert ) const;
      75             :     inline 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    35988354 :     SwNode& GetNode() const { return *pNd; }
      93             : };
      94             : 
      95             : // SwRange
      96             : 
      97      113157 : 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    47643719 : inline sal_uLong SwNodeIndex::GetIndex() const
     117             : {
     118    47643719 :     return pNd->GetIndex();
     119             : }
     120     1564846 : inline const SwNodes& SwNodeIndex::GetNodes() const
     121             : {
     122     1564846 :     return pNd->GetNodes();
     123             : }
     124     2026536 : inline SwNodes& SwNodeIndex::GetNodes()
     125             : {
     126     2026536 :     return pNd->GetNodes();
     127             : }
     128      854815 : inline bool SwNodeIndex::operator< ( sal_uLong nWert ) const
     129             : {
     130      854815 :     return pNd->GetIndex() < nWert;
     131             : }
     132        7304 : inline bool SwNodeIndex::operator<=( sal_uLong nWert ) const
     133             : {
     134        7304 :     return pNd->GetIndex() <= nWert;
     135             : }
     136       27280 : inline bool SwNodeIndex::operator> ( sal_uLong nWert ) const
     137             : {
     138       27280 :     return pNd->GetIndex() > nWert;
     139             : }
     140        3694 : inline bool SwNodeIndex::operator>=( sal_uLong nWert ) const
     141             : {
     142        3694 :     return pNd->GetIndex() >= nWert;
     143             : }
     144     2129255 : inline bool SwNodeIndex::operator==( sal_uLong nWert ) const
     145             : {
     146     2129255 :     return pNd->GetIndex() == nWert;
     147             : }
     148        7268 : inline bool SwNodeIndex::operator!=( sal_uLong nWert ) const
     149             : {
     150        7268 :     return pNd->GetIndex() != nWert;
     151             : }
     152    20390103 : inline bool SwNodeIndex::operator<( const SwNodeIndex& rIndex ) const
     153             : {
     154    20390103 :     return pNd->GetIndex() < rIndex.GetIndex();
     155             : }
     156      162656 : inline bool SwNodeIndex::operator<=( const SwNodeIndex& rIndex ) const
     157             : {
     158      162656 :     return pNd->GetIndex() <= rIndex.GetIndex();
     159             : }
     160    10491099 : inline bool SwNodeIndex::operator>( const SwNodeIndex& rIndex ) const
     161             : {
     162    10491099 :     return pNd->GetIndex() > rIndex.GetIndex();
     163             : }
     164      152648 : inline bool SwNodeIndex::operator>=( const SwNodeIndex& rIndex ) const
     165             : {
     166      152648 :     return pNd->GetIndex() >= rIndex.GetIndex();
     167             : }
     168    29828995 : inline bool SwNodeIndex::operator==( const SwNodeIndex& rIdx ) const
     169             : {
     170    29828995 :     return pNd == rIdx.pNd;
     171             : }
     172      916890 : inline bool SwNodeIndex::operator!=( const SwNodeIndex& rIdx ) const
     173             : {
     174      916890 :     return pNd != rIdx.pNd;
     175             : }
     176             : 
     177      583636 : inline sal_uLong SwNodeIndex::operator++()
     178             : {
     179      583636 :     return ( pNd = GetNodes()[ pNd->GetIndex()+1 ] )->GetIndex();
     180             : }
     181         162 : inline sal_uLong SwNodeIndex::operator--()
     182             : {
     183         162 :     return ( pNd = GetNodes()[ pNd->GetIndex()-1 ] )->GetIndex();
     184             : }
     185      185859 : inline sal_uLong SwNodeIndex::operator++(int)
     186             : {
     187      185859 :     sal_uLong nOldIndex = pNd->GetIndex();
     188      185859 :     pNd = GetNodes()[ nOldIndex + 1 ];
     189      185859 :     return nOldIndex;
     190             : }
     191      167083 : inline sal_uLong SwNodeIndex::operator--(int)
     192             : {
     193      167083 :     sal_uLong nOldIndex = pNd->GetIndex();
     194      167083 :     pNd = GetNodes()[ nOldIndex - 1 ];
     195      167083 :     return nOldIndex;
     196             : }
     197             : 
     198        2468 : inline sal_uLong SwNodeIndex::operator+=( sal_uLong nWert )
     199             : {
     200        2468 :     return ( pNd = GetNodes()[ pNd->GetIndex() + nWert ] )->GetIndex();
     201             : }
     202         982 : inline sal_uLong SwNodeIndex::operator-=( sal_uLong nWert )
     203             : {
     204         982 :     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      117436 : inline SwNodeIndex& SwNodeIndex::operator=( sal_uLong nWert )
     216             : {
     217      117436 :     pNd = GetNodes()[ nWert ];
     218      117436 :     return *this;
     219             : }
     220             : 
     221             : #endif
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10