diff options
-rw-r--r-- | sw/inc/docary.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/docnode/nodes.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/findfrm.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/layout/trvlfrm.cxx | 22 |
7 files changed, 32 insertions, 37 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index dce6a44b7576..5cd132f0ef44 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -131,7 +131,7 @@ public: erase( begin() + aStartIdx, begin() + aEndIdx); } - size_t GetPos(Value const& p) const + size_t GetPos(typename std::remove_pointer_t<Value> const* const p) const { const_iterator const it = std::find(begin(), end(), p); return it == end() ? SIZE_MAX : it - begin(); @@ -159,9 +159,6 @@ public: virtual Value GetFormat(size_t idx) const override { return SwVectorModifyBase<Value>::operator[](idx); } - size_t GetPos(const SwFormat *p) const - { return SwVectorModifyBase<Value>::GetPos( static_cast<Value>( const_cast<SwFormat*>( p ) ) ); } - // Override return type to reduce casting virtual Value FindFormatByName(const OUString& rName) const override { return static_cast<Value>(SwFormatsBase::FindFormatByName(rName)); } @@ -230,7 +227,7 @@ private: mutable sal_uInt32 m_nMaxMovedID = 1; //every move-redline pair get a unique ID, so they can find each other. public: ~SwRedlineTable(); - bool Contains(const SwRangeRedline* p) const { return maVector.find(const_cast<SwRangeRedline*>(p)) != maVector.end(); } + bool Contains(const SwRangeRedline* p) const { return maVector.find(p) != maVector.end(); } size_type GetPos(const SwRangeRedline* p) const; bool Insert(SwRangeRedline*& p); diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 32696630e591..b8bb35056de1 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -658,7 +658,7 @@ SwRedlineTable::~SwRedlineTable() SwRedlineTable::size_type SwRedlineTable::GetPos(const SwRangeRedline* p) const { - vector_type::const_iterator it = maVector.find(const_cast<SwRangeRedline*>(p)); + vector_type::const_iterator it = maVector.find(p); if( it == maVector.end() ) return npos; return it - maVector.begin(); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index af957c8a7318..8acfafbe6dea 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -859,7 +859,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, { if (!GetFormat()) return; - SwSectionNode const*const pSectNd(GetFormat()->GetSectionNode()); + SwSectionNode* const pSectNd(GetFormat()->GetSectionNode()); if (nullptr == pSectNd || !pSectNd->GetNodes().IsDocNodes() || IsHiddenFlag() || @@ -873,7 +873,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, maMSTOCExpression.clear(); } - SwDoc& rDoc = const_cast<SwDoc&>(pSectNd->GetDoc()); + SwDoc& rDoc = pSectNd->GetDoc(); if (pAttr && GetFormat()) rDoc.ChgFormat(*GetFormat(), *pAttr); @@ -949,7 +949,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, : nullptr; SwNode2LayoutSaveUpperFrames aN2L(*pSectNd); - const_cast<SwSectionNode*>(pSectNd)->DelFrames(); + pSectNd->DelFrames(); // This would be a good time to update the Numbering rDoc.UpdateNumRule(); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index d180a3a584c6..23729d1bedc0 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -283,7 +283,7 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, SwNodeOffset nSz, SwTextField* pTextField = static_txtattr_cast<SwTextField*>(pAttr); rNds.GetDoc().getIDocumentFieldsAccess().InsDelFieldInFieldLst( !bToUndo, *pTextField ); - const SwFieldType* pTyp = pTextField->GetFormatField().GetField()->GetTyp(); + SwFieldType* pTyp = pTextField->GetFormatField().GetField()->GetTyp(); if ( SwFieldIds::Postit == pTyp->Which() ) { rNds.GetDoc().GetDocShell()->Broadcast( @@ -296,9 +296,9 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, SwNodeOffset nSz, else if( SwFieldIds::Dde == pTyp->Which() ) { if( bToUndo ) - const_cast<SwDDEFieldType*>(static_cast<const SwDDEFieldType*>(pTyp))->DecRefCnt(); + static_cast<SwDDEFieldType*>(pTyp)->DecRefCnt(); else - const_cast<SwDDEFieldType*>(static_cast<const SwDDEFieldType*>(pTyp))->IncRefCnt(); + static_cast<SwDDEFieldType*>(pTyp)->IncRefCnt(); } static_cast<SwFormatField&>(pAttr->GetAttr()) .InvalidateField(); diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index 466bb59b76be..c910ebf48992 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -1075,7 +1075,7 @@ SwContentFrame *SwFrame::FindNextCnt_( const bool _bInSameFootnote ) // handling for environments 'each footnote': // Assure that found next content frame belongs to the same footnotes const SwFootnoteFrame* pFootnoteFrameOfNext( pNxtCnt->FindFootnoteFrame() ); - const SwFootnoteFrame* pFootnoteFrameOfCurr( pThis->FindFootnoteFrame() ); + SwFootnoteFrame* pFootnoteFrameOfCurr(pThis->FindFootnoteFrame()); OSL_ENSURE( pFootnoteFrameOfCurr, "<SwFrame::FindNextCnt_() - unknown layout situation: current frame has to have an upper footnote frame." ); if ( pFootnoteFrameOfNext == pFootnoteFrameOfCurr ) @@ -1086,8 +1086,7 @@ SwContentFrame *SwFrame::FindNextCnt_( const bool _bInSameFootnote ) { // next content frame has to be the first content frame // in the follow footnote, which contains a content frame. - SwFootnoteFrame* pFollowFootnoteFrameOfCurr( - const_cast<SwFootnoteFrame*>(pFootnoteFrameOfCurr) ); + SwFootnoteFrame* pFollowFootnoteFrameOfCurr(pFootnoteFrameOfCurr); pNxtCnt = nullptr; do { pFollowFootnoteFrameOfCurr = pFollowFootnoteFrameOfCurr->GetFollow(); @@ -1219,13 +1218,12 @@ SwContentFrame* SwFrame::FindPrevCnt_() // handling for environments 'each footnote': // Assure that found next content frame belongs to the same footnotes const SwFootnoteFrame* pFootnoteFrameOfPrev( pPrevContentFrame->FindFootnoteFrame() ); - const SwFootnoteFrame* pFootnoteFrameOfCurr( pCurrContentFrame->FindFootnoteFrame() ); + SwFootnoteFrame* pFootnoteFrameOfCurr(pCurrContentFrame->FindFootnoteFrame()); if ( pFootnoteFrameOfPrev != pFootnoteFrameOfCurr ) { if ( pFootnoteFrameOfCurr->GetMaster() ) { - SwFootnoteFrame* pMasterFootnoteFrameOfCurr( - const_cast<SwFootnoteFrame*>(pFootnoteFrameOfCurr) ); + SwFootnoteFrame* pMasterFootnoteFrameOfCurr(pFootnoteFrameOfCurr); pPrevContentFrame = nullptr; // correct wrong loop-condition do { @@ -1507,7 +1505,7 @@ bool SwFrame::IsMoveable( const SwLayoutFrame* _pLayoutFrame ) const { // if fly frame has a follow (next linked fly frame) or can split, // frame is moveable. - SwFlyFrame* pFlyFrame = const_cast<SwLayoutFrame*>(_pLayoutFrame)->FindFlyFrame(); + const SwFlyFrame* pFlyFrame = _pLayoutFrame->FindFlyFrame(); if ( pFlyFrame->GetNextLink() || pFlyFrame->IsFlySplitAllowed() ) { bRetVal = true; diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index a9efde0d3708..c9b31e84599e 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3986,15 +3986,15 @@ SwFrame *SwTabFrame::FindLastContentOrTable() // We have to find the last content the hard way: OSL_ENSURE( pRet->IsCellFrame(), "SwTabFrame::FindLastContent failed" ); - const SwFrame* pRow = pRet->GetUpper(); + SwFrame* pRow = pRet->GetUpper(); while ( pRow && !pRow->GetUpper()->IsTabFrame() ) pRow = pRow->GetUpper(); - const SwContentFrame* pContentFrame = pRow ? static_cast<const SwLayoutFrame*>(pRow)->ContainsContent() : nullptr; + SwContentFrame* pContentFrame = pRow ? static_cast<SwLayoutFrame*>(pRow)->ContainsContent() : nullptr; pRet = nullptr; while ( pContentFrame && static_cast<const SwLayoutFrame*>(pRow)->IsAnLower( pContentFrame ) ) { - pRet = const_cast<SwContentFrame*>(pContentFrame); + pRet = pContentFrame; pContentFrame = pContentFrame->GetNextContentFrame(); } } @@ -4831,7 +4831,7 @@ static sal_uInt16 lcl_GetTopSpace( const SwRowFrame& rRow ) nTmpTopSpace = lcl_GetTopSpace( *static_cast<const SwRowFrame*>(pCurrLower->Lower()) ); else { - const SwAttrSet& rSet = const_cast<SwCellFrame*>(pCurrLower)->GetFormat()->GetAttrSet(); + const SwAttrSet& rSet = pCurrLower->GetFormat()->GetAttrSet(); const SvxBoxItem& rBoxItem = rSet.GetBox(); nTmpTopSpace = rBoxItem.CalcLineSpace( SvxBoxItemLine::TOP, true ); } @@ -4852,7 +4852,7 @@ static sal_uInt16 lcl_GetTopLineDist( const SwRowFrame& rRow ) nTmpTopLineDist = lcl_GetTopLineDist( *static_cast<const SwRowFrame*>(pCurrLower->Lower()) ); else { - const SwAttrSet& rSet = const_cast<SwCellFrame*>(pCurrLower)->GetFormat()->GetAttrSet(); + const SwAttrSet& rSet = pCurrLower->GetFormat()->GetAttrSet(); const SvxBoxItem& rBoxItem = rSet.GetBox(); nTmpTopLineDist = rBoxItem.GetDistance( SvxBoxItemLine::TOP ); } @@ -4876,7 +4876,7 @@ static sal_uInt16 lcl_GetBottomLineSize( const SwRowFrame& rRow ) } else { - const SwAttrSet& rSet = const_cast<SwCellFrame*>(pCurrLower)->GetFormat()->GetAttrSet(); + const SwAttrSet& rSet = pCurrLower->GetFormat()->GetAttrSet(); const SvxBoxItem& rBoxItem = rSet.GetBox(); nTmpBottomLineSize = rBoxItem.CalcLineSpace( SvxBoxItemLine::BOTTOM, true ) - rBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ); @@ -4901,7 +4901,7 @@ static sal_uInt16 lcl_GetBottomLineDist( const SwRowFrame& rRow ) } else { - const SwAttrSet& rSet = const_cast<SwCellFrame*>(pCurrLower)->GetFormat()->GetAttrSet(); + const SwAttrSet& rSet = pCurrLower->GetFormat()->GetAttrSet(); const SvxBoxItem& rBoxItem = rSet.GetBox(); nTmpBottomLineDist = rBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ); } diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 14096ae308ce..aa1a255fc421 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -962,7 +962,7 @@ static bool lcl_UpDown( SwPaM *pPam, const SwContentFrame *pStart, else { // set the Point on the Content-Node assert(pCnt->IsNoTextFrame()); - SwContentNode *const pCNd = const_cast<SwContentNode*>(static_cast<SwNoTextFrame const*>(pCnt)->GetNode()); + const SwContentNode* const pCNd = static_cast<SwNoTextFrame const*>(pCnt)->GetNode(); if ( fnNxtPrv == lcl_GetPrvCnt ) pPam->GetPoint()->AssignEndIndex(*pCNd); else @@ -1768,9 +1768,9 @@ bool SwFrame::WannaRightPage() const } if ( !pDesc ) { - SwPageFrame *pPrv = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(pPage->GetPrev())); + const SwPageFrame* pPrv = static_cast<const SwPageFrame*>(pPage->GetPrev()); if( pPrv && pPrv->IsEmptyPage() ) - pPrv = static_cast<SwPageFrame*>(pPrv->GetPrev()); + pPrv = static_cast<const SwPageFrame*>(pPrv->GetPrev()); if( pPrv ) pDesc = pPrv->GetPageDesc()->GetFollow(); else @@ -1864,7 +1864,7 @@ sal_uInt16 SwFrame::GetVirtPageNum() const if ( pDesc->GetNumOffset() && pDesc->GetDefinedIn() ) { - auto pMod = const_cast<sw::BroadcastingModify*>(pDesc->GetDefinedIn()); + auto pMod = pDesc->GetDefinedIn(); sw::VirtPageNumHint aHint(pPage); pMod->CallSwClientNotify(aHint); if(aHint.GetPage()) @@ -1947,9 +1947,9 @@ bool SwRootFrame::MakeTableCursors( SwTableCursor& rTableCursor ) const SwTabFrame *pTable = rUnion.GetTable(); // Skip any repeated headlines in the follow: - SwLayoutFrame* pRow = pTable->IsFollow() ? + const SwLayoutFrame* pRow = pTable->IsFollow() ? pTable->GetFirstNonHeadlineRow() : - const_cast<SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pTable->Lower())); + static_cast<const SwLayoutFrame*>(pTable->Lower()); while ( pRow ) { @@ -1993,7 +1993,7 @@ bool SwRootFrame::MakeTableCursors( SwTableCursor& rTableCursor ) } } } - pRow = static_cast<SwLayoutFrame*>(pRow->GetNext()); + pRow = static_cast<const SwLayoutFrame*>(pRow->GetNext()); } } @@ -2084,14 +2084,14 @@ void SwRootFrame::CalcFrameRects(SwShellCursor const& rCursor, SwRects & rRects, SwSortedObjs aSortObjs; if ( pStartFrame->IsInFly() ) { - const SwAnchoredObject* pObj = pStartFrame->FindFlyFrame(); + SwAnchoredObject* pObj = pStartFrame->FindFlyFrame(); OSL_ENSURE( pObj, "No Start Object." ); - if (pObj) aSortObjs.Insert( *const_cast<SwAnchoredObject*>(pObj) ); - const SwAnchoredObject* pObj2 = pEndFrame->FindFlyFrame(); + if (pObj) aSortObjs.Insert( *pObj ); + SwAnchoredObject* pObj2 = pEndFrame->FindFlyFrame(); OSL_ENSURE( pObj2, "SwRootFrame::CalcFrameRects(..) - FlyFrame missing - looks like an invalid selection" ); if ( pObj2 != nullptr && pObj2 != pObj ) { - aSortObjs.Insert( *const_cast<SwAnchoredObject*>(pObj2) ); + aSortObjs.Insert(*pObj2); } } |