diff options
author | László Németh <nemeth@numbertext.org> | 2022-02-11 08:58:05 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-02-15 11:31:43 +0100 |
commit | c4f6fee3bea0d8618b5815e60304ff9359ccd21c (patch) | |
tree | cd00462adf417d5cb394b3f349037de2bdcb1733 | |
parent | 71e8a947753d359bd5b4d1174f4d6332eaf4a309 (diff) |
tdf#147435 sw: enable Accept Change for table selection
Accept/Reject Track Change options were only enabled for
table selections, if the first cell of the selected cell range
contains a redline. Now they are enabled, when arbitrary cell
of the table selection contains a redline.
Note: if the selected columns don't contain any redlines and
any tracked row changes, but the adjacent not selected columns
contain a redline, there is a false Enable.
Follow-up to commit 23846867ea32667ccf328c36142394dd6aaee8ba
"tdf#147182 sw: accept/reject all changes of a table selection".
Change-Id: I1d7af04aa3fe5232bb1ff7f9af6116bcdc621ae7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129811
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/uitest/table/tdf146145.py | 47 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewstat.cxx | 20 |
2 files changed, 66 insertions, 1 deletions
diff --git a/sw/qa/uitest/table/tdf146145.py b/sw/qa/uitest/table/tdf146145.py index a082ea780018..357ce82a45f7 100644 --- a/sw/qa/uitest/table/tdf146145.py +++ b/sw/qa/uitest/table/tdf146145.py @@ -107,4 +107,51 @@ class tdf146145(UITestCase): xToolkit.processEventsToIdle() self.assertEqual(len(tables[0].getRows()), 3) + def test_Related_tdf147182(self): + with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document: + + # Check enabling Accept/Reject Track Change icons + # and Accept Change/Reject Change context menu items + # on table rows with tracked deletion or insertion + + # enable Track Changes toolbar + self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes") + + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + # cursor at changed text: Accept Track Change is enabled + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # cursor in a changed row, but not at changed text: Accept Track Change is enabled now + self.xUITest.executeCommand(".uno:GoRight") + xToolkit.processEventsToIdle() + # This was false + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # delete first row + self.xUITest.executeCommand(".uno:AcceptTrackedChange") + xToolkit.processEventsToIdle() + # disabled Accept Track Change + while self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + self.assertFalse(self.is_enabled_Accept_Track_Change()) + + # delete first row + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:SelectAll") + xToolkit.processEventsToIdle() + # This was false + while not self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # delete all changes in the selected table + self.xUITest.executeCommand(".uno:AcceptTrackedChange") + xToolkit.processEventsToIdle() + while self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + # disabled Accept Track Change + self.assertFalse(self.is_enabled_Accept_Track_Change()) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx index f262df107ccb..2a672b23f8ed 100644 --- a/sw/source/uibase/uiview/viewstat.cxx +++ b/sw/source/uibase/uiview/viewstat.cxx @@ -389,10 +389,28 @@ void SwView::GetState(SfxItemSet &rSet) redline = nullptr; if( redline == nullptr ) { + // for table selections, GetCursor() gives only PaM of the first cell, + // so extend the redline limit to end of last cell of the selection + // TODO: adjust this for column selections, where the selected columns + // don't contain any redlines and any tracked row changes, but the + // adjacent not selected columns do to avoid false Enable + std::unique_ptr<SwPosition> pSelectionEnd; + if ( m_pWrtShell->IsTableMode() && + m_pWrtShell->GetTableCursor()->GetSelectedBoxesCount() ) + { + const SwSelBoxes& rBoxes = m_pWrtShell->GetTableCursor()->GetSelectedBoxes(); + const SwStartNode *pSttNd = rBoxes.back()->GetSttNd(); + const SwNode* pEndNode = pSttNd->GetNodes()[pSttNd->EndOfSectionIndex()]; + pSelectionEnd.reset(new SwPosition(*pEndNode)); + } + else + pSelectionEnd.reset( + new SwPosition(pCursor->End()->nNode, pCursor->End()->nContent)); + for(; index < table.size(); ++index ) { const SwRangeRedline* tmp = table[ index ]; - if( *tmp->Start() >= *pCursor->End()) + if( *tmp->Start() >= *pSelectionEnd ) break; if( tmp->HasMark() && tmp->IsVisible()) { |