sd/source/ui/view/sdview3.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
New commits: commit 86b48c757906c3ef647f3d5e2579ac1fef1bf55b Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Fri May 5 11:12:36 2023 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Fri May 5 13:23:27 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> diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 6a1b776f4ead..06f07048455e 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -1568,19 +1568,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; }