[Libreoffice-commits] core.git: include/vcl sfx2/source vcl/jsdialog vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 22 08:59:18 UTC 2020


 include/vcl/builderpage.hxx              |    2 
 include/vcl/jsdialog/jsdialogbuilder.hxx |    5 +
 sfx2/source/dialog/tabdlg.cxx            |    5 +
 vcl/jsdialog/jsdialogbuilder.cxx         |   84 ++++++++++++++++++++++---------
 vcl/source/app/weldutils.cxx             |    4 -
 5 files changed, 74 insertions(+), 26 deletions(-)

New commits:
commit 027245720fec55bada1f787f81508c212f941c58
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 Jun 22 10:58:41 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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96831
    Tested-by: Jenkins

diff --git a/include/vcl/builderpage.hxx b/include/vcl/builderpage.hxx
index 85d9accd9a1c..e77cf47c443b 100644
--- a/include/vcl/builderpage.hxx
+++ b/include/vcl/builderpage.hxx
@@ -16,7 +16,7 @@ class VCL_DLLPUBLIC BuilderPage
 {
 public:
     BuilderPage(weld::Widget* pParent, weld::DialogController* pController,
-                const OUString& rUIXMLDescription, const OString& rID);
+                const OUString& rUIXMLDescription, const OString& rID, bool bIsMobile = false);
     virtual ~BuilderPage() COVERITY_NOEXCEPT_FALSE;
 
     /* The title of the page, in an Assistant the dialog may append this page title to the
diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index f57d3da7ec7f..2c6977b205dc 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 8ad06f98e967..7ced6461675b 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -30,6 +30,7 @@
 #include <sal/log.hxx>
 #include <tools/debug.hxx>
 #include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
 
 #include <sfx2/strings.hrc>
 #include <helpids.h>
@@ -135,7 +136,9 @@ css::uno::Reference< css::frame::XFrame > SfxTabPage::GetFrame() const
 }
 
 SfxTabPage::SfxTabPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet *rAttrSet)
-    : BuilderPage(pPage, pController, rUIXMLDescription, rID)
+    : BuilderPage(pPage, pController, rUIXMLDescription, rID,
+                    comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current()
+                    && SfxViewShell::Current()->isLOKMobilePhone())
     , pSet                ( rAttrSet )
     , bHasExchangeSupport ( false )
     , pImpl               ( new TabPageImpl )
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 21c678739d88..3e9825efd7c1 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 = m_xBuilder->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,
diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx
index 69562cf0d8c7..20372a7b14b1 100644
--- a/vcl/source/app/weldutils.cxx
+++ b/vcl/source/app/weldutils.cxx
@@ -14,9 +14,9 @@
 #include <vcl/weldutils.hxx>
 
 BuilderPage::BuilderPage(weld::Widget* pParent, weld::DialogController* pController,
-                         const OUString& rUIXMLDescription, const OString& rID)
+                         const OUString& rUIXMLDescription, const OString& rID, bool bIsMobile)
     : m_pDialogController(pController)
-    , m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription))
+    , m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription, bIsMobile))
     , m_xContainer(m_xBuilder->weld_container(rID))
 {
 }


More information about the Libreoffice-commits mailing list