Rebased ref, commits from common ancestor: commit 2aa96b29aae493199564c1a10877298e2f87c310 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 5 15:50:54 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 18:22:35 2020 +0100
jsdialog: move weld handling code into separate block Change-Id: I439aae59168054045387beb841762be7c16458b2 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b9bb05f3da88..690b441b591d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3556,68 +3556,96 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin try { - WindowUIObject aUIObject(pWindow); - std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"])); - OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); - if (pUIWindow) { - bool bIsClickAction = false; - - if (aMap.find("cmd") != aMap.end()) { - if (aMap["cmd"] == "selected") + bool bIsWeldedDialog = pBuilder != nullptr; + bool bContinueWithLOKWindow = false; + + if (bIsWeldedDialog) + { + OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); + OUString sControlType = aMap["type"]; + OUString sAction = aMap["cmd"]; + + if (sControlType == "tabcontrol") + { + auto pNotebook = pBuilder->weld_notebook(sControlId, false); + if (pNotebook) { - if (pBuilder) + if (sAction == "selecttab") { - auto pCombobox = pBuilder->weld_combo_box(sControlId, false); - if (pCombobox) + OString pageId = OUStringToOString(aMap["data"], RTL_TEXTENCODING_ASCII_US); + int page = std::atoi(pageId.getStr()); + + pNotebook->set_current_page(page); + } + else + bContinueWithLOKWindow = true; + } + } + else if (sControlType == "combobox") + { + auto pCombobox = pBuilder->weld_combo_box(sControlId, false); + if (pCombobox) + { + if (sAction == "selected") + { + int separatorPos = aMap["data"].indexOf(';'); + if (separatorPos) { - int separatorPos = aMap["data"].indexOf(';'); - if (separatorPos) - { - OUString entryPos = aMap["data"].copy(0, separatorPos); - OString posString = OUStringToOString(entryPos, RTL_TEXTENCODING_ASCII_US); - int pos = std::atoi(posString.getStr()); - pCombobox->set_active(pos); - } + OUString entryPos = aMap["data"].copy(0, separatorPos); + OString posString = OUStringToOString(entryPos, RTL_TEXTENCODING_ASCII_US); + int pos = std::atoi(posString.getStr()); + pCombobox->set_active(pos); } } else + bContinueWithLOKWindow = true; + } + } + else + { + bContinueWithLOKWindow = true; + } + } + + if (!bIsWeldedDialog || bContinueWithLOKWindow) + { + WindowUIObject aUIObject(pWindow); + std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"])); + if (pUIWindow) { + bool bIsClickAction = false; + + if (aMap.find("cmd") != aMap.end()) { + if (aMap["cmd"] == "selected") { aMap["POS"] = aMap["data"]; aMap["TEXT"] = aMap["data"]; pUIWindow->execute(sSelectAction, aMap); } - } - else if (aMap["cmd"] == "plus") - { - pUIWindow->execute(sUpAction, aMap); - } - else if (aMap["cmd"] == "minus") - { - pUIWindow->execute(sDownAction, aMap); - } - else if (aMap["cmd"] == "set" || aMap["cmd"] == "change") - { - aMap["TEXT"] = aMap["data"]; - - pUIWindow->execute(sClearAction, aMap); - pUIWindow->execute(sTypeAction, aMap); - } - else if (aMap["cmd"] == "selecttab") - { - OString pageId = OUStringToOString(aMap["data"], RTL_TEXTENCODING_ASCII_US); - int page = std::atoi(pageId.getStr()); + else if (aMap["cmd"] == "plus") + { + pUIWindow->execute(sUpAction, aMap); + } + else if (aMap["cmd"] == "minus") + { + pUIWindow->execute(sDownAction, aMap); + } + else if (aMap["cmd"] == "set" || aMap["cmd"] == "change") + { + aMap["TEXT"] = aMap["data"]; - pBuilder->weld_notebook(sControlId, false)->set_current_page(page); + pUIWindow->execute(sClearAction, aMap); + pUIWindow->execute(sTypeAction, aMap); + } + else + bIsClickAction = true; } else bIsClickAction = true; - } - else - bIsClickAction = true; - if (bIsClickAction) - pUIWindow->execute(sClickAction, aMap); + if (bIsClickAction) + pUIWindow->execute(sClickAction, aMap); + } } } catch(...) {} commit 5e19bc06c6b738731ef0b8908f9544e9eb8dce48 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 5 14:42:44 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 18:22:34 2020 +0100 jsdialog: send JSON on selection change Change-Id: I34bbd037c83e319b5689d2230d629e72e110bf74 diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index 4bd5989e9fcc..7d76fba4d68b 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -110,6 +110,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 c6ca0548a3eb..bb10fd7d6927 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -198,6 +198,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, bTakeOwnership) commit 70a24f6ac1520b5faa106a14114e3e1dba644c6e Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 5 12:45:53 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 18:22:34 2020 +0100 jsdialog: execute combobox selection using weld wrapper Change-Id: Ia708b01f4ebcd385272df91d839a90ad91c4bd01 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0c452852d65a..b9bb05f3da88 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3558,16 +3558,35 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin { WindowUIObject aUIObject(pWindow); std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"])); + OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); if (pUIWindow) { bool bIsClickAction = false; if (aMap.find("cmd") != aMap.end()) { if (aMap["cmd"] == "selected") { - aMap["POS"] = aMap["data"]; - aMap["TEXT"] = aMap["data"]; + if (pBuilder) + { + auto pCombobox = pBuilder->weld_combo_box(sControlId, false); + if (pCombobox) + { + int separatorPos = aMap["data"].indexOf(';'); + if (separatorPos) + { + OUString entryPos = aMap["data"].copy(0, separatorPos); + OString posString = OUStringToOString(entryPos, RTL_TEXTENCODING_ASCII_US); + int pos = std::atoi(posString.getStr()); + pCombobox->set_active(pos); + } + } + } + else + { + aMap["POS"] = aMap["data"]; + aMap["TEXT"] = aMap["data"]; - pUIWindow->execute(sSelectAction, aMap); + pUIWindow->execute(sSelectAction, aMap); + } } else if (aMap["cmd"] == "plus") { @@ -3586,11 +3605,10 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin } else if (aMap["cmd"] == "selecttab") { - OString notebookId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); OString pageId = OUStringToOString(aMap["data"], RTL_TEXTENCODING_ASCII_US); int page = std::atoi(pageId.getStr()); - pBuilder->weld_notebook(notebookId, false)->set_current_page(page); + pBuilder->weld_notebook(sControlId, false)->set_current_page(page); } else bIsClickAction = true; commit 69ea2ea6c625af6489987e448f8f039c59a944ef Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 5 12:24:27 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 18:22:33 2020 +0100 jsdialog: execute tab change using weld wrapper Change-Id: Ib9e1b52742b489e812e0756b364a7f7ac62f84ad diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 3980592851ee..0c452852d65a 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -153,6 +153,7 @@ #include <vcl/builder.hxx> #include <vcl/abstdlg.hxx> #include <vcl/uitest/uiobject.hxx> +#include <vcl/jsdialog/jsdialogbuilder.hxx> // Needef for getUndoManager() #include <com/sun/star/document/XUndoManager.hpp> @@ -3534,6 +3535,7 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin StringMap aMap(jsonToStringMap(pArguments)); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nWindowId); + JSInstanceBuilder* pBuilder = JSInstanceBuilder::FindLOKWeldBuilder(nWindowId); if (!pWindow && nWindowId >= 1000000000 /* why unsigned? */) pWindow = getSidebarWindow(); @@ -3584,9 +3586,11 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin } else if (aMap["cmd"] == "selecttab") { - aMap["POS"] = aMap["data"]; + OString notebookId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); + OString pageId = OUStringToOString(aMap["data"], RTL_TEXTENCODING_ASCII_US); + int page = std::atoi(pageId.getStr()); - pUIWindow->execute(sSelectAction, aMap); + pBuilder->weld_notebook(notebookId, false)->set_current_page(page); } else bIsClickAction = true; commit ab328e66e6eb85534700571e41791fa69f5e2bae Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 5 12:18:38 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 18:22:31 2020 +0100 jsdialog: Remember builder connected with LOK window id Change-Id: I9e38fe570b2296341c1694fe8128da30ba209494 diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx index d25b842da0d0..24e3946feabf 100644 --- a/compilerplugins/clang/badstatics.cxx +++ b/compilerplugins/clang/badstatics.cxx @@ -200,6 +200,7 @@ public: || (loplugin::DeclCheck(pVarDecl).Var("maThreadSpecific") .Class("ScDocument").GlobalNamespace()) // not owning || name == "s_pLOKWindowsMap" // LOK only, guarded by assert, and LOK never tries to perform a VCL cleanup + || name == "s_aLOKWeldBuildersMap" // LOK only, similar case as above || name == "gStaticManager" // vcl/source/graphic/Manager.cxx - stores non-owning pointers || name == "aThreadedInterpreterPool" // ScInterpreterContext(Pool), not owning || name == "aNonThreadedInterpreterPool" // ScInterpreterContext(Pool), not owning diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx similarity index 80% rename from vcl/inc/jsdialog/jsdialogbuilder.hxx rename to include/vcl/jsdialog/jsdialogbuilder.hxx index 4d04ea12f77b..4bd5989e9fcc 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -6,7 +6,7 @@ #include <vcl/sysdata.hxx> #include <vcl/virdev.hxx> #include <vcl/builder.hxx> -#include <salvtables.hxx> +#include <vcl/salvtables.hxx> #include <vcl/combobox.hxx> #include <vcl/button.hxx> @@ -21,20 +21,26 @@ public: void notifyDialogState(); }; -class JSInstanceBuilder : public SalInstanceBuilder +class VCL_DLLPUBLIC JSInstanceBuilder : public SalInstanceBuilder { + vcl::LOKWindowId m_nWindowId; + public: JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile); + virtual ~JSInstanceBuilder() override; virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id, bool bTakeOwnership = true) override; virtual std::unique_ptr<weld::Label> weld_label(const OString &id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Button> weld_button(const OString &id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString &id, bool bTakeOwnership = false) override; + + static std::map<vcl::LOKWindowId, JSInstanceBuilder*>& GetLOKWeldBuilderMap(); + static JSInstanceBuilder* FindLOKWeldBuilder(vcl::LOKWindowId nWindowId); }; template<class BaseInstanceClass, class VclClass> -class JSWidget : public BaseInstanceClass, public JSDialogSender +class VCL_DLLPUBLIC JSWidget : public BaseInstanceClass, public JSDialogSender { public: JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, @@ -62,7 +68,7 @@ public: } }; -class JSLabel : public JSWidget<SalInstanceLabel, FixedText> +class VCL_DLLPUBLIC JSLabel : public JSWidget<SalInstanceLabel, FixedText> { public: JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, @@ -70,14 +76,14 @@ public: virtual void set_label(const OUString& rText) override; }; -class JSButton : public JSWidget<SalInstanceButton, ::Button> +class VCL_DLLPUBLIC JSButton : public JSWidget<SalInstanceButton, ::Button> { public: JSButton(VclPtr<vcl::Window> aOwnedToplevel, ::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership); }; -class JSEntry : public JSWidget<SalInstanceEntry, ::Edit> +class VCL_DLLPUBLIC JSEntry : public JSWidget<SalInstanceEntry, ::Edit> { public: JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, @@ -85,7 +91,7 @@ public: virtual void set_text(const OUString& rText) override; }; -class JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox> +class VCL_DLLPUBLIC JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox> { public: JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, @@ -95,7 +101,7 @@ public: virtual void remove(int pos) override; }; -class JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox> +class VCL_DLLPUBLIC JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox> { public: JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox, @@ -106,7 +112,7 @@ public: virtual void set_entry_text(const OUString& rText) override; }; -class JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl> +class VCL_DLLPUBLIC JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl> { public: JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, @@ -121,4 +127,4 @@ public: virtual void append_page(const OString& rIdent, const OUString& rLabel) override; }; -#endif \ No newline at end of file +#endif diff --git a/vcl/inc/salvtables.hxx b/include/vcl/salvtables.hxx similarity index 100% rename from vcl/inc/salvtables.hxx rename to include/vcl/salvtables.hxx diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index eae0ed3c015b..c6ca0548a3eb 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1,4 +1,4 @@ -#include <jsdialog/jsdialogbuilder.hxx> +#include <vcl/jsdialog/jsdialogbuilder.hxx> #include <sal/log.hxx> #include <boost/property_tree/json_parser.hpp> #include <comphelper/lok.hxx> @@ -29,12 +29,41 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR dynamic_cast<SalInstanceWidget*>(pParent) ? dynamic_cast<SalInstanceWidget*>(pParent)->getWidget() : nullptr, rUIRoot, rUIFile) + , m_nWindowId(0) { } +JSInstanceBuilder::~JSInstanceBuilder() +{ + if (m_nWindowId) + GetLOKWeldBuilderMap().erase(m_nWindowId); +} + +std::map<vcl::LOKWindowId, JSInstanceBuilder*>& JSInstanceBuilder::GetLOKWeldBuilderMap() +{ + // Map to remember the LOKWindowId <-> Builder binding. + static std::map<vcl::LOKWindowId, JSInstanceBuilder*> s_aLOKWeldBuildersMap; + + return s_aLOKWeldBuildersMap; +} + +JSInstanceBuilder* JSInstanceBuilder::FindLOKWeldBuilder(vcl::LOKWindowId nWindowId) +{ + const auto it = GetLOKWeldBuilderMap().find(nWindowId); + if (it != GetLOKWeldBuilderMap().end()) + return it->second; + + return nullptr; +} + std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, bool bTakeOwnership) { ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id); + m_nWindowId = pDialog->GetLOKWindowId(); + + GetLOKWeldBuilderMap().insert( + std::map<vcl::LOKWindowId, JSInstanceBuilder*>::value_type(m_nWindowId, this)); + std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false) : nullptr); if (bTakeOwnership && pDialog) { diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index a5c642b80efc..c88426dd61b6 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -53,7 +53,7 @@ #include <vcl/toolkit/unowrap.hxx> #include <vcl/weld.hxx> #include <bitmaps.hlst> -#include <salvtables.hxx> +#include <vcl/salvtables.hxx> SalFrame::SalFrame() : m_pWindow(nullptr) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index bbf3679cf1ef..bc1f903081bc 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -62,7 +62,7 @@ #include <tools/svlibrary.h> #include <tools/diagnose_ex.h> #include <comphelper/lok.hxx> -#include <jsdialog/jsdialogbuilder.hxx> +#include <vcl/jsdialog/jsdialogbuilder.hxx> #if defined(DISABLE_DYNLOADING) || defined(LINUX) #include <dlfcn.h> commit 07985969278e9c6533de1ec7de6bae5b46768c4a Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Mar 4 16:05:10 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 18:21:30 2020 +0100 jsdialog: refresh on notebook changes Change-Id: I81159d043add3d8bdd1b81f26f642f99c1430f73 diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index fedbbf860e82..4d04ea12f77b 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -30,6 +30,7 @@ public: virtual std::unique_ptr<weld::Button> weld_button(const OString &id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString &id, bool bTakeOwnership = false) override; }; template<class BaseInstanceClass, class VclClass> @@ -105,4 +106,19 @@ public: virtual void set_entry_text(const OUString& rText) override; }; +class JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl> +{ +public: + JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_current_page(int nPage) override; + + virtual void set_current_page(const OString& rIdent) override; + + virtual void remove_page(const OString& rIdent) override; + + virtual void append_page(const OString& rIdent, const OUString& rLabel) override; +}; + #endif \ No newline at end of file diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 4a28ed1933a0..eae0ed3c015b 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -66,7 +66,7 @@ std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString &id, bo std::unique_ptr<weld::Button> JSInstanceBuilder::weld_button(const OString &id, bool bTakeOwnership) { ::Button* pButton = m_xBuilder->get<::Button>(id); - return pButton ? o3tl::make_unique<JSButton>(m_aOwnedToplevel, pButton, this, bTakeOwnership) : nullptr; + return pButton ? std::make_unique<JSButton>(m_aOwnedToplevel, pButton, this, bTakeOwnership) : nullptr; } std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id, bool bTakeOwnership) @@ -84,10 +84,16 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString& return std::make_unique<JSComboBox>(m_aOwnedToplevel, pComboBox, this, bTakeOwnership); ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); return pListBox - ? std::make_unique<JSListBox>(m_aOwnedToplevel,pListBox, this, bTakeOwnership) + ? std::make_unique<JSListBox>(m_aOwnedToplevel, pListBox, this, bTakeOwnership) : nullptr; } +std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString &id, bool bTakeOwnership) +{ + TabControl* pNotebook = m_xBuilder->get<TabControl>(id); + return pNotebook ? std::make_unique<JSNotebook>(m_aOwnedToplevel, pNotebook, this, bTakeOwnership) : nullptr; +} + JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership) @@ -162,3 +168,33 @@ void JSComboBox::set_entry_text(const OUString& rText) SalInstanceComboBoxWithEdit::set_entry_text(rText); notifyDialogState(); } + +JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) +: JSWidget<SalInstanceNotebook, ::TabControl>(aOwnedToplevel, pControl, pBuilder, bTakeOwnership) +{ +} + +void JSNotebook::set_current_page(int nPage) +{ + SalInstanceNotebook::set_current_page(nPage); + notifyDialogState(); +} + +void JSNotebook::set_current_page(const OString& rIdent) +{ + SalInstanceNotebook::set_current_page(rIdent); + notifyDialogState(); +} + +void JSNotebook::remove_page(const OString& rIdent) +{ + SalInstanceNotebook::remove_page(rIdent); + notifyDialogState(); +} + +void JSNotebook::append_page(const OString& rIdent, const OUString& rLabel) +{ + SalInstanceNotebook::append_page(rIdent, rLabel); + notifyDialogState(); +} commit 5088142237b02bd86c294644679f9e783b1f6f37 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Mar 4 16:04:08 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Mar 5 09:32:40 2020 +0100 jsdialog: send tab names Change-Id: Iaae09ec6fc1af0de7f052b89a09ea184a023be70 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 91379bbbf1c8..3980592851ee 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3582,6 +3582,12 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin pUIWindow->execute(sClearAction, aMap); pUIWindow->execute(sTypeAction, aMap); } + else if (aMap["cmd"] == "selecttab") + { + aMap["POS"] = aMap["data"]; + + pUIWindow->execute(sSelectAction, aMap); + } else bIsClickAction = true; } diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index 39b45b1b423b..8e094020231b 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -187,6 +187,8 @@ public: virtual FactoryFunction GetUITestFactory() const override; virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; }; class NotebookBar; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 6f284f8e042f..cab39a8feb94 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2184,6 +2184,24 @@ FactoryFunction TabControl::GetUITestFactory() const return TabControlUIObject::create; } +boost::property_tree::ptree TabControl::DumpAsPropertyTree() +{ + boost::property_tree::ptree aTree = Control::DumpAsPropertyTree(); + + boost::property_tree::ptree aTabs; + for(auto id : GetPageIDs()) + { + boost::property_tree::ptree aTab; + aTab.put("text", GetPageText(id)); + aTab.put("id", id); + aTabs.push_back(std::make_pair("", aTab)); + } + + aTree.add_child("tabs", aTabs); + + return aTree; +} + sal_uInt16 NotebookbarTabControlBase::m_nHeaderHeight = 0; IMPL_LINK_NOARG(NotebookbarTabControlBase, OpenMenu, Button*, void) commit 4b2101e720b8ad20cc63e4a7d030f37051c08b62 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Mar 4 16:03:01 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Mar 4 18:05:55 2020 +0100 Move SalInstanceNotebook to header file Change-Id: Id14b6fca6f12f49691a621f636300f9da320834c diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 77fb1e74e8c5..3a798e560a25 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -11,6 +11,8 @@ #include <vcl/spinfld.hxx> #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/layout.hxx> class SalInstanceBuilder : public weld::Builder { @@ -673,4 +675,39 @@ public: virtual ~SalInstanceButton() override; }; +class SalInstanceNotebook : public SalInstanceContainer, public virtual weld::Notebook +{ +private: + VclPtr<TabControl> m_xNotebook; + mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; + std::vector<VclPtr<TabPage>> m_aAddedPages; + std::vector<VclPtr<VclGrid>> m_aAddedGrids; + + DECL_LINK(DeactivatePageHdl, TabControl*, bool); + DECL_LINK(ActivatePageHdl, TabControl*, void); + +public: + SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual int get_current_page() const override; + + virtual OString get_current_page_ident() const override; + + virtual weld::Container* get_page(const OString& rIdent) const override; + + virtual void set_current_page(int nPage) override; + + virtual void set_current_page(const OString& rIdent) override; + + virtual void remove_page(const OString& rIdent) override; + + virtual void append_page(const OString& rIdent, const OUString& rLabel) override; + + virtual int get_n_pages() const override; + + virtual OUString get_tab_label_text(const OString& rIdent) const override; + + virtual ~SalInstanceNotebook() override; +}; + #endif \ No newline at end of file diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index ecb7bcea6670..a5c642b80efc 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1176,103 +1176,90 @@ IMPL_LINK_NOARG(SalInstanceScrolledWindow, VscrollHdl, ScrollBar*, void) m_aOrigVScrollHdl.Call(&m_xScrolledWindow->getVertScrollBar()); } -class SalInstanceNotebook : public SalInstanceContainer, public virtual weld::Notebook +SalInstanceNotebook::SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership) + , m_xNotebook(pNotebook) { -private: - VclPtr<TabControl> m_xNotebook; - mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; - std::vector<VclPtr<TabPage>> m_aAddedPages; - std::vector<VclPtr<VclGrid>> m_aAddedGrids; - - DECL_LINK(DeactivatePageHdl, TabControl*, bool); - DECL_LINK(ActivatePageHdl, TabControl*, void); - -public: - SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership) - , m_xNotebook(pNotebook) - { - m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl)); - m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook, DeactivatePageHdl)); - } + m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl)); + m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook, DeactivatePageHdl)); +} - virtual int get_current_page() const override - { - return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); - } +int SalInstanceNotebook::get_current_page() const +{ + return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); +} - virtual OString get_current_page_ident() const override - { - return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId()); - } +OString SalInstanceNotebook::get_current_page_ident() const +{ + return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId()); +} - virtual weld::Container* get_page(const OString& rIdent) const override - { - sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); - sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId); - if (nPageIndex == TAB_PAGE_NOTFOUND) - return nullptr; - TabPage* pPage = m_xNotebook->GetTabPage(nPageId); - vcl::Window* pChild = pPage->GetChild(0); - if (m_aPages.size() < nPageIndex + 1U) - m_aPages.resize(nPageIndex + 1U); - if (!m_aPages[nPageIndex]) - m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false)); - return m_aPages[nPageIndex].get(); - } +weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const +{ + sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); + sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId); + if (nPageIndex == TAB_PAGE_NOTFOUND) + return nullptr; + TabPage* pPage = m_xNotebook->GetTabPage(nPageId); + vcl::Window* pChild = pPage->GetChild(0); + if (m_aPages.size() < nPageIndex + 1U) + m_aPages.resize(nPageIndex + 1U); + if (!m_aPages[nPageIndex]) + m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false)); + return m_aPages[nPageIndex].get(); +} - virtual void set_current_page(int nPage) override - { - m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); - } +void SalInstanceNotebook::set_current_page(int nPage) +{ + m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); +} - virtual void set_current_page(const OString& rIdent) override - { - m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent)); - } +void SalInstanceNotebook::set_current_page(const OString& rIdent) +{ + m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent)); +} - virtual void remove_page(const OString& rIdent) override - { - m_xNotebook->RemovePage(m_xNotebook->GetPageId(rIdent)); - } +void SalInstanceNotebook::remove_page(const OString& rIdent) +{ + m_xNotebook->RemovePage(m_xNotebook->GetPageId(rIdent)); +} - virtual void append_page(const OString& rIdent, const OUString& rLabel) override - { - sal_uInt16 nNewPageCount = m_xNotebook->GetPageCount() + 1; - sal_uInt16 nNewPageId = nNewPageCount; - m_xNotebook->InsertPage(nNewPageId, rLabel); - VclPtrInstance<TabPage> xPage(m_xNotebook); - VclPtrInstance<VclGrid> xGrid(xPage); - xPage->Show(); - xGrid->set_hexpand(true); - xGrid->set_vexpand(true); - xGrid->Show(); - m_xNotebook->SetTabPage(nNewPageId, xPage); - m_xNotebook->SetPageName(nNewPageId, rIdent); - m_aAddedPages.push_back(xPage); - m_aAddedGrids.push_back(xGrid); - } +void SalInstanceNotebook::append_page(const OString& rIdent, const OUString& rLabel) +{ + sal_uInt16 nNewPageCount = m_xNotebook->GetPageCount() + 1; + sal_uInt16 nNewPageId = nNewPageCount; + m_xNotebook->InsertPage(nNewPageId, rLabel); + VclPtrInstance<TabPage> xPage(m_xNotebook); + VclPtrInstance<VclGrid> xGrid(xPage); + xPage->Show(); + xGrid->set_hexpand(true); + xGrid->set_vexpand(true); + xGrid->Show(); + m_xNotebook->SetTabPage(nNewPageId, xPage); + m_xNotebook->SetPageName(nNewPageId, rIdent); + m_aAddedPages.push_back(xPage); + m_aAddedGrids.push_back(xGrid); +} - virtual int get_n_pages() const override - { - return m_xNotebook->GetPageCount(); - } +int SalInstanceNotebook::get_n_pages() const +{ + return m_xNotebook->GetPageCount(); +} - virtual OUString get_tab_label_text(const OString& rIdent) const override - { - return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent)); - } +OUString SalInstanceNotebook::get_tab_label_text(const OString& rIdent) const +{ + return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent)); +} - virtual ~SalInstanceNotebook() override - { - for (auto &rGrid : m_aAddedGrids) - rGrid.disposeAndClear(); - for (auto &rPage : m_aAddedPages) - rPage.disposeAndClear(); - m_xNotebook->SetActivatePageHdl(Link<TabControl*,void>()); - m_xNotebook->SetDeactivatePageHdl(Link<TabControl*,bool>()); - } -}; +SalInstanceNotebook::~SalInstanceNotebook() +{ + for (auto &rGrid : m_aAddedGrids) + rGrid.disposeAndClear(); + for (auto &rPage : m_aAddedPages) + rPage.disposeAndClear(); + m_xNotebook->SetActivatePageHdl(Link<TabControl*,void>()); + m_xNotebook->SetDeactivatePageHdl(Link<TabControl*,bool>()); +} IMPL_LINK_NOARG(SalInstanceNotebook, DeactivatePageHdl, TabControl*, bool) { commit 6e4d27d3116e62e7ca0dff3bfce30adb65e03837 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Apr 16 17:17:58 2019 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Mar 4 18:05:54 2020 +0100 weld ScTPValidationValue and ScValidationDlg Change-Id: I74b1569fe378f42c1cc78ca8d9b758c6e585c979 Reviewed-on: https://gerrit.libreoffice.org/70845 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 78b49b2f0cf5..f717813549fb 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -366,10 +366,6 @@ generic-name="Reference Button" parent="GtkButton" icon-name="widget-gtk-button"/> - <glade-widget-class title="Extended Reference Button" name="scuilo-ScRefButtonEx" - generic-name="Extended Reference Button" parent="foruilo-RefButton" - icon-name="widget-gtk-button"/> - <glade-widget-class title="Reference Edit" name="foruilo-RefEdit" generic-name="Reference Edit" parent="GtkEntry" icon-name="widget-gtk-textentry"/> diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx index 9d28fad846d2..db23c12bc641 100644 --- a/formula/source/ui/dlg/funcutl.cxx +++ b/formula/source/ui/dlg/funcutl.cxx @@ -732,6 +732,7 @@ void WeldRefButton::SetReferences( IControlReferenceHandler* pDlg, WeldRefEdit* IMPL_LINK_NOARG(WeldRefButton, Click, weld::Button&, void) { + maClickHdl.Call(*this); if( pAnyRefDlg ) pAnyRefDlg->ToggleCollapsed( pRefEdit, this ); } diff --git a/include/formula/funcutl.hxx b/include/formula/funcutl.hxx index 087339ab6e36..8d2e626bcafe 100644 --- a/include/formula/funcutl.hxx +++ b/include/formula/funcutl.hxx @@ -191,6 +191,7 @@ private: Link<WeldRefButton&,void> maGetFocusHdl; Link<WeldRefButton&,void> maLoseFocusHdl; Link<weld::Widget&,bool> maActivateHdl; + Link<WeldRefButton&,void> maClickHdl; protected: DECL_LINK(Click, weld::Button&, void); @@ -212,6 +213,7 @@ public: void SetGetFocusHdl(const Link<WeldRefButton&,void>& rLink) { maGetFocusHdl = rLink; } void SetLoseFocusHdl(const Link<WeldRefButton&,void>& rLink) { maLoseFocusHdl = rLink; } void SetActivateHdl(const Link<weld::Widget&,bool>& rLink) { maActivateHdl = rLink; } + void SetClickHdl(const Link<WeldRefButton&,void>& rLink) { maClickHdl = rLink; } }; diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 4121a03722ce..adc4239d045e 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -74,7 +74,7 @@ class ScSelectionTransferObj; class ScFormEditData; class ScMarkData; struct ScDragData; -class SfxModelessDialogController; +class SfxDialogController; class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationListener { @@ -107,7 +107,8 @@ class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationL bool m_bIsInSharedDocSaving:1; std::map<sal_uInt16, std::vector<VclPtr<vcl::Window> > > m_mapRefWindow; - std::map<sal_uInt16, std::vector<SfxModelessDialogController*>> m_mapRefController; + // a way to find existing Dialogs for a given parent Window of the slot type + std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController; css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller; @@ -242,10 +243,10 @@ public: SC_DLLPUBLIC void RegisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd ); SC_DLLPUBLIC void UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd ); - SC_DLLPUBLIC vcl::Window * Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor ); - SC_DLLPUBLIC void RegisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ); - SC_DLLPUBLIC void UnregisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ); + SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor); + SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd); + SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, weld::Window *pWndAncestor); SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller); SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 1c9b78b36b43..25b24b9cc74c 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2224,26 +2224,34 @@ void ScModule::UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd ) m_mapRefWindow.erase( nSlotId ); } -void ScModule::RegisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ) +void ScModule::RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor) { - std::vector<SfxModelessDialogController*> & rlRefWindow = m_mapRefController[nSlotId]; + std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = m_mapRefController[nSlotId]; - if( std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ) == rlRefWindow.end() ) + if (std::find_if(rlRefWindow.begin(), rlRefWindow.end(), + [rWnd](const std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>& rCandidate) + { + return rCandidate.first.get() == rWnd.get(); + }) == rlRefWindow.end()) { - rlRefWindow.emplace_back(pWnd ); + rlRefWindow.emplace_back(rWnd, pWndAncestor); } } -void ScModule::UnregisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ) +void ScModule::UnregisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd) { auto iSlot = m_mapRefController.find( nSlotId ); if( iSlot == m_mapRefController.end() ) return; - std::vector<SfxModelessDialogController* > & rlRefWindow = iSlot->second; + std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = iSlot->second; - auto i = std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ); + auto i = std::find_if(rlRefWindow.begin(), rlRefWindow.end(), + [rWnd](const std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>& rCandidate) + { + return rCandidate.first.get() == rWnd.get(); + }); if( i == rlRefWindow.end() ) return; @@ -2254,23 +2262,21 @@ void ScModule::UnregisterRefController( sal_uInt16 nSlotId, SfxModelessDialogCo m_mapRefController.erase( nSlotId ); } -vcl::Window * ScModule::Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor ) +std::shared_ptr<SfxDialogController> ScModule::Find1RefWindow(sal_uInt16 nSlotId, weld::Window *pWndAncestor) { if (!pWndAncestor) return nullptr; - auto iSlot = m_mapRefWindow.find( nSlotId ); + auto iSlot = m_mapRefController.find( nSlotId ); - if( iSlot == m_mapRefWindow.end() ) + if( iSlot == m_mapRefController.end() ) return nullptr; - std::vector<VclPtr<vcl::Window> > & rlRefWindow = iSlot->second; - - while( vcl::Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent; + std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = iSlot->second; for (auto const& refWindow : rlRefWindow) - if ( pWndAncestor->IsWindowOrChild( refWindow, refWindow->IsSystemWindow() ) ) - return refWindow; + if ( refWindow.second == pWndAncestor ) + return refWindow.first; return nullptr; } diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 08998266c7f2..c38de3295786 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -84,24 +84,25 @@ const sal_uInt16 ScTPValidationValue::pValueRanges[] = 0 }; -ScValidationDlg::ScValidationDlg(vcl::Window* pParent, const SfxItemSet* pArgSet, +ScValidationDlg::ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell *pTabViewSh) - : ScValidationDlgBase(pParent ? pParent : SfxGetpApp()->GetTopWindow(), - "ValidationDialog", "modules/scalc/ui/validationdialog.ui", pArgSet, nullptr) + : ScValidationDlgBase(pParent, + "modules/scalc/ui/validationdialog.ui", "ValidationDialog", pArgSet, nullptr) , m_pTabVwSh(pTabViewSh) - , m_nValuePageId(0) + , m_sValuePageId("criteria") , m_bOwnRefHdlr(false) , m_bRefInputting(false) + , m_xHBox(m_xBuilder->weld_container("refinputbox")) { - m_nValuePageId = AddTabPage("criteria", ScTPValidationValue::Create, nullptr); + AddTabPage(m_sValuePageId, ScTPValidationValue::Create, nullptr); AddTabPage("inputhelp", ScTPValidationHelp::Create, nullptr); AddTabPage("erroralert", ScTPValidationError::Create, nullptr); - get(m_pHBox, "refinputbox"); } ScValidationDlg::~ScValidationDlg() { - disposeOnce(); + if (m_bOwnRefHdlr) + RemoveRefDlg(false); } void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , const ScDocument* pDoc ) @@ -129,39 +130,52 @@ void ScTPValidationValue:: SetActiveHdl() } } -void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, const formula::RefButton* pButton ) +void ScTPValidationValue::RefInputStartPreHdl( formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton ) { - if ( ScValidationDlg *pValidationDlg = GetValidationDlg() ) + if (ScValidationDlg *pValidationDlg = GetValidationDlg()) { - vcl::Window *pNewParent = pValidationDlg->get_refinput_shrink_parent(); - if( pEdit == m_pRefEdit && m_pRefEdit->GetParent() != pNewParent ) + weld::Container* pNewParent = pValidationDlg->get_refinput_shrink_parent(); + if (pEdit == m_pRefEdit && pNewParent != m_pRefEditParent) { - m_pRefEdit->SetParent(pNewParent); + m_xRefGrid->move(m_pRefEdit->GetWidget(), pNewParent); + m_pRefEditParent = pNewParent; } - if( pButton == m_pBtnRef && m_pBtnRef->GetParent() != pNewParent ) + if (pNewParent != m_pBtnRefParent) { - m_pBtnRef->SetParent(pNewParent); + // if Edit SetParent but button not, the tab order will be + // incorrect, so move button anyway, and restore + // parent later in order to restore the tab order. But + // hide it if its moved but unwanted + m_xRefGrid->move(m_xBtnRef->GetWidget(), pNewParent); + m_xBtnRef->GetWidget()->set_visible(pButton == m_xBtnRef.get()); + m_pBtnRefParent = pNewParent; } - pNewParent->Show(); + pNewParent->show(); } } void ScTPValidationValue::RefInputDonePostHdl() { - if( m_pRefEdit && m_pRefEdit->GetParent() != m_pRefGrid ) + if (ScValidationDlg *pValidationDlg = GetValidationDlg()) { - m_pRefEdit->SetParent( m_pRefGrid ); - m_pBtnRef->SetParent( m_pRefEdit ); //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to another window and restore parent later in order to restore the tab order - } + weld::Container* pOldParent = pValidationDlg->get_refinput_shrink_parent(); - if( m_pBtnRef->GetParent() != m_pRefGrid ) - m_pBtnRef->SetParent( m_pRefGrid ); + if (m_pRefEdit && m_pRefEditParent != m_xRefGrid.get()) + { + pOldParent->move(m_pRefEdit->GetWidget(), m_xRefGrid.get()); + m_pRefEditParent = m_xRefGrid.get(); + } - if ( ScValidationDlg *pValidationDlg = GetValidationDlg() ) - { - pValidationDlg->get_refinput_shrink_parent()->Hide(); + if (m_pBtnRefParent != m_xRefGrid.get()) + { + pOldParent->move(m_xBtnRef->GetWidget(), m_xRefGrid.get()); + m_xBtnRef->GetWidget()->show(); + m_pBtnRefParent = m_xRefGrid.get(); + } + + pOldParent->hide(); ScViewData& rViewData = pValidationDlg->GetTabViewShell()->GetViewData(); SCTAB nCurTab = rViewData.GetTabNo(); SCTAB nRefTab = rViewData.GetRefTabNo(); @@ -173,21 +187,10 @@ void ScTPValidationValue::RefInputDonePostHdl() } } - if( m_pRefEdit && !m_pRefEdit->HasFocus() ) + if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus()) m_pRefEdit->GrabFocus(); } -ScTPValidationValue::ScRefButtonEx::~ScRefButtonEx() -{ - disposeOnce(); -} - -void ScTPValidationValue::ScRefButtonEx::dispose() -{ - m_pPage.clear(); - ::formula::RefButton::dispose(); -} - namespace { /** Converts the passed ScValidationMode to the position in the list box. */ @@ -327,9 +330,9 @@ bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaSt } // namespace -ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet& rArgSet ) - : SfxTabPage( pParent, "ValidationCriteriaPage", - "modules/scalc/ui/validationcriteriapage.ui", &rArgSet) +ScTPValidationValue::ScTPValidationValue(TabPageParent pParent, const SfxItemSet& rArgSet) + : SfxTabPage(pParent, "modules/scalc/ui/validationcriteriapage.ui", + "ValidationCriteriaPage", &rArgSet) , maStrMin(ScResId(SCSTR_VALID_MINIMUM)) , maStrMax(ScResId(SCSTR_VALID_MAXIMUM)) , maStrValue(ScResId(SCSTR_VALID_VALUE)) @@ -337,33 +340,34 @@ ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet , maStrRange(ScResId(SCSTR_VALID_RANGE)) , maStrList(ScResId(SCSTR_VALID_LIST)) , m_pRefEdit(nullptr) -{ - get(m_pLbAllow, "allow"); - get(m_pCbAllow, "allowempty"); - get(m_pCbShow, "showlist"); - get(m_pCbSort, "sortascend"); - get(m_pFtValue, "valueft"); - get(m_pLbValue, "data"); - get(m_pFtMin, "minft"); - get(m_pMinGrid, "mingrid"); - get(m_pEdMin, "min"); - m_pEdMin->SetReferences(nullptr, m_pFtMin); - get(m_pEdList, "minlist"); + , m_xLbAllow(m_xBuilder->weld_combo_box("allow")) + , m_xCbAllow(m_xBuilder->weld_check_button("allowempty")) + , m_xCbShow(m_xBuilder->weld_check_button("showlist")) + , m_xCbSort(m_xBuilder->weld_check_button("sortascend")) + , m_xFtValue(m_xBuilder->weld_label("valueft")) + , m_xLbValue(m_xBuilder->weld_combo_box("data")) + , m_xFtMin(m_xBuilder->weld_label("minft")) + , m_xMinGrid(m_xBuilder->weld_widget("mingrid")) + , m_xEdMin(new formula::WeldRefEdit(m_xBuilder->weld_entry("min"))) + , m_xEdList(m_xBuilder->weld_text_view("minlist")) + , m_xFtMax(m_xBuilder->weld_label("maxft")) + , m_xEdMax(new formula::WeldRefEdit(m_xBuilder->weld_entry("max"))) + , m_xFtHint(m_xBuilder->weld_label("hintft")) + , m_xBtnRef(new formula::WeldRefButton(m_xBuilder->weld_button("validref"))) + , m_xRefGrid(m_xBuilder->weld_container("refgrid")) + , m_pRefEditParent(m_xRefGrid.get()) + , m_pBtnRefParent(m_xRefGrid.get()) +{ + m_xEdMin->SetReferences(nullptr, m_xFtMin.get()); Size aSize(LogicToPixel(Size(174, 105), MapMode(MapUnit::MapAppFont))); - m_pEdList->set_width_request(aSize.Width()); - m_pEdList->set_height_request(aSize.Height()); - get(m_pFtMax, "maxft"); - get(m_pEdMax, "max"); - m_pEdMax->SetReferences(nullptr, m_pFtMax); - get(m_pFtHint, "hintft"); - get(m_pBtnRef, "validref"); - m_pBtnRef->SetParentPage(this); - get(m_pRefGrid, "refgrid"); + m_xEdList->set_size_request(aSize.Width(), aSize.Height()); + m_xEdMax->SetReferences(nullptr, m_xFtMax.get()); + + m_xBtnRef->SetClickHdl(LINK(this, ScTPValidationValue, ClickHdl)); //lock in the max size initial config - aSize = get_preferred_size(); - set_width_request(aSize.Width()); - set_height_request(aSize.Height()); + aSize = m_xContainer->get_preferred_size(); + m_xContainer->set_size_request(aSize.Width(), aSize.Height()); Init(); @@ -371,7 +375,7 @@ ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet OUString aListSep = ::ScCompiler::GetNativeSymbol( ocSep ); OSL_ENSURE( aListSep.getLength() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" ); mcFmlaSep = aListSep.getLength() ? aListSep[0] : ';'; - m_pBtnRef->Hide(); // cell range picker + m_xBtnRef->GetWidget()->hide(); // cell range picker } ScTPValidationValue::~ScTPValidationValue() @@ -381,49 +385,37 @@ ScTPValidationValue::~ScTPValidationValue() void ScTPValidationValue::dispose() { - m_pLbAllow.clear(); - m_pCbAllow.clear(); - m_pCbShow.clear(); - m_pCbSort.clear(); - m_pFtValue.clear(); - m_pLbValue.clear(); - m_pFtMin.clear(); - m_pMinGrid.clear(); - m_pEdMin.clear(); - m_pEdList.clear(); - m_pFtMax.clear(); - m_pEdMax.clear(); - m_pFtHint.clear(); - m_pRefEdit.clear(); - m_pBtnRef.clear(); - m_pRefGrid.clear(); + m_xEdMin.reset(); + m_xEdMin.reset(); + m_xEdMax.reset(); + m_xBtnRef.reset(); + m_xEdMax.reset(); SfxTabPage::dispose(); } - void ScTPValidationValue::Init() { - m_pLbAllow->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); - m_pLbValue->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); - m_pCbShow->SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) ); + m_xLbAllow->connect_changed( LINK( this, ScTPValidationValue, SelectHdl ) ); + m_xLbValue->connect_changed( LINK( this, ScTPValidationValue, SelectHdl ) ); + m_xCbShow->connect_clicked( LINK( this, ScTPValidationValue, CheckHdl ) ); // cell range picker - m_pEdMin->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); - m_pEdMin->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); - m_pEdMax->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); - m_pBtnRef->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); - m_pEdMax->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); + m_xEdMin->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); + m_xEdMin->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillEditFocusHdl ) ); + m_xEdMax->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); + m_xBtnRef->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillButtonFocusHdl ) ); + m_xEdMax->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillEditFocusHdl ) ); - m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_ANY ); - m_pLbValue->SelectEntryPos( SC_VALIDDLG_DATA_EQUAL ); + m_xLbAllow->set_active( SC_VALIDDLG_ALLOW_ANY ); + m_xLbValue->set_active( SC_VALIDDLG_DATA_EQUAL ); - SelectHdl( *m_pLbAllow.get() ); - CheckHdl( nullptr ); + SelectHdl( *m_xLbAllow.get() ); + CheckHdl( *m_xCbShow ); } -VclPtr<SfxTabPage> ScTPValidationValue::Create( TabPageParent pParent, const SfxItemSet* rArgSet ) +VclPtr<SfxTabPage> ScTPValidationValue::Create(TabPageParent pParent, const SfxItemSet* rArgSet) { - return VclPtr<ScTPValidationValue>::Create( pParent.pParent, *rArgSet ); + return VclPtr<ScTPValidationValue>::Create(pParent, *rArgSet); } void ScTPValidationValue::Reset( const SfxItemSet* rArgSet ) @@ -434,25 +426,25 @@ void ScTPValidationValue::Reset( const SfxItemSet* rArgSet ) if( rArgSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET ) nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >( static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) ); - m_pLbAllow->SelectEntryPos( nLbPos ); + m_xLbAllow->set_active( nLbPos ); nLbPos = SC_VALIDDLG_DATA_EQUAL; if( rArgSet->GetItemState( FID_VALID_CONDMODE, true, &pItem ) == SfxItemState::SET ) nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >( static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) ); - m_pLbValue->SelectEntryPos( nLbPos ); + m_xLbValue->set_active( nLbPos ); // *** check boxes *** bool bCheck = true; if( rArgSet->GetItemState( FID_VALID_BLANK, true, &pItem ) == SfxItemState::SET ) bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue(); - m_pCbAllow->Check( bCheck ); + m_xCbAllow->set_active( bCheck ); sal_Int32 nListType = ValidListType::UNSORTED; if( rArgSet->GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SfxItemState::SET ) nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue(); - m_pCbShow->Check( nListType != ValidListType::INVISIBLE ); - m_pCbSort->Check( nListType == ValidListType::SORTEDASCENDING ); + m_xCbShow->set_active( nListType != ValidListType::INVISIBLE ); + m_xCbSort->set_active( nListType == ValidListType::SORTEDASCENDING ); // *** formulas *** OUString aFmlaStr; @@ -465,27 +457,27 @@ void ScTPValidationValue::Reset( const SfxItemSet* rArgSet ) aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue(); SetSecondFormula( aFmlaStr ); - SelectHdl( *m_pLbAllow.get() ); - CheckHdl( nullptr ); + SelectHdl( *m_xLbAllow.get() ); + CheckHdl( *m_xCbShow ); } bool ScTPValidationValue::FillItemSet( SfxItemSet* rArgSet ) { - sal_Int16 nListType = m_pCbShow->IsChecked() ? - (m_pCbSort->IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) : + sal_Int16 nListType = m_xCbShow->get_active() ? + (m_xCbSort->get_active() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) : ValidListType::INVISIBLE; - const sal_Int32 nLbPos = m_pLbAllow->GetSelectedEntryPos(); + const sal_Int32 nLbPos = m_xLbAllow->get_active(); bool bCustom = (nLbPos == SC_VALIDDLG_ALLOW_CUSTOM); ScConditionMode eCondMode = bCustom ? - ScConditionMode::Direct : lclGetCondModeFromPos( m_pLbValue->GetSelectedEntryPos() ); + ScConditionMode::Direct : lclGetCondModeFromPos( m_xLbValue->get_active() ); rArgSet->Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>( lclGetValModeFromPos( nLbPos ) ) ) ); rArgSet->Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>( eCondMode ) ) ); rArgSet->Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) ); rArgSet->Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) ); - rArgSet->Put( SfxBoolItem( FID_VALID_BLANK, m_pCbAllow->IsChecked() ) ); + rArgSet->Put( SfxBoolItem( FID_VALID_BLANK, m_xCbAllow->get_active() ) ); rArgSet->Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) ); return true; } @@ -493,50 +485,45 @@ bool ScTPValidationValue::FillItemSet( SfxItemSet* rArgSet ) OUString ScTPValidationValue::GetFirstFormula() const { OUString aFmlaStr; - if( m_pLbAllow->GetSelectedEntryPos() == SC_VALIDDLG_ALLOW_LIST ) - lclGetFormulaFromStringList( aFmlaStr, m_pEdList->GetText(), mcFmlaSep ); + if( m_xLbAllow->get_active() == SC_VALIDDLG_ALLOW_LIST ) + lclGetFormulaFromStringList( aFmlaStr, m_xEdList->get_text(), mcFmlaSep ); else - aFmlaStr = m_pEdMin->GetText(); + aFmlaStr = m_xEdMin->GetText(); return aFmlaStr; } OUString ScTPValidationValue::GetSecondFormula() const { - return m_pEdMax->GetText(); + return m_xEdMax->GetText(); } void ScTPValidationValue::SetFirstFormula( const OUString& rFmlaStr ) { // try if formula is a string list, validation mode must already be set OUString aStringList; - if( (m_pLbAllow->GetSelectedEntryPos() == SC_VALIDDLG_ALLOW_RANGE) && + if( (m_xLbAllow->get_active() == SC_VALIDDLG_ALLOW_RANGE) && lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) ) { - m_pEdList->SetText( aStringList ); - m_pEdMin->SetText( EMPTY_OUSTRING ); + m_xEdList->set_text( aStringList ); + m_xEdMin->SetText( EMPTY_OUSTRING ); // change validation mode to string list - m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_LIST ); + m_xLbAllow->set_active( SC_VALIDDLG_ALLOW_LIST ); } else { - m_pEdMin->SetText( rFmlaStr ); - m_pEdList->SetText( EMPTY_OUSTRING ); + m_xEdMin->SetText( rFmlaStr ); + m_xEdList->set_text( EMPTY_OUSTRING ); } } void ScTPValidationValue::SetSecondFormula( const OUString& rFmlaStr ) { - m_pEdMax->SetText( rFmlaStr ); + m_xEdMax->SetText( rFmlaStr ); } ScValidationDlg * ScTPValidationValue::GetValidationDlg() { - if( vcl::Window *pParent = GetParent() ) - do{ - if ( auto pValidationDlg = dynamic_cast<ScValidationDlg*>( pParent ) ) - return pValidationDlg; - }while ( nullptr != ( pParent = pParent->GetParent() ) ); - return nullptr; + return dynamic_cast<ScValidationDlg*>(GetDialogController()); } void ScTPValidationValue::SetupRefDlg() @@ -551,35 +538,35 @@ void ScTPValidationValue::SetupRefDlg() pValidationDlg->SetRefInputStartPreHdl( static_cast<ScRefHandlerHelper::PINPUTSTARTDLTYPE>( &ScTPValidationValue::RefInputStartPreHdl ) ); pValidationDlg->SetRefInputDonePostHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::RefInputDonePostHdl ) ); - vcl::Window *pLabel = nullptr; + weld::Label* pLabel = nullptr; - if ( m_pEdMax->IsVisible() ) + if (m_xEdMax->GetWidget()->get_visible()) { - m_pRefEdit = m_pEdMax; - pLabel = m_pFtMax; + m_pRefEdit = m_xEdMax.get(); + pLabel = m_xFtMax.get(); } - else if ( m_pEdMin->IsVisible() ) + else if (m_xEdMin->GetWidget()->get_visible()) { - m_pRefEdit = m_pEdMin; - pLabel = m_pFtMin; + m_pRefEdit = m_xEdMin.get(); + pLabel = m_xFtMin.get(); } - if( m_pRefEdit && !m_pRefEdit->HasFocus() ) + if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus()) m_pRefEdit->GrabFocus(); if( m_pRefEdit ) m_pRefEdit->SetReferences( pValidationDlg, pLabel ); - m_pBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); + m_xBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); } } } -void ScTPValidationValue::RemoveRefDlg() +void ScTPValidationValue::RemoveRefDlg(bool bRestoreModal) { if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) { - if( pValidationDlg->RemoveRefDlg(true) ) + if( pValidationDlg->RemoveRefDlg(bRestoreModal) ) { pValidationDlg->SetHandler( nullptr ); pValidationDlg->SetSetRefHdl( nullptr ); @@ -591,14 +578,14 @@ void ScTPValidationValue::RemoveRefDlg() m_pRefEdit->SetReferences( nullptr, nullptr ); m_pRefEdit = nullptr; - m_pBtnRef->SetReferences( nullptr, nullptr ); + m_xBtnRef->SetReferences( nullptr, nullptr ); } } } -IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, Control&, void) +IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, formula::WeldRefEdit&, void) { - const sal_Int32 nPos = m_pLbAllow->GetSelectedEntryPos(); + const sal_Int32 nPos = m_xLbAllow->get_active(); if ( nPos == SC_VALIDDLG_ALLOW_RANGE ) { @@ -606,87 +593,96 @@ IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, Control&, void) } } -IMPL_LINK( ScTPValidationValue, KillFocusHdl, Control&, rControl, void ) +IMPL_LINK( ScTPValidationValue, KillEditFocusHdl, formula::WeldRefEdit&, rWnd, void ) +{ + if (&rWnd != m_pRefEdit) + return; + if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) + { + if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting()) + { + if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() ) + { + RemoveRefDlg(true); + } + } + } +} + +IMPL_LINK( ScTPValidationValue, KillButtonFocusHdl, formula::WeldRefButton&, rWnd, void ) { - vcl::Window* pWnd = static_cast<vcl::Window*>(&rControl); - if( pWnd == m_pRefEdit || pWnd == m_pBtnRef ) - if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) - if ( (pValidationDlg->IsActive() || pValidationDlg->IsChildFocus() ) && !pValidationDlg->IsRefInputting() ) - if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_pBtnRef->HasFocus() ) - { - RemoveRefDlg(); - } + if( &rWnd != m_xBtnRef.get()) + return; + if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) + if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting()) + if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() ) + { + RemoveRefDlg(true); + } } -IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl, ListBox&, void) +IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl, weld::ComboBox&, void) { - const sal_Int32 nLbPos = m_pLbAllow->GetSelectedEntryPos(); + const sal_Int32 nLbPos = m_xLbAllow->get_active(); bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY); bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE); bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST); bool bCustom = (nLbPos == SC_VALIDDLG_ALLOW_CUSTOM); - m_pCbAllow->Enable( bEnable ); // Empty cell - m_pFtValue->Enable( bEnable ); - m_pLbValue->Enable( bEnable ); - m_pFtMin->Enable( bEnable ); - m_pEdMin->Enable( bEnable ); - m_pEdList->Enable( bEnable ); - m_pFtMax->Enable( bEnable ); - m_pEdMax->Enable( bEnable ); + m_xCbAllow->set_sensitive( bEnable ); // Empty cell + m_xFtValue->set_sensitive( bEnable ); + m_xLbValue->set_sensitive( bEnable ); + m_xFtMin->set_sensitive( bEnable ); + m_xEdMin->GetWidget()->set_sensitive( bEnable ); + m_xEdList->set_sensitive( bEnable ); + m_xFtMax->set_sensitive( bEnable ); + m_xEdMax->GetWidget()->set_sensitive( bEnable ); bool bShowMax = false; if( bRange ) - m_pFtMin->SetText( maStrRange ); + m_xFtMin->set_label( maStrRange ); else if( bList ) - m_pFtMin->SetText( maStrList ); + m_xFtMin->set_label( maStrList ); else if( bCustom ) - m_pFtMin->SetText( maStrFormula ); + m_xFtMin->set_label( maStrFormula ); else { - switch( m_pLbValue->GetSelectedEntryPos() ) + switch( m_xLbValue->get_active() ) { case SC_VALIDDLG_DATA_EQUAL: - case SC_VALIDDLG_DATA_NOTEQUAL: m_pFtMin->SetText( maStrValue ); break; + case SC_VALIDDLG_DATA_NOTEQUAL: m_xFtMin->set_label( maStrValue ); break; case SC_VALIDDLG_DATA_LESS: - case SC_VALIDDLG_DATA_EQLESS: m_pFtMin->SetText( maStrMax ); break; + case SC_VALIDDLG_DATA_EQLESS: m_xFtMin->set_label( maStrMax ); break; case SC_VALIDDLG_DATA_VALIDRANGE: case SC_VALIDDLG_DATA_INVALIDRANGE: bShowMax = true; SAL_FALLTHROUGH; case SC_VALIDDLG_DATA_GREATER: - case SC_VALIDDLG_DATA_EQGREATER: m_pFtMin->SetText( maStrMin ); break; + case SC_VALIDDLG_DATA_EQGREATER: m_xFtMin->set_label( maStrMin ); break; default: OSL_FAIL( "ScTPValidationValue::SelectHdl - unknown condition mode" ); } } - m_pCbShow->Show( bRange || bList ); - m_pCbSort->Show( bRange || bList ); - m_pFtValue->Show( !bRange && !bList && !bCustom); - m_pLbValue->Show( !bRange && !bList && !bCustom ); - m_pEdMin->Show( !bList ); - m_pEdList->Show( bList ); - m_pMinGrid->set_vexpand( bList ); - WinBits nBits = m_pFtMin->GetStyle(); - nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM); - if (bList) - nBits |= WB_TOP; - else - nBits |= WB_VCENTER; - m_pFtMin->SetStyle( nBits ); - m_pFtMax->Show( bShowMax ); - m_pEdMax->Show( bShowMax ); - m_pFtHint->Show( bRange ); - m_pBtnRef->Show( bRange ); // cell range picker + m_xCbShow->set_visible( bRange || bList ); + m_xCbSort->set_visible( bRange || bList ); + m_xFtValue->set_visible( !bRange && !bList && !bCustom); + m_xLbValue->set_visible( !bRange && !bList && !bCustom ); + m_xEdMin->GetWidget()->set_visible( !bList ); + m_xEdList->set_visible( bList ); + m_xMinGrid->set_vexpand( bList ); + m_xFtMax->set_visible( bShowMax ); + m_xEdMax->GetWidget()->set_visible( bShowMax ); + m_xFtHint->set_visible( bRange ); + m_xBtnRef->GetWidget()->set_visible( bRange ); // cell range picker } -IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl, Button*, void) +IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl, weld::Button&, void) { - m_pCbSort->Enable( m_pCbShow->IsChecked() ); + m_xCbSort->set_sensitive( m_xCbShow->get_active() ); } // Input Help Page @@ -849,7 +845,7 @@ bool ScValidationDlg::EnterRefStatus() SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); - if ( pWnd && pWnd->GetWindow()!= this ) pWnd = nullptr; + if (pWnd && pWnd->GetController().get() != this) pWnd = nullptr; SC_MOD()->SetRefDialog( nId, pWnd == nullptr ); @@ -904,7 +900,9 @@ bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ ) m_bOwnRefHdlr = false; if( bRestoreModal ) + { SetModal( true ); + } } if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) ) @@ -916,33 +914,14 @@ bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ ) return true; } -extern "C" SAL_DLLPUBLIC_EXPORT void makeScRefButtonEx(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &) -{ - rRet = VclPtr<ScTPValidationValue::ScRefButtonEx>::Create(pParent, 0); -} - -void ScTPValidationValue::ScRefButtonEx::Click() +IMPL_LINK_NOARG(ScTPValidationValue, ClickHdl, formula::WeldRefButton&, void) { - if( ScTPValidationValue *pParent = GetParentPage() ) - pParent->OnClick( this ); - - formula::RefButton::Click(); -} - -void ScTPValidationValue::OnClick( const Button *pBtn ) -{ - if( pBtn == m_pBtnRef ) - SetupRefDlg(); + SetupRefDlg(); } bool ScValidationDlg::IsChildFocus() { - if ( const vcl::Window *pWin = Application::GetFocusWindow() ) - while( nullptr != ( pWin = pWin->GetParent() ) ) - if( pWin == this ) - return true; - - return false; + return m_xDialog->has_toplevel_focus(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx index 3da706925491..c52db0a48f2a 100644 --- a/sc/source/ui/inc/anyrefdg.hxx +++ b/sc/source/ui/inc/anyrefdg.hxx @@ -97,7 +97,7 @@ public: static void enableInput(bool _bInput); public: - static bool CanInputStart( const formula::RefEdit *pEdit ){ return !!pEdit; } + static bool CanInputStart( const formula::WeldRefEdit *pEdit ){ return !!pEdit; } bool CanInputDone( bool bForced ){ return (m_pRefEdit || m_pWeldRefEdit) && (bForced || !(m_pRefBtn || m_pWeldRefBtn)); } }; @@ -133,7 +133,7 @@ protected: public: ScRefHandler( vcl::Window &rWindow, SfxBindings* pB, bool bBindRef ); - ScRefHandler( SfxModelessDialogController &rController, SfxBindings* pB, bool bBindRef ); + ScRefHandler( SfxDialogController &rController, SfxBindings* pB, bool bBindRef ); virtual ~ScRefHandler() override; virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override = 0; @@ -159,7 +159,7 @@ public: public: bool EnterRefMode(); bool LeaveRefMode(); - static inline bool CanInputStart( const formula::RefEdit *pEdit ); + static inline bool CanInputStart( const formula::WeldRefEdit *pEdit ); inline bool CanInputDone( bool bForced ); }; @@ -244,74 +244,50 @@ template< class TWindow, bool bBindRef = true > class ScRefHdlrControllerImplBase: public TWindow, public ScRefHandler { private: - template<class TBindings, class TChildWindow, class TParentWindow > - ScRefHdlrControllerImplBase( TBindings* pB, TChildWindow* pCW, - TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID ); + ScRefHdlrControllerImplBase(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID) + : TWindow(pB, pCW, pParent, rUIXMLDescription, rID) + , ScRefHandler(*static_cast<TWindow*>(this), pB, bBindRef) + { + } - template<class TParentWindow, class TArg> - ScRefHdlrControllerImplBase(TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID, const TArg &rArg, SfxBindings *pB); + ScRefHdlrControllerImplBase(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet* pArg, SfxBindings *pB) + : TWindow(pParent, rUIXMLDescription, rID, pArg) + , ScRefHandler(*static_cast<TWindow*>(this), pB, bBindRef) + { + } - virtual ~ScRefHdlrControllerImplBase() override; + virtual ~ScRefHdlrControllerImplBase() override + { + } template<class, class, bool> friend struct ScRefHdlrControllerImpl; }; -template<class TWindow, bool bBindRef > -ScRefHdlrControllerImplBase<TWindow,bBindRef>::~ScRefHdlrControllerImplBase(){} - -template<class TWindow, bool bBindRef> -template<class TBindings, class TChildWindow, class TParentWindow> -ScRefHdlrControllerImplBase<TWindow, bBindRef>::ScRefHdlrControllerImplBase(TBindings* pB, TChildWindow* pCW, - TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID) - : TWindow(pB, pCW, pParent, rUIXMLDescription, rID) - , ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ) -{ -} - -template<class TWindow, bool bBindRef > -template<class TParentWindow, class TArg> -ScRefHdlrControllerImplBase<TWindow,bBindRef>::ScRefHdlrControllerImplBase(TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID, - const TArg &rArg, SfxBindings *pB) - : TWindow(pParent, rUIXMLDescription, rID, rArg) - , ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ) -{ -} - template<class TDerived, class TBase, bool bBindRef = true> -struct ScRefHdlrControllerImpl: ScRefHdlrControllerImplBase< TBase, bBindRef > +struct ScRefHdlrControllerImpl : ScRefHdlrControllerImplBase<TBase, bBindRef> { enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID }; - template<class T1, class T2, class T3, class T4> - ScRefHdlrControllerImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 ) - : ScRefHdlrControllerImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4) - { - SC_MOD()->RegisterRefController( static_cast<sal_uInt16>( TDerived::SLOTID ), this ); - } - - template<class T1, class T2, class T3, class T4, class T5> - ScRefHdlrControllerImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 ) + ScRefHdlrControllerImpl(weld::Window* rt1, const OUString& rt2, const OString& rt3, const SfxItemSet* rt4, SfxBindings *rt5) : ScRefHdlrControllerImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4, rt5) { - SC_MOD()->RegisterRefController( static_cast<sal_uInt16>( TDerived::SLOTID ), this ); } - ~ScRefHdlrControllerImpl() + ScRefHdlrControllerImpl(SfxBindings* rt1, SfxChildWindow* rt2, weld::Window* rt3, const OUString& rt4, const OString& rt5) + : ScRefHdlrControllerImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4, rt5) { - SC_MOD()->UnregisterRefController( static_cast<sal_uInt16>( TDerived::SLOTID ), this ); } }; -struct ScAnyRefDlgController : ::ScRefHdlrControllerImpl<ScAnyRefDlgController, SfxModelessDialogController> +struct ScAnyRefDlgController : ScRefHdlrControllerImpl<ScAnyRefDlgController, SfxModelessDialogController> { - template<class T1, class T2, class T3, class T4, class T5> - ScAnyRefDlgController( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 ) + ScAnyRefDlgController(SfxBindings* rt1, SfxChildWindow* rt2, weld::Window* rt3, const OUString& rt4, const OString& rt5) : ScRefHdlrControllerImpl<ScAnyRefDlgController, SfxModelessDialogController>(rt1, rt2, rt3, rt4, rt5) { } }; -inline bool ScRefHandler::CanInputStart( const formula::RefEdit *pEdit ) +inline bool ScRefHandler::CanInputStart( const formula::WeldRefEdit *pEdit ) { return ScFormulaReferenceHelper::CanInputStart( pEdit ); } diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index e5cbd9479f9b..f599f2162818 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -179,7 +179,6 @@ class SC_DLLPUBLIC ScValidityRefChildWin : public SfxChildWindow { bool m_bVisibleLock:1; bool m_bFreeWindowLock:1; - VclPtr<vcl::Window> m_pSavedWndParent; public: ScValidityRefChildWin( vcl::Window*, sal_uInt16, const SfxBindings*, SfxChildWinInfo* ); SFX_DECL_CHILDWINDOW_WITHID(ScValidityRefChildWin); diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx index c29d8b6c7335..d28ee58192cd 100644 --- a/sc/source/ui/inc/validate.hxx +++ b/sc/source/ui/inc/validate.hxx @@ -41,7 +41,7 @@ protected: #endif void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , const ScDocument* ); void (ScRefHandlerCaller::*m_pSetActiveHdl)(); - void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton ); void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)(); #if defined( _WIN32) #pragma pack(pop) @@ -50,7 +50,7 @@ protected: public: typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument* ); typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)(); - typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton ); void SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl ) { @@ -79,10 +79,10 @@ class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage { static const sal_uInt16 pValueRanges[]; public: - explicit ScTPValidationValue( vcl::Window* pParent, const SfxItemSet& rArgSet ); - virtual ~ScTPValidationValue() override; + explicit ScTPValidationValue(TabPageParent pParent, const SfxItemSet& rArgSet); virtual void dispose() override; - static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rArgSet ); + virtual ~ScTPValidationValue() override; + static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rArgSet ); static const sal_uInt16* GetRanges() { return pValueRanges; } virtual bool FillItemSet( SfxItemSet* rArgSet ) override; @@ -97,22 +97,8 @@ private: void SetFirstFormula( const OUString& rFmlaStr ); void SetSecondFormula( const OUString& rFmlaStr ); - DECL_LINK(SelectHdl, ListBox&, void); - DECL_LINK(CheckHdl, Button*, void); - - VclPtr<ListBox> m_pLbAllow; - VclPtr<CheckBox> m_pCbAllow; /// Allow blank cells. - VclPtr<CheckBox> m_pCbShow; /// Show selection list in cell. - VclPtr<CheckBox> m_pCbSort; /// Sort selection list in cell. - VclPtr<FixedText> m_pFtValue; - VclPtr<ListBox> m_pLbValue; - VclPtr<FixedText> m_pFtMin; - VclPtr<VclContainer> m_pMinGrid; - VclPtr<formula::RefEdit> m_pEdMin; - VclPtr<VclMultiLineEdit> m_pEdList; /// Entries for explicit list - VclPtr<FixedText> m_pFtMax; - VclPtr<formula::RefEdit> m_pEdMax; - VclPtr<FixedText> m_pFtHint; /// Hint text for cell range validity. + DECL_LINK(SelectHdl, weld::ComboBox&, void); + DECL_LINK(CheckHdl, weld::Button&, void); OUString const maStrMin; OUString const maStrMax; @@ -122,75 +108,65 @@ private: OUString const maStrList; sal_Unicode mcFmlaSep; /// List separator in formulas. - DECL_LINK( EditSetFocusHdl, Control&, void ); - DECL_LINK( KillFocusHdl, Control&, void ); - void OnClick( const Button *pBtn ); - VclPtr<formula::RefEdit> m_pRefEdit; -public: - class ScRefButtonEx : public ::formula::RefButton - { - VclPtr<ScTPValidationValue> m_pPage; - virtual void Click() override; - public: - ScRefButtonEx(vcl::Window* pParent, WinBits nStyle) - : ::formula::RefButton(pParent, nStyle) - , m_pPage(nullptr) - { - } - virtual ~ScRefButtonEx() override; - virtual void dispose() override; - void SetParentPage(ScTPValidationValue *pPage) - { - m_pPage = pPage; - } - ScTPValidationValue* GetParentPage() - { - return m_pPage; - } - }; -private: - VclPtr<ScRefButtonEx> m_pBtnRef; - VclPtr<VclContainer> m_pRefGrid; - friend class ScRefButtonEx; + DECL_LINK( EditSetFocusHdl, formula::WeldRefEdit&, void ); + DECL_LINK( KillEditFocusHdl, formula::WeldRefEdit&, void ); + DECL_LINK( KillButtonFocusHdl, formula::WeldRefButton&, void ); + DECL_LINK( ClickHdl, formula::WeldRefButton&, void ); + + formula::WeldRefEdit* m_pRefEdit; + + std::unique_ptr<weld::ComboBox> m_xLbAllow; + std::unique_ptr<weld::CheckButton> m_xCbAllow; /// Allow blank cells. + std::unique_ptr<weld::CheckButton> m_xCbShow; /// Show selection list in cell. + std::unique_ptr<weld::CheckButton> m_xCbSort; /// Sort selection list in cell. + std::unique_ptr<weld::Label> m_xFtValue; + std::unique_ptr<weld::ComboBox> m_xLbValue; + std::unique_ptr<weld::Label> m_xFtMin; + std::unique_ptr<weld::Widget> m_xMinGrid; + std::unique_ptr<formula::WeldRefEdit> m_xEdMin; + std::unique_ptr<weld::TextView> m_xEdList; /// Entries for explicit list + std::unique_ptr<weld::Label> m_xFtMax; + std::unique_ptr<formula::WeldRefEdit> m_xEdMax; + std::unique_ptr<weld::Label> m_xFtHint; /// Hint text for cell range validity. + std::unique_ptr<formula::WeldRefButton> m_xBtnRef; + std::unique_ptr<weld::Container> m_xRefGrid; + + weld::Container* m_pRefEditParent; + weld::Container* m_pBtnRefParent; + void SetReferenceHdl( const ScRange& , const ScDocument* ); void SetActiveHdl(); - void RefInputStartPreHdl( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + void RefInputStartPreHdl(formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton); void RefInputDonePostHdl(); ScValidationDlg * GetValidationDlg(); public: void SetupRefDlg(); - void RemoveRefDlg(); + void RemoveRefDlg(bool bRestoreModal); }; /** The "Validity" tab dialog. */ class ScValidationDlg - : public ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false> + : public ScRefHdlrControllerImpl<ScValidationDlg, SfxTabDialogController, false> , public ScRefHandlerHelper { - typedef ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false> ScValidationDlgBase; + typedef ScRefHdlrControllerImpl<ScValidationDlg, SfxTabDialogController, false> ScValidationDlgBase; ScTabViewShell * const m_pTabVwSh; - VclPtr<VclHBox> m_pHBox; - sal_uInt16 m_nValuePageId; + OString m_sValuePageId; bool m_bOwnRefHdlr:1; bool m_bRefInputting:1; + std::unique_ptr<weld::Container> m_xHBox; + bool EnterRefStatus(); bool LeaveRefStatus(); public: - explicit ScValidationDlg( vcl::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh ); - virtual ~ScValidationDlg() override; - virtual void dispose() override - { - if( m_bOwnRefHdlr ) - RemoveRefDlg( false ); - m_pHBox.clear(); - ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false>::dispose(); - } - static ScValidationDlg * Find1AliveObject( vcl::Window *pAncestor ) + explicit ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell* pTabViewSh); + virtual ~ScValidationDlg() override; + static std::shared_ptr<SfxDialogController> Find1AliveObject(weld::Window *pAncestor) { - return static_cast<ScValidationDlg *>( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) ); + return SC_MOD()->Find1RefWindow(SLOTID, pAncestor); } ScTabViewShell *GetTabViewShell() { @@ -198,9 +174,9 @@ public: } bool SetupRefDlg(); - bool RemoveRefDlg( bool bRestoreModal ); + bool RemoveRefDlg(bool bRestoreModal); - void SetModal( bool bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); } + void SetModal(bool bModal) { m_xDialog->set_modal(bModal); } virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override { @@ -215,9 +191,9 @@ public: } bool IsRefInputting(){ return m_bRefInputting; } - vcl::Window* get_refinput_shrink_parent() { return m_pHBox; } + weld::Container* get_refinput_shrink_parent() { return m_xHBox.get(); } - virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override + virtual void RefInputStart( formula::WeldRefEdit* pEdit, formula::WeldRefButton* pButton = nullptr ) override { if( !CanInputStart( pEdit ) ) return; @@ -228,7 +204,7 @@ public: ScValidationDlgBase::RefInputStart( pEdit, pButton ); } - virtual void RefInputStart( formula::WeldRefEdit* /*pEdit*/, formula::WeldRefButton* /*pButton*/ = nullptr ) override + virtual void RefInputStart( formula::RefEdit* /*pEdit*/, formula::RefButton* /*pButton*/ = nullptr ) override { assert(false); } @@ -249,15 +225,14 @@ public: enum { SLOTID = SID_VALIDITY_REFERENCE }; - bool Close() override + virtual void Close() override { - if( m_bOwnRefHdlr ) + if (m_bOwnRefHdlr) { - if (SfxTabPage* pPage = GetTabPage(m_nValuePageId)) - static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(); + if (SfxTabPage* pPage = GetTabPage(m_sValuePageId)) + static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false); } - - return ScValidationDlgBase::Close(); + ScValidationDlgBase::Close(); } }; diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index a8a9282cc174..a1c0bebdc663 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -888,7 +888,7 @@ ScRefHandler::ScRefHandler( vcl::Window &rWindow, SfxBindings* pB, bool bBindRef if( bBindRef ) EnterRefMode(); } -ScRefHandler::ScRefHandler(SfxModelessDialogController& rController, SfxBindings* pB, bool bBindRef) +ScRefHandler::ScRefHandler(SfxDialogController& rController, SfxBindings* pB, bool bBindRef) : m_pController(&rController) , m_bInRefMode(false) , m_aHelper(this, pB) @@ -968,10 +968,6 @@ bool ScRefHandler::LeaveRefMode() lcl_HideAllReferences(); - if( Dialog *pDlg = dynamic_cast<Dialog*>( m_rWindow.get() ) ) - pDlg->SetModalInputMode(false); - if (m_pController) - m_pController->getDialog()->set_modal(false); SetDispatcherLock( false ); //! here and in DoClose ? ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 41343911fe3f..cf4e00a35816 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -210,6 +210,26 @@ static bool lcl_GetSortParam( const ScViewData* pData, const ScSortParam& rSortP return bSort; } +namespace +{ + // this registers the dialog which Find1RefWindow search for + class ScValidationRegisteredDlg + { + std::shared_ptr<SfxDialogController> m_xDlg; + public: + ScValidationRegisteredDlg(weld::Window* pParent, std::shared_ptr<SfxDialogController>& rDlg) + : m_xDlg(rDlg) + { + SC_MOD()->RegisterRefController(static_cast<sal_uInt16>(ScValidationDlg::SLOTID), m_xDlg, pParent); + } + ~ScValidationRegisteredDlg() + { + m_xDlg->Close(); + SC_MOD()->UnregisterRefController(static_cast<sal_uInt16>(ScValidationDlg::SLOTID), m_xDlg); + } + }; +} + void ScCellShell::ExecuteDB( SfxRequest& rReq ) { ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); @@ -871,12 +891,15 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) } // cell range picker - ScopedVclPtrInstance<ScValidationDlg> pDlg(GetViewData()->GetActiveWin(), &aArgSet, pTabViewShell); + vcl::Window* pWin = GetViewData()->GetActiveWin(); + weld::Window* pParentWin = pWin ? pWin->GetFrameWeld() : nullptr; + std::shared_ptr<SfxDialogController> xDlg(new ScValidationDlg(pParentWin, &aArgSet, pTabViewShell)); + ScValidationRegisteredDlg aRegisterThatDlgExists(pParentWin, xDlg); - short nResult = pDlg->Execute(); + short nResult = xDlg->run(); if ( nResult == RET_OK ) { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + const SfxItemSet* pOutSet = static_cast<ScValidationDlg*>(xDlg.get())->GetOutputItemSet(); if ( pOutSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET ) eMode = static_cast<ScValidationMode>(static_cast<const SfxAllEnumItem*>(pItem)->GetValue()); diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index 5b4a6044a217..c5b697d95639 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -277,38 +277,33 @@ namespace } } -ScValidityRefChildWin::ScValidityRefChildWin( vcl::Window* pParentP, - sal_uInt16 nId, - const SfxBindings* p, +ScValidityRefChildWin::ScValidityRefChildWin(vcl::Window* pParentP, + sal_uInt16 nId, + const SfxBindings* p, SAL_UNUSED_PARAMETER SfxChildWinInfo* /*pInfo*/ ) - : SfxChildWindow(pParentP, nId), - m_bVisibleLock( false ), - m_bFreeWindowLock( false ), - m_pSavedWndParent( nullptr ) + : SfxChildWindow(pParentP, nId) + , m_bVisibleLock(false) + , m_bFreeWindowLock(false) { SetWantsFocus( false ); - VclPtr<ScValidationDlg> pDlg = ScValidationDlg::Find1AliveObject( pParentP ); - SetWindow(pDlg); + std::shared_ptr<SfxDialogController> xDlg(ScValidationDlg::Find1AliveObject(pParentP->GetFrameWeld())); + SetController(xDlg); ScTabViewShell* pViewShell; - if (pDlg) - pViewShell = static_cast<ScValidationDlg*>(GetWindow())->GetTabViewShell(); + if (xDlg) + pViewShell = static_cast<ScValidationDlg*>(xDlg.get())->GetTabViewShell(); else pViewShell = lcl_GetTabViewShell( p ); if (!pViewShell) pViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); OSL_ENSURE( pViewShell, "missing view shell :-(" ); - if (pViewShell && !GetWindow()) + if (pViewShell && !xDlg) pViewShell->GetViewFrame()->SetChildWindow( nId, false ); - - if( GetWindow() ) m_pSavedWndParent = GetWindow()->GetParent(); } ScValidityRefChildWin::~ScValidityRefChildWin() { - if( GetWindow() ) GetWindow()->SetParent( m_pSavedWndParent ); - - if( m_bFreeWindowLock ) - SetWindow(nullptr); + if (m_bFreeWindowLock) + SetController(nullptr); } IMPL_CHILD_CTOR( ScCondFormatDlgWrapper, WID_CONDFRMT_REF ) diff --git a/sc/uiconfig/scalc/ui/validationcriteriapage.ui b/sc/uiconfig/scalc/ui/validationcriteriapage.ui index 2bf0bab17955..00897a20510e 100644 --- a/sc/uiconfig/scalc/ui/validationcriteriapage.ui +++ b/sc/uiconfig/scalc/ui/validationcriteriapage.ui @@ -1,96 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sc"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> - <object class="GtkListStore" id="liststore1"> - <columns> - <!-- column-name gchararray1 --> - <column type="gchararray"/> - <!-- column-name gint1 --> - <column type="gint"/> - </columns> - <data> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">All values</col> - <col id="1">0</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Whole Numbers</col> - <col id="1">1</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Decimal</col> - <col id="1">2</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Date</col> - <col id="1">3</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Time</col> - <col id="1">4</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Cell range</col> - <col id="1">5</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">List</col> - <col id="1">6</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Text length</col> - <col id="1">7</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore1">Custom</col> - <col id="1">8</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore2"> - <columns> - <!-- column-name gchararray1 --> - <column type="gchararray"/> - <!-- column-name gint1 --> - <column type="gint"/> - </columns> - <data> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">equal</col> - <col id="1">0</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">less than</col> - <col id="1">1</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">greater than</col> - <col id="1">2</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">less than or equal</col> - <col id="1">3</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">greater than or equal to</col> - <col id="1">4</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">not equal</col> - <col id="1">5</col> - </row> - <row> - <col id="0" translatable="yes" context="validationcriteriapage|liststore2">valid range</col> - <col id="1">6</col> - </row> - <row> ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits