sd/source/ui/view/sdview3.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
New commits: commit a614740c09d99daf1a68f4642fded2c0c7608916 Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Fri May 5 11:12:36 2023 +0300 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon May 8 13:42:29 2023 +0200 tdf#155144 sd: Don't reset table styles on RTF pasting Regression of daab698b346e5e40b67f1e15c796c4e399ccaf8a ("sd: replace hardcoded table styles with xml file"). The problem is with the temp SdDrawDocument reusing the document's DrawDocShell. Before the mentioned commit we used to insert the default table styles directly into the style sheets pool, and that didn't affect the dest document as each SdDrawDocument maintains its own pool. However, after that commit we go through ODF import which use the document model which happens to be the dest document. This results with all the default table styles being replaced, with all their formatting being reset, and all existing tables being reset to the default style following the disposal of the original styles. At the same time, this leaves the temp SdDrawDocument with no table styles in its pool, and so the newly inserted table ends up with no style assigned. Change-Id: I9bebae929ec3d54e0139dd212ad0ad1dfe815caa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151417 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> (cherry picked from commit 86b48c757906c3ef647f3d5e2579ac1fef1bf55b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151376 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index f96cd774a92a..9b94d9cca8b5 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -1571,19 +1571,17 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, bool View::PasteRTFTable( const ::tools::SvRef<SotTempStream>& xStm, SdrPage* pPage, SdrInsertFlags nPasteOptions ) { - SdDrawDocument aModel( DocumentType::Impress, mpDocSh ); - aModel.NewOrLoadCompleted(DocCreationMode::New); - aModel.GetItemPool().SetDefaultMetric(MapUnit::Map100thMM); - aModel.InsertPage(aModel.AllocPage(false).get()); + DrawDocShellRef xShell = new DrawDocShell(SfxObjectCreateMode::INTERNAL, false, DocumentType::Impress); + xShell->DoInitNew(); - Reference< XComponent > xComponent( new SdXImpressDocument( &aModel, true ) ); - aModel.setUnoModel( Reference< XInterface >::query( xComponent ) ); + SdDrawDocument* pModel = xShell->GetDoc(); + pModel->GetItemPool().SetDefaultMetric(MapUnit::Map100thMM); + pModel->InsertPage(pModel->AllocPage(false).get()); - CreateTableFromRTF( *xStm, &aModel ); - bool bRet = Paste(aModel, maDropPos, pPage, nPasteOptions); + CreateTableFromRTF(*xStm, pModel); + bool bRet = Paste(*pModel, maDropPos, pPage, nPasteOptions); - xComponent->dispose(); - xComponent.clear(); + xShell->DoClose(); return bRet; }