LCOV - code coverage report
Current view: top level - sw/inc - index.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 44 0.0 %
Date: 2014-04-14 Functions: 0 23 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             : #ifndef INCLUDED_SW_INC_INDEX_HXX
      20             : #define INCLUDED_SW_INC_INDEX_HXX
      21             : 
      22             : #include <sal/types.h>
      23             : #include <tools/rtti.hxx>
      24             : #include <swdllapi.h>
      25             : 
      26             : class SwIndexReg;
      27             : struct SwPosition;
      28             : 
      29             : /// Marks a character position inside a document model node.
      30             : class SW_DLLPUBLIC SwIndex
      31             : {
      32             : private:
      33             :     friend class SwIndexReg;
      34             : 
      35             :     sal_Int32 m_nIndex;
      36             :     SwIndexReg * m_pIndexReg;
      37             :     // doubly linked list of Indexes registered at m_pIndexReg
      38             :     SwIndex * m_pNext;
      39             :     SwIndex * m_pPrev;
      40             : 
      41             :     SwIndex& ChgValue( const SwIndex& rIdx, sal_Int32 nNewValue );
      42             :     void Init(sal_Int32 const nIdx);
      43             :     void Remove();
      44             : 
      45             : public:
      46             :     explicit SwIndex(SwIndexReg *const pReg, sal_Int32 const nIdx = 0);
      47             :     SwIndex( const SwIndex & );
      48             :     SwIndex( const SwIndex &, short nDiff );
      49           0 :     ~SwIndex() { Remove(); }
      50             : 
      51             :     SwIndex& operator=( sal_Int32 const );
      52             :     SwIndex& operator=( const SwIndex & );
      53             : 
      54             :     sal_Int32 operator++();
      55             :     sal_Int32 operator--();
      56             :     sal_Int32 operator++(int);
      57             :     sal_Int32 operator--(int);
      58             : 
      59             :     sal_Int32 operator+=( sal_Int32 const );
      60             :     sal_Int32 operator-=( sal_Int32 const );
      61             :     sal_Int32 operator+=( const SwIndex& );
      62             :     sal_Int32 operator-=( const SwIndex& );
      63             : 
      64             :     bool operator< ( const SwIndex& ) const;
      65             :     bool operator<=( const SwIndex& ) const;
      66             :     bool operator> ( const SwIndex& ) const;
      67             :     bool operator>=( const SwIndex& ) const;
      68             : 
      69           0 :     bool operator< ( sal_Int32 const nVal ) const { return m_nIndex <  nVal; }
      70           0 :     bool operator<=( sal_Int32 const nVal ) const { return m_nIndex <= nVal; }
      71           0 :     bool operator> ( sal_Int32 const nVal ) const { return m_nIndex >  nVal; }
      72           0 :     bool operator>=( sal_Int32 const nVal ) const { return m_nIndex >= nVal; }
      73           0 :     bool operator==( sal_Int32 const nVal ) const { return m_nIndex == nVal; }
      74           0 :     bool operator!=( sal_Int32 const nVal ) const { return m_nIndex != nVal; }
      75             : 
      76           0 :     bool operator==( const SwIndex& rSwIndex ) const
      77             :     {
      78           0 :         return (m_nIndex    == rSwIndex.m_nIndex)
      79           0 :             && (m_pIndexReg == rSwIndex.m_pIndexReg);
      80             :     }
      81             : 
      82           0 :     bool operator!=( const SwIndex& rSwIndex ) const
      83             :     {
      84           0 :         return (m_nIndex    != rSwIndex.m_nIndex)
      85           0 :             || (m_pIndexReg != rSwIndex.m_pIndexReg);
      86             :     }
      87             : 
      88           0 :     sal_Int32 GetIndex() const { return m_nIndex; }
      89             : 
      90             :     // Assignments without creating a temporary object.
      91             :     SwIndex &Assign(SwIndexReg *, sal_Int32);
      92             : 
      93             :     // Returns pointer to IndexArray (for RTTI at SwIndexReg).
      94           0 :     const SwIndexReg* GetIdxReg() const { return m_pIndexReg; }
      95             : };
      96             : 
      97             : class SwIndexReg
      98             : {
      99             :     friend class SwIndex;
     100             :     friend bool sw_PosOk(const SwPosition & aPos);
     101             : 
     102             :     const SwIndex * m_pFirst;
     103             :     const SwIndex * m_pLast;
     104             : 
     105             : protected:
     106             :     virtual void Update( SwIndex const & rPos, const sal_Int32 nChangeLen,
     107             :                  const bool bNegative = false, const bool bDelete = false );
     108             : 
     109             :     void ChkArr();
     110             : 
     111           0 :     bool HasAnyIndex() const { return 0 != m_pFirst; }
     112             : 
     113             : public:
     114             :     SwIndexReg();
     115             :     virtual ~SwIndexReg();
     116             : 
     117             :     /// rtti, derived classes might do the same. If so, one can cast typesavely
     118             :     /// via SwIndexReg.
     119             :     TYPEINFO();
     120             : 
     121             :     void MoveTo( SwIndexReg& rArr );
     122             : };
     123             : 
     124             : #ifndef DBG_UTIL
     125             : 
     126           0 : inline sal_Int32 SwIndex::operator++()
     127             : {
     128           0 :     return ChgValue( *this, m_nIndex+1 ).m_nIndex;
     129             : }
     130             : 
     131             : inline sal_Int32 SwIndex::operator--()
     132             : {
     133             :     return ChgValue( *this, m_nIndex-1 ).m_nIndex;
     134             : }
     135             : 
     136           0 : inline sal_Int32 SwIndex::operator++(int)
     137             : {
     138           0 :     sal_Int32 const nOldIndex = m_nIndex;
     139           0 :     ChgValue( *this, m_nIndex+1 );
     140           0 :     return nOldIndex;
     141             : }
     142             : 
     143           0 : inline sal_Int32 SwIndex::operator--(int)
     144             : {
     145           0 :     sal_Int32 const nOldIndex = m_nIndex;
     146           0 :     ChgValue( *this, m_nIndex-1 );
     147           0 :     return nOldIndex;
     148             : }
     149             : 
     150           0 : inline sal_Int32 SwIndex::operator+=( sal_Int32 const nVal )
     151             : {
     152           0 :     return ChgValue( *this, m_nIndex + nVal ).m_nIndex;
     153             : }
     154             : 
     155           0 : inline sal_Int32 SwIndex::operator-=( sal_Int32 const nVal )
     156             : {
     157           0 :     return ChgValue( *this, m_nIndex - nVal ).m_nIndex;
     158             : }
     159             : 
     160             : inline sal_Int32 SwIndex::operator+=( const SwIndex& rIndex )
     161             : {
     162             :     return ChgValue( *this, m_nIndex + rIndex.m_nIndex ).m_nIndex;
     163             : }
     164             : 
     165           0 : inline sal_Int32 SwIndex::operator-=( const SwIndex& rIndex )
     166             : {
     167           0 :     return ChgValue( *this, m_nIndex - rIndex.m_nIndex ).m_nIndex;
     168             : }
     169             : 
     170           0 : inline bool SwIndex::operator< ( const SwIndex& rIndex ) const
     171             : {
     172           0 :     return m_nIndex <  rIndex.m_nIndex;
     173             : }
     174             : 
     175           0 : inline bool SwIndex::operator<=( const SwIndex& rIndex ) const
     176             : {
     177           0 :     return m_nIndex <= rIndex.m_nIndex;
     178             : }
     179             : 
     180           0 : inline bool SwIndex::operator> ( const SwIndex& rIndex ) const
     181             : {
     182           0 :     return m_nIndex >  rIndex.m_nIndex;
     183             : }
     184             : 
     185           0 : inline bool SwIndex::operator>=( const SwIndex& rIndex ) const
     186             : {
     187           0 :     return m_nIndex >= rIndex.m_nIndex;
     188             : }
     189             : 
     190           0 : inline SwIndex& SwIndex::operator= ( sal_Int32 const nVal )
     191             : {
     192           0 :     if (m_nIndex != nVal)
     193             :     {
     194           0 :         ChgValue( *this, nVal );
     195             :     }
     196           0 :     return *this;
     197             : }
     198             : 
     199             : #endif // ifndef DBG_UTIL
     200             : 
     201             : #endif
     202             : 
     203             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10