include/sfx2/objsh.hxx | 4 ++-- sfx2/source/appl/appopen.cxx | 6 +++--- sfx2/source/doc/objcont.cxx | 4 +--- sfx2/source/doc/objmisc.cxx | 24 +++++++++++++++--------- 4 files changed, 21 insertions(+), 17 deletions(-)
New commits: commit 3f66a801aeab257705922998e518398d27e4d698 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Mar 11 09:52:56 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Mar 11 18:35:27 2021 +0100 keep SfxObjectShell::GetDialogParent ret as an awt::XWindow instead of extracting the vcl::Window impl details from it Change-Id: Ia13c1559861ab2a65a2108c8ccd704cba711916c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112329 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index b21f7bf4bb69..40715f29e6ac 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -88,7 +88,7 @@ namespace sfx2 class StyleManager; } -namespace vcl { class Window; } +namespace com::sun::star::awt { class XWindow; } namespace com::sun::star::beans { struct PropertyValue; } namespace com::sun::star::document { struct CmisVersion; } namespace com::sun::star::document { class XDocumentProperties; } @@ -574,7 +574,7 @@ public: virtual css::uno::Sequence< OUString > GetEventNames(); - vcl::Window* GetDialogParent( SfxMedium const * pMedium=nullptr ); + css::uno::Reference<css::awt::XWindow> GetDialogParent(SfxMedium const* pMedium = nullptr); static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD ); static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD ); static css::uno::Reference< css::lang::XComponent > diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 4a6c1f403bbb..025316846d3d 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -206,9 +206,9 @@ ErrCode CheckPasswd_Impl if ( bIsEncrypted ) { - vcl::Window* pWin = pDoc ? pDoc->GetDialogParent( pFile ) : nullptr; - if ( pWin ) - pWin->Show(); + css::uno::Reference<css::awt::XWindow> xWin(pDoc ? pDoc->GetDialogParent(pFile) : nullptr); + if (xWin) + xWin->setVisible(true); nRet = ERRCODE_SFX_CANTGETPASSWD; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 04255063fd3f..f7f69f595e85 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -26,7 +26,6 @@ #include <comphelper/fileurl.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> -#include <vcl/window.hxx> #include <svl/style.hxx> #include <svl/intitem.hxx> @@ -523,8 +522,7 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG ) { const OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).replaceAll( "$(ARG1)", aTemplName ) ); - vcl::Window *pWin = GetDialogParent(); - QueryTemplateBox aBox(pWin ? pWin->GetFrameWeld() : nullptr, sMessage); + QueryTemplateBox aBox(Application::GetFrameWeld(GetDialogParent()), sMessage); if (RET_YES == aBox.run()) bLoad = true; } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index b4321576b3b8..81298eb8ff11 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -28,6 +28,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <sal/log.hxx> +#include <com/sun/star/awt/XTopWindow.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -1602,18 +1603,18 @@ bool SfxObjectShell::AdjustMacroMode() return pImpl->aMacroMode.adjustMacroMode( xInteraction ); } -vcl::Window* SfxObjectShell::GetDialogParent( SfxMedium const * pLoadingMedium ) +css::uno::Reference<css::awt::XWindow> SfxObjectShell::GetDialogParent( SfxMedium const * pLoadingMedium ) { - VclPtr<vcl::Window> pWindow; + css::uno::Reference<css::awt::XWindow> xWindow; SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet(); const SfxUnoFrameItem* pUnoItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pSet, SID_FILLFRAME, false); if ( pUnoItem ) { const uno::Reference < frame::XFrame >& xFrame( pUnoItem->GetFrame() ); - pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + xWindow = xFrame->getContainerWindow(); } - if ( !pWindow ) + if (!xWindow) { SfxFrame* pFrame = nullptr; const SfxFrameItem* pFrameItem = SfxItemSet::GetItem<SfxFrameItem>(pSet, SID_DOCFRAME, false); @@ -1632,22 +1633,27 @@ vcl::Window* SfxObjectShell::GetDialogParent( SfxMedium const * pLoadingMedium ) } if ( pFrame ) + { // get topmost window - pWindow = VCLUnoHelper::GetWindow( pFrame->GetFrameInterface()->getContainerWindow() ); + xWindow = pFrame->GetFrameInterface()->getContainerWindow(); + } } - if ( pWindow ) + if (xWindow) { // this frame may be invisible, show it if it is allowed const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pSet, SID_HIDDEN, false); if ( !pHiddenItem || !pHiddenItem->GetValue() ) { - pWindow->Show(); - pWindow->ToTop(); + xWindow->setVisible(true); + css::uno::Reference<css::awt::XTopWindow> xTopWindow(xWindow, uno::UNO_QUERY); + SAL_WARN_IF(!xTopWindow, "sfx.appl", "XTopWindow not available from XWindow"); + if (xTopWindow) + xTopWindow->toFront(); } } - return pWindow; + return xWindow; } void SfxObjectShell::SetCreateMode_Impl( SfxObjectCreateMode nMode ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits