sw/source/core/doc/docnew.cxx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
New commits: commit 00520330140f6895f617f973b7c881620e339714 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Jun 29 19:17:04 2025 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Jun 29 20:37:50 2025 +0200 Use more concrete type to avoid a query And drop a comment obsoleted by commit 1ac5353bbb25bd9ff0ab0e157b3dbd0da325480a (Use weak reference to SfxObjectShell in SfxEventHint to avoid use-after-free, 2024-03-11). Change-Id: I7512328fea6c6bd5c893163616826c571e7b78bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187154 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 0d3d4fc5fcc0..0032bbff3f06 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -919,10 +919,7 @@ rtl::Reference<SfxObjectShell> SwDoc::CreateCopy(bool bCallInitNew, bool bEmpty) rtl::Reference<SwDoc> xRet( new SwDoc ); xRet->SetInMailMerge(IsInMailMerge()); - // we have to use pointer here, since the callee has to decide whether - // SfxObjectShellLock or SfxObjectShellRef should be used sometimes the - // object will be returned with refcount set to 0 ( if no DoInitNew is done ) - rtl::Reference<SfxObjectShell> pRetShell = new SwDocShell(*xRet, SfxObjectCreateMode::STANDARD); + rtl::Reference<SwDocShell> pRetShell = new SwDocShell(*xRet, SfxObjectCreateMode::STANDARD); if( bCallInitNew ) { // it could happen that DoInitNew creates model, @@ -936,12 +933,9 @@ rtl::Reference<SfxObjectShell> SwDoc::CreateCopy(bool bCallInitNew, bool bEmpty) xRet->ReplaceStyles(*this); - rtl::Reference<SwXTextDocument> const xThisSet(GetDocShell()->GetBaseModel()); - uno::Reference<beans::XPropertySet> const xRetSet( - pRetShell->GetBaseModel(), uno::UNO_QUERY_THROW); uno::Sequence<beans::PropertyValue> aInteropGrabBag; - xThisSet->getPropertyValue(u"InteropGrabBag"_ustr) >>= aInteropGrabBag; - xRetSet->setPropertyValue(u"InteropGrabBag"_ustr, uno::Any(aInteropGrabBag)); + GetDocShell()->GetBaseModel()->getPropertyValue(u"InteropGrabBag"_ustr) >>= aInteropGrabBag; + pRetShell->GetBaseModel()->setPropertyValue(u"InteropGrabBag"_ustr, uno::Any(aInteropGrabBag)); if( !bEmpty ) {