From ec277dfdda8acd08694b03a6b1fb88c5fede35d2 Mon Sep 17 00:00:00 2001 From: Balazs Santha Date: Fri, 2 Jul 2021 19:21:47 +0200 Subject: tdf#131771 sw: fix missing table style after copying and pasting the table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: László Németh --- 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(-) (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d5c3a210af42..361bf3494c37 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1268,7 +1268,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( const OUString& rTableName ); bool UnProtectCells( const SwSelBoxes& rBoxes ); diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 8838c54ec76e..6c98d5bed360 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(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 2fb74d2734d7..d6c37d252d36 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -4284,7 +4284,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; @@ -4307,7 +4307,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; -- cgit