[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - cui/source include/sfx2 include/vcl sfx2/source vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 31 09:27:36 UTC 2018


 cui/source/dialogs/cuicharmap.cxx |    2 -
 cui/source/inc/cuicharmap.hxx     |    2 -
 include/sfx2/basedlgs.hxx         |   12 +++++++-
 include/vcl/dialog.hxx            |    2 +
 include/vcl/weld.hxx              |    8 +++++
 sfx2/source/dialog/basedlgs.cxx   |   55 +++++++++++++++++---------------------
 vcl/source/app/salvtables.cxx     |    5 +++
 vcl/source/window/dialog.cxx      |   32 ++++++++++++++++++++--
 vcl/unx/gtk3/gtk3gtkinst.cxx      |    5 +++
 9 files changed, 88 insertions(+), 35 deletions(-)

New commits:
commit 12ed60bc8cc391811b9447300b0d06bba8e18975
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 3 14:48:35 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Wed Oct 31 10:27:12 2018 +0100

    Resolves: tdf#120277 special character dialog not appearing in Online
    
    the magic smoke connecting the dialog to the viewshell was in
    SfxModalDialog, so not inheriting from that drops the connection
    
    add a SfxDialogController to enable setting up the connection
    
    Change-Id: I29c45cd43e05295309fc647b039db0c6565ca0d1
    Reviewed-on: https://gerrit.libreoffice.org/61311
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 7837e6fa6f5d..2d3caa50944b 100755
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -53,7 +53,7 @@
 using namespace css;
 
 SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet, bool bInsert)
-    : GenericDialogController(pParent, "cui/ui/specialcharacters.ui", "SpecialCharactersDialog")
+    : SfxDialogController(pParent, "cui/ui/specialcharacters.ui", "SpecialCharactersDialog")
     , m_xVirDev(VclPtr<VirtualDevice>::Create())
     , pSubsetMap( nullptr )
     , isSearchMode(true)
diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx
index 70a98593b5e2..02dca3683843 100644
--- a/cui/source/inc/cuicharmap.hxx
+++ b/cui/source/inc/cuicharmap.hxx
@@ -68,7 +68,7 @@ public:
 
 /** The main purpose of this dialog is to enable the use of characters
     that are not easily accessible from the keyboard. */
-class SvxCharacterMap : public weld::GenericDialogController
+class SvxCharacterMap : public SfxDialogController
 {
 private:
 
diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index 58657fc58e8b..14bdad25b075 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -27,6 +27,7 @@
 #include <vcl/dialog.hxx>
 #include <vcl/floatwin.hxx>
 #include <vcl/timer.hxx>
+#include <vcl/weld.hxx>
 
 class TabPage;
 class SfxTabPage;
@@ -55,6 +56,7 @@ private:
 
     SAL_DLLPRIVATE void SetDialogData_Impl();
     SAL_DLLPRIVATE void GetDialogData_Impl();
+    DECL_DLLPRIVATE_LINK(InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*);
 
 protected:
     SfxModalDialog(vcl::Window *pParent, const OUString& rID, const OUString& rUIXMLDescription);
@@ -86,6 +88,7 @@ class SFX2_DLLPUBLIC SfxModelessDialog: public ModelessDialog
 
     void Init(SfxBindings *pBindinx, SfxChildWindow *pCW);
 
+    DECL_DLLPRIVATE_LINK(InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*);
 protected:
     SfxModelessDialog( SfxBindings*, SfxChildWindow*,
         vcl::Window*, const OUString& rID, const OUString& rUIXMLDescription );
@@ -104,7 +107,6 @@ public:
                             { return *pBindings; }
 
     DECL_LINK(TimerHdl, Timer *, void);
-
 };
 
 // class SfxFloatingWindow --------------------------------------------------
@@ -189,6 +191,14 @@ private:
     std::unique_ptr<SingleTabDlgImpl>   pImpl;
 };
 
+class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController
+{
+private:
+    DECL_DLLPRIVATE_LINK(InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*);
+public:
+    SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId);
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 36f88b8feb45..8c952c9b668a 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -176,6 +176,8 @@ public:
     void            GrabFocusToFirstControl();
     virtual void    Resize() override;
 
+    void            SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink);
+
     void            add_button(PushButton* pButton, int nResponse, bool bTransferOwnership);
     void            set_default_response(int nResponse);
     vcl::Window*    get_widget_for_response(int nResponse);
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 17f2b5119049..98f2b7394a7d 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -23,6 +23,11 @@
 typedef css::uno::Reference<css::accessibility::XAccessible> a11yref;
 typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> a11yrelationset;
 
+namespace vcl
+{
+class ILibreOfficeKitNotifier;
+}
+
 namespace weld
 {
 class Container;
@@ -225,6 +230,9 @@ public:
     virtual void set_default_response(int response) = 0;
     virtual Button* get_widget_for_response(int response) = 0;
     virtual Container* weld_content_area() = 0;
+
+    virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink)
+        = 0;
 };
 
 class VCL_DLLPUBLIC MessageDialog : virtual public Dialog
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 8bda421974bf..f060a84f73ce 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -127,9 +127,15 @@ SfxModalDialog::SfxModalDialog(vcl::Window *pParent, const OUString& rID, const
     pInputSet(nullptr),
     pOutputSet(nullptr)
 {
+    SetInstallLOKNotifierHdl(LINK(this, SfxModalDialog, InstallLOKNotifierHdl));
     GetDialogData_Impl();
 }
 
+IMPL_LINK_NOARG(SfxModalDialog, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*)
+{
+    return SfxViewShell::Current();
+}
+
 SfxModalDialog::~SfxModalDialog()
 {
     disposeOnce();
@@ -153,37 +159,11 @@ void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
     }
 }
 
-namespace
-{
-    void InstallLOKNotifierCallback(Dialog& rDialog)
-    {
-        if (rDialog.GetLOKNotifier())
-            return;
-
-        SfxViewShell* pViewShell = SfxViewShell::Current();
-        if (!pViewShell)
-            return;
-
-        // There are some dialogs, like Hyperlink dialog, which inherit from
-        // SfxModalDialog even though they are modeless, i.e., their Execute method
-        // isn't called.
-        rDialog.SetLOKNotifier(pViewShell);
-        std::vector<vcl::LOKPayloadItem> aItems;
-        aItems.emplace_back("type", "dialog");
-        aItems.emplace_back("size", rDialog.GetSizePixel().toString());
-        if (!rDialog.GetText().isEmpty())
-            aItems.emplace_back("title", rDialog.GetText().toUtf8());
-        pViewShell->notifyWindow(rDialog.GetLOKWindowId(), "created", aItems);
-    }
-}
-
 void SfxModalDialog::StateChanged( StateChangedType nType )
 {
     if (comphelper::LibreOfficeKit::isActive())
     {
-        if (nType == StateChangedType::InitShow)
-            InstallLOKNotifierCallback(*this);
-        else if (nType == StateChangedType::Visible &&
+        if (nType == StateChangedType::Visible &&
                  !IsVisible() &&
                  GetLOKNotifier())
         {
@@ -234,9 +214,6 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
             }
         }
 
-        if (comphelper::LibreOfficeKit::isActive())
-            InstallLOKNotifierCallback(*this);
-
         pImpl->bConstructed = true;
     }
 
@@ -310,9 +287,15 @@ SfxModelessDialog::SfxModelessDialog(SfxBindings* pBindinx,
     const OUString& rUIXMLDescription)
     : ModelessDialog(pParent, rID, rUIXMLDescription)
 {
+    SetInstallLOKNotifierHdl(LINK(this, SfxModelessDialog, InstallLOKNotifierHdl));
     Init(pBindinx, pCW);
 }
 
+IMPL_LINK_NOARG(SfxModelessDialog, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*)
+{
+    return SfxViewShell::Current();
+}
+
 void SfxModelessDialog::Init(SfxBindings *pBindinx, SfxChildWindow *pCW)
 {
     pBindings = pBindinx;
@@ -743,4 +726,16 @@ void SfxSingleTabDialog::SetTabPage(SfxTabPage* pTabPage)
     }
 }
 
+SfxDialogController::SfxDialogController(weld::Widget* pParent, const OUString& rUIFile,
+                                         const OString& rDialogId)
+    : GenericDialogController(pParent, rUIFile, rDialogId)
+{
+    m_xDialog->SetInstallLOKNotifierHdl(LINK(this, SfxDialogController, InstallLOKNotifierHdl));
+}
+
+IMPL_LINK_NOARG(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*)
+{
+    return SfxViewShell::Current();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index b89ad836136c..baf21c15532c 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -676,6 +676,11 @@ public:
         return m_xDialog->StartExecuteAsync(aCtx);
     }
 
+    virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) override
+    {
+        m_xDialog->SetInstallLOKNotifierHdl(rLink);
+    }
+
     virtual int run() override
     {
         VclButtonBox* pActionArea = m_xDialog->get_action_area();
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index c29227d86b25..2d34490b523b 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -343,6 +343,7 @@ struct DialogImpl
     long    mnResult;
     bool    mbStartedModal;
     VclAbstractDialog::AsyncContext maEndCtx;
+    Link<void*, vcl::ILibreOfficeKitNotifier*> m_aInstallLOKNotifierHdl;
 
     DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {}
 
@@ -717,10 +718,30 @@ Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize)
                 std::max<long>(h, 480 - 50));
 }
 
+void Dialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink)
+{
+    mpDialogImpl->m_aInstallLOKNotifierHdl = rLink;
+}
+
 void Dialog::StateChanged( StateChangedType nType )
 {
     if (nType == StateChangedType::InitShow)
     {
+        if (comphelper::LibreOfficeKit::isActive() && !GetLOKNotifier())
+        {
+            vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr);
+            if (pViewShell)
+            {
+                SetLOKNotifier(pViewShell);
+                std::vector<vcl::LOKPayloadItem> aItems;
+                aItems.emplace_back("type", "dialog");
+                aItems.emplace_back("size", GetSizePixel().toString());
+                if (!GetText().isEmpty())
+                    aItems.emplace_back("title", GetText().toUtf8());
+                pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
+            }
+        }
+
         DoInitialLayout();
 
         if ( !HasChildPathFocus() || HasFocus() )
@@ -826,6 +847,13 @@ bool Dialog::ImplStartExecuteModal()
 
     ImplSVData* pSVData = ImplGetSVData();
 
+    const bool bKitActive = comphelper::LibreOfficeKit::isActive();
+    if (bKitActive && !GetLOKNotifier())
+    {
+        if (vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr))
+            SetLOKNotifier(pViewShell);
+    }
+
     switch ( Application::GetDialogCancelMode() )
     {
     case Application::DialogCancelMode::Off:
@@ -887,7 +915,7 @@ bool Dialog::ImplStartExecuteModal()
     }
     mbInExecute = true;
     // no real modality in LibreOfficeKit
-    if (!comphelper::LibreOfficeKit::isActive())
+    if (!bKitActive)
         SetModalInputMode(true);
 
     // FIXME: no layouting, workaround some clipping issues
@@ -907,7 +935,7 @@ bool Dialog::ImplStartExecuteModal()
     xEventBroadcaster->documentEventOccured(aObject);
     UITestLogger::getInstance().log("DialogExecute");
 
-    if (comphelper::LibreOfficeKit::isActive())
+    if (bKitActive)
     {
         if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
         {
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 0b855ebd4822..ee3dc615243a 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2152,6 +2152,11 @@ public:
         return new GtkInstanceContainer(GTK_CONTAINER(gtk_dialog_get_content_area(m_pDialog)), false);
     }
 
+    virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&) override
+    {
+        //not implemented for the gtk variant
+    }
+
     virtual ~GtkInstanceDialog() override
     {
         g_signal_handler_disconnect(m_pDialog, m_nCloseSignalId);


More information about the Libreoffice-commits mailing list