Kaydet (Commit) ee9344b6 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

more const correctness

Change-Id: I786269210a7906c0d6b74e2cdb32100c8ae07666
üst d150ace1
...@@ -66,10 +66,16 @@ namespace sw ...@@ -66,10 +66,16 @@ namespace sw
std::swap(*(&pPrev), *(&pDestRing->pPrev)); std::swap(*(&pPrev), *(&pDestRing->pPrev));
} }
/** @return the next item in the ring container */ /** @return the next item in the ring container */
value_type* GetNext() const value_type* GetNext()
{ return pNext; } { return pNext; }
/** @return the previous item in the ring container */ /** @return the previous item in the ring container */
value_type* GetPrev() const value_type* GetPrev()
{ return pPrev; }
/** @return the next item in the ring container */
const_value_type* GetNext() const
{ return pNext; }
/** @return the previous item in the ring container */
const_value_type* GetPrev() const
{ return pPrev; } { return pPrev; }
/** @return a stl-like container with begin()/end() for iteration */ /** @return a stl-like container with begin()/end() for iteration */
ring_container GetRingContainer(); ring_container GetRingContainer();
...@@ -99,9 +105,9 @@ namespace sw ...@@ -99,9 +105,9 @@ namespace sw
typedef value_type node; typedef value_type node;
typedef value_type* node_ptr; typedef value_type* node_ptr;
typedef const value_type* const_node_ptr; typedef const value_type* const_node_ptr;
static node_ptr get_next(const_node_ptr n) { return n->GetNext(); }; static node_ptr get_next(const_node_ptr n) { return const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetNext(); };
static void set_next(node_ptr n, node_ptr next) { n->pNext = next; }; static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); }; static node_ptr get_previous(const_node_ptr n) { return const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetPrev(); };
static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; }; static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
}; };
friend typename ring_container::iterator; friend typename ring_container::iterator;
......
...@@ -578,7 +578,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, ...@@ -578,7 +578,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
SwPaM* pPrev(nullptr); SwPaM* pPrev(nullptr);
if( bRegExp ) if( bRegExp )
{ {
pPrev = pRegion->GetPrev(); pPrev = const_cast<SwPaM*>(pRegion)->GetPrev();
const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor ); const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor );
} }
......
...@@ -545,24 +545,14 @@ void SwShellCrsr::Show() ...@@ -545,24 +545,14 @@ void SwShellCrsr::Show()
// area is invalid. // area is invalid.
void SwShellCrsr::Invalidate( const SwRect& rRect ) void SwShellCrsr::Invalidate( const SwRect& rRect )
{ {
SwShellCrsr * pTmp = this; for(SwPaM& rPaM : GetRingContainer())
do
{ {
pTmp->SwSelPaintRects::Invalidate( rRect ); SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
// skip any non SwShellCrsr objects in the ring // skip any non SwShellCrsr objects in the ring
// see also: SwAutoFormat::DeleteSel() // see also: SwAutoFormat::DeleteSel()
Ring* pTmpRing = pTmp; if(pShCrsr)
pTmp = 0; pShCrsr->SwSelPaintRects::Invalidate(rRect);
do
{
pTmpRing = pTmpRing->GetNext();
pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing);
}
while ( !pTmp );
} }
while( this != pTmp );
} }
void SwShellCrsr::Hide() void SwShellCrsr::Hide()
......
...@@ -1836,6 +1836,10 @@ public: ...@@ -1836,6 +1836,10 @@ public:
_SaveMergeRedlines( const SwNode& rDstNd, _SaveMergeRedlines( const SwNode& rDstNd,
const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing ); const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing );
sal_uInt16 InsertRedline(); sal_uInt16 InsertRedline();
_SaveMergeRedlines* GetNext()
{ return GetNext(); }
_SaveMergeRedlines* GetPrev()
{ return GetPrev(); }
}; };
_SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd, _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
......
...@@ -48,7 +48,7 @@ using namespace ::com::sun::star::i18n; ...@@ -48,7 +48,7 @@ using namespace ::com::sun::star::i18n;
sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList, sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
sal_uInt16 nMode ) sal_uInt16 nMode )
{ {
const SwPaM *_pStartCrsr = static_cast<SwPaM*>(rPam.GetNext()), const SwPaM *_pStartCrsr = rPam.GetNext(),
*__pStartCrsr = _pStartCrsr; *__pStartCrsr = _pStartCrsr;
bool bCheckEmpty = &rPam != _pStartCrsr; bool bCheckEmpty = &rPam != _pStartCrsr;
do { do {
...@@ -86,7 +86,7 @@ sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList, ...@@ -86,7 +86,7 @@ sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
} while( 30 > rList.size() && *aPam.GetPoint() < *pEnd ); } while( 30 > rList.size() && *aPam.GetPoint() < *pEnd );
} }
} while( 30 > rList.size() && } while( 30 > rList.size() &&
(_pStartCrsr = static_cast<SwPaM *>(_pStartCrsr->GetNext())) != __pStartCrsr ); (_pStartCrsr = _pStartCrsr->GetNext()) != __pStartCrsr );
return rList.size(); return rList.size();
} }
...@@ -100,7 +100,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, ...@@ -100,7 +100,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
sal_uInt16 nListEntry = 0; sal_uInt16 nListEntry = 0;
const SwPaM *_pStartCrsr = static_cast<SwPaM*>(rPam.GetNext()), const SwPaM *_pStartCrsr = rPam.GetNext(),
*__pStartCrsr = _pStartCrsr; *__pStartCrsr = _pStartCrsr;
bool bCheckEmpty = &rPam != _pStartCrsr; bool bCheckEmpty = &rPam != _pStartCrsr;
do { do {
...@@ -173,7 +173,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, ...@@ -173,7 +173,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
} while( nListEntry < rList.size() && *aPam.GetPoint() < *pEnd ); } while( nListEntry < rList.size() && *aPam.GetPoint() < *pEnd );
} }
} while( 30 > rList.size() && } while( 30 > rList.size() &&
(_pStartCrsr = static_cast<SwPaM *>(_pStartCrsr->GetNext())) != __pStartCrsr ); (_pStartCrsr = _pStartCrsr->GetNext()) != __pStartCrsr );
GetIDocumentUndoRedo().EndUndo( UNDO_SETRUBYATTR, NULL ); GetIDocumentUndoRedo().EndUndo( UNDO_SETRUBYATTR, NULL );
......
...@@ -139,7 +139,7 @@ static bool lcl_GetBoxSel( const SwCursor& rCursor, SwSelBoxes& rBoxes, ...@@ -139,7 +139,7 @@ static bool lcl_GetBoxSel( const SwCursor& rCursor, SwSelBoxes& rBoxes,
rBoxes.insert( pBox ); rBoxes.insert( pBox );
} }
} while( bAllCrsr && } while( bAllCrsr &&
pSttPam != ( pCurPam = static_cast<SwPaM*>(pCurPam->GetNext())) ); pSttPam != ( pCurPam = pCurPam->GetNext()) );
} }
return !rBoxes.empty(); return !rBoxes.empty();
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
SwPamRanges::SwPamRanges( const SwPaM& rRing ) SwPamRanges::SwPamRanges( const SwPaM& rRing )
{ {
for(const SwPaM& rTmp : rRing.GetRingContainer()) for(SwPaM& rTmp : const_cast<SwPaM*>(&rRing)->GetRingContainer())
Insert( rTmp.GetMark()->nNode, rTmp.GetPoint()->nNode ); Insert( rTmp.GetMark()->nNode, rTmp.GetPoint()->nNode );
} }
......
...@@ -140,7 +140,7 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget) ...@@ -140,7 +140,7 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
if (rSource.GetNext() != &rSource) if (rSource.GetNext() != &rSource)
{ {
SwPaM *pPam = rSource.GetNext(); SwPaM *pPam = const_cast<SwPaM*>(rSource.GetNext());
do do
{ {
// create new PaM // create new PaM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment