summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-02-09 12:15:33 +0100
committerLászló Németh <nemeth@numbertext.org>2022-02-09 21:39:30 +0100
commit23846867ea32667ccf328c36142394dd6aaee8ba (patch)
tree5127c6392a2948095aa3a621ecc6d555f8a38f77 /sw
parent2bb9ad2078e355b71ab25db0c46f3d0bb19cf6d4 (diff)
tdf#147182 sw: accept/reject all changes of a table selection
Selecting multiple cells of a text table which contain tracked text changes, and choosing Accept Track Change/Reject Track Change, only text changes of the first cell were accepted/rejected (a problem inherited from OOo). The fix allows to accept/reject also all tracked row deletions/insertions in the selected table rows by a single click. Note for manual testing: first cell of the selection should still contain a tracked change, otherwise Accept Track Change/ Reject Track Change menu items/icons aren't active. Change-Id: I11e71075f4144bba86dda690ec712a24ccf815dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129717 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter4.cxx53
-rw-r--r--sw/source/core/edit/edredln.cxx46
-rw-r--r--sw/source/uibase/uiview/view2.cxx14
3 files changed, 110 insertions, 3 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx
index e52318062a7d..6b0724eae54e 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -1533,6 +1533,59 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTableRemoveHasTextChangesOnly2)
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(14), pEditShell->GetRedlineCount());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf147182_AcceptAllChangesInTableSelection)
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-del-add.docx");
+ CPPUNIT_ASSERT(pDoc);
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ // check redline count
+ SwEditShell* const pEditShell(pDoc->GetEditShell());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(14), pEditShell->GetRedlineCount());
+
+ // 4 rows in Show Changes mode
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 4);
+
+ // Select the first table to get a table selection
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:AcceptTrackedChange", {});
+ Scheduler::ProcessEventsToIdle();
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ // Accepting tracked changes in the selected table results 3 rows
+ // This was 4 (only text changes of the first selected cell were accepted)
+ assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 3);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(8), pEditShell->GetRedlineCount());
+
+ // Undo: 4 rows again
+ pDoc->GetIDocumentUndoRedo().Undo();
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 4);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(14), pEditShell->GetRedlineCount());
+
+ // To check Undo of HasTextChangesOnly reject the same row results 3 rows
+ dispatchCommand(mxComponent, ".uno:Escape", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:RejectTrackedChange", {});
+ Scheduler::ProcessEventsToIdle();
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ // This was 4 (only text changes of the first selected cell were rejected)
+ assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 3);
+
+ // Undo: 4 rows again
+ pDoc->GetIDocumentUndoRedo().Undo();
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 4);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(14), pEditShell->GetRedlineCount());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf66405)
{
// Imported formula should have zero margins
diff --git a/sw/source/core/edit/edredln.cxx b/sw/source/core/edit/edredln.cxx
index 3fd94b4a64d5..835a1c37389c 100644
--- a/sw/source/core/edit/edredln.cxx
+++ b/sw/source/core/edit/edredln.cxx
@@ -90,7 +90,28 @@ bool SwEditShell::AcceptRedlinesInSelection()
{
CurrShell aCurr( this );
StartAllAction();
- bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
+ // in table selection mode, process the selected boxes in reverse order
+ // to allow accepting their text changes and the tracked row deletions
+ bool bRet = false;
+ if ( IsTableMode() )
+ {
+ const SwSelBoxes& rBoxes = GetTableCursor()->GetSelectedBoxes();
+ std::vector<std::unique_ptr<SwPaM>> vBoxes;
+ for(auto pBox : rBoxes)
+ {
+ if ( !pBox->IsEmpty() )
+ {
+ const SwStartNode *pSttNd = pBox->GetSttNd();
+ SwNode* pEndNode = pSttNd->GetNodes()[pSttNd->EndOfSectionIndex()];
+ vBoxes.push_back(std::unique_ptr<SwPaM>(new SwPaM(*pEndNode, 0, *pSttNd, 0)));
+ }
+ }
+
+ for (size_t i = 0; i < vBoxes.size(); ++i)
+ bRet |= GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *vBoxes[vBoxes.size()-i-1], true );
+ }
+ else
+ bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
EndAllAction();
return bRet;
}
@@ -99,7 +120,28 @@ bool SwEditShell::RejectRedlinesInSelection()
{
CurrShell aCurr( this );
StartAllAction();
- bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
+ bool bRet = false;
+ // in table selection mode, process the selected boxes in reverse order
+ // to allow rejecting their text changes and the tracked row insertions
+ if ( IsTableMode() )
+ {
+ const SwSelBoxes& rBoxes = GetTableCursor()->GetSelectedBoxes();
+ std::vector<std::unique_ptr<SwPaM>> vBoxes;
+ for(auto pBox : rBoxes)
+ {
+ if ( !pBox->IsEmpty() )
+ {
+ const SwStartNode *pSttNd = pBox->GetSttNd();
+ SwNode* pEndNode = pSttNd->GetNodes()[pSttNd->EndOfSectionIndex()];
+ vBoxes.push_back(std::unique_ptr<SwPaM>(new SwPaM(*pEndNode, 0, *pSttNd, 0)));
+ }
+ }
+
+ for (size_t i = 0; i < vBoxes.size(); ++i)
+ bRet |= GetDoc()->getIDocumentRedlineAccess().RejectRedline( *vBoxes[vBoxes.size()-i-1], true );
+ }
+ else
+ bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
EndAllAction();
return bRet;
}
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 088de02af581..17acec2e3da7 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -805,10 +805,22 @@ void SwView::Execute(SfxRequest &rReq)
if( pCursor->HasMark() && nRedline == SwRedlineTable::npos)
{
- if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
+ bool bAccept = FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot;
+ SwUndoId eUndoId = bAccept ? SwUndoId::ACCEPT_REDLINE : SwUndoId::REJECT_REDLINE;
+ SwWrtShell& rSh = GetWrtShell();
+ SwRewriter aRewriter;
+ bool bTableSelection = rSh.IsTableMode();
+ if ( bTableSelection )
+ {
+ aRewriter.AddRule(UndoArg1, SwResId( STR_REDLINE_TABLECHG ));
+ rSh.StartUndo( eUndoId, &aRewriter);
+ }
+ if ( bAccept )
m_pWrtShell->AcceptRedlinesInSelection();
else
m_pWrtShell->RejectRedlinesInSelection();
+ if ( bTableSelection )
+ rSh.EndUndo( eUndoId, &aRewriter);
}
else
{