include/vcl/svtabbx.hxx | 3 vcl/inc/jsdialog/jsdialogbuilder.hxx | 108 ++++++--- vcl/jsdialog/jsdialogbuilder.cxx | 278 ++++++++++++++++--------- vcl/source/control/WeldedTabbedNotebookbar.cxx | 4 vcl/source/treelist/svtabbx.cxx | 51 ++++ vcl/source/window/builder.cxx | 10 6 files changed, 319 insertions(+), 135 deletions(-)
New commits: commit d6898cf9b6f1e919d3423e32ebb9ed78c5ac4988 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Oct 28 16:08:43 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Nov 30 15:02:38 2020 +0100 jsdialog: dump treelistview Change-Id: Id6152a1b96a92a8ee863e1426d458b9f81605065 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106565 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/svtabbx.hxx b/include/vcl/svtabbx.hxx index fda6c2a28c35..a732736a031c 100644 --- a/include/vcl/svtabbx.hxx +++ b/include/vcl/svtabbx.hxx @@ -22,6 +22,7 @@ #include <vcl/dllapi.h> #include <vcl/treelistbox.hxx> #include <vcl/accessibletableprovider.hxx> +#include <boost/property_tree/ptree_fwd.hpp> #include <tools/debug.hxx> @@ -96,6 +97,8 @@ public: sal_uLong GetEntryPos( const SvTreeListEntry* pEntry ) const; void SetTabJustify( sal_uInt16 nTab, SvTabJustify ); + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; }; // class SvHeaderTabListBox --------------------------------------------------- diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx index c7e17fe66f4b..1696f3e316ba 100644 --- a/vcl/source/treelist/svtabbx.cxx +++ b/vcl/source/treelist/svtabbx.cxx @@ -30,6 +30,7 @@ #include <strings.hrc> #include <svdata.hxx> #include <memory> +#include <boost/property_tree/ptree.hpp> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; @@ -37,6 +38,56 @@ using namespace ::com::sun::star::accessibility; static constexpr SvLBoxTabFlags MYTABMASK = SvLBoxTabFlags::ADJUST_RIGHT | SvLBoxTabFlags::ADJUST_LEFT | SvLBoxTabFlags::ADJUST_CENTER | SvLBoxTabFlags::FORCE; +static boost::property_tree::ptree lcl_DumpEntryAndSiblings(SvTreeListEntry* pEntry, + SvTabListBox* pTabListBox, + bool bCheckButtons) +{ + boost::property_tree::ptree aEntries; + + while (pEntry) + { + boost::property_tree::ptree aEntry; + + const SvLBoxItem* pIt = pEntry->GetFirstItem(SvLBoxItemType::String); + if (pIt) + aEntry.put("text", static_cast<const SvLBoxString*>(pIt)->GetText()); + + if (bCheckButtons) + { + SvButtonState eCheckState = pTabListBox->GetCheckButtonState(pEntry); + if (eCheckState == SvButtonState::Unchecked) + aEntry.put("state", "false"); + else if (eCheckState == SvButtonState::Checked) + aEntry.put("state", "true"); + } + + if (pTabListBox->IsSelected(pEntry)) + aEntry.put("selected", "true"); + + aEntry.put("row", OString::number(pTabListBox->GetModel()->GetAbsPos(pEntry)).getStr()); + + SvTreeListEntry* pChild = pTabListBox->FirstChild(pEntry); + if (pChild) + aEntry.push_back(std::make_pair("children", lcl_DumpEntryAndSiblings(pChild, pTabListBox, bCheckButtons))); + + aEntries.push_back(std::make_pair("", aEntry)); + + pEntry = pEntry->NextSibling(); + } + + return aEntries; +} + +boost::property_tree::ptree SvTabListBox::DumpAsPropertyTree() +{ + boost::property_tree::ptree aTree(SvTreeListBox::DumpAsPropertyTree()); + + bool bCheckButtons = static_cast<int>(nTreeFlags & SvTreeFlags::CHKBTN); + aTree.push_back(std::make_pair("entries", lcl_DumpEntryAndSiblings(First(), this, bCheckButtons))); + + return aTree; +} + // SvTreeListBox callback void SvTabListBox::SetTabs() commit e28d2e09f304256dcf3785fe2d2e6a79e40e6e05 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Oct 21 15:45:19 2020 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Nov 30 15:02:24 2020 +0100 jsdialog: use separate content and notificator windows Change-Id: I42208dd69bc790d136637253d7f1ae39a6306820 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106564 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index ed120ffa2108..0682cc0d1bc5 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -28,12 +28,17 @@ typedef std::map<OString, weld::Widget*> WidgetMap; class JSDialogNotifyIdle : public Idle { - VclPtr<vcl::Window> m_aWindow; + // used to send message + VclPtr<vcl::Window> m_aNotifierWindow; + // used to generate JSON + VclPtr<vcl::Window> m_aContentWindow; + std::string m_sTypeOfJSON; std::string m_LastNotificationMessage; bool m_bForce; public: - JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow); + JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + std::string sTypeOfJSON); void Invoke() override; void ForceUpdate(); @@ -44,8 +49,9 @@ class VCL_DLLPUBLIC JSDialogSender std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify; public: - JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel) - : mpIdleNotify(new JSDialogNotifyIdle(aOwnedToplevel)) + JSDialogSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + std::string sTypeOfJSON) + : mpIdleNotify(new JSDialogNotifyIdle(aNotifierWindow, aContentWindow, sTypeOfJSON)) { } @@ -57,6 +63,8 @@ class JSInstanceBuilder : public SalInstanceBuilder sal_uInt64 m_nWindowId; /// used in case of tab pages where dialog is not a direct top level VclPtr<vcl::Window> m_aParentDialog; + VclPtr<vcl::Window> m_aContentWindow; + std::string m_sTypeOfJSON; bool m_bHasTopLevelDialog; bool m_bIsNotebookbar; @@ -68,12 +76,26 @@ class JSInstanceBuilder : public SalInstanceBuilder void RememberWidget(const OString& id, weld::Widget* pWidget); static weld::Widget* FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget); -public: + /// used for dialogs JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile); - /// optional nWindowId is used if getting parent id failed + /// used for notebookbar, optional nWindowId is used if getting parent id failed JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile, const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId = 0); + /// for autofilter dropdown + JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile); + +public: + static JSInstanceBuilder* CreateDialogBuilder(weld::Widget* pParent, const OUString& rUIRoot, + const OUString& rUIFile); + static JSInstanceBuilder* + CreateNotebookbarBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile, + const css::uno::Reference<css::frame::XFrame>& rFrame, + sal_uInt64 nWindowId = 0); + static JSInstanceBuilder* CreateAutofilterWindowBuilder(vcl::Window* 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; @@ -104,16 +126,21 @@ public: VclMessageType eMessageType, VclButtonsType eButtonType, const OUString& rPrimaryMessage); + +private: + VclPtr<vcl::Window>& GetContentWindow(); + VclPtr<vcl::Window>& GetNotifierWindow(); }; template <class BaseInstanceClass, class VclClass> class JSWidget : public BaseInstanceClass, public JSDialogSender { public: - JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder, - bool bTakeOwnership) + JSWidget(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + VclClass* pObject, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) : BaseInstanceClass(pObject, pBuilder, bTakeOwnership) - , JSDialogSender(aOwnedToplevel) + , JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON) { } @@ -139,8 +166,9 @@ public: class VCL_DLLPUBLIC JSDialog : public JSWidget<SalInstanceDialog, ::Dialog> { public: - JSDialog(VclPtr<vcl::Window> aOwnedToplevel, ::Dialog* pDialog, SalInstanceBuilder* pBuilder, - bool bTakeOwnership); + JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override; virtual void undo_collapse() override; @@ -149,31 +177,34 @@ public: class JSLabel : public JSWidget<SalInstanceLabel, FixedText> { public: - JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, - bool bTakeOwnership); + JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void set_label(const OUString& rText) override; }; class JSButton : public JSWidget<SalInstanceButton, ::Button> { public: - JSButton(VclPtr<vcl::Window> aOwnedToplevel, ::Button* pButton, SalInstanceBuilder* pBuilder, - bool bTakeOwnership); + JSButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); }; class JSEntry : public JSWidget<SalInstanceEntry, ::Edit> { public: - JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, - bool bTakeOwnership); + JSEntry(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::Edit* pEntry, + SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON); virtual void set_text(const OUString& rText) override; }; class JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox> { public: - JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder, - bool bTakeOwnership); + JSListBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) override; virtual void remove(int pos) override; @@ -183,8 +214,9 @@ public: class JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox> { public: - JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox, - SalInstanceBuilder* pBuilder, bool bTakeOwnership); + JSComboBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) override; virtual void remove(int pos) override; @@ -195,8 +227,9 @@ public: class JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl> { public: - JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, - SalInstanceBuilder* pBuilder, bool bTakeOwnership); + JSNotebook(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::TabControl* pControl, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void set_current_page(int nPage) override; @@ -210,8 +243,9 @@ public: class JSSpinButton : public JSWidget<SalInstanceSpinButton, ::FormattedField> { public: - JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, - SalInstanceBuilder* pBuilder, bool bTakeOwnership); + JSSpinButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::FormattedField* pSpin, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void set_value(int value) override; }; @@ -219,7 +253,8 @@ public: class JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender { public: - JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); virtual void set_primary_text(const OUString& rText) override; @@ -229,8 +264,9 @@ public: class JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox> { public: - JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, - SalInstanceBuilder* pBuilder, bool bTakeOwnership); + JSCheckButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void set_active(bool active) override; }; @@ -238,9 +274,9 @@ public: class JSDrawingArea : public SalInstanceDrawingArea, public JSDialogSender { public: - JSDrawingArea(VclPtr<vcl::Window> aOwnedToplevel, VclDrawingArea* pDrawingArea, - SalInstanceBuilder* pBuilder, const a11yref& rAlly, - FactoryFunction pUITestFactoryFunction, void* pUserData, + JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + VclDrawingArea* pDrawingArea, SalInstanceBuilder* pBuilder, const a11yref& rAlly, + FactoryFunction pUITestFactoryFunction, void* pUserData, std::string sTypeOfJSON, bool bTakeOwnership = false); virtual void queue_draw() override; @@ -250,8 +286,9 @@ public: class JSToolbar : public JSWidget<SalInstanceToolbar, ::ToolBox> { public: - JSToolbar(VclPtr<vcl::Window> aOwnedToplevel, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, - bool bTakeOwnership); + JSToolbar(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void signal_clicked(const OString& rIdent) override; }; @@ -259,8 +296,9 @@ public: class JSTextView : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit> { public: - JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView, - SalInstanceBuilder* pBuilder, bool bTakeOwnership); + JSTextView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON); virtual void set_text(const OUString& rText) override; }; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index d9fcf3032081..92f0dc9769ea 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -18,9 +18,12 @@ using namespace weld; -JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow) +JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, + VclPtr<vcl::Window> aContentWindow, std::string sTypeOfJSON) : Idle("JSDialog notify") - , m_aWindow(aWindow) + , m_aNotifierWindow(aNotifierWindow) + , m_aContentWindow(aContentWindow) + , m_sTypeOfJSON(sTypeOfJSON) , m_LastNotificationMessage() , m_bForce(false) { @@ -33,15 +36,16 @@ void JSDialogNotifyIdle::Invoke() { try { - if (!m_aWindow) + if (!m_aNotifierWindow) return; - const vcl::ILibreOfficeKitNotifier* pNotifier = m_aWindow->GetLOKNotifier(); + const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier(); if (pNotifier) { std::stringstream aStream; - boost::property_tree::ptree aTree = m_aWindow->DumpAsPropertyTree(); - aTree.put("id", m_aWindow->GetLOKWindowId()); + boost::property_tree::ptree aTree = m_aContentWindow->DumpAsPropertyTree(); + aTree.put("id", m_aNotifierWindow->GetLOKWindowId()); + aTree.put("jsontype", m_sTypeOfJSON); boost::property_tree::write_json(aStream, aTree); const std::string message = aStream.str(); if (m_bForce || message != m_LastNotificationMessage) @@ -65,6 +69,7 @@ void JSDialogSender::notifyDialogState(bool bForce) mpIdleNotify->Start(); } +// used for dialogs JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) : SalInstanceBuilder(dynamic_cast<SalInstanceWidget*>(pParent) @@ -73,6 +78,8 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR rUIRoot, rUIFile) , m_nWindowId(0) , m_aParentDialog(nullptr) + , m_aContentWindow(nullptr) + , m_sTypeOfJSON("dialog") , m_bHasTopLevelDialog(false) , m_bIsNotebookbar(false) { @@ -86,6 +93,7 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR } } +// used for notebookbar JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile, const css::uno::Reference<css::frame::XFrame>& rFrame, @@ -93,6 +101,8 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRo : SalInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame) , m_nWindowId(0) , m_aParentDialog(nullptr) + , m_aContentWindow(nullptr) + , m_sTypeOfJSON("notebookbar") , m_bHasTopLevelDialog(false) , m_bIsNotebookbar(false) { @@ -111,6 +121,49 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRo } } +// used for autofilter dropdown +JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, + const OUString& rUIFile) + : SalInstanceBuilder(pParent, rUIRoot, rUIFile) + , m_nWindowId(0) + , m_aParentDialog(nullptr) + , m_aContentWindow(nullptr) + , m_sTypeOfJSON("autofilter") + , m_bHasTopLevelDialog(false) + , m_bIsNotebookbar(false) +{ + vcl::Window* pRoot = get_builder().get_widget_root(); + m_aContentWindow = pParent; + if (pRoot && pRoot->GetParent()) + { + m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier(); + if (m_aParentDialog) + m_nWindowId = m_aParentDialog->GetLOKWindowId(); + InsertWindowToMap(m_nWindowId); + } +} + +JSInstanceBuilder* JSInstanceBuilder::CreateDialogBuilder(weld::Widget* pParent, + const OUString& rUIRoot, + const OUString& rUIFile) +{ + return new JSInstanceBuilder(pParent, rUIRoot, rUIFile); +} + +JSInstanceBuilder* JSInstanceBuilder::CreateNotebookbarBuilder( + vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile, + const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId) +{ + return new JSInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame, nWindowId); +} + +JSInstanceBuilder* JSInstanceBuilder::CreateAutofilterWindowBuilder(vcl::Window* pParent, + const OUString& rUIRoot, + const OUString& rUIFile) +{ + return new JSInstanceBuilder(pParent, rUIRoot, rUIFile); +} + JSInstanceBuilder::~JSInstanceBuilder() { if (m_nWindowId && (m_bHasTopLevelDialog || m_bIsNotebookbar)) @@ -157,6 +210,19 @@ void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget) } } +VclPtr<vcl::Window>& JSInstanceBuilder::GetContentWindow() +{ + if (m_aContentWindow) + return m_aContentWindow; + else + return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog; +} + +VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow() +{ + return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog; +} + std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, bool bTakeOwnership) { ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id); @@ -164,8 +230,9 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, InsertWindowToMap(m_nWindowId); - std::unique_ptr<weld::Dialog> pRet( - pDialog ? new JSDialog(m_aOwnedToplevel, pDialog, this, false) : nullptr); + std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, + pDialog, this, false, m_sTypeOfJSON) + : nullptr); if (bTakeOwnership && pDialog) { assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); @@ -191,8 +258,8 @@ 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_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, pLabel, this, bTakeOwnership); + auto pWeldWidget = std::make_unique<JSLabel>(GetNotifierWindow(), GetContentWindow(), pLabel, + this, bTakeOwnership, m_sTypeOfJSON); if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -203,10 +270,10 @@ 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); - auto pWeldWidget = pButton ? std::make_unique<JSButton>(m_bHasTopLevelDialog ? m_aOwnedToplevel - : m_aParentDialog, - pButton, this, bTakeOwnership) - : nullptr; + auto pWeldWidget + = pButton ? std::make_unique<JSButton>(GetNotifierWindow(), GetContentWindow(), pButton, + this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -217,10 +284,10 @@ std::unique_ptr<weld::Button> JSInstanceBuilder::weld_button(const OString& id, 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_bHasTopLevelDialog ? m_aOwnedToplevel - : m_aParentDialog, - pEntry, this, bTakeOwnership) - : nullptr; + auto pWeldWidget = pEntry + ? std::make_unique<JSEntry>(GetNotifierWindow(), GetContentWindow(), + pEntry, this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -237,17 +304,16 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString& if (pComboBox) { - pWeldWidget = std::make_unique<JSComboBox>(m_bHasTopLevelDialog ? m_aOwnedToplevel - : m_aParentDialog, - pComboBox, this, bTakeOwnership); + pWeldWidget = std::make_unique<JSComboBox>(GetNotifierWindow(), GetContentWindow(), + pComboBox, this, bTakeOwnership, m_sTypeOfJSON); } else { ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); - pWeldWidget = pListBox ? std::make_unique<JSListBox>(m_bHasTopLevelDialog ? m_aOwnedToplevel - : m_aParentDialog, - pListBox, this, bTakeOwnership) - : nullptr; + pWeldWidget + = pListBox ? std::make_unique<JSListBox>(GetNotifierWindow(), GetContentWindow(), + pListBox, this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; } if (pWeldWidget) @@ -260,10 +326,10 @@ 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_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, - pNotebook, this, bTakeOwnership) - : nullptr; + auto pWeldWidget + = pNotebook ? std::make_unique<JSNotebook>(GetNotifierWindow(), GetContentWindow(), + pNotebook, this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -275,10 +341,11 @@ std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OStr bool bTakeOwnership) { FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); - auto pWeldWidget = pSpinButton ? std::make_unique<JSSpinButton>( - m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, - pSpinButton, this, bTakeOwnership) - : nullptr; + auto pWeldWidget + = pSpinButton + ? std::make_unique<JSSpinButton>(GetNotifierWindow(), GetContentWindow(), pSpinButton, + this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -290,10 +357,11 @@ std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const OS bool bTakeOwnership) { CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); - auto pWeldWidget = pCheckButton ? std::make_unique<JSCheckButton>( - m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, - pCheckButton, this, bTakeOwnership) - : nullptr; + auto pWeldWidget + = pCheckButton + ? std::make_unique<JSCheckButton>(GetNotifierWindow(), GetContentWindow(), + pCheckButton, this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -307,11 +375,10 @@ JSInstanceBuilder::weld_drawing_area(const OString& id, const a11yref& rA11yImpl bool bTakeOwnership) { VclDrawingArea* pArea = m_xBuilder->get<VclDrawingArea>(id); - auto pWeldWidget = pArea - ? std::make_unique<JSDrawingArea>( - m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, pArea, - this, rA11yImpl, pUITestFactoryFunction, pUserData, bTakeOwnership) - : nullptr; + auto pWeldWidget = pArea ? std::make_unique<JSDrawingArea>( + GetNotifierWindow(), GetContentWindow(), pArea, this, rA11yImpl, + pUITestFactoryFunction, pUserData, m_sTypeOfJSON, bTakeOwnership) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -323,10 +390,10 @@ std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OString& id bool bTakeOwnership) { ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id); - auto pWeldWidget = pToolBox ? std::make_unique<JSToolbar>( - m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, - pToolBox, this, bTakeOwnership) - : nullptr; + auto pWeldWidget + = pToolBox ? std::make_unique<JSToolbar>(GetNotifierWindow(), GetContentWindow(), pToolBox, + this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -338,10 +405,10 @@ std::unique_ptr<weld::TextView> JSInstanceBuilder::weld_text_view(const OString& bool bTakeOwnership) { VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id); - auto pWeldWidget = pTextView ? std::make_unique<JSTextView>( - m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, - pTextView, this, bTakeOwnership) - : nullptr; + auto pWeldWidget + = pTextView ? std::make_unique<JSTextView>(GetNotifierWindow(), GetContentWindow(), + pTextView, this, bTakeOwnership, m_sTypeOfJSON) + : nullptr; if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -365,17 +432,20 @@ weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen std::stringstream aStream; boost::property_tree::ptree aTree = xMessageDialog->DumpAsPropertyTree(); aTree.put("id", xMessageDialog->GetLOKWindowId()); + aTree.put("jsontype", "dialog"); boost::property_tree::write_json(aStream, aTree); const std::string message = aStream.str(); pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); } - return new JSMessageDialog(xMessageDialog, nullptr, true); + return new JSMessageDialog(xMessageDialog, xMessageDialog, nullptr, true); } -JSDialog::JSDialog(VclPtr<vcl::Window> aOwnedToplevel, ::Dialog* pDialog, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceDialog, ::Dialog>(aOwnedToplevel, pDialog, pBuilder, bTakeOwnership) +JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, pDialog, pBuilder, + bTakeOwnership, sTypeOfJSON) { } @@ -391,9 +461,11 @@ void JSDialog::undo_collapse() notifyDialogState(); } -JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership) +JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceLabel, FixedText>(aNotifierWindow, aContentWindow, pLabel, pBuilder, + bTakeOwnership, sTypeOfJSON) { } @@ -403,15 +475,19 @@ void JSLabel::set_label(const OUString& rText) notifyDialogState(); }; -JSButton::JSButton(VclPtr<vcl::Window> aOwnedToplevel, ::Button* pButton, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceButton, ::Button>(aOwnedToplevel, pButton, pBuilder, bTakeOwnership) +JSButton::JSButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceButton, ::Button>(aNotifierWindow, aContentWindow, pButton, pBuilder, + bTakeOwnership, sTypeOfJSON) { } -JSEntry::JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, - bool bTakeOwnership) - : JSWidget<SalInstanceEntry, ::Edit>(aOwnedToplevel, pEntry, pBuilder, bTakeOwnership) +JSEntry::JSEntry(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceEntry, ::Edit>(aNotifierWindow, aContentWindow, pEntry, pBuilder, + bTakeOwnership, sTypeOfJSON) { } @@ -421,10 +497,11 @@ void JSEntry::set_text(const OUString& rText) notifyDialogState(); } -JSListBox::JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(aOwnedToplevel, pListBox, pBuilder, - bTakeOwnership) +JSListBox::JSListBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(aNotifierWindow, aContentWindow, pListBox, + pBuilder, bTakeOwnership, sTypeOfJSON) { } @@ -447,10 +524,11 @@ void JSListBox::set_active(int pos) notifyDialogState(); } -JSComboBox::JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aOwnedToplevel, pComboBox, pBuilder, - bTakeOwnership) +JSComboBox::JSComboBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aNotifierWindow, aContentWindow, pComboBox, + pBuilder, bTakeOwnership, sTypeOfJSON) { } @@ -479,10 +557,11 @@ void JSComboBox::set_active(int pos) notifyDialogState(); } -JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceNotebook, ::TabControl>(aOwnedToplevel, pControl, pBuilder, - bTakeOwnership) +JSNotebook::JSNotebook(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::TabControl* pControl, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceNotebook, ::TabControl>(aNotifierWindow, aContentWindow, pControl, + pBuilder, bTakeOwnership, sTypeOfJSON) { } @@ -520,10 +599,11 @@ void JSNotebook::append_page(const OString& rIdent, const OUString& rLabel) notifyDialogState(); } -JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceSpinButton, ::FormattedField>(aOwnedToplevel, pSpin, pBuilder, - bTakeOwnership) +JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::FormattedField* pSpin, SalInstanceBuilder* pBuilder, + bool bTakeOwnership, std::string sTypeOfJSON) + : JSWidget<SalInstanceSpinButton, ::FormattedField>(aNotifierWindow, aContentWindow, pSpin, + pBuilder, bTakeOwnership, sTypeOfJSON) { } @@ -533,10 +613,10 @@ void JSSpinButton::set_value(int value) notifyDialogState(); } -JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, - bool bTakeOwnership) +JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) - , JSDialogSender(m_xMessageDialog) + , JSDialogSender(m_xMessageDialog, aContentWindow, "dialog") { } @@ -552,10 +632,12 @@ void JSMessageDialog::set_secondary_text(const OUString& rText) notifyDialogState(); } -JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceCheckButton, ::CheckBox>(aOwnedToplevel, pCheckBox, pBuilder, - bTakeOwnership) +JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aNotifierWindow, + VclPtr<vcl::Window> aContentWindow, ::CheckBox* pCheckBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceCheckButton, ::CheckBox>(aNotifierWindow, aContentWindow, pCheckBox, + pBuilder, bTakeOwnership, sTypeOfJSON) { } @@ -565,13 +647,14 @@ void JSCheckButton::set_active(bool active) notifyDialogState(); } -JSDrawingArea::JSDrawingArea(VclPtr<vcl::Window> aOwnedToplevel, VclDrawingArea* pDrawingArea, +JSDrawingArea::JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow, + VclPtr<vcl::Window> aContentWindow, VclDrawingArea* pDrawingArea, SalInstanceBuilder* pBuilder, const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, void* pUserData, - bool bTakeOwnership) + std::string sTypeOfJSON, bool bTakeOwnership) : SalInstanceDrawingArea(pDrawingArea, pBuilder, rAlly, pUITestFactoryFunction, pUserData, bTakeOwnership) - , JSDialogSender(aOwnedToplevel) + , JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON) { } @@ -587,9 +670,11 @@ void JSDrawingArea::queue_draw_area(int x, int y, int width, int height) notifyDialogState(); } -JSToolbar::JSToolbar(VclPtr<vcl::Window> aOwnedToplevel, ::ToolBox* pToolbox, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceToolbar, ::ToolBox>(aOwnedToplevel, pToolbox, pBuilder, bTakeOwnership) +JSToolbar::JSToolbar(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::string sTypeOfJSON) + : JSWidget<SalInstanceToolbar, ::ToolBox>(aNotifierWindow, aContentWindow, pToolbox, pBuilder, + bTakeOwnership, sTypeOfJSON) { } @@ -599,10 +684,11 @@ void JSToolbar::signal_clicked(const OString& rIdent) notifyDialogState(); } -JSTextView::JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView, - SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aOwnedToplevel, pTextView, pBuilder, - bTakeOwnership) +JSTextView::JSTextView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, + bool bTakeOwnership, std::string sTypeOfJSON) + : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aNotifierWindow, aContentWindow, pTextView, + pBuilder, bTakeOwnership, sTypeOfJSON) { } diff --git a/vcl/source/control/WeldedTabbedNotebookbar.cxx b/vcl/source/control/WeldedTabbedNotebookbar.cxx index 2ecab57b267e..ad9947241e32 100644 --- a/vcl/source/control/WeldedTabbedNotebookbar.cxx +++ b/vcl/source/control/WeldedTabbedNotebookbar.cxx @@ -14,8 +14,8 @@ WeldedTabbedNotebookbar::WeldedTabbedNotebookbar( VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath, const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId) - : m_xBuilder(new JSInstanceBuilder(pContainerWindow, VclBuilderContainer::getUIRootDir(), - rUIFilePath, rFrame, nWindowId)) + : m_xBuilder(JSInstanceBuilder::CreateNotebookbarBuilder( + pContainerWindow, VclBuilderContainer::getUIRootDir(), rUIFilePath, rFrame, nWindowId)) { m_xContainer = m_xBuilder->weld_container("NotebookBar"); m_xNotebook = m_xBuilder->weld_notebook("ContextContainer"); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index ecc497f0c142..d141dace9e98 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -167,18 +167,24 @@ weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString } if (bUseJSBuilder) - return new JSInstanceBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); + return JSInstanceBuilder::CreateDialogBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); else return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); } weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, sal_uInt64 nLOKWindowId) { + // Notebookbar sub controls if (comphelper::LibreOfficeKit::isActive() && (rUIFile == "svx/ui/stylespreview.ui" || rUIFile == "modules/scalc/ui/numberbox.ui")) { - return new JSInstanceBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>(), nLOKWindowId); + return JSInstanceBuilder::CreateNotebookbarBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>(), nLOKWindowId); + } + else if (comphelper::LibreOfficeKit::isActive() + && (rUIFile == "modules/scalc/ui/filterdropdown.ui")) + { + return JSInstanceBuilder::CreateAutofilterWindowBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); } return ImplGetSVData()->mpDefInst->CreateInterimBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile, nLOKWindowId); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits