diff options
author | László Németh <nemeth@numbertext.org> | 2023-05-26 18:47:57 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-06-02 03:57:30 +0200 |
commit | 472abf99a4d90d7a53316394a2e51a26b7e62345 (patch) | |
tree | ef686e0a6e5038e897ba2087da5a9db13a5ba7c2 /sw/source | |
parent | 389a8d52d9961f89c0b2847b30ee1ca59a8fdc80 (diff) |
tdf#155341 sw tracked table column: add insertion
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 <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/table/swnewtable.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 34 |
2 files changed, 36 insertions, 14 deletions
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 <swtable.hxx> +#include <swcrsr.hxx> #include <tblsel.hxx> #include <tblrwcl.hxx> #include <ndtxt.hxx> @@ -34,6 +35,7 @@ #include <IDocumentContentOperations.hxx> #include <IDocumentFieldsAccess.hxx> #include <IDocumentLayoutAccess.hxx> +#include <IDocumentRedlineAccess.hxx> #include <cstdlib> #include <vector> #include <set> @@ -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<SvxPrintItem>(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<SvxPrintItem>(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; } |