summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-07-12 13:27:05 +0200
committerGabor Kelemen <kelemen.gabor2@nisz.hu>2021-09-01 12:40:59 +0200
commit8564ef201fd38736f9f192b724c42d236a855662 (patch)
treea87357896b44d9ff59089eb31e06daf3b210579e
parentd3111c9ff66e9aabdfb8e7b330a1311a935be78f (diff)
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 <nemeth@numbertext.org> (cherry picked from commit 03b29d4ddb99337c4d54b241020c95e8b2a66991) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118801 (cherry picked from commit 21c56b7412fda90350732737f2f11cbaa7abad46) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121420 Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r--sw/qa/extras/uiwriter/data/TC-table-converttotable.docxbin0 -> 14913 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx23
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx3
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx24
4 files changed, 38 insertions, 12 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 3bd70a0d970a..245862605d51 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3602,6 +3602,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 4ed633d18753..8c60dae20292 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -725,7 +725,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 f18f05a5f02f..8385bb71eb32 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1402,24 +1402,24 @@ void makeTableRowRedline( SwTableLine& rTableLine,
else if ( rRedlineType == "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;