SwContentIndex: move the const_cast inside
instead of doing it at the call sites Change-Id: I2ae8aafc14801894fa70c17b666b7d95849c7429 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137446 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -49,7 +49,7 @@ private:
|
||||
void Remove();
|
||||
|
||||
public:
|
||||
explicit SwContentIndex(SwContentNode *const pContentNode, sal_Int32 const nIdx = 0);
|
||||
explicit SwContentIndex(const SwContentNode * pContentNode, sal_Int32 const nIdx = 0);
|
||||
SwContentIndex( const SwContentIndex & );
|
||||
SwContentIndex( const SwContentIndex &, short nDiff );
|
||||
~SwContentIndex() { Remove(); }
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
sal_Int32 GetIndex() const { return m_nIndex; }
|
||||
|
||||
// Assignments without creating a temporary object.
|
||||
SwContentIndex &Assign(SwContentNode *, sal_Int32);
|
||||
SwContentIndex &Assign(const SwContentNode *, sal_Int32);
|
||||
|
||||
// Returns pointer to SwContentNode (for RTTI at SwContentIndexReg).
|
||||
const SwContentNode* GetContentNode() const { return m_pContentNode; }
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
|
||||
#include <crossrefbookmark.hxx>
|
||||
|
||||
SwContentIndex::SwContentIndex(SwContentNode *const pContentNode, sal_Int32 const nIdx)
|
||||
SwContentIndex::SwContentIndex(const SwContentNode * pContentNode, sal_Int32 const nIdx)
|
||||
: m_nIndex( nIdx )
|
||||
, m_pContentNode( pContentNode )
|
||||
, m_pContentNode( const_cast<SwContentNode*>(pContentNode) )
|
||||
, m_pNext( nullptr )
|
||||
, m_pPrev( nullptr )
|
||||
, m_pMark( nullptr )
|
||||
@@ -203,12 +203,12 @@ SwContentIndex& SwContentIndex::operator=( const SwContentIndex& rIdx )
|
||||
return *this;
|
||||
}
|
||||
|
||||
SwContentIndex& SwContentIndex::Assign( SwContentNode* pArr, sal_Int32 nIdx )
|
||||
SwContentIndex& SwContentIndex::Assign( const SwContentNode* pArr, sal_Int32 nIdx )
|
||||
{
|
||||
if (pArr != m_pContentNode) // unregister!
|
||||
{
|
||||
Remove();
|
||||
m_pContentNode = pArr;
|
||||
m_pContentNode = const_cast<SwContentNode*>(pArr);
|
||||
m_pNext = m_pPrev = nullptr;
|
||||
Init(nIdx);
|
||||
}
|
||||
|
||||
@@ -845,7 +845,7 @@ bool SwCursorShell::GotoFootnoteAnchor(const SwTextFootnote& rTextFootnote)
|
||||
SwCursorSaveState aSaveState(*pCursor);
|
||||
|
||||
pCursor->GetPoint()->nNode = rTextFootnote.GetTextNode();
|
||||
pCursor->GetPoint()->nContent.Assign(const_cast<SwTextNode*>(&rTextFootnote.GetTextNode()),
|
||||
pCursor->GetPoint()->nContent.Assign(&rTextFootnote.GetTextNode(),
|
||||
rTextFootnote.GetStart());
|
||||
bRet = !pCursor->IsSelOvr();
|
||||
if (bRet)
|
||||
@@ -2176,8 +2176,7 @@ bool SwCursorShell::GotoINetAttr( const SwTextINetFormat& rAttr )
|
||||
SwCursorSaveState aSaveState( *pCursor );
|
||||
|
||||
pCursor->GetPoint()->nNode = *rAttr.GetpTextNode();
|
||||
pCursor->GetPoint()->nContent.Assign( const_cast<SwTextNode*>(rAttr.GetpTextNode()),
|
||||
rAttr.GetStart() );
|
||||
pCursor->GetPoint()->nContent.Assign( rAttr.GetpTextNode(), rAttr.GetStart() );
|
||||
bRet = !pCursor->IsSelOvr();
|
||||
if( bRet )
|
||||
UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
|
||||
|
||||
@@ -78,7 +78,7 @@ SwPosition::SwPosition( SwNodes& rNodes, SwNodeOffset nIndex )
|
||||
}
|
||||
|
||||
SwPosition::SwPosition( const SwContentNode & rNode, const sal_Int32 nContentOffset )
|
||||
: nNode( rNode ), nContent( const_cast<SwContentNode*>(&rNode), nContentOffset )
|
||||
: nNode( rNode ), nContent( &rNode, nContentOffset )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -2453,7 +2453,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pCurrentCursor )
|
||||
SwPosition* pPos = pCur->GetMark();
|
||||
if( pNd != &pPos->nNode.GetNode() )
|
||||
pPos->nNode = *pNd;
|
||||
pPos->nContent.Assign( const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)), 0 );
|
||||
pPos->nContent.Assign( static_cast<const SwContentNode*>(pNd), 0 );
|
||||
|
||||
aIdx.Assign( *pSttNd->EndOfSectionNode(), - 1 );
|
||||
pNd = &aIdx.GetNode();
|
||||
@@ -2463,7 +2463,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pCurrentCursor )
|
||||
pPos = pCur->GetPoint();
|
||||
if (pNd && pNd != &pPos->nNode.GetNode())
|
||||
pPos->nNode = *pNd;
|
||||
pPos->nContent.Assign(const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)), pNd ? static_cast<const SwContentNode*>(pNd)->Len() : 0);
|
||||
pPos->nContent.Assign( static_cast<const SwContentNode*>(pNd), pNd ? static_cast<const SwContentNode*>(pNd)->Len() : 0);
|
||||
|
||||
aTmp.erase( aTmp.begin() + nPos );
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace
|
||||
void operator()(SwPosition& rPos, sal_Int32 nContent) const
|
||||
{
|
||||
rPos.nNode = *m_pNewContentNode;
|
||||
rPos.nContent.Assign(const_cast<SwContentNode*>(m_pNewContentNode), nContent + m_nOffset);
|
||||
rPos.nContent.Assign(m_pNewContentNode, nContent + m_nOffset);
|
||||
};
|
||||
};
|
||||
struct LimitUpdater
|
||||
@@ -112,7 +112,7 @@ namespace
|
||||
rPos.nNode = *m_pNewContentNode;
|
||||
if( nContent < m_nCorrLen )
|
||||
{
|
||||
rPos.nContent.Assign(const_cast<SwContentNode*>(m_pNewContentNode), std::min( nContent, static_cast<sal_Int32>(m_nLen) ) );
|
||||
rPos.nContent.Assign(m_pNewContentNode, std::min( nContent, static_cast<sal_Int32>(m_nLen) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1921,7 +1921,7 @@ SaveMergeRedline::SaveMergeRedline( const SwNode& rDstNd,
|
||||
|
||||
const SwPosition* pStt = rSrcRedl.Start();
|
||||
if( rDstNd.IsContentNode() )
|
||||
aPos.nContent.Assign( const_cast<SwContentNode*>(static_cast<const SwContentNode*>(&rDstNd)), pStt->nContent.GetIndex() );
|
||||
aPos.nContent.Assign( static_cast<const SwContentNode*>(&rDstNd), pStt->nContent.GetIndex() );
|
||||
pDestRedl = new SwRangeRedline( rSrcRedl.GetRedlineData(), aPos );
|
||||
|
||||
if( RedlineType::Delete != pDestRedl->GetType() )
|
||||
|
||||
@@ -193,7 +193,7 @@ void SetGetExpField::GetPosOfContent( SwPosition& rPos ) const
|
||||
if( pNd )
|
||||
{
|
||||
rPos.nNode = *pNd;
|
||||
rPos.nContent.Assign( const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)), GetCntPosFromContent() );
|
||||
rPos.nContent.Assign( static_cast<const SwContentNode*>(pNd), GetCntPosFromContent() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1569,7 +1569,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
|
||||
static_cast<sal_uInt8>(pNd->GetActualListLevel()) ))
|
||||
{
|
||||
rPos.nNode = aIdx;
|
||||
rPos.nContent.Assign( const_cast<SwTextNode*>(pNd), 0 );
|
||||
rPos.nContent.Assign( pNd, 0 );
|
||||
bRet = true;
|
||||
break;
|
||||
}
|
||||
@@ -1599,7 +1599,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
|
||||
else
|
||||
{
|
||||
rPos.nNode.Assign( *pLast );
|
||||
rPos.nContent.Assign( const_cast<SwTextNode*>(pLast), 0 );
|
||||
rPos.nContent.Assign( pLast, 0 );
|
||||
}
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& rHin
|
||||
SwDoc& rDoc = pPaM->GetDoc();
|
||||
const SwTextNode& rTextNode = mpTextField->GetTextNode();
|
||||
pPaM->GetPoint()->nNode = rTextNode;
|
||||
pPaM->GetPoint()->nContent.Assign( const_cast<SwTextNode*>(&rTextNode), mpTextField->GetStart() );
|
||||
pPaM->GetPoint()->nContent.Assign( &rTextNode, mpTextField->GetStart() );
|
||||
|
||||
OUString const aEntry(mpField->ExpandField(rDoc.IsClipBoard(), pFieldHint->m_pLayout));
|
||||
pPaM->SetMark();
|
||||
|
||||
@@ -139,7 +139,7 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
|
||||
|
||||
SwDoc& rDoc = const_cast<SwDoc&>(pNode->GetDoc());
|
||||
|
||||
SwContentIndex aIdx( const_cast<SwTextNode*>(pNode), GetStart() );
|
||||
SwContentIndex aIdx( pNode, GetStart() );
|
||||
SwPosition aPos( *pNode->StartOfSectionNode(), aIdx );
|
||||
SwFrameFormat* pFormat = GetFlyCnt().GetFrameFormat();
|
||||
SwFormatAnchor aAnchor( pFormat->GetAnchor() );
|
||||
|
||||
@@ -238,7 +238,7 @@ SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const SwTextNode& rTextNd) :
|
||||
|
||||
if ( !m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() )
|
||||
{
|
||||
SwPosition aPosition( m_rNode, SwContentIndex( const_cast<SwTextNode*>(&m_rNode) ) );
|
||||
SwPosition aPosition( m_rNode, SwContentIndex( &m_rNode ) );
|
||||
m_pCurRedline = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedline( aPosition, &m_nCurRedlinePos );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user