diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-07-25 00:24:08 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-07-25 09:47:52 +0200 |
commit | f3974d020b8c066dcb08a54ad94740d5131c86f9 (patch) | |
tree | 5467f91ab14ced38a0fdcc96a27119273e596298 /sw | |
parent | bb67dc2752cc37a636fc851ba5b29e6cf0236362 (diff) |
simplify ChkPaM some more
Change-Id: I499f76252d145fc3a3afd2e3646ef81e8055e327
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 7b5137b98ddd..1606d2afd107 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1475,36 +1475,7 @@ namespace inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos) { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); }; }; - static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, sal_uLong nNode, sal_Int32 nCntnt, - const SwPaM& rPam, - bool bChkSelDirection ) - { - // Respect direction of selection - bool bBound1IsStart = !bChkSelDirection || - ( *rPam.GetPoint() < *rPam.GetMark() - ? rPam.GetPoint() == &rPam.GetBound() - : rPam.GetMark() == &rPam.GetBound()); - - const SwPosition* pPos = &rPam.GetBound( true ); - if( pPos->nNode.GetIndex() == nNode && - ( bBound1IsStart ? pPos->nContent.GetIndex() < nCntnt - : pPos->nContent.GetIndex() <= nCntnt )) - { - const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), false, pPos->nContent.GetIndex() }; - rMarkEntries.push_back(aEntry); - } - - pPos = &rPam.GetBound( false ); - if( pPos->nNode.GetIndex() == nNode && - ( (bBound1IsStart && bChkSelDirection) - ? pPos->nContent.GetIndex() <= nCntnt - : pPos->nContent.GetIndex() < nCntnt )) - { - const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), true, pPos->nContent.GetIndex() }; - rMarkEntries.push_back(aEntry); - } - } - static void lcl_ChkPaM( std::vector<PaMEntry> &rPaMEntries, sal_uLong nNode, sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint) + static inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint) { const SwPosition* pPos = &rPaM.GetBound( bPoint ); if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt ) @@ -1513,6 +1484,11 @@ namespace rPaMEntries.push_back(aEntry); } } + static inline void lcl_ChkPaMBoth( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM) + { + lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, true); + lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, false); + } #if 0 static void DumpEntries(std::vector<MarkEntry>* pEntries) @@ -1693,13 +1669,13 @@ void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCn BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl()) { FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) ) - lcl_ChkUnoCrsrPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, false ); + lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR ); FOREACHPAM_END() const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr); if( pUnoTblCrsr ) { FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() ) - lcl_ChkUnoCrsrPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, false ); + lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR ); FOREACHPAM_END() } } @@ -1725,14 +1701,12 @@ void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 n SwPaM *_pStkCrsr = ((SwCrsrShell*)_pStartShell)->GetStkCrsr(); if( _pStkCrsr ) do { - lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true); - lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false); + lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr); } while ( (_pStkCrsr != 0 ) && ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != ((SwCrsrShell*)_pStartShell)->GetStkCrsr()) ); FOREACHPAM_START( ((SwCrsrShell*)_pStartShell)->_GetCrsr() ) - lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true); - lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false); + lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR); FOREACHPAM_END() } } while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pShell ); |