From d465d5b1cc962f56534d685fe8af5f26083fb7ba Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 30 Oct 2019 09:40:23 +0000 Subject: can avoid intermediate vcl::Window use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I51d1a84fdf7a8c7d204691d52dec10db051c3b00 Reviewed-on: https://gerrit.libreoffice.org/81745 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sfx2/inc/guisaveas.hxx | 4 ++-- sfx2/source/doc/guisaveas.cxx | 30 +++++++++++------------------- sfx2/source/view/ipclient.cxx | 3 +-- sfx2/source/view/viewprn.cxx | 3 +-- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx index ac9df75aea61..5e7355709680 100644 --- a/sfx2/inc/guisaveas.hxx +++ b/sfx2/inc/guisaveas.hxx @@ -37,7 +37,7 @@ namespace com { namespace sun { namespace star { } } } } -namespace vcl { class Window; } +namespace weld { class Window; } class ModelData_Impl; class SfxStoringHelper @@ -79,7 +79,7 @@ public: bool rDefaultIsAlien ); static css::uno::Reference GetModelXWindow(const css::uno::Reference& rModel); - static vcl::Window* GetModelWindow( const css::uno::Reference< css::frame::XModel >& xModel ); + static weld::Window* GetModelWindow( const css::uno::Reference< css::frame::XModel >& xModel ); }; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 573ee808d474..6a9012f63c1f 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -650,8 +650,7 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus ) && GetMediaDescr().find( OUString("VersionComment") ) == GetMediaDescr().end() ) { // notify the user that SaveAs is going to be done - vcl::Window* pWin = SfxStoringHelper::GetModelWindow(m_xModel); - std::unique_ptr xMessageBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + std::unique_ptr xMessageBox(Application::CreateMessageDialog(SfxStoringHelper::GetModelWindow(m_xModel), VclMessageType::Question, VclButtonsType::OkCancel, SfxResId(STR_NEW_FILENAME_SAVE))); if (xMessageBox->run() == RET_OK) nResult = STATUS_SAVEAS; @@ -848,8 +847,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode, SfxFilterFlags nMust = getMustFlags( nStoreMode ); SfxFilterFlags nDont = getDontFlags( nStoreMode ); - vcl::Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel ); - weld::Window* pFrameWin = pWin ? pWin->GetFrameWeld() : nullptr; + weld::Window* pFrameWin = SfxStoringHelper::GetModelWindow(m_xModel); if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) { if ( ( nStoreMode & PDFEXPORT_REQUESTED ) && !aPreselectedFilterPropsHM.empty() ) @@ -1390,8 +1388,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo || SignatureState::NOTVALIDATED == nDocumentSignatureState || SignatureState::PARTIAL_OK == nDocumentSignatureState) { - vcl::Window* pWin = SfxStoringHelper::GetModelWindow( xModel ); - std::unique_ptr xMessageBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + std::unique_ptr xMessageBox(Application::CreateMessageDialog(SfxStoringHelper::GetModelWindow(xModel), VclMessageType::Question, VclButtonsType::YesNo, SfxResId(RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE))); if (xMessageBox->run() != RET_YES) { @@ -1796,8 +1793,8 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod if ( !SvtSaveOptions().IsWarnAlienFormat() ) return true; - vcl::Window* pWin = SfxStoringHelper::GetModelWindow( xModel ); - SfxAlienWarningDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, aOldUIName, aDefExtension, bDefIsAlien); + weld::Window* pWin = SfxStoringHelper::GetModelWindow(xModel); + SfxAlienWarningDialog aDlg(pWin, aOldUIName, aDefExtension, bDefIsAlien); return aDlg.run() == RET_OK; } @@ -1825,20 +1822,15 @@ uno::Reference SfxStoringHelper::GetModelXWindow(const uno::Refere return uno::Reference(); } -vcl::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel ) +weld::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel ) { - VclPtr pWin; + weld::Window* pWin = nullptr; - try { - uno::Reference xWindow = GetModelXWindow(xModel); - if ( xWindow.is() ) - { - VCLXWindow* pVCLWindow = comphelper::getUnoTunnelImplementation( xWindow ); - if ( pVCLWindow ) - pWin = pVCLWindow->GetWindow(); - } + try + { + pWin = Application::GetFrameWeld(GetModelXWindow(xModel)); } - catch ( const uno::Exception& ) + catch (const uno::Exception&) { } diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index d810bd44374e..be9b43cd9035 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -878,8 +878,7 @@ sal_Int64 SfxInPlaceClient::GetAspect() const ErrCode SfxInPlaceClient::DoVerb( long nVerb ) { - vcl::Window* pWin = m_pViewSh->GetWindow(); - SfxErrorContext aEc(ERRCTX_SO_DOVERB, pWin ? pWin->GetFrameWeld() : nullptr, RID_SO_ERRCTX); + SfxErrorContext aEc(ERRCTX_SO_DOVERB, m_pViewSh->GetFrameWeld(), RID_SO_ERRCTX); ErrCode nError = ERRCODE_NONE; if ( m_xImp->m_xObject.is() ) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 31befa4e2987..2347f69584c4 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -350,8 +350,7 @@ void SfxPrinterController::jobFinished( css::view::PrintableState nState ) OUString aMsg( SfxResId(STR_NOSTARTPRINTER) ); if ( !m_bApi ) { - vcl::Window* pWindow = mpViewShell->GetWindow(); - std::unique_ptr xBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + std::unique_ptr xBox(Application::CreateMessageDialog(mpViewShell->GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, aMsg)); xBox->run(); -- cgit