[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/vcl sfx2/source vcl/jsdialog

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Mon May 18 12:48:42 UTC 2020


 include/vcl/jsdialog/jsdialogbuilder.hxx |    5 +
 sfx2/source/dialog/tabdlg.cxx            |    4 +
 vcl/jsdialog/jsdialogbuilder.cxx         |   84 ++++++++++++++++++++++---------
 3 files changed, 70 insertions(+), 23 deletions(-)

New commits:
commit 92e0a646f958fd149c2a0d56e684e47ae52a8b5d
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Mar 9 14:11:06 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon May 18 14:48:09 2020 +0200

    jsdialog: handle nested tab pages
    
    Change-Id: I04d5df55af0df18948730fcd9ee387abce77ac27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94339
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index e0d4bc2dcdc1..b375daf4f2b1 100644
--- a/include/vcl/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -28,8 +28,12 @@ public:
 class VCL_DLLPUBLIC JSInstanceBuilder : public SalInstanceBuilder
 {
     vcl::LOKWindowId m_nWindowId;
+    /// used in case of tab pages where dialog is not a direct top level
+    VclPtr<vcl::Window> m_aParentDialog;
+    bool m_bHasTopLevelDialog;
 
     static std::map<vcl::LOKWindowId, WidgetMap>& GetLOKWeldWidgetsMap();
+    static void InsertWindowToMap(int nWindowId);
     void RememberWidget(const OString& id, weld::Widget* pWidget);
 
 public:
@@ -112,6 +116,7 @@ public:
     virtual void insert(int pos, const OUString& rStr, const OUString* pId,
                         const OUString* pIconName, VirtualDevice* pImageSurface) override;
     virtual void remove(int pos) override;
+    virtual void set_active(int pos) override;
 };
 
 class VCL_DLLPUBLIC JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 8ef457dd31a7..6cc7e797d3d2 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -39,6 +39,7 @@
 #include <vcl/IDialogRenderable.hxx>
 #include <sal/log.hxx>
 #include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
 
 #include <sfx2/strings.hrc>
 #include <helpids.h>
@@ -187,7 +188,8 @@ SfxTabPage::SfxTabPage(TabPageParent pParent, const OUString& rUIXMLDescription,
     , pSet                ( rAttrSet )
     , bHasExchangeSupport ( false )
     , pImpl               ( new TabPageImpl )
-    , m_xBuilder(pParent.pPage ? Application::CreateBuilder(pParent.pPage, rUIXMLDescription)
+    , m_xBuilder(pParent.pPage ? Application::CreateBuilder(pParent.pPage, rUIXMLDescription, comphelper::LibreOfficeKit::isActive()
+                                    && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
                                : Application::CreateInterimBuilder(this, rUIXMLDescription))
     , m_xContainer(m_xBuilder->weld_container(rID))
 {
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index da9f04fe4044..1d572534e46c 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -31,12 +31,21 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR
                              : nullptr,
                          rUIRoot, rUIFile)
     , m_nWindowId(0)
+    , m_aParentDialog(nullptr)
+    , m_bHasTopLevelDialog(false)
 {
+    vcl::Window* pRoot = get_builder().get_widget_root();
+    if (pRoot && pRoot->GetParent())
+    {
+        m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
+        m_nWindowId = m_aParentDialog->GetLOKWindowId();
+        InsertWindowToMap(m_nWindowId);
+    }
 }
 
 JSInstanceBuilder::~JSInstanceBuilder()
 {
-    if (m_nWindowId)
+    if (m_nWindowId && m_bHasTopLevelDialog)
         GetLOKWeldWidgetsMap().erase(m_nWindowId);
 }
 
@@ -52,6 +61,7 @@ weld::Widget* JSInstanceBuilder::FindWeldWidgetsMap(vcl::LOKWindowId nWindowId,
                                                     const OString& rWidget)
 {
     const auto it = GetLOKWeldWidgetsMap().find(nWindowId);
+
     if (it != GetLOKWeldWidgetsMap().end())
     {
         auto widgetIt = it->second.find(rWidget);
@@ -62,6 +72,15 @@ weld::Widget* JSInstanceBuilder::FindWeldWidgetsMap(vcl::LOKWindowId nWindowId,
     return nullptr;
 }
 
+void JSInstanceBuilder::InsertWindowToMap(int nWindowId)
+{
+    WidgetMap map;
+    auto it = GetLOKWeldWidgetsMap().find(nWindowId);
+    if (it == GetLOKWeldWidgetsMap().end())
+        GetLOKWeldWidgetsMap().insert(
+            std::map<vcl::LOKWindowId, WidgetMap>::value_type(nWindowId, map));
+}
+
 void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget)
 {
     auto it = GetLOKWeldWidgetsMap().find(m_nWindowId);
@@ -76,9 +95,7 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id,
     ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
     m_nWindowId = pDialog->GetLOKWindowId();
 
-    WidgetMap map;
-    GetLOKWeldWidgetsMap().insert(
-        std::map<vcl::LOKWindowId, WidgetMap>::value_type(m_nWindowId, map));
+    InsertWindowToMap(m_nWindowId);
 
     std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false)
                                                : nullptr);
@@ -87,6 +104,7 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id,
         assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
         m_aOwnedToplevel.set(pDialog);
         m_xBuilder->drop_ownership(pDialog);
+        m_bHasTopLevelDialog = true;
     }
 
     const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier();
@@ -106,31 +124,40 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id,
 std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id, bool bTakeOwnership)
 {
     ::FixedText* pLabel = m_xBuilder->get<FixedText>(id);
-    auto pWeldWidget = std::make_unique<JSLabel>(m_aOwnedToplevel, pLabel, this, bTakeOwnership);
+    auto pWeldWidget = std::make_unique<JSLabel>(
+        m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, pLabel, this, bTakeOwnership);
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
 
-    RememberWidget(id, pWeldWidget.get());
     return pWeldWidget;
 }
 
 std::unique_ptr<weld::Button> JSInstanceBuilder::weld_button(const OString& id, bool bTakeOwnership)
 {
     ::Button* pButton = m_xBuilder->get<::Button>(id);
-    auto pWeldWidget
-        = pButton ? std::make_unique<JSButton>(m_aOwnedToplevel, pButton, this, bTakeOwnership)
-                  : nullptr;
+    auto pWeldWidget = pButton ? std::make_unique<JSButton>(m_bHasTopLevelDialog ? m_aOwnedToplevel
+                                                                                 : m_aParentDialog,
+                                                            pButton, this, bTakeOwnership)
+                               : nullptr;
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
 
-    RememberWidget(id, pWeldWidget.get());
     return pWeldWidget;
 }
 
 std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id, bool bTakeOwnership)
 {
     Edit* pEntry = m_xBuilder->get<Edit>(id);
-    auto pWeldWidget
-        = pEntry ? std::make_unique<JSEntry>(m_aOwnedToplevel, pEntry, this, bTakeOwnership)
-                 : nullptr;
+    auto pWeldWidget = pEntry ? std::make_unique<JSEntry>(m_bHasTopLevelDialog ? m_aOwnedToplevel
+                                                                               : m_aParentDialog,
+                                                          pEntry, this, bTakeOwnership)
+                              : nullptr;
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
 
-    RememberWidget(id, pWeldWidget.get());
     return pWeldWidget;
 }
 
@@ -143,18 +170,22 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString&
 
     if (pComboBox)
     {
-        pWeldWidget
-            = std::make_unique<JSComboBox>(m_aOwnedToplevel, pComboBox, this, bTakeOwnership);
+        pWeldWidget = std::make_unique<JSComboBox>(m_bHasTopLevelDialog ? m_aOwnedToplevel
+                                                                        : m_aParentDialog,
+                                                   pComboBox, this, bTakeOwnership);
     }
     else
     {
         ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
-        pWeldWidget = pListBox ? std::make_unique<JSListBox>(m_aOwnedToplevel, pListBox, this,
-                                                             bTakeOwnership)
+        pWeldWidget = pListBox ? std::make_unique<JSListBox>(m_bHasTopLevelDialog ? m_aOwnedToplevel
+                                                                                  : m_aParentDialog,
+                                                             pListBox, this, bTakeOwnership)
                                : nullptr;
     }
 
-    RememberWidget(id, pWeldWidget.get());
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
+
     return pWeldWidget;
 }
 
@@ -162,11 +193,14 @@ std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString&
                                                                  bool bTakeOwnership)
 {
     TabControl* pNotebook = m_xBuilder->get<TabControl>(id);
-    auto pWeldWidget = pNotebook ? std::make_unique<JSNotebook>(m_aOwnedToplevel, pNotebook, this,
-                                                                bTakeOwnership)
+    auto pWeldWidget = pNotebook ? std::make_unique<JSNotebook>(
+                                       m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
+                                       pNotebook, this, bTakeOwnership)
                                  : nullptr;
 
-    RememberWidget(id, pWeldWidget.get());
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
+
     return pWeldWidget;
 }
 
@@ -220,6 +254,12 @@ void JSListBox::remove(int pos)
     notifyDialogState();
 }
 
+void JSListBox::set_active(int pos)
+{
+    SalInstanceComboBoxWithoutEdit::set_active(pos);
+    notifyDialogState();
+}
+
 JSComboBox::JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
                        SalInstanceBuilder* pBuilder, bool bTakeOwnership)
     : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aOwnedToplevel, pComboBox, pBuilder,


More information about the Libreoffice-commits mailing list