diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-20 16:53:29 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-23 04:02:13 +0100 |
commit | 96c7fff36eb2ed21bba604b3c0c376559e14539c (patch) | |
tree | 54b29d97962dfcc42b739917743fb092c9f4249b /sw | |
parent | eaf3774752869e0322a340d5be4ab1b328f3632a (diff) |
inline Assign
Change-Id: Ibeb8d7b8e83d432a502707f83a8fde7900596aec
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/ndindex.hxx | 34 | ||||
-rw-r--r-- | sw/source/core/docnode/ndindex.cxx | 55 |
2 files changed, 32 insertions, 57 deletions
diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx index 51ae6827fb77..72f28de07124 100644 --- a/sw/inc/ndindex.hxx +++ b/sw/inc/ndindex.hxx @@ -114,8 +114,8 @@ public: inline sal_uLong GetIndex() const; // Enables assignments without creation of a temporary object. - SwNodeIndex& Assign( SwNodes& rNds, sal_uLong ); - SwNodeIndex& Assign( const SwNode& rNd, long nOffset = 0 ); + inline SwNodeIndex& Assign( SwNodes& rNds, sal_uLong ); + inline SwNodeIndex& Assign( const SwNode& rNd, long nOffset = 0 ); // Gets pointer on NodesArray. inline const SwNodes& GetNodes() const; @@ -282,6 +282,36 @@ SwNodeIndex& SwNodeIndex::operator=( const SwNode& rNd ) return *this; } +SwNodeIndex& SwNodeIndex::Assign( SwNodes& rNds, sal_uLong nIdx ) +{ + if( &pNd->GetNodes() != &rNds ) + { + DeRegisterIndex( pNd->GetNodes() ); + pNd = rNds[ nIdx ]; + RegisterIndex( pNd->GetNodes() ); + } + else + pNd = rNds[ nIdx ]; + return *this; +} + +SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, long nOffset ) +{ + if( &pNd->GetNodes() != &rNd.GetNodes() ) + { + DeRegisterIndex( pNd->GetNodes() ); + pNd = (SwNode*)&rNd; + RegisterIndex( pNd->GetNodes() ); + } + else + pNd = (SwNode*)&rNd; + + if( nOffset ) + pNd = pNd->GetNodes()[ pNd->GetIndex() + nOffset ]; + + return *this; +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/docnode/ndindex.cxx b/sw/source/core/docnode/ndindex.cxx index 4f563a2eca3f..eed90809703e 100644 --- a/sw/source/core/docnode/ndindex.cxx +++ b/sw/source/core/docnode/ndindex.cxx @@ -19,61 +19,6 @@ #include "ndindex.hxx" -SwNodeIndex& SwNodeIndex::operator=( const SwNodeIndex& rIdx ) -{ - if( &pNd->GetNodes() != &rIdx.pNd->GetNodes() ) - { - DeRegisterIndex( pNd->GetNodes() ); - pNd = rIdx.pNd; - RegisterIndex( pNd->GetNodes() ); - } - else - pNd = rIdx.pNd; - return *this; -} - -SwNodeIndex& SwNodeIndex::operator=( const SwNode& rNd ) -{ - if( &pNd->GetNodes() != &rNd.GetNodes() ) - { - DeRegisterIndex( pNd->GetNodes() ); - pNd = (SwNode*)&rNd; - RegisterIndex( pNd->GetNodes() ); - } - else - pNd = (SwNode*)&rNd; - return *this; -} - -SwNodeIndex& SwNodeIndex::Assign( SwNodes& rNds, sal_uLong nIdx ) -{ - if( &pNd->GetNodes() != &rNds ) - { - DeRegisterIndex( pNd->GetNodes() ); - pNd = rNds[ nIdx ]; - RegisterIndex( pNd->GetNodes() ); - } - else - pNd = rNds[ nIdx ]; - return *this; -} - -SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, long nOffset ) -{ - if( &pNd->GetNodes() != &rNd.GetNodes() ) - { - DeRegisterIndex( pNd->GetNodes() ); - pNd = (SwNode*)&rNd; - RegisterIndex( pNd->GetNodes() ); - } - else - pNd = (SwNode*)&rNd; - - if( nOffset ) - pNd = pNd->GetNodes()[ pNd->GetIndex() + nOffset ]; - - return *this; -} std::ostream &operator <<(std::ostream& s, const SwNodeIndex& index) { |