From 472abf99a4d90d7a53316394a2e51a26b7e62345 Mon Sep 17 00:00:00 2001 From: László Németh Date: Fri, 26 May 2023 18:47:57 +0200 Subject: tdf#155341 sw tracked table column: add insertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All the inserted cells get a dummy redline to store the change tracking metadata, setting also the HasTextChangesOnly bit of the table box to FALSE. Follow-up to commit ffd8d20d368a885d6d786749278fa438573227a7 "tdf#150673 sw xmloff: import/export tracked table column". Change-Id: I55f5a44ac0ec040993a100156665f116355c235a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152336 Tested-by: László Németh Reviewed-by: László Németh --- sw/source/core/table/swnewtable.cxx | 16 ++++++++++++++++ sw/source/core/table/swtable.cxx | 34 ++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 14 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index cd98b4fb186a..6debaf7fa577 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -745,6 +747,20 @@ bool SwTable::NewInsertCol( SwDoc& rDoc, const SwSelBoxes& rBoxes, for( sal_uInt16 j = 0; j < nCnt; ++j ) { SwTableBox *pCurrBox = pLine->GetTabBoxes()[nInsPos+j]; + + // set tracked insertion by inserting a dummy redline + if ( rDoc.getIDocumentRedlineAccess().IsRedlineOn() ) + { + SwPosition aPos(*pCurrBox->GetSttNd()); + SwCursor aCursor( aPos, nullptr ); + SwNodeIndex aInsDummyPos(*pCurrBox->GetSttNd(), 1 ); + SwPaM aPaM(aInsDummyPos); + rDoc.getIDocumentContentOperations().InsertString( aPaM, + OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR) ); + SvxPrintItem aHasTextChangesOnly(RES_PRINT, false); + rDoc.SetBoxAttr( aCursor, aHasTextChangesOnly ); + } + if( bNewSpan ) { pCurrBox->setRowSpan( nLastRowSpan ); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index e5703eb7f039..ee4753b96d67 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2981,15 +2981,22 @@ void SwTableBox::ActualiseValueBox() SwRedlineTable::size_type SwTableBox::GetRedline() const { + const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); const SwStartNode *pSttNd = GetSttNd(); - if ( !pSttNd || GetRedlineType() == RedlineType::None ) + if ( aRedlineTable.empty() || !pSttNd ) + return SwRedlineTable::npos; + + // check table row property "HasTextChangesOnly", if it's defined and its value is + // false, return with the first redline of the cell + const SvxPrintItem *pHasTextChangesOnlyProp = + GetFrameFormat()->GetAttrSet().GetItem(RES_PRINT); + if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() ) return SwRedlineTable::npos; SwPosition aCellStart( *GetSttNd(), SwNodeOffset(0) ); SwPosition aCellEnd( *GetSttNd()->EndOfSectionNode(), SwNodeOffset(-1) ); SwNodeIndex pEndNodeIndex(aCellEnd.GetNode()); - const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); SwRedlineTable::size_type nRedlinePos = 0; for( ; nRedlinePos < aRedlineTable.size(); ++nRedlinePos ) { @@ -3012,18 +3019,17 @@ SwRedlineTable::size_type SwTableBox::GetRedline() const 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(RES_PRINT); - if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() ) - return RedlineType::Delete; - + SwRedlineTable::size_type nPos = GetRedline(); + if ( nPos != SwRedlineTable::npos ) + { + const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); + const SwRangeRedline* pRedline = aRedlineTable[ nPos ]; + if ( RedlineType::Delete == pRedline->GetType() || + RedlineType::Insert == pRedline->GetType() ) + { + return pRedline->GetType(); + } + } return RedlineType::None; } -- cgit