diff options
author | László Németh <nemeth@numbertext.org> | 2022-03-28 11:35:35 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-03-28 17:12:22 +0200 |
commit | eda1a7aeff42c08e02295e5a8353a6d86a61a118 (patch) | |
tree | 0433e0de0fb18d31ffe471f1b81d7b5768eed58c | |
parent | 70507d8dabbb92c26a1db116bfb0dc633869d93e (diff) |
tdf#148228 sw: fix Undo of tracked table deletion in Hide Changes mode
In Hide Changes mode, tables didn't reappear during
Undo of their tracked deletion, only by saving and
reloading the document.
Follow-up to commit 0c6221e1545e7b96d9df23cdc24302c28ae935b8
"tdf#148227 sw: fix Undo of tracked row deletion in Hide Changes mode".
Change-Id: Ifdc25ab4ae0be25a0c7559ee05b6af2e4f1aa8cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132169
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/undo/untbl.cxx | 20 |
2 files changed, 28 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 1559aab9887e..839106e5d41c 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -2354,7 +2354,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146962) // only a single row is visible again assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1); - // check Undo + // tdf#148227 check Undo of tracked table row deletion dispatchCommand(mxComponent, ".uno:Undo", {}); discardDumpedLayout(); @@ -2406,6 +2406,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147347) pXmlDoc = parseLayoutDump(); // no visible row again assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 0); + + // tdf#148228 check Undo of tracked table deletion + + dispatchCommand(mxComponent, ".uno:Undo", {}); + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + // This was 0 + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014) diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 213d17c72060..6e1b421e9517 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -949,14 +949,20 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox ) pFormat->InvalidateInSwCache(RES_ATTRSET_CHG); + // table without table frame + bool bHiddenTable = true; + // for safety, invalidate all TableFrames SwIterator<SwTabFrame,SwFormat> aIter( *pFormat ); for( SwTabFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() ) + { if( pLast->GetTable() == &rTable ) { pLast->InvalidateAll(); pLast->SetCompletePaint(); + bHiddenTable = false; } + } // fill FrameFormats with defaults (0) pFormat = nullptr; @@ -983,7 +989,19 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox ) m_bModifyBox = false; if ( bHideChanges ) - aTmpBox.MakeFrames( rTable ); + { + if ( bHiddenTable ) + { + SwTableNode* pTableNode = rTable.GetTableNode(); + pTableNode->DelFrames(); + SwNodeIndex aTableIdx( *pTableNode->EndOfSectionNode(), 1 ); + pTableNode->MakeOwnFrames(&aTableIdx); + } + else + { + aTmpBox.MakeFrames( rTable ); + } + } } void SaveTable::SaveContentAttrs( SwDoc* pDoc ) |