sw/inc/doc.hxx | 2 +- sw/inc/swtable.hxx | 2 +- sw/source/core/doc/tblrwcl.cxx | 3 ++- sw/source/core/docnode/ndcopy.cxx | 1 + sw/source/core/docnode/ndtbl.cxx | 4 ++-- sw/source/core/edit/edglss.cxx | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-)
New commits: commit 15fbc6f2dbf114247a89cd3d4d3360c9c00a4390 Author: Balazs Santha <santha.bal...@simonyi.bme.hu> AuthorDate: Fri Jul 2 19:21:47 2021 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Aug 12 13:46:56 2021 +0200 tdf#131771 sw: fix missing table style after copying and pasting the table This fixes the loss of table style setting when copying and then pasting a table. Change-Id: Ie678a269b4cdcddfd73a5d6a27ef9fcb55dcaa46 Change-Id: I48208337ee14fde30417fa3999f56999cc5eda19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118336 Tested-by: Jenkins Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120373 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index c94e5f04c5f3..6ff73c35cb8c 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1269,7 +1269,7 @@ public: bool InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, const SwTable* pCpyTable, bool bCpyName = false, - bool bCorrPos = false ); + bool bCorrPos = false, const OUString& rStyleName = "" ); void UnProtectCells( std::u16string_view rTableName ); bool UnProtectCells( const SwSelBoxes& rBoxes ); diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index fd3cb0367a67..23930d19b7f3 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -278,7 +278,7 @@ public: const bool bPerformValidCheck = false ) const; // Copy selected boxes to another document. bool MakeCopy( SwDoc&, const SwPosition&, const SwSelBoxes&, - bool bCpyName = false ) const; + bool bCpyName = false, const OUString& rStyleName = "" ) const; // Copy table in this bool InsTable( const SwTable& rCpyTable, const SwNodeIndex&, SwUndoTableCpyTable* pUndo ); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 18eab679a289..7b5367255fda 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -2045,7 +2045,7 @@ void SwTable::CopyHeadlineIntoTable( SwTableNode& rTableNd ) bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos, const SwSelBoxes& rSelBoxes, - bool bCpyName ) const + bool bCpyName, const OUString& rStyleName ) const { // Find all Boxes/Lines FndBox_ aFndBox( nullptr, nullptr ); @@ -2081,6 +2081,7 @@ bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos, pNewTable->SetTableStyleName(pTableNd->GetTable().GetTableStyleName()); + pTableNd->GetTable().SetTableStyleName(rStyleName); if( auto pSwDDETable = dynamic_cast<const SwDDETable*>(this) ) { // A DDE-Table is being copied diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 5b3c9edbd9db..91bb99d696b6 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -271,6 +271,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc& rDoc, const SwNodeIndex& rIdx ) const SwNodeIndex aInsPos( *pEndNd ); SwTable& rTable = pTableNd->GetTable(); + rTable.SetTableStyleName(GetTable().GetTableStyleName()); rTable.RegisterToFormat( *pTableFormat ); rTable.SetRowsToRepeat( GetTable().GetRowsToRepeat() ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 3ddfd2019d17..d6005e273192 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -4283,7 +4283,7 @@ void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode ) * This method is called by edglss.cxx/fecopy.cxx */ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, - const SwTable* pCpyTable, bool bCpyName, bool bCorrPos ) + const SwTable* pCpyTable, bool bCpyName, bool bCorrPos, const OUString& rStyleName ) { bool bRet; @@ -4306,7 +4306,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, { ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); bRet = pSrcTableNd->GetTable().MakeCopy( *this, rInsPos, rBoxes, - bCpyName ); + bCpyName, rStyleName ); } if( pUndo && bRet ) diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 536a0c1643ff..47791dc69a49 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -190,7 +190,7 @@ bool SwEditShell::CopySelToDoc( SwDoc& rInsDoc ) break; } } - bRet = rInsDoc.InsCopyOfTable( aPos, aBoxes, nullptr, bCpyTableNm ); + bRet = rInsDoc.InsCopyOfTable( aPos, aBoxes, nullptr, bCpyTableNm, false, pTableNd->GetTable().GetTableStyleName() ); } else bRet = false;