2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 10:25:34 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 10:25:34 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 10:25:34 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 10:25:34 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 10:25:34 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 10:25:34 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _NDINDEX_HXX
|
|
|
|
#define _NDINDEX_HXX
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <tools/solar.h>
|
|
|
|
|
|
|
|
#include "node.hxx"
|
|
|
|
#include "ndarr.hxx"
|
|
|
|
|
|
|
|
class SwNode;
|
|
|
|
class SwNodes;
|
|
|
|
|
2009-01-05 14:06:42 +00:00
|
|
|
class SW_DLLPUBLIC SwNodeIndex
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
friend void SwNodes::RegisterIndex( SwNodeIndex& );
|
|
|
|
friend void SwNodes::DeRegisterIndex( SwNodeIndex& );
|
2007-09-27 07:06:33 +00:00
|
|
|
friend void SwNodes::RemoveNode( ULONG, ULONG, BOOL );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 16:15:01 +00:00
|
|
|
static int nSerial;
|
|
|
|
int MySerial;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SwNode* pNd;
|
|
|
|
SwNodeIndex *pNext, *pPrev;
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
void Remove();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// These are not allowed!
|
2000-09-18 16:15:01 +00:00
|
|
|
SwNodeIndex( SwNodes& rNds, USHORT nIdx );
|
|
|
|
SwNodeIndex( SwNodes& rNds, int nIdx );
|
|
|
|
|
|
|
|
public:
|
|
|
|
SwNodeIndex( SwNodes& rNds, ULONG nIdx = 0 );
|
|
|
|
SwNodeIndex( const SwNodeIndex &, long nDiff = 0 );
|
|
|
|
SwNodeIndex( const SwNode&, long nDiff = 0 );
|
|
|
|
~SwNodeIndex() { Remove(); }
|
|
|
|
|
|
|
|
inline ULONG operator++();
|
|
|
|
inline ULONG operator--();
|
|
|
|
inline ULONG operator++(int);
|
|
|
|
inline ULONG operator--(int);
|
|
|
|
|
|
|
|
inline ULONG operator+=( ULONG );
|
|
|
|
inline ULONG operator-=( ULONG );
|
|
|
|
inline ULONG operator+=( const SwNodeIndex& );
|
|
|
|
inline ULONG operator-=( const SwNodeIndex& );
|
|
|
|
|
|
|
|
inline BOOL operator< ( const SwNodeIndex& ) const;
|
|
|
|
inline BOOL operator<=( const SwNodeIndex& ) const;
|
|
|
|
inline BOOL operator> ( const SwNodeIndex& ) const;
|
|
|
|
inline BOOL operator>=( const SwNodeIndex& ) const;
|
|
|
|
inline BOOL operator==( const SwNodeIndex& ) const;
|
|
|
|
inline BOOL operator!=( const SwNodeIndex& ) const;
|
|
|
|
|
|
|
|
inline BOOL operator< ( ULONG nWert ) const;
|
|
|
|
inline BOOL operator<=( ULONG nWert ) const;
|
|
|
|
inline BOOL operator> ( ULONG nWert ) const;
|
|
|
|
inline BOOL operator>=( ULONG nWert ) const;
|
|
|
|
inline BOOL operator==( ULONG nWert ) const;
|
|
|
|
inline BOOL operator!=( ULONG nWert ) const;
|
|
|
|
|
|
|
|
inline SwNodeIndex& operator=( ULONG );
|
|
|
|
SwNodeIndex& operator=( const SwNodeIndex& );
|
|
|
|
SwNodeIndex& operator=( const SwNode& );
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// Return value of index as ULONG.
|
2000-09-18 16:15:01 +00:00
|
|
|
inline ULONG GetIndex() const;
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// Enables assignments without creation of a temporary object.
|
2000-09-18 16:15:01 +00:00
|
|
|
SwNodeIndex& Assign( SwNodes& rNds, ULONG );
|
|
|
|
SwNodeIndex& Assign( const SwNode& rNd, long nOffset = 0 );
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// Gets pointer on NodesArray.
|
2000-09-18 16:15:01 +00:00
|
|
|
inline const SwNodes& GetNodes() const;
|
|
|
|
inline SwNodes& GetNodes();
|
|
|
|
|
|
|
|
SwNode& GetNode() const { return *pNd; }
|
|
|
|
};
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// SwRange
|
|
|
|
|
2009-01-05 14:06:42 +00:00
|
|
|
class SW_DLLPUBLIC SwNodeRange
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SwNodeIndex aStart;
|
|
|
|
SwNodeIndex aEnd;
|
|
|
|
|
|
|
|
SwNodeRange( const SwNodeIndex &rS, const SwNodeIndex &rE );
|
|
|
|
SwNodeRange( const SwNodeRange &rRange );
|
|
|
|
|
|
|
|
SwNodeRange( SwNodes& rArr, ULONG nSttIdx = 0, ULONG nEndIdx = 0 );
|
|
|
|
SwNodeRange( const SwNodeIndex& rS, long nSttDiff,
|
|
|
|
const SwNodeIndex& rE, long nEndDiff = 0 );
|
|
|
|
SwNodeRange( const SwNode& rS, long nSttDiff,
|
|
|
|
const SwNode& rE, long nEndDiff = 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// For inlines node.hxx is needed which in turn needs this one.
|
|
|
|
// Therefore all inlines accessing pNd are implemented here.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
inline ULONG SwNodeIndex::GetIndex() const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex();
|
|
|
|
}
|
|
|
|
inline const SwNodes& SwNodeIndex::GetNodes() const
|
|
|
|
{
|
|
|
|
return pNd->GetNodes();
|
|
|
|
}
|
|
|
|
inline SwNodes& SwNodeIndex::GetNodes()
|
|
|
|
{
|
|
|
|
return pNd->GetNodes();
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator< ( ULONG nWert ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() < nWert;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator<=( ULONG nWert ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() <= nWert;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator> ( ULONG nWert ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() > nWert;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator>=( ULONG nWert ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() >= nWert;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator==( ULONG nWert ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() == nWert;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator!=( ULONG nWert ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() != nWert;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator<( const SwNodeIndex& rIndex ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() < rIndex.GetIndex();
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator<=( const SwNodeIndex& rIndex ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() <= rIndex.GetIndex();
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator>( const SwNodeIndex& rIndex ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() > rIndex.GetIndex();
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator>=( const SwNodeIndex& rIndex ) const
|
|
|
|
{
|
|
|
|
return pNd->GetIndex() >= rIndex.GetIndex();
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator==( const SwNodeIndex& rIdx ) const
|
|
|
|
{
|
|
|
|
return pNd == rIdx.pNd;
|
|
|
|
}
|
|
|
|
inline BOOL SwNodeIndex::operator!=( const SwNodeIndex& rIdx ) const
|
|
|
|
{
|
|
|
|
return pNd != rIdx.pNd;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ULONG SwNodeIndex::operator++()
|
|
|
|
{
|
|
|
|
return ( pNd = GetNodes()[ pNd->GetIndex()+1 ] )->GetIndex();
|
|
|
|
}
|
|
|
|
inline ULONG SwNodeIndex::operator--()
|
|
|
|
{
|
|
|
|
return ( pNd = GetNodes()[ pNd->GetIndex()-1 ] )->GetIndex();
|
|
|
|
}
|
|
|
|
inline ULONG SwNodeIndex::operator++(int)
|
|
|
|
{
|
|
|
|
ULONG nOldIndex = pNd->GetIndex();
|
|
|
|
pNd = GetNodes()[ nOldIndex + 1 ];
|
|
|
|
return nOldIndex;
|
|
|
|
}
|
|
|
|
inline ULONG SwNodeIndex::operator--(int)
|
|
|
|
{
|
|
|
|
ULONG nOldIndex = pNd->GetIndex();
|
|
|
|
pNd = GetNodes()[ nOldIndex - 1 ];
|
|
|
|
return nOldIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ULONG SwNodeIndex::operator+=( ULONG nWert )
|
|
|
|
{
|
|
|
|
return ( pNd = GetNodes()[ pNd->GetIndex() + nWert ] )->GetIndex();
|
|
|
|
}
|
|
|
|
inline ULONG SwNodeIndex::operator-=( ULONG nWert )
|
|
|
|
{
|
|
|
|
return ( pNd = GetNodes()[ pNd->GetIndex() - nWert ] )->GetIndex();
|
|
|
|
}
|
|
|
|
inline ULONG SwNodeIndex::operator+=( const SwNodeIndex& rIndex )
|
|
|
|
{
|
|
|
|
return ( pNd = GetNodes()[ pNd->GetIndex() + rIndex.GetIndex() ] )->GetIndex();
|
|
|
|
}
|
|
|
|
inline ULONG SwNodeIndex::operator-=( const SwNodeIndex& rIndex )
|
|
|
|
{
|
|
|
|
return ( pNd = GetNodes()[ pNd->GetIndex() - rIndex.GetIndex() ] )->GetIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline SwNodeIndex& SwNodeIndex::operator=( ULONG nWert )
|
|
|
|
{
|
|
|
|
pNd = GetNodes()[ nWert ];
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-21 02:20:33 +01:00
|
|
|
// Implementation in ndindex.hxx - should be adapted to the
|
|
|
|
// new interface as soon as possible.
|
2000-09-18 16:15:01 +00:00
|
|
|
inline SwNode* SwNodes::operator[]( const SwNodeIndex& rIdx ) const
|
|
|
|
{
|
|
|
|
return &rIdx.GetNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|