summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-12-13 12:09:10 +0100
committerLászló Németh <nemeth@numbertext.org>2021-12-14 16:09:11 +0100
commitc50dbeaac64a24c9afd9825fc91ace9482802557 (patch)
treeeb9f5799468b48ea188587ea80cb79c2179dbff6 /sw/source
parentdb37343aca0584cbaaf8703a91998d9938a3177d (diff)
tdf#146145 sw: 1-click Accept/Reject of table row changes
Now context menu of a changed table row shows Accept Change/ Reject Change menu items, which accept or reject the deletion or insertion of the table row. Also Accept Change/Reject Change icons of the Track Changes toolbar are enabled, and do the same, if the cursor is not before or in a tracked change. Add the following labels to the Undo actions: "Accept change: Row Inserted" "Accept change: Row Deleted" "Reject change: Row Inserted" "Reject change: Row Deleted" Change-Id: I12ae0158d059b044e430cc0ab86f0cf8931eadd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126770 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 95c003d75e0f8b255344715a35358072b5eba99d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126811 Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/uiview/view2.cxx55
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx9
2 files changed, 61 insertions, 3 deletions
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 6cb9340b758c..c6e2ff5db8f1 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -827,8 +827,59 @@ void SwView::Execute(SfxRequest &rReq)
else
pRedline = pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), &nRedline);
- assert(pRedline != nullptr);
- if (pRedline)
+ // accept or reject table row deletion or insertion
+ bool bTableChange = false;
+ if ( !pRedline && m_pWrtShell->IsCursorInTable() )
+ {
+ nRedline = 0;
+ auto pTabLine = pCursor->Start()->nNode.GetNode().GetTableBox()->GetUpper();
+
+ if ( RedlineType::None != pTabLine->GetRedlineType() )
+ {
+ nRedline = pTabLine->UpdateTextChangesOnly(nRedline);
+
+ if ( nRedline != SwRedlineTable::npos )
+ {
+ bTableChange = true;
+
+ SwWrtShell& rSh = GetWrtShell();
+ SwRewriter aRewriter;
+
+ aRewriter.AddRule(UndoArg1, SwResId(
+ rRedlineTable[nRedline]->GetType() == RedlineType::Delete
+ ? STR_REDLINE_TABLE_ROW_DELETE
+ : STR_REDLINE_TABLE_ROW_INSERT ));
+
+ SwUndoId eUndoId =
+ (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
+ ? SwUndoId::ACCEPT_REDLINE
+ : SwUndoId::REJECT_REDLINE;
+
+ rSh.StartUndo( eUndoId, &aRewriter);
+ while ( nRedline != SwRedlineTable::npos && nRedline < rRedlineTable.size() )
+ {
+ pRedline = rRedlineTable[nRedline];
+
+ // until next redline is not in the same row
+ SwTableBox* pTableBox = pRedline->Start()->nNode.GetNode().GetTableBox();
+ if ( !pTableBox || pTableBox->GetUpper() != pTabLine )
+ break;
+
+ if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
+ m_pWrtShell->AcceptRedline(nRedline);
+ else
+ m_pWrtShell->RejectRedline(nRedline);
+ }
+ rSh.EndUndo( eUndoId, &aRewriter);
+ }
+ }
+ }
+ else
+ {
+ assert(pRedline != nullptr);
+ }
+
+ if (pRedline && !bTableChange)
{
if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
m_pWrtShell->AcceptRedline(nRedline);
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index c2e94cb85479..e7ab14f6c3f8 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -408,8 +408,15 @@ void SwView::GetState(SfxItemSet &rSet)
{
// If the cursor position isn't on a redline, disable
// accepting/rejecting changes.
- if (nullptr == pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), nullptr))
+ SwTableBox* pTableBox;
+ if (nullptr == pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), nullptr) &&
+ // except in the case of an inserted or deleted table row
+ ( !m_pWrtShell->IsCursorInTable() ||
+ (pTableBox = pCursor->Start()->nNode.GetNode().GetTableBox() ) == nullptr ||
+ RedlineType::None == pTableBox->GetUpper()->GetRedlineType() ) )
+ {
bDisable = true;
+ }
}
// LibreOfficeKit wants to handle changes by index, so always allow here.