Kaydet (Commit) 6e390564 authored tarafından Michael Stahl's avatar Michael Stahl

sw: avoid updating redlines to be empty in Overwrite()

The problem is that SwIndexReg::Update will correct a 1-character
redline in the middle of the newly-inserted part of the overwrite string
into a 0-length redline, which then a later SwTextNode::Update() will
correct in such a way that the whole thing becomes unsorted.

Just delete redlines in the entire overwrite range, which should help;
the aPam actually deletes them in the *last* character only which
seems rather unintentional anyway.

Change-Id: I61b6b312998e0779651d30f636312ef13556428c
üst 7b859bdb
......@@ -2357,8 +2357,12 @@ bool DocumentContentOperationsManager::MoveAndJoin( SwPaM& rPaM, SwPosition& rPo
return bRet;
}
// Overwrite only uses the point of the PaM, the mark is ignored; characters
// are replaced from point until the end of the node; at the end of the node,
// characters are inserted.
bool DocumentContentOperationsManager::Overwrite( const SwPaM &rRg, const OUString &rStr )
{
assert(rStr.getLength());
SwPosition& rPt = *const_cast<SwPosition*>(rRg.GetPoint());
if( m_rDoc.GetAutoCorrExceptWord() ) // Add to AutoCorrect
{
......@@ -2382,6 +2386,7 @@ bool DocumentContentOperationsManager::Overwrite( const SwPaM &rRg, const OUStri
? pNode->GetpSwpHints()->Count() : 0;
SwDataChanged aTmp( rRg );
SwIndex& rIdx = rPt.nContent;
sal_Int32 const nActualStart(rIdx.GetIndex());
sal_Int32 nStart = 0;
bool bOldExpFlg = pNode->IsIgnoreDontExpand();
......@@ -2443,14 +2448,14 @@ bool DocumentContentOperationsManager::Overwrite( const SwPaM &rRg, const OUStri
if (!m_rDoc.GetIDocumentUndoRedo().DoesUndo() &&
!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty())
{
SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
SwPaM aPam(rPt.nNode, nActualStart, rPt.nNode, rPt.nContent.GetIndex());
m_rDoc.getIDocumentRedlineAccess().DeleteRedline( aPam, true, USHRT_MAX );
}
else if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
{
// FIXME: this redline is WRONG: there is no DELETE, and the skipped
// characters are also included in aPam
SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
SwPaM aPam(rPt.nNode, nActualStart, rPt.nNode, rPt.nContent.GetIndex());
m_rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
}
......
......@@ -82,6 +82,8 @@ using namespace com::sun::star;
for(SwRangeRedline* j : rTable)
{
// check for empty redlines
// note: these can destroy sorting in SwTextNode::Update()
// if there's another one wihout mark on the same pos.
OSL_ENSURE( ( *(j->GetPoint()) != *(j->GetMark()) ) ||
( j->GetContentIdx() != nullptr ),
ERROR_PREFIX "empty redline" );
......
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