diff options
-rw-r--r-- | sw/inc/doc.hxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 55 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 11 |
4 files changed, 89 insertions, 3 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 361bf3494c37..a09b74f4b16b 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1489,7 +1489,8 @@ public: void SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew ); static bool GetRowBackground( const SwCursor& rCursor, std::unique_ptr<SvxBrushItem>& rToFill ); /// rNotTracked = false means that the row was deleted or inserted with its tracked cell content - void SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNotTracked ); + /// bAll: delete all table rows without selection + void SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNotTracked, bool bAll = false ); void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet ); void SetTabLineStyle( const SwCursor& rCursor, const Color* pColor, bool bSetLine, diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 6c7e71df3ef2..de9cd406ee90 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -43,6 +43,7 @@ #include <docsh.hxx> #include <IDocumentLayoutAccess.hxx> #include <IDocumentDrawModelAccess.hxx> +#include <IDocumentRedlineAccess.hxx> #include <textboxhelper.hxx> #include <unoframe.hxx> #include <drawdoc.hxx> @@ -2336,6 +2337,60 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144057) assertXPath(pXmlDoc, "/root/page[4]/body/tab/row[6]/cell/txt/Text", "Portion", "B12"); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347) +{ + createSwDoc(DATA_DIRECTORY, "tdf144057.fodt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); + SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); + + // enable redlining + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + + // remove first table + SwEditShell* const pEditShell(pDoc->GetEditShell()); + for (int i = 0; i < 12; ++i) + pEditShell->AcceptRedline(0); + + pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + discardDumpedLayout(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // show tracked row deletions + assertXPath(pXmlDoc, "/root/page", 2); + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); + + // select all the text, including the texts before and after the table + // Note: this table contains tracked changes, which was a + // problem for the original OOo implementation of track changes, + // resulting empty tables after accepting the deletion of these tables. + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Delete", {}); + pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + + // table is deleted with change tracking: it still exists + assertXPath(pXmlDoc, "/root/page", 2); + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); + + // accept all deletions, removing the table completely + while (pEditShell->GetRedlineCount() > 0) + pEditShell->AcceptRedline(0); + + pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page", 1); + // This was 1 (bad empty table) + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 0); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137) { createSwDoc(DATA_DIRECTORY, "tdf109137.docx"); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 00608633c969..73e775f667e2 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -2265,6 +2265,29 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall pTextNd = aIdx.GetNode().GetContentNode(); } } + + // delete tables of the deletion explicitly, to avoid + // remaining empty tables after accepting the rejection + // and visible empty tables in Hide Changes mode + // (this was the case, if tables have already contained + // other tracked changes) + // FIXME: because of recursive nature of AppendRedline, + // this doesn't work for selections with multiple tables + if ( m_rDoc.GetIDocumentUndoRedo().DoesUndo() ) + { + SwNodeIndex aSttIdx( pStt->nNode.GetNode() ); + SwNodeIndex aEndIdx( pEnd->nNode.GetNode() ); + while ( aSttIdx < aEndIdx ) + { + if ( aSttIdx.GetNode().IsTableNode() ) + { + SvxPrintItem aNotTracked(RES_PRINT, false); + SwCursor aCursor( SwPosition(aSttIdx), nullptr ); + m_rDoc.SetRowNotTracked( aCursor, aNotTracked, /*bAll=*/true ); + } + ++aSttIdx; + } + } } bool const ret = maRedlineTable.Insert( pNewRedl ); assert(ret || !pNewRedl); diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 9922a5d97338..4e56000d760b 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -538,14 +538,21 @@ bool SwDoc::GetRowBackground( const SwCursor& rCursor, std::unique_ptr<SvxBrushI return bRet; } -void SwDoc::SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNew ) +void SwDoc::SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNew, bool bAll ) { SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode(); if( !pTableNd ) return; std::vector<SwTableLine*> aRowArr; // For Lines collecting - ::lcl_CollectLines( aRowArr, rCursor, true ); + if ( bAll ) + { + const SwTableLines &rLines = pTableNd->GetTable().GetTabLines(); + for ( auto pLine : rLines ) + aRowArr.push_back(pLine); + } + else + ::lcl_CollectLines( aRowArr, rCursor, true ); if( aRowArr.empty() ) return; |