sw/qa/extras/uiwriter/data/tdf149498.docx |binary sw/qa/extras/uiwriter/uiwriter5.cxx | 18 ++++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 +++-- 3 files changed, 21 insertions(+), 2 deletions(-)
New commits: commit 818f8f13128ba78769b4f542ed1efef658de38d9 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Jul 21 17:35:12 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Sat Jul 22 01:14:19 2023 +0200 tdf#149498 sw: fix Undo crash at bookmark over cells Importing DOCX files with bookmarks between w:p paragraph elements resulted bookmark ranges over cell boundaries within text tables, causing crash with Undo. Partial revert of commit 9e1e88ad5cf2dc0e9b188c60930445652a6c7519 to avoid bookmark ranges over cell boundaries, creating only collapsed bookmarks here, as before. Regression from commit 9e1e88ad5cf2dc0e9b188c60930445652a6c7519 "tdf#145720 DOCX export: fix loss of tracked moving". Note: to avoid of another assertion, skip testing with debug builds. Change-Id: I3ed6daa55323f20130fcee6cc24d00a480731d0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154743 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/data/tdf149498.docx b/sw/qa/extras/uiwriter/data/tdf149498.docx new file mode 100644 index 000000000000..b310e88aa735 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149498.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 88868f8086c2..dfe0cc80f7ec 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2589,6 +2589,24 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1); } +#ifndef DBG_UTIL +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) +{ + // load a table, and delete the first column with enabled change tracking: + // now the column is not deleted silently, but keeps the deleted cell content, + // and only accepting it will result the deletion of the table column. + createSwDoc("tdf149498.docx"); + + // select table, copy, paste and Undo + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Copy", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); + + // this would crash due to bookmark over cell boundary + dispatchCommand(mxComponent, ".uno:Undo", {}); +} +#endif + CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150673_RedlineTableColumnDeletionWithExport) { // load a table, and delete the first column with enabled change tracking: diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index ec1766f9e750..a9522e53db2c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -8454,10 +8454,11 @@ void DomainMapper_Impl::StartOrEndBookmark( const OUString& rId ) // then move the bookmark-End to the earlier paragraph if (IsOutsideAParagraph()) { - // keep bookmark range + // keep bookmark range, if it doesn't exceed cell boundary uno::Reference< text::XTextRange > xStart = xCursor->getStart(); xCursor->goLeft( 1, false ); - xCursor->gotoRange(xStart, true ); + if (m_nTableDepth == 0 || !m_bFirstParagraphInCell) + xCursor->gotoRange(xStart, true ); } uno::Reference< container::XNamed > xBkmNamed( xBookmark, uno::UNO_QUERY_THROW ); SAL_WARN_IF(aBookmarkIter->second.m_sBookmarkName.isEmpty(), "writerfilter.dmapper", "anonymous bookmark");