tdf#150673 sw tracked table column: color deletion
Reset also HasTextChangesOnly property of the table cell
at rejecting the deletion.
Follow-up to commit f348440e17debacbcba9153e238e010e8c020bdc
"tdf#146120 sw: show tracked table changes with different color".
Change-Id: I7bc1643b13a54934d1538f39e0a0d4516c88fa31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151638
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index bd67448..0e01f1c 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -552,6 +552,8 @@ public:
sal_uInt16 nMaxStep ) const
{ return const_cast<SwTableBox*>(this)->FindEndOfRowSpan( rTable, nMaxStep ); }
void RegisterToFormat( SwFormat& rFormat ) ;
// get redline type
RedlineType GetRedlineType() const;
};
class SwCellFrame;
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 52fefec..4dd0a42d 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2603,6 +2603,42 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150673_RedlineTableColumnDeletionWi
pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "//page[1]//body/tab");
assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1);
// check removing HasTextChangesOnly at acceptance of the deletion
// Undo, and delete the column without change tracking
dispatchCommand(mxComponent, ".uno:Undo", {});
// table column exists again
discardDumpedLayout();
pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "//page[1]//body/tab");
assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
// reject deletion, setting HasTextChangesOnly to TRUE
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount());
pEditShell->RejectRedline(0);
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), pEditShell->GetRedlineCount());
// delete table column with enabled change tracking
dispatchCommand(mxComponent, ".uno:SelectColumn", {});
dispatchCommand(mxComponent, ".uno:Delete", {});
// Table column still exists
discardDumpedLayout();
pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "//page[1]//body/tab");
assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
// reject the deletion of the content of the first cell
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount());
pEditShell->AcceptRedline(0);
// table column is still not deleted
discardDumpedLayout();
pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "//page[1]//body/tab");
assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128335)
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 8ce8a48..ac0bfe5 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -509,6 +509,21 @@ namespace
if ( !pBox )
return;
// tracked column deletion
const SvxPrintItem *pHasBoxTextChangesOnlyProp =
pBox->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
// table cell property "HasTextChangesOnly" is set and its value is false
if ( bRejectDeletion && pHasBoxTextChangesOnlyProp &&
!pHasBoxTextChangesOnlyProp->GetValue() )
{
SvxPrintItem aUnsetTracking(RES_PRINT, true);
SwCursor aCursor( *pPos, nullptr );
pPos->GetDoc().SetBoxAttr( aCursor, aUnsetTracking );
}
// tracked row deletion
const SwTableLine* pLine = pBox->GetUpper();
const SvxPrintItem *pHasTextChangesOnlyProp =
pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index c4134fb..47e56b3 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -6540,7 +6540,17 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP
bBack = true;
}
}
else if ( bBack && IsCellFrame() && !getRootFrame()->IsHideRedlines() &&
else if ( IsCellFrame() && !getRootFrame()->IsHideRedlines() )
{
RedlineType eType = static_cast<const SwCellFrame*>(this)->GetTabBox()->GetRedlineType();
if ( RedlineType::Delete == eType || RedlineType::Insert == eType )
{
pCol = RedlineType::Delete == eType ? COL_AUTHOR_TABLE_DEL : COL_AUTHOR_TABLE_INS;
bBack = true;
}
}
if ( bBack && IsCellFrame() && !getRootFrame()->IsHideRedlines() &&
// skip cell background to show the row colored according to its tracked change
RedlineType::None != static_cast<const SwRowFrame*>(GetUpper())->GetTabLine()->GetRedlineType() )
{
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index d488197..83cb70f 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2960,6 +2960,23 @@ void SwTableBox::ActualiseValueBox()
}
}
RedlineType SwTableBox::GetRedlineType() const
{
const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
if ( aRedlineTable.empty() )
return RedlineType::None;
// check table row property "HasTextChangesOnly", if it's defined and its value is
// false, return with RedlineType::Delete
// TODO add support for RedlineType::Insert
const SvxPrintItem *pHasTextChangesOnlyProp =
GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() )
return RedlineType::Delete;
return RedlineType::None;
}
struct SwTableCellInfo::Impl
{
const SwTable * m_pTable;