tdf#150876 sw: track new rows inserted after a tracked row insertion
New row insertions after an already tracked row insertion weren't tracked. Regression from commitb251228d2e"tdf#150666 sw: allow to delete tracked table row insertions" Follow-up to commitdbc82c02eb"tdf#143358 sw: track insertion of empty table rows". Change-Id: Ic365e70aa7808237a1bd69d0101a098ae70e8813 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139594 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
+3
-1
@@ -1493,7 +1493,9 @@ public:
|
||||
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
|
||||
/// bAll: delete all table rows without selection
|
||||
void SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNotTracked, bool bAll = false );
|
||||
/// bIns: insert table row
|
||||
void SetRowNotTracked( const SwCursor& rCursor,
|
||||
const SvxPrintItem &rNotTracked, bool bAll = false, bool bIns = false );
|
||||
/// don't call SetRowNotTracked() for rows with tracked row change
|
||||
static bool HasRowNotTracked( const SwCursor& rCursor );
|
||||
void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet );
|
||||
|
||||
@@ -2086,6 +2086,35 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150666)
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRows()->getCount());
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150666_regression)
|
||||
{
|
||||
// load a table with tracked insertion of an empty row
|
||||
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-rowadd.docx");
|
||||
|
||||
// check table count
|
||||
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
|
||||
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
|
||||
uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
|
||||
|
||||
// check table row count
|
||||
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getRows()->getCount());
|
||||
|
||||
// select the second row (tracked table row insertion)
|
||||
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
|
||||
pWrtShell->Down(/*bSelect=*/false);
|
||||
|
||||
// insert a new table row with track changes
|
||||
dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {});
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTable->getRows()->getCount());
|
||||
|
||||
dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
|
||||
|
||||
// This was 4 (the inserted table row wasn't tracked)
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRows()->getCount());
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf144748)
|
||||
{
|
||||
// load a table with an empty row, and an empty line before the table
|
||||
|
||||
@@ -598,7 +598,7 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& rBoxes,
|
||||
SwPaM aPaM(*pNewTableLine->GetTabBoxes()[0]->GetSttNd(), SwNodeOffset(1));
|
||||
pDoc->getIDocumentContentOperations().InsertString( aPaM,
|
||||
OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR) );
|
||||
pDoc->SetRowNotTracked( aCursor, aSetTracking );
|
||||
pDoc->SetRowNotTracked( aCursor, aSetTracking, /*bAll=*/false, /*bIns=*/true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,7 +578,8 @@ bool SwDoc::HasRowNotTracked( const SwCursor& rCursor )
|
||||
return false;
|
||||
}
|
||||
|
||||
void SwDoc::SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNew, bool bAll )
|
||||
void SwDoc::SetRowNotTracked( const SwCursor& rCursor,
|
||||
const SvxPrintItem &rNew, bool bAll, bool bIns )
|
||||
{
|
||||
SwTableNode* pTableNd = rCursor.GetPoint()->GetNode().FindTableNode();
|
||||
if( !pTableNd )
|
||||
@@ -601,28 +602,34 @@ void SwDoc::SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNew,
|
||||
GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
|
||||
}
|
||||
|
||||
bool bInsertDummy = !bAll && !bIns &&
|
||||
// HasTextChangesOnly == false, i.e. a tracked row change (deletion, if bIns == false)
|
||||
!rNew.GetValue();
|
||||
std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
|
||||
aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
|
||||
|
||||
SwRedlineTable::size_type nRedlinePos = 0;
|
||||
for( auto pLn : aRowArr )
|
||||
{
|
||||
// tdf#150666 row insertion from the same author needs special handling,
|
||||
// tdf#150666 deleting row insertion from the same author needs special handling,
|
||||
// because removing redlines of the author can result an empty line,
|
||||
// which doesn't contain any redline for the tracked row
|
||||
bool bDeletionOfOwnRowInsertion = false;
|
||||
SwRedlineTable::size_type nPos = pLn->UpdateTextChangesOnly(nRedlinePos);
|
||||
if ( nPos != SwRedlineTable::npos )
|
||||
if ( bInsertDummy )
|
||||
{
|
||||
SwDoc* pDoc = pLn->GetFrameFormat()->GetDoc();
|
||||
IDocumentRedlineAccess& rIDRA = pDoc->getIDocumentRedlineAccess();
|
||||
const SwRedlineTable& aRedlineTable = rIDRA.GetRedlineTable();
|
||||
SwRangeRedline* pTmp = aRedlineTable[ nPos ];
|
||||
if ( RedlineType::Insert == pTmp->GetType() &&
|
||||
rIDRA.GetRedlineAuthor() == pTmp->GetRedlineData().GetAuthor() &&
|
||||
pTmp->GetText()[0] == CH_TXT_TRACKED_DUMMY_CHAR )
|
||||
SwRedlineTable::size_type nPos = pLn->UpdateTextChangesOnly(nRedlinePos);
|
||||
if ( nPos != SwRedlineTable::npos )
|
||||
{
|
||||
bDeletionOfOwnRowInsertion = true;
|
||||
SwDoc* pDoc = pLn->GetFrameFormat()->GetDoc();
|
||||
IDocumentRedlineAccess& rIDRA = pDoc->getIDocumentRedlineAccess();
|
||||
const SwRedlineTable& aRedlineTable = rIDRA.GetRedlineTable();
|
||||
SwRangeRedline* pTmp = aRedlineTable[ nPos ];
|
||||
if ( RedlineType::Insert == pTmp->GetType() &&
|
||||
rIDRA.GetRedlineAuthor() == pTmp->GetRedlineData().GetAuthor() &&
|
||||
pTmp->GetText()[0] == CH_TXT_TRACKED_DUMMY_CHAR )
|
||||
{
|
||||
bDeletionOfOwnRowInsertion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,9 +638,7 @@ void SwDoc::SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem &rNew,
|
||||
// add a redline with invisible text CH_TXT_TRACKED_DUMMY_CHAR
|
||||
// (unless the table is part of a bigger deletion, where the
|
||||
// new redline can cause a problem)
|
||||
if ( !bAll &&
|
||||
// HasTextChangesOnly == false, i.e. a tracked row insertion or deletion
|
||||
!rNew.GetValue() && (pLn->IsEmpty() || bDeletionOfOwnRowInsertion ) )
|
||||
if ( bInsertDummy && (pLn->IsEmpty() || bDeletionOfOwnRowInsertion ) )
|
||||
{
|
||||
SwNodeIndex aInsPos( *(pLn->GetTabBoxes()[0]->GetSttNd()), 1 );
|
||||
RedlineFlags eOld = getIDocumentRedlineAccess().GetRedlineFlags();
|
||||
|
||||
Reference in New Issue
Block a user