diff options
-rw-r--r-- | sw/inc/docary.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 55 |
2 files changed, 34 insertions, 25 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index c3c4724ab505..80d21c23b72e 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -331,7 +331,7 @@ public: void Remove( size_type nPos ); void Remove( const SwRangeRedline* p ); - void DeleteAndDestroy( size_type nPos, size_type nLen = 1 ); + void DeleteAndDestroy(size_type nPos); void DeleteAndDestroyAll(); void dumpAsXml(struct _xmlTextWriter* pWriter) const; @@ -375,7 +375,7 @@ public: void Insert( SwExtraRedline* p ); - void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 ); + void DeleteAndDestroy( sal_uInt16 nPos); void DeleteAndDestroyAll(); void dumpAsXml(struct _xmlTextWriter* pWriter) const; diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 1e31e7150324..95a885b0985a 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -604,26 +604,32 @@ void SwRedlineTable::Remove( size_type nP ) void SwRedlineTable::DeleteAndDestroyAll() { - DeleteAndDestroy(0, size()); -} - -void SwRedlineTable::DeleteAndDestroy( size_type nP, size_type nL ) -{ - SwDoc* pDoc = nullptr; - if( !nP && nL && nL == size() ) - pDoc = maVector.front()->GetDoc(); - - for( vector_type::const_iterator it = maVector.begin() + nP; it != maVector.begin() + nP + nL; ++it ) + if (maVector.empty()) + return; + SwDoc *const pDoc = maVector.front()->GetDoc(); + while (!maVector.empty()) + { + auto const pRedline = maVector.back(); + maVector.erase(maVector.back()); + LOKRedlineNotification(RedlineNotification::Remove, pRedline); + delete pRedline; + } + if (pDoc && !pDoc->IsInDtor()) { - LOKRedlineNotification(RedlineNotification::Remove, *it); - delete *it; + SwViewShell* pSh(pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() ); + if (pSh) + { + pSh->InvalidateWindows(SwRect(0, 0, SAL_MAX_INT32, SAL_MAX_INT32)); + } } - maVector.erase( maVector.begin() + nP, maVector.begin() + nP + nL ); +} - SwViewShell* pSh; - if( pDoc && !pDoc->IsInDtor() && - nullptr != ( pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() ) ) - pSh->InvalidateWindows( SwRect( 0, 0, SAL_MAX_INT32, SAL_MAX_INT32 ) ); +void SwRedlineTable::DeleteAndDestroy(size_type const nP) +{ + auto const pRedline = maVector[nP]; + maVector.erase(maVector.begin() + nP); + LOKRedlineNotification(RedlineNotification::Remove, pRedline); + delete pRedline; } SwRedlineTable::size_type SwRedlineTable::FindNextOfSeqNo( size_type nSttPos ) const @@ -1873,7 +1879,7 @@ void SwExtraRedlineTable::Insert( SwExtraRedline* p ) //p->CallDisplayFunc(); } -void SwExtraRedlineTable::DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen ) +void SwExtraRedlineTable::DeleteAndDestroy(sal_uInt16 const nPos) { /* SwDoc* pDoc = 0; @@ -1881,10 +1887,8 @@ void SwExtraRedlineTable::DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen ) pDoc = front()->GetDoc(); */ - for( std::vector<SwExtraRedline*>::iterator it = m_aExtraRedlines.begin() + nPos; it != m_aExtraRedlines.begin() + nPos + nLen; ++it ) - delete *it; - - m_aExtraRedlines.erase( m_aExtraRedlines.begin() + nPos, m_aExtraRedlines.begin() + nPos + nLen ); + delete m_aExtraRedlines[nPos]; + m_aExtraRedlines.erase(m_aExtraRedlines.begin() + nPos); /* SwViewShell* pSh; @@ -1896,7 +1900,12 @@ void SwExtraRedlineTable::DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen ) void SwExtraRedlineTable::DeleteAndDestroyAll() { - DeleteAndDestroy(0, m_aExtraRedlines.size()); + while (!m_aExtraRedlines.empty()) + { + auto const pRedline = m_aExtraRedlines.back(); + m_aExtraRedlines.pop_back(); + delete pRedline; + } } SwExtraRedline::~SwExtraRedline() |