desktop/source/lib/init.cxx | 7 +- include/vcl/builderpage.hxx | 2 include/vcl/jsdialog/jsdialogbuilder.hxx | 6 ++ sfx2/source/dialog/tabdlg.cxx | 5 + vcl/jsdialog/jsdialogbuilder.cxx | 90 +++++++++++++++++++++++-------- vcl/source/app/weldutils.cxx | 4 - 6 files changed, 86 insertions(+), 28 deletions(-)
New commits: commit 0a9cc3f2f76ebb5fed76475bbec14ce66c9bb003 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 5 14:42:44 2020 +0100 Commit: Szymon Kłos <eszka...@gmail.com> CommitDate: Tue May 19 11:18:01 2020 +0200 jsdialog: send JSON on selection change Change-Id: I34bbd037c83e319b5689d2230d629e72e110bf74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94301 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index b375daf4f2b1..8befb2b0f79b 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -128,6 +128,7 @@ public: const OUString* pIconName, VirtualDevice* pImageSurface) override; virtual void remove(int pos) override; virtual void set_entry_text(const OUString& rText) override; + virtual void set_active(int pos) override; }; class VCL_DLLPUBLIC JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 1d572534e46c..080d5089eeb2 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -286,6 +286,12 @@ void JSComboBox::set_entry_text(const OUString& rText) notifyDialogState(); } +void JSComboBox::set_active(int pos) +{ + SalInstanceComboBoxWithEdit::set_active(pos); + notifyDialogState(); +} + JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceNotebook, ::TabControl>(aOwnedToplevel, pControl, pBuilder, commit 3b4f668d9027f03ec7ff45abdffe593d8cd2bf9a Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Mar 9 14:11:06 2020 +0100 Commit: Szymon Kłos <eszka...@gmail.com> CommitDate: Tue May 19 11:17:53 2020 +0200 jsdialog: handle nested tab pages Change-Id: I04d5df55af0df18948730fcd9ee387abce77ac27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94339 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/builderpage.hxx b/include/vcl/builderpage.hxx index 6f721dde233a..c2ba9d4163a1 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 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 273eaaf03917..a0370e292c6b 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -39,6 +39,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #include <sfx2/strings.hrc> #include <helpids.h> @@ -140,7 +141,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() + && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) , pSet ( rAttrSet ) , bHasExchangeSupport ( false ) , pImpl ( new TabPageImpl ) 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, diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx index 32251e5400f4..3d8f78392671 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)) { } commit 7ff207662b459d0673f3b369c29c9b47da64589b Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Mar 10 16:24:16 2020 +0100 Commit: Szymon Kłos <eszka...@gmail.com> CommitDate: Tue May 19 11:09:16 2020 +0200 jsdialog: avoid crash in watermark dialog Change-Id: Iea4a0e6ce005d6a86f9a228026471dd4b4c7b2da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94340 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 2734dd52c035..9f56344b640f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3571,12 +3571,14 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin const OUString sDownAction("DOWN"); const OUString sValue("VALUE"); + bool bIsWeldedDialog = false; + try { OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); weld::Widget* pWidget = JSInstanceBuilder::FindWeldWidgetsMap(nWindowId, sControlId); - bool bIsWeldedDialog = pWidget != nullptr; + bIsWeldedDialog = pWidget != nullptr; bool bContinueWithLOKWindow = false; if (bIsWeldedDialog) @@ -3679,7 +3681,8 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin } catch(...) {} // force resend - pWindow->Resize(); + if (!bIsWeldedDialog) + pWindow->Resize(); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits