summaryrefslogtreecommitdiff
path: root/sw/source/core/undo/unredln.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/undo/unredln.cxx')
-rw-r--r--sw/source/core/undo/unredln.cxx38
1 files changed, 34 insertions, 4 deletions
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 8aae3c055b63..c66d8eed133e 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -26,6 +26,8 @@
#include <pam.hxx>
#include <ndtxt.hxx>
#include <txtfrm.hxx>
+#include <mvsave.hxx>
+#include <rolbck.hxx>
#include <UndoCore.hxx>
#include <UndoDelete.hxx>
#include <strings.hrc>
@@ -153,7 +155,8 @@ void SwUndoRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
rDoc.getIDocumentRedlineAccess().DeleteRedline(rPam, true, RedlineType::Any);
}
-SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId )
+SwUndoRedlineDelete::SwUndoRedlineDelete(
+ const SwPaM& rRange, SwUndoId const nUsrId, SwDeleteFlags const flags)
: SwUndoRedline( nUsrId != SwUndoId::EMPTY ? nUsrId : SwUndoId::DELETE, rRange ),
bCanGroup( false ), bIsDelim( false ), bIsBackspace( false )
{
@@ -174,6 +177,24 @@ SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId )
}
m_bCacheComment = false;
+ if (flags & SwDeleteFlags::ArtificialSelection)
+ {
+ InitHistory(rRange);
+ }
+}
+
+void SwUndoRedlineDelete::InitHistory(SwPaM const& rRedline)
+{
+ m_pHistory.reset(new SwHistory);
+ // try to rely on direction of rPam here so it works for
+ // backspacing/deleting consecutive characters
+ SaveFlyArr flys;
+ SaveFlyInRange(rRedline, *rRedline.GetMark(), flys, false, m_pHistory.get());
+ RestFlyInRange(flys, *rRedline.GetPoint(), &rRedline.GetPoint()->nNode, true);
+ if (m_pHistory->Count())
+ {
+ bCanGroup = false; // how to group history?
+ }
}
// bit of a hack, replace everything...
@@ -197,12 +218,21 @@ void SwUndoRedlineDelete::SetRedlineText(const OUString & rText)
void SwUndoRedlineDelete::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
rDoc.getIDocumentRedlineAccess().DeleteRedline(rPam, true, RedlineType::Any);
+ if (m_pHistory)
+ {
+ m_pHistory->TmpRollback(&rDoc, 0);
+ }
}
void SwUndoRedlineDelete::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
if (rPam.GetPoint() != rPam.GetMark())
{
+ if (m_pHistory) // if it was created before, it must be recreated now
+ {
+ rPam.Normalize(bIsBackspace); // to check the correct edge
+ InitHistory(rPam);
+ }
rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(*mpRedlData, rPam), false );
}
sw::UpdateFramesForAddDeleteRedline(rDoc, rPam);
@@ -212,7 +242,7 @@ bool SwUndoRedlineDelete::CanGrouping( const SwUndoRedlineDelete& rNext )
{
bool bRet = false;
if( SwUndoId::DELETE == mnUserId && mnUserId == rNext.mnUserId &&
- bCanGroup == rNext.bCanGroup &&
+ bCanGroup && rNext.bCanGroup &&
bIsDelim == rNext.bIsDelim &&
bIsBackspace == rNext.bIsBackspace &&
m_nSttNode == m_nEndNode &&
@@ -449,7 +479,7 @@ void SwUndoCompDoc::UndoImpl(::sw::UndoRedoContext & rContext)
bool bJoinText, bJoinPrev;
sw_GetJoinFlags(rPam, bJoinText, bJoinPrev);
- pUnDel.reset( new SwUndoDelete(rPam, false) );
+ pUnDel.reset( new SwUndoDelete(rPam, SwDeleteFlags::Default, false) );
if( bJoinText )
sw_JoinText(rPam, bJoinPrev);
@@ -466,7 +496,7 @@ void SwUndoCompDoc::UndoImpl(::sw::UndoRedoContext & rContext)
++rPam.GetPoint()->nNode;
rPam.GetBound().nContent.Assign( nullptr, 0 );
rPam.GetBound( false ).nContent.Assign( nullptr, 0 );
- pUnDel2.reset( new SwUndoDelete(rPam, true) );
+ pUnDel2.reset( new SwUndoDelete(rPam, SwDeleteFlags::Default, true) );
}
}
rPam.DeleteMark();