[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 19 18:48:23 UTC 2021
sw/qa/extras/uiwriter/uiwriter2.cxx | 79 ++++++++++++++++++++++++++
sw/source/core/doc/DocumentRedlineManager.cxx | 21 ++++++
2 files changed, 100 insertions(+)
New commits:
commit edae513ffaf7f78b282ef19cc962a2d3f2628781
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Mon May 31 14:38:31 2021 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Aug 19 20:47:48 2021 +0200
tdf#60382 sw: fix tracked row deletion at rejection
At rejection of a tracked deletion in a table row,
set HasTextChangesOnly property of the row to true.
Follow-up to commit 05366b8e6683363688de8708a3d88cf144c7a2bf
"tdf#60382 sw offapi: add change tracking of table/row deletion".
Change-Id: Iea78f8394890995cbc06209abd4bf5ea4ceb7357
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116446
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 6a4409647519e0466896fae4ffe2dc64edd53d9a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120722
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 37820608d74f..ebe526a4ffc8 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3578,6 +3578,85 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf128335)
pView->GetViewFrame()->GetDispatcher()->Execute(SID_CUT, SfxCallMode::SYNCHRON);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineTableRowDeletionWithReject)
+{
+ // load a 1-row table, and delete the row with enabled change tracking:
+ // now the row is not deleted silently, but keeps the deleted cell contents,
+ // and only accepting all of them will result the deletion of the table row.
+ SwDoc* pDoc = createDoc("tdf118311.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // turn on red-lining and show changes
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // check table
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//page[1]//body/tab");
+
+ // delete table row with enabled change tracking
+ // (HasTextChangesOnly property of the row will be false)
+ dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+
+ // Deleted text content with change tracking,
+ // but not table deletion
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//page[1]//body/tab");
+
+ // Save it and load it back.
+ reload("writer8", "tdf60382_tracked_table_deletion.odt");
+ pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ pDoc = pTextDoc->GetDocShell()->GetWrtShell()->GetDoc();
+
+ // reject the deletion of the content of the first cell
+ // HasTextChangesOnly property of the table row will be true
+ SwEditShell* const pEditShell(pDoc->GetEditShell());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount());
+ pEditShell->RejectRedline(0);
+
+ // Select and delete the content of the first cell
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:Delete", {});
+
+ // table row was still not deleted
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//page[1]//body/tab");
+
+ // accept all redlines
+ while (pEditShell->GetRedlineCount())
+ pEditShell->AcceptRedline(0);
+
+ // This was table row deletion instead of remaining the empty row
+ // (HasTextChangesOnly was false)
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//page[1]//body/tab");
+
+ // restore HasTextChangesOnly = false
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+
+ // accept all redlines
+ while (pEditShell->GetRedlineCount())
+ pEditShell->AcceptRedline(0);
+
+ // table row (and the 1-row table) was deleted finally
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//page[1]//body/tab", 0);
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf128603)
{
// Load the bugdoc, which has 3 textboxes.
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 26ad2204d786..4ed633d18753 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -457,6 +457,24 @@ namespace
}
}
+ // at rejection of a deletion in a table, remove the tracking of the table row
+ void lcl_RemoveTrackingOfTableRow( const SwPosition* pPos )
+ {
+ if ( const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox() )
+ {
+ const SwTableLine* pLine = pBox->GetUpper();
+ const SvxPrintItem *pHasTextChangesOnlyProp =
+ pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
+ // table row property "HasTextChangesOnly" is set and its value is false
+ if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() )
+ {
+ SvxPrintItem aUnsetTracking(RES_PRINT, true);
+ SwCursor aCursor( *pPos, nullptr );
+ pPos->GetDoc().SetRowNotTracked( aCursor, aUnsetTracking );
+ }
+ }
+ }
+
bool lcl_AcceptRedline( SwRedlineTable& rArr, SwRedlineTable::size_type& rPos,
bool bCallDelete,
const SwPosition* pSttRng = nullptr,
@@ -739,6 +757,9 @@ namespace
if( pRedl->GetExtraData() )
pRedl->GetExtraData()->Reject( *pRedl );
+ // remove tracking of the table row, if needed
+ lcl_RemoveTrackingOfTableRow( updatePaM.End() );
+
switch( eCmp )
{
case SwComparePosition::Inside:
More information about the Libreoffice-commits
mailing list