[Libreoffice-commits] core.git: sfx2/inc sfx2/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 30 15:59:43 UTC 2019


 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(-)

New commits:
commit d465d5b1cc962f56534d685fe8af5f26083fb7ba
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 30 09:40:23 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Oct 30 16:58:19 2019 +0100

    can avoid intermediate vcl::Window use
    
    Change-Id: I51d1a84fdf7a8c7d204691d52dec10db051c3b00
    Reviewed-on: https://gerrit.libreoffice.org/81745
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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<css::awt::XWindow> GetModelXWindow(const css::uno::Reference<css::frame::XModel>& 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<weld::MessageDialog> xMessageBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr,
+            std::unique_ptr<weld::MessageDialog> 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<weld::MessageDialog> xMessageBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr,
+            std::unique_ptr<weld::MessageDialog> 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<awt::XWindow> SfxStoringHelper::GetModelXWindow(const uno::Refere
     return uno::Reference<awt::XWindow>();
 }
 
-vcl::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel )
+weld::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel )
 {
-    VclPtr<vcl::Window> pWin;
+    weld::Window* pWin = nullptr;
 
-    try {
-        uno::Reference<awt::XWindow> xWindow = GetModelXWindow(xModel);
-        if ( xWindow.is() )
-        {
-            VCLXWindow* pVCLWindow = comphelper::getUnoTunnelImplementation<VCLXWindow>( 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<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr,
+                std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(mpViewShell->GetFrameWeld(),
                                                                          VclMessageType::Warning, VclButtonsType::Ok,
                                                                          aMsg));
                 xBox->run();


More information about the Libreoffice-commits mailing list