[Libreoffice-commits] core.git: include/vcl toolkit/inc toolkit/source uui/source vcl/inc vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Thu Apr 5 13:29:38 UTC 2018


 include/vcl/svapp.hxx                |    4 ++++
 include/vcl/unowrap.hxx              |    2 ++
 toolkit/inc/helper/unowrapper.hxx    |    1 +
 toolkit/source/helper/unowrapper.cxx |    5 +++++
 uui/source/iahndl-authentication.cxx |    6 +++---
 vcl/inc/salinst.hxx                  |    9 +++++++++
 vcl/inc/unx/gtk/gtkinst.hxx          |   13 +++++++++++--
 vcl/source/app/salvtables.cxx        |   12 ++++++++++++
 vcl/source/window/builder.cxx        |    5 +++++
 vcl/unx/gtk3/gtk3gtkinst.cxx         |    9 ++++++++-
 10 files changed, 60 insertions(+), 6 deletions(-)

New commits:
commit 6c5aa32a3ca51f9feecf2ed59944080e766b9ac2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Apr 5 12:40:52 2018 +0100

    enable mapping direct from awt::XWindow and weld::Window
    
    Change-Id: I33b1309a4b81bfd84449213099c4f3f781413e00
    Reviewed-on: https://gerrit.libreoffice.org/52456
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 98c123e217b5..6d39a6b67efe 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -53,6 +53,7 @@ namespace weld
     class Container;
     class MessageDialog;
     class Widget;
+    class Window;
 }
 class AllSettings;
 class DataChangedEvent;
@@ -85,6 +86,7 @@ namespace ui {
 namespace awt {
     class XToolkit;
     class XDisplayConnection;
+    class XWindow;
 }
 } } }
 
@@ -1397,6 +1399,8 @@ public:
 
     static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
                                                     VclButtonsType eButtonType, const OUString& rPrimaryMessage);
+
+    static weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
 private:
     DECL_STATIC_LINK( Application, PostEventHandler, void*, void );
 };
diff --git a/include/vcl/unowrap.hxx b/include/vcl/unowrap.hxx
index 090fb8c4242f..bc4cc3ca848e 100644
--- a/include/vcl/unowrap.hxx
+++ b/include/vcl/unowrap.hxx
@@ -40,6 +40,7 @@ namespace star {
 namespace awt {
     class XGraphics;
     class XToolkit;
+    class XWindow;
     class XWindowPeer;
 }
 namespace lang {
@@ -69,6 +70,7 @@ public:
     // Window
     virtual css::uno::Reference< css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) = 0;
     virtual void                SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer > xIFace ) = 0;
+    virtual VclPtr<vcl::Window> GetWindow(const css::uno::Reference<css::awt::XWindow>& rxWindow) = 0;
 
     virtual void                WindowDestroyed( vcl::Window* pWindow ) = 0;
 
diff --git a/toolkit/inc/helper/unowrapper.hxx b/toolkit/inc/helper/unowrapper.hxx
index f58494a70a08..31844f12cd35 100644
--- a/toolkit/inc/helper/unowrapper.hxx
+++ b/toolkit/inc/helper/unowrapper.hxx
@@ -54,6 +54,7 @@ public:
     // Window
     virtual css::uno::Reference< css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) override;
     virtual void        SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer> xIFace ) override;
+    virtual VclPtr<vcl::Window> GetWindow(const css::uno::Reference<css::awt::XWindow>& rxWindow) override;
 
     void                WindowDestroyed( vcl::Window* pWindow ) override;
 
diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx
index 151536d44baa..c389d04ed8fa 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -161,6 +161,11 @@ css::uno::Reference< css::awt::XWindowPeer> UnoWrapper::GetWindowInterface( vcl:
     return xPeer;
 }
 
+VclPtr<vcl::Window> UnoWrapper::GetWindow(const css::uno::Reference<css::awt::XWindow>& rWindow)
+{
+    return VCLUnoHelper::GetWindow(rWindow);
+}
+
 void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer> xIFace )
 {
     VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( xIFace );
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index 3897469c87ec..1852e67b6a6d 100644
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -664,7 +664,7 @@ UUIInteractionHelper::handlePasswordRequest(
     uno::Reference< task::XInteractionRequest > const & rRequest)
 {
     // parameters to be filled for the call to handlePasswordRequest_
-    vcl::Window * pParent = getParentProperty();
+    uno::Reference<awt::XWindow> xParent = getParentXWindow();
     task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
     OUString aDocumentName;
@@ -721,7 +721,7 @@ UUIInteractionHelper::handlePasswordRequest(
 
     if (bDoHandleRequest)
     {
-        handlePasswordRequest_( pParent ? pParent->GetFrameWeld() : nullptr, nMode, rContinuations,
+        handlePasswordRequest_( Application::GetFrameWeld(xParent), nMode, rContinuations,
                 aDocumentName, bMSCryptoMode, bIsPasswordToModify );
         return true;
     }
@@ -729,7 +729,7 @@ UUIInteractionHelper::handlePasswordRequest(
     task::PasswordRequest aPasswordRequest;
     if( aAnyRequest >>= aPasswordRequest )
     {
-        handlePasswordRequest_(pParent ? pParent->GetFrameWeld() : nullptr,
+        handlePasswordRequest_(Application::GetFrameWeld(xParent),
                                aPasswordRequest.Mode,
                                rRequest->getContinuations(),
                                OUString(),
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 8b7a77f34543..49091b6f577c 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -34,12 +34,20 @@
 #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
 #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
 
+namespace com {
+namespace sun {
+namespace star {
+namespace awt {
+    class XWindow;
+}
+} } }
 namespace comphelper { class SolarMutex; }
 namespace vcl { class Window; }
 namespace weld {
     class Builder;
     class MessageDialog;
     class Widget;
+    class Window;
 }
 struct SystemParentData;
 struct SalPrinterQueueInfo;
@@ -157,6 +165,7 @@ public:
     virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
     virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
                                                      VclButtonsType eButtonType, const OUString& rPrimaryMessage);
+    virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
 
     // methods for XDisplayConnection
 
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 9a3cb48dfe03..b6f00a0752d7 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -229,6 +229,7 @@ public:
     virtual OpenGLContext* CreateOpenGLContext() override;
     virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) override;
     virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage) override;
+    virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) override;
 #endif
 
     virtual const cairo_font_options_t* GetCairoFontOptions() override;
@@ -257,25 +258,33 @@ class SalGtkXWindow : public SalGtkXWindow_Base
 {
 private:
     osl::Mutex m_aHelperMtx;
+    weld::Window* m_pWeldWidget;
     GtkWidget* m_pWidget;
 public:
 
-    SalGtkXWindow(GtkWidget* pWidget)
+    SalGtkXWindow(weld::Window* pWeldWidget, GtkWidget* pWidget)
         : SalGtkXWindow_Base(m_aHelperMtx)
+        , m_pWeldWidget(pWeldWidget)
         , m_pWidget(pWidget)
     {
     }
 
     void clear()
     {
+        m_pWeldWidget = nullptr;
         m_pWidget = nullptr;
     }
 
-    GtkWidget * getWidget() const
+    GtkWidget* getWidget() const
     {
         return m_pWidget;
     }
 
+    weld::Window* getFrameWeld() const
+    {
+        return m_pWeldWidget;
+    }
+
     // css::awt::XWindow
     void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override
     {
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index d473f7b59ddd..62e5873b8501 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -37,6 +37,7 @@
 #include <vcl/layout.hxx>
 #include <vcl/tabctrl.hxx>
 #include <vcl/tabpage.hxx>
+#include <vcl/unowrap.hxx>
 #include <vcl/weld.hxx>
 #include <bitmaps.hlst>
 
@@ -1840,6 +1841,17 @@ weld::MessageDialog* SalInstance::CreateMessageDialog(weld::Widget* pParent, Vcl
     return new SalInstanceMessageDialog(xMessageDialog, true);
 }
 
+weld::Window* SalInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow)
+{
+    UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
+    if (!pWrapper)
+        return nullptr;
+    VclPtr<vcl::Window> xWindow = pWrapper->GetWindow(rWindow);
+    if (!xWindow)
+        return nullptr;
+    return xWindow->GetFrameWeld();
+}
+
 weld::Window* SalFrame::GetFrameWeld() const
 {
     if (!m_xFrameWeld)
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 926a69b47231..fafae4c130bc 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -135,6 +135,11 @@ weld::MessageDialog* Application::CreateMessageDialog(weld::Widget* pParent, Vcl
     return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage);
 }
 
+weld::Window* Application::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow)
+{
+    return ImplGetSVData()->mpDefInst->GetFrameWeld(rWindow);
+}
+
 namespace
 {
     const OUString MetricToString(FieldUnit rUnit)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 916fda03ff74..133406925d79 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1612,7 +1612,7 @@ public:
     virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override
     {
         if (!m_xWindow.is())
-            m_xWindow.set(new SalGtkXWindow(m_pWidget));
+            m_xWindow.set(new SalGtkXWindow(this, m_pWidget));
         return css::uno::Reference<css::awt::XWindow>(m_xWindow.get());
     }
 
@@ -4041,6 +4041,13 @@ weld::MessageDialog* GtkInstance::CreateMessageDialog(weld::Widget* pParent, Vcl
     return new GtkInstanceMessageDialog(pMessageDialog, true);
 }
 
+weld::Window* GtkInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow)
+{
+    if (SalGtkXWindow* pGtkXWindow = dynamic_cast<SalGtkXWindow*>(rWindow.get()))
+        return pGtkXWindow->getFrameWeld();
+    return nullptr;
+}
+
 weld::Window* GtkSalFrame::GetFrameWeld() const
 {
     if (!m_xFrameWeld)


More information about the Libreoffice-commits mailing list