Kaydet (Commit) 1c0ea92c authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Caolán McNamara

ofz#1262 sw: DeleteAndJoin could delete proposed new redline

... because that calls CompressRedlines, which may combine the new
redline with a previous one.

In that case, the part of the new redline that follows the currently
handled overlap cannot be checked for overlaps with subsequent existing
redlines.

So prevent this with a new flag m_isForbidCompressRedlines and instead
call CompressRedlines() at the end of AppendRedline().

Change-Id: I7567962c31366ded9a433a13232d3db985745e43
Reviewed-on: https://gerrit.libreoffice.org/36901Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e436f713
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <swmodule.hxx> #include <swmodule.hxx>
#include <editsh.hxx> #include <editsh.hxx>
#include <vcl/layout.hxx> #include <vcl/layout.hxx>
#include <comphelper/flagguard.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -1226,10 +1227,15 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall ...@@ -1226,10 +1227,15 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall
// also dealt with when moving the indices. // also dealt with when moving the indices.
if( bCallDelete ) if( bCallDelete )
{ {
::comphelper::FlagGuard g(m_isForbidCompressRedlines);
mpRedlineTable->Insert( pNewRedl ); mpRedlineTable->Insert( pNewRedl );
m_rDoc.getIDocumentContentOperations().DeleteAndJoin( *pRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( *pRedl );
if( !mpRedlineTable->Remove( pNewRedl ) ) if( !mpRedlineTable->Remove( pNewRedl ) )
{
assert(false); // can't happen
pNewRedl = nullptr; pNewRedl = nullptr;
}
bCompress = true; // delayed compress
} }
delete pRedl; delete pRedl;
} }
...@@ -1253,10 +1259,15 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall ...@@ -1253,10 +1259,15 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall
{ {
// We insert temporarily so that pNew is // We insert temporarily so that pNew is
// also dealt with when moving the indices. // also dealt with when moving the indices.
::comphelper::FlagGuard g(m_isForbidCompressRedlines);
mpRedlineTable->Insert( pNewRedl ); mpRedlineTable->Insert( pNewRedl );
m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
if( !mpRedlineTable->Remove( pNewRedl ) ) if( !mpRedlineTable->Remove( pNewRedl ) )
{
assert(false); // can't happen
pNewRedl = nullptr; pNewRedl = nullptr;
}
bCompress = true; // delayed compress
n = 0; // re-initialize n = 0; // re-initialize
} }
bDec = true; bDec = true;
...@@ -1279,10 +1290,15 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall ...@@ -1279,10 +1290,15 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall
{ {
// We insert temporarily so that pNew is // We insert temporarily so that pNew is
// also dealt with when moving the indices. // also dealt with when moving the indices.
::comphelper::FlagGuard g(m_isForbidCompressRedlines);
mpRedlineTable->Insert( pNewRedl ); mpRedlineTable->Insert( pNewRedl );
m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
if( !mpRedlineTable->Remove( pNewRedl ) ) if( !mpRedlineTable->Remove( pNewRedl ) )
{
assert(false); // can't happen
pNewRedl = nullptr; pNewRedl = nullptr;
}
bCompress = true; // delayed compress
n = 0; // re-initialize n = 0; // re-initialize
bDec = true; bDec = true;
} }
...@@ -1777,6 +1793,11 @@ bool DocumentRedlineManager::AppendTableCellRedline( SwTableCellRedline* pNewRed ...@@ -1777,6 +1793,11 @@ bool DocumentRedlineManager::AppendTableCellRedline( SwTableCellRedline* pNewRed
void DocumentRedlineManager::CompressRedlines() void DocumentRedlineManager::CompressRedlines()
{ {
if (m_isForbidCompressRedlines)
{
return;
}
CHECK_REDLINE( *this ) CHECK_REDLINE( *this )
void (SwRangeRedline::*pFnc)(sal_uInt16, size_t) = nullptr; void (SwRangeRedline::*pFnc)(sal_uInt16, size_t) = nullptr;
......
...@@ -137,6 +137,7 @@ private: ...@@ -137,6 +137,7 @@ private:
sal_uInt16 mnAutoFormatRedlnCommentNo; /**< SeqNo for conjoining of AutoFormat-Redlines. sal_uInt16 mnAutoFormatRedlnCommentNo; /**< SeqNo for conjoining of AutoFormat-Redlines.
by the UI. Managed by SwAutoFormat! */ by the UI. Managed by SwAutoFormat! */
css::uno::Sequence <sal_Int8 > maRedlinePasswd; css::uno::Sequence <sal_Int8 > maRedlinePasswd;
bool m_isForbidCompressRedlines = false;
}; };
} }
......
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