sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 7 +++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-)
New commits: commit cfc851da557214286685cde26baaac6be70d8624 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Sep 6 09:31:07 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Sep 6 10:05:24 2022 +0200 crashtesting: fix DOCX export of forum-mso-en-11199.docx This went wrong in a4432eb0946c0bc775b3d30b634bef5d66544f8d (tdf#104823: support for sdt plain text fields, 2021-11-24), when we started to turn cell SDTs into a field containing the cell text, which now needs to work with redlining, even if the original DOCX file had no fields. The root cause was introduced earlier, in 0c84c60f48cf681daf467c0678a768711f22e5c3 (tdf#77419 DOCX table import: ignore right white space, 2020-01-21), which assumed that goRight(2, select=false) is the opposite of goLeft(1, false) + goLeft(1, true), which is not true for input fields where an input field with 2 chars will select 5 chars (not 1) when you do goLeft(1, true) with a cursor at the right edge of the field (2 chars of content + CH_TXT_ATR_INPUTFIELDSTART + CH_TXT_ATR_INPUTFIELDEND + the field's dummy character itself), as "going left" selects the entire field, not just 1 character. Fix the problem by replacing goRight() with re-positioning the cursor the way it was positioned before trimming whitespace a few lines above. Change-Id: Iaae8878e9801df95d3bc7465d3e8ad12c724a888 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139469 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx b/sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx new file mode 100644 index 000000000000..41d722299070 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index a2d5f2cca2b2..1bf487a1f3bc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -63,6 +63,13 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineSdtHeader) loadAndSave("inline-sdt-header.docx"); } +CPPUNIT_TEST_FIXTURE(Test, testCellSdtRedline) +{ + // Without the accompanying fix in place, this test would have failed with an assertion failure, + // we produced not-well-formed XML on save. + loadAndSave("cell-sdt-redline.docx"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index a93f435fca49..8966e096dd59 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2408,7 +2408,11 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con else break; } - xCur->goRight(2, false); + + if (rAppendContext.xInsertPosition.is()) + xCur->gotoRange(rAppendContext.xInsertPosition, false); + else + xCur->gotoEnd(false); } xCur->goLeft( 1 , true );