summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-05-17 16:08:39 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-06-21 11:32:58 +0200
commit1eb76797f64147be720dc73967600e3c39400cfc (patch)
treef7e12bf2df0f0b744fc6ada4557bfc24864355f3
parentsw: fix assert in SwObjectFormatterTextFrame (diff)
downloadcore-1eb76797f64147be720dc73967600e3c39400cfc.tar.gz
core-1eb76797f64147be720dc73967600e3c39400cfc.zip
tdf#147220 sw_redlinehide: update frames in ReplaceRangeImpl()
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134483 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 1f8795df957c18c5c06bf1d68d0d60b1d30f015d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134448 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 085ae759c1dc10a40cf3be95201c1028e847d012) Change-Id: Ie5d62eaec01a3b06ff1bd6070510384641ea7ad3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136175 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx38
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx5
2 files changed, 43 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c7642d54d9dd..5e99211ea450 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -129,6 +129,7 @@
#include <iodetect.hxx>
#include <wrthtml.hxx>
#include <dbmgr.hxx>
+#include <txtfrm.hxx>
namespace
{
@@ -4147,6 +4148,43 @@ static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xCompone
xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf147220)
+{
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ pWrtShell->Insert(u"él");
+
+ // hide and enable
+ lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+ lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+ CPPUNIT_ASSERT(pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT(
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+ CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
+
+ pWrtShell->GoStartSentence();
+ pWrtShell->SetMark();
+ pWrtShell->GoEndSentence();
+
+ // this did not remove the original text from the layout
+ pWrtShell->Replace(u"Él", false);
+
+ // currently the deleted text is before the replacement text, not sure if
+ // that is really required
+ CPPUNIT_ASSERT_EQUAL(OUString(u"élÉl"),
+ pWrtShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString(u"Él"),
+ static_cast<SwTextFrame const*>(pWrtShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->getLayoutFrame(nullptr))->GetText());
+
+ SwRedlineTable const& rRedlines(pDoc->getIDocumentRedlineAccess().GetRedlineTable());
+ CPPUNIT_ASSERT_EQUAL(SwRedlineTable::size_type(2), rRedlines.size());
+ CPPUNIT_ASSERT_EQUAL(RedlineType::Delete, rRedlines[0]->GetType());
+ CPPUNIT_ASSERT_EQUAL(OUString(u"él"), rRedlines[0]->GetText());
+ CPPUNIT_ASSERT_EQUAL(RedlineType::Insert, rRedlines[1]->GetType());
+ CPPUNIT_ASSERT_EQUAL(OUString(u"Él"), rRedlines[1]->GetText());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf135978)
{
SwDoc* pDoc = createDoc();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 80a3a97d242f..aefb3f438cef 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4422,7 +4422,12 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
m_rDoc.GetIDocumentUndoRedo().AppendUndo(
std::make_unique<SwUndoRedlineDelete>( aDelPam, SwUndoId::REPLACE ));
}
+ // add redline similar to DeleteAndJoinWithRedlineImpl()
+ std::shared_ptr<SwUnoCursor> const pCursor(m_rDoc.CreateUnoCursor(*aDelPam.GetMark()));
+ pCursor->SetMark();
+ *pCursor->GetPoint() = *aDelPam.GetPoint();
m_rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Delete, aDelPam ), true);
+ sw::UpdateFramesForAddDeleteRedline(m_rDoc, *pCursor);
*rPam.GetMark() = *aDelPam.GetMark();
if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())