[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 23 14:16:02 UTC 2021
sw/qa/core/undo/data/table-copy-redline.odt |binary
sw/qa/core/undo/undo.cxx | 19 +++++++++++++++++++
sw/source/core/undo/untbl.cxx | 10 +++++++++-
3 files changed, 28 insertions(+), 1 deletion(-)
New commits:
commit ac1056f9d9a922660b84f20ea86e5aabbe0e8716
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 22 21:03:15 2021 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Mar 23 15:15:30 2021 +0100
tdf#133933 sw: fix crash on undo of redlined pasted table
This is just a crash fix, there is some deeper problem here around undo:
once redlining is on, overwriting table content during paste does not
delete the fly frames anchored to empty cells (see lcl_CpyBox()), and we
have the same problem on undo as well (see
SwUndoTableCpyTable::UndoImpl()). And node indexes are recorded before
inserting flys, so if they are not deleted, then the indexes don't
match.
Change-Id: I419e96c4d64f70a582358cab3808cea8b0e36649
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112939
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
(cherry picked from commit 140192fd5a2fc5e9d250d077d00bcebc014f7cbf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112810
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/sw/qa/core/undo/data/table-copy-redline.odt b/sw/qa/core/undo/data/table-copy-redline.odt
new file mode 100644
index 000000000000..f391687823aa
Binary files /dev/null and b/sw/qa/core/undo/data/table-copy-redline.odt differ
diff --git a/sw/qa/core/undo/undo.cxx b/sw/qa/core/undo/undo.cxx
index e43d154f3a66..6aacac27aa68 100644
--- a/sw/qa/core/undo/undo.cxx
+++ b/sw/qa/core/undo/undo.cxx
@@ -84,6 +84,25 @@ CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTextboxCutUndo)
CPPUNIT_ASSERT_EQUAL(pIndex1->GetIndex(), pIndex2->GetIndex());
}
+CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTableCopyRedline)
+{
+ // Given a document with two table cells and redlining enabled:
+ load(DATA_DIRECTORY, "table-copy-redline.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDocShell* pDocShell = pTextDoc->GetDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+
+ // When doing select-all, copy, paste and undo:
+ pWrtShell->SelAll();
+ rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+ pTransfer->Copy();
+ TransferableDataHelper aHelper(pTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+
+ // Without the accompanying fix in place, this test would have crashed.
+ pWrtShell->Undo();
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 85a797d5f509..d3cf5d465d01 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -2328,7 +2328,15 @@ void SwUndoTableCpyTable::UndoImpl(::sw::UndoRedoContext & rContext)
if( !pTableNd )
pTableNd = pSNd->FindTableNode();
- SwTableBox& rBox = *pTableNd->GetTable().GetTableBox( nSttPos );
+ SwTableBox* pBox = pTableNd->GetTable().GetTableBox( nSttPos );
+ if (!pBox)
+ {
+ SAL_WARN("sw.core",
+ "SwUndoTableCpyTable::UndoImpl: invalid start node index for table box");
+ continue;
+ }
+
+ SwTableBox& rBox = *pBox;
SwNodeIndex aInsIdx( *rBox.GetSttNd(), 1 );
rDoc.GetNodes().MakeTextNode( aInsIdx, rDoc.GetDfltTextFormatColl() );
More information about the Libreoffice-commits
mailing list