From 3a727d26fd9eb6fa140bc3f5cadf3db079d42206 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 13 Apr 2023 11:39:25 +0100 Subject: adjust IFrameObject so it could reuse mxFrame for a reload of content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7eec3132a23faafd9a2878215a0a117a67bc9bf2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150343 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- sfx2/source/doc/iframe.cxx | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'sfx2/source/doc') diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index daa94e699974..0bea24b14c69 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -184,28 +184,31 @@ sal_Bool SAL_CALL IFrameObject::load( if (pDoc && pDoc->HasName()) sReferer = pDoc->GetMedium()->GetName(); - DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); uno::Reference xParentWindow(xFrame->getContainerWindow()); - VclPtr pParent = VCLUnoHelper::GetWindow(xParentWindow); - VclPtr pWin = VclPtr::Create( pParent, maFrmDescr.IsFrameBorderOn() ); - pWin->SetSizePixel( pParent->GetOutputSizePixel() ); - pWin->SetBackground(); - pWin->Show(); - - uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); - xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); - - // we must destroy the IFrame before the parent is destroyed - xWindow->addEventListener( this ); - - mxFrame = frame::Frame::create( mxContext ); - uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); - mxFrame->initialize( xWin ); - mxFrame->setName( maFrmDescr.GetName() ); - - uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY ); - if ( xFramesSupplier.is() ) - mxFrame->setCreator( xFramesSupplier ); + + if (!mxFrame.is()) + { + VclPtr pParent = VCLUnoHelper::GetWindow(xParentWindow); + VclPtr pWin = VclPtr::Create( pParent, maFrmDescr.IsFrameBorderOn() ); + pWin->SetSizePixel( pParent->GetOutputSizePixel() ); + pWin->SetBackground(); + pWin->Show(); + + uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); + xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); + + // we must destroy the IFrame before the parent is destroyed + xWindow->addEventListener( this ); + + mxFrame = frame::Frame::create( mxContext ); + uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); + mxFrame->initialize( xWin ); + mxFrame->setName( maFrmDescr.GetName() ); + + uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY ); + if ( xFramesSupplier.is() ) + mxFrame->setCreator( xFramesSupplier ); + } uno::Reference xInteractionHandler(task::InteractionHandler::createWithParent(mxContext, xParentWindow)); uno::Sequence < beans::PropertyValue > aProps{ -- cgit