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
std::swap(*(&pPrev), *(&pDestRing->pPrev));
}
/** @return the next item in the ring container */
value_type* GetNext() const
value_type* GetNext()
{ return pNext; }
/** @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 a stl-like container with begin()/end() for iteration */
ring_container GetRingContainer();
......@@ -99,9 +105,9 @@ namespace sw
typedef value_type node;
typedef value_type* 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 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; };
};
friend typename ring_container::iterator;
......
......@@ -578,7 +578,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
SwPaM* pPrev(nullptr);
if( bRegExp )
{
pPrev = pRegion->GetPrev();
pPrev = const_cast<SwPaM*>(pRegion)->GetPrev();
const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor );
}
......
......@@ -545,24 +545,14 @@ void SwShellCrsr::Show()
// area is invalid.
void SwShellCrsr::Invalidate( const SwRect& rRect )
{
SwShellCrsr * pTmp = this;
do
for(SwPaM& rPaM : GetRingContainer())
{
pTmp->SwSelPaintRects::Invalidate( rRect );
SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
// skip any non SwShellCrsr objects in the ring
// see also: SwAutoFormat::DeleteSel()
Ring* pTmpRing = pTmp;
pTmp = 0;
do
{
pTmpRing = pTmpRing->GetNext();
pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing);
}
while ( !pTmp );
if(pShCrsr)
pShCrsr->SwSelPaintRects::Invalidate(rRect);
}
while( this != pTmp );
}
void SwShellCrsr::Hide()
......
......@@ -1836,6 +1836,10 @@ public:
_SaveMergeRedlines( const SwNode& rDstNd,
const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing );
sal_uInt16 InsertRedline();
_SaveMergeRedlines* GetNext()
{ return GetNext(); }
_SaveMergeRedlines* GetPrev()
{ return GetPrev(); }
};
_SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
......
......@@ -48,7 +48,7 @@ using namespace ::com::sun::star::i18n;
sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
sal_uInt16 nMode )
{
const SwPaM *_pStartCrsr = static_cast<SwPaM*>(rPam.GetNext()),
const SwPaM *_pStartCrsr = rPam.GetNext(),
*__pStartCrsr = _pStartCrsr;
bool bCheckEmpty = &rPam != _pStartCrsr;
do {
......@@ -86,7 +86,7 @@ sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
} while( 30 > rList.size() && *aPam.GetPoint() < *pEnd );
}
} while( 30 > rList.size() &&
(_pStartCrsr = static_cast<SwPaM *>(_pStartCrsr->GetNext())) != __pStartCrsr );
(_pStartCrsr = _pStartCrsr->GetNext()) != __pStartCrsr );
return rList.size();
}
......@@ -100,7 +100,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
sal_uInt16 nListEntry = 0;
const SwPaM *_pStartCrsr = static_cast<SwPaM*>(rPam.GetNext()),
const SwPaM *_pStartCrsr = rPam.GetNext(),
*__pStartCrsr = _pStartCrsr;
bool bCheckEmpty = &rPam != _pStartCrsr;
do {
......@@ -173,7 +173,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
} while( nListEntry < rList.size() && *aPam.GetPoint() < *pEnd );
}
} while( 30 > rList.size() &&
(_pStartCrsr = static_cast<SwPaM *>(_pStartCrsr->GetNext())) != __pStartCrsr );
(_pStartCrsr = _pStartCrsr->GetNext()) != __pStartCrsr );
GetIDocumentUndoRedo().EndUndo( UNDO_SETRUBYATTR, NULL );
......
......@@ -139,7 +139,7 @@ static bool lcl_GetBoxSel( const SwCursor& rCursor, SwSelBoxes& rBoxes,
rBoxes.insert( pBox );
}
} while( bAllCrsr &&
pSttPam != ( pCurPam = static_cast<SwPaM*>(pCurPam->GetNext())) );
pSttPam != ( pCurPam = pCurPam->GetNext()) );
}
return !rBoxes.empty();
}
......
......@@ -30,7 +30,7 @@
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 );
}
......
......@@ -140,7 +140,7 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
if (rSource.GetNext() != &rSource)
{
SwPaM *pPam = rSource.GetNext();
SwPaM *pPam = const_cast<SwPaM*>(rSource.GetNext());
do
{
// 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