sw/qa/extras/uiwriter/data/TC-table-converttotable.docx |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 23 +++++++++++++++ sw/source/core/doc/DocumentRedlineManager.cxx | 3 ++ sw/source/core/unocore/unocrsrhelper.cxx | 24 ++++++++-------- 4 files changed, 38 insertions(+), 12 deletions(-)
New commits: commit 03b29d4ddb99337c4d54b241020c95e8b2a66991 Author: László Németh <[email protected]> AuthorDate: Mon Jul 12 13:27:05 2021 +0200 Commit: László Németh <[email protected]> CommitDate: Tue Jul 13 13:31:57 2021 +0200 tdf#143278 DOCX: support tracked table (row) insertion Rejection of tracked table insertion didn't remove the table from the text, leaving an empty table at the place of the insertion. Regression from commit c4cf85766453982f1aa94a7f2cb22af19ed100be "sw: fix crash due to redlines on tables on ooo121112-2.docx". Follow-up to commit 05366b8e6683363688de8708a3d88cf144c7a2bf "tdf#60382 sw offapi: add change tracking of table/row deletion" and commit 896c2199d9f0a28bd405dd2d1068f5e2973cdf06 "tdf#79069 DOCX: support tracked table (row) deletion". Change-Id: I4c7242c432d1ad329a56a9a5423aa68fd7f94420 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118773 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> diff --git a/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx b/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx new file mode 100644 index 000000000000..9af615ba8268 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 869c4d304a28..50af673c5d0e 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -4022,6 +4022,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineTableRowDeletionWithDOCXExport) assertXPath(pXmlDoc, "//page[1]//body/tab", 0); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineDOCXTableInsertion) +{ + // load a 3-row table inserted with change tracking by text to table conversion + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-converttotable.docx"); + + // check table count (1) + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + + // reject the text insertions of the table cells (also reject deletion of the tabulated + // text source of the table, which was used by the tracked text to table conversion) + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(10), pEditShell->GetRedlineCount()); + while (pEditShell->GetRedlineCount()) + pEditShell->RejectRedline(0); + + // rejecting all text insertions must undo the table insertion + // This was 1 (remaining empty table after rejecting all table text insertions) + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf128335) { // Load the bugdoc, which has 3 textboxes. diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index a8c8044c86c5..0196ea4d5e30 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -733,7 +733,10 @@ namespace rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore)); if( pCSttNd && pCEndNd ) + { rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); + lcl_DeleteTrackedTableRow( aPam.End() ); + } else if (pCSttNd && !pCEndNd) { aPam.GetBound().nContent.Assign( nullptr, 0 ); diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 1c9f9d4b28db..aaa223d02894 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -1398,24 +1398,24 @@ void makeTableRowRedline( SwTableLine& rTableLine, else if ( rRedlineType == u"TableRowDelete" ) { eType = RedlineType::TableRowDelete; - - // set table row property "HasTextChangesOnly" to false - // to handle tracked deletion of the table row on the UI - const SvxPrintItem *pHasTextChangesOnlyProp = - rTableLine.GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); - if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() ) - { - SvxPrintItem aSetTracking(RES_PRINT, false); - SwPosition aPos( *rTableLine.GetTabBoxes()[0]->GetSttNd() ); - SwCursor aCursor( aPos, nullptr ); - pDoc->SetRowNotTracked( aCursor, aSetTracking ); - } } else { throw lang::IllegalArgumentException(); } + // set table row property "HasTextChangesOnly" to false + // to handle tracked deletion or insertion of the table row on the UI + const SvxPrintItem *pHasTextChangesOnlyProp = + rTableLine.GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); + if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() ) + { + SvxPrintItem aSetTracking(RES_PRINT, false); + SwPosition aPos( *rTableLine.GetTabBoxes()[0]->GetSttNd() ); + SwCursor aCursor( aPos, nullptr ); + pDoc->SetRowNotTracked( aCursor, aSetTracking ); + } + comphelper::SequenceAsHashMap aPropMap( rRedlineProperties ); std::size_t nAuthor = 0; OUString sAuthor; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
