sfx2/source/doc/iframe.cxx | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-)
New commits: commit 3a727d26fd9eb6fa140bc3f5cadf3db079d42206 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Apr 13 11:39:25 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Apr 13 16:45:18 2023 +0200 adjust IFrameObject so it could reuse mxFrame for a reload of content Change-Id: I7eec3132a23faafd9a2878215a0a117a67bc9bf2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150343 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> 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<css::awt::XWindow> xParentWindow(xFrame->getContainerWindow()); - VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(xParentWindow); - VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::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<vcl::Window> pParent = VCLUnoHelper::GetWindow(xParentWindow); + VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::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<task::XInteractionHandler> xInteractionHandler(task::InteractionHandler::createWithParent(mxContext, xParentWindow)); uno::Sequence < beans::PropertyValue > aProps{ commit f93edf343658abd489bde3639d2ffaefd50c0f99 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Apr 13 11:36:33 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Apr 13 16:45:05 2023 +0200 use parent window as dialog parent it makes no odds, but is more convenient for upcoming modification Change-Id: Ibc5333b137d2da089b3b701ff615c6ddf43063d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150342 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index 3502a116c299..daa94e699974 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -185,7 +185,8 @@ sal_Bool SAL_CALL IFrameObject::load( sReferer = pDoc->GetMedium()->GetName(); DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); - VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + uno::Reference<css::awt::XWindow> xParentWindow(xFrame->getContainerWindow()); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(xParentWindow); VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::Create( pParent, maFrmDescr.IsFrameBorderOn() ); pWin->SetSizePixel( pParent->GetOutputSizePixel() ); pWin->SetBackground(); @@ -206,7 +207,7 @@ sal_Bool SAL_CALL IFrameObject::load( if ( xFramesSupplier.is() ) mxFrame->setCreator( xFramesSupplier ); - uno::Reference<task::XInteractionHandler> xInteractionHandler(task::InteractionHandler::createWithParent(mxContext, xWin)); + uno::Reference<task::XInteractionHandler> xInteractionHandler(task::InteractionHandler::createWithParent(mxContext, xParentWindow)); uno::Sequence < beans::PropertyValue > aProps{ comphelper::makePropertyValue("PluginMode", sal_Int16(2)), comphelper::makePropertyValue("ReadOnly", true),