[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 21 12:37:29 UTC 2021
sw/inc/doc.hxx | 3 -
sw/qa/extras/layout/layout.cxx | 55 ++++++++++++++++++++++++++
sw/source/core/doc/DocumentRedlineManager.cxx | 23 ++++++++++
sw/source/core/docnode/ndtbl1.cxx | 11 ++++-
4 files changed, 89 insertions(+), 3 deletions(-)
New commits:
commit 9994120c8d0fe8c5a029390ad7411b99c18ff5c9
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Mon Sep 20 13:11:24 2021 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Tue Sep 21 14:36:56 2021 +0200
tdf#144347 sw: fix tracked deletion of table with tracked content
When a table contained tracked content already, its tracked
deletion (or cut) didn't work correctly, if the deletion
contained also the text before or after the table: accepting
the deletion left an empty table in the text, also Hide Changes
showed an empty table before that in the place of the deleted
text.
Follow-up of commit f481c2c8e74bded11fac754e493560391229dbcd
"df#144057 sw track changes: hide deleted table rows".
Change-Id: If3294fe0316df7c065e7ff63290c1723386ec7ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122382
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
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;
More information about the Libreoffice-commits
mailing list