diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-05-12 09:18:25 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-05-25 16:26:38 +0200 |
commit | 323f2739e038d9b9753864989af03bf7f61cfc83 (patch) | |
tree | 7ab52e9af5385378e7d437f2b6c3fdf77178c3ab | |
parent | f48b5efa7a31bddfcaec6b5fc1a4217d35052c70 (diff) |
jsdialog: sidebar: send sidebar Panels
Change-Id: Ia5a936c44e5d83fd4626098bcc027b0382523231
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116098
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | include/vcl/svapp.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/sidebar/DeckLayouter.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/sidebar/Panel.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/sidebar/PanelLayout.cxx | 3 | ||||
-rw-r--r-- | vcl/inc/jsdialog/enabled.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 6 | ||||
-rw-r--r-- | vcl/jsdialog/enabled.cxx | 43 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 47 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 16 |
9 files changed, 115 insertions, 11 deletions
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index ab2af42dc41c..d6a6bfbc5065 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1317,7 +1317,7 @@ public: // For vclbootstrapprotector: static void setDeInitHook(Link<LinkParamNone*,void> const & hook); - static weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile = false); + static weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile = false, sal_uInt64 nLOKWindowId = 0); // For the duration of vcl parent windows static weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId = 0); diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx index 36d6357ef305..9a758f1f7215 100644 --- a/sfx2/source/sidebar/DeckLayouter.cxx +++ b/sfx2/source/sidebar/DeckLayouter.cxx @@ -25,9 +25,11 @@ #include <sfx2/sidebar/Theme.hxx> #include <sfx2/sidebar/SidebarDockingWindow.hxx> #include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/viewsh.hxx> #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> +#include <vcl/jsdialog/executor.hxx> #include <vcl/window.hxx> #include <vcl/scrbar.hxx> @@ -309,6 +311,9 @@ sal_Int32 PlacePanels ( } } + if (comphelper::LibreOfficeKit::isActive()) + jsdialog::SendFullUpdate(reinterpret_cast<sal_uInt64>(SfxViewShell::Current()), "Panel"); + return nY; } diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx index 471a5f2b9507..d49f93c06659 100644 --- a/sfx2/source/sidebar/Panel.cxx +++ b/sfx2/source/sidebar/Panel.cxx @@ -24,6 +24,7 @@ #include <sfx2/sidebar/ResourceManager.hxx> #include <sfx2/sidebar/SidebarController.hxx> #include <sfx2/sidebar/SidebarPanelBase.hxx> +#include <sfx2/viewsh.hxx> #include <tools/json_writer.hxx> @@ -50,7 +51,7 @@ Panel::Panel(const PanelDescriptor& rPanelDescriptor, Deck* pDeck, const std::function<Context()>& rContextAccess, const css::uno::Reference<css::frame::XFrame>& rxFrame) - : mxBuilder(Application::CreateBuilder(pParentWindow, "sfx/ui/panel.ui")) + : mxBuilder(Application::CreateBuilder(pParentWindow, "sfx/ui/panel.ui", false, reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))) , msPanelId(rPanelDescriptor.msId) , msTitle(rPanelDescriptor.msTitle) , mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional) diff --git a/sfx2/source/sidebar/PanelLayout.cxx b/sfx2/source/sidebar/PanelLayout.cxx index 271f4d8a6c36..fb7e5a48c2a2 100644 --- a/sfx2/source/sidebar/PanelLayout.cxx +++ b/sfx2/source/sidebar/PanelLayout.cxx @@ -12,12 +12,13 @@ #include <sfx2/sidebar/PanelLayout.hxx> #include <sfx2/sidebar/TabBar.hxx> #include <sfx2/sidebar/Theme.hxx> +#include <sfx2/viewsh.hxx> #include <vcl/event.hxx> using namespace sfx2::sidebar; PanelLayout::PanelLayout(weld::Widget* pParent, const OString& rID, const OUString& rUIXMLDescription) - : m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription)) + : m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription, false, reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))) , m_xContainer(m_xBuilder->weld_container(rID)) , m_pPanel(nullptr) { diff --git a/vcl/inc/jsdialog/enabled.hxx b/vcl/inc/jsdialog/enabled.hxx index 34116b41c009..1b2ec56ce84e 100644 --- a/vcl/inc/jsdialog/enabled.hxx +++ b/vcl/inc/jsdialog/enabled.hxx @@ -14,6 +14,7 @@ namespace jsdialog { bool isBuilderEnabled(const OUString& rUIFile, bool bMobile); +bool isBuilderEnabledForSidebar(const OUString& rUIFile); bool isInterimBuilderEnabledForNotebookbar(const OUString& rUIFile); } diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index aee7121b7271..0ca30d00c8b5 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -207,6 +207,9 @@ class JSInstanceBuilder : public SalInstanceBuilder, public JSDialogSender /// used for dialogs JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile); + /// used for sidebar panels + JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile, + sal_uInt64 nLOKWindowId); /// 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, @@ -224,6 +227,9 @@ public: static JSInstanceBuilder* CreateAutofilterWindowBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile); + static JSInstanceBuilder* CreateSidebarBuilder(weld::Widget* pParent, const OUString& rUIRoot, + const OUString& rUIFile, + sal_uInt64 nLOKWindowId = 0); virtual ~JSInstanceBuilder() override; virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString& id) override; diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index a82f75ea6e30..da0174c81a8f 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -58,6 +58,49 @@ bool isBuilderEnabled(const OUString& rUIFile, bool bMobile) return false; } +bool isBuilderEnabledForSidebar(const OUString& rUIFile) +{ + if (rUIFile == "sfx/ui/panel.ui" || rUIFile == "svx/ui/sidebartextpanel.ui" + || rUIFile == "svx/ui/sidebarstylespanel.ui" || rUIFile == "svx/ui/sidebarparagraph.ui" + || rUIFile == "svx/ui/sidebarlists.ui" || rUIFile == "svx/ui/sidebararea.ui" + || rUIFile == "svx/ui/sidebarfontwork.ui" || rUIFile == "svx/ui/sidebarshadow.ui" + || rUIFile == "svx/ui/sidebareffect.ui" || rUIFile == "svx/ui/sidebargraphic.ui" + || rUIFile == "svx/ui/sidebarline.ui" || rUIFile == "svx/ui/sidebarpossize.ui" + || rUIFile == "svx/ui/defaultshapespanel.ui" || rUIFile == "svx/ui/mediaplayback.ui" + || rUIFile == "svx/ui/sidebargallery.ui" || rUIFile == "sfx/ui/templatepanel.ui" + || rUIFile == "svx/ui/sidebarempty.ui" || rUIFile == "modules/schart/ui/sidebarelements.ui" + || rUIFile == "modules/schart/ui/sidebartype.ui" + || rUIFile == "modules/schart/ui/sidebarseries.ui" + || rUIFile == "modules/schart/ui/sidebaraxis.ui" + || rUIFile == "modules/schart/ui/sidebarerrorbar.ui" + || rUIFile == "modules/simpress/ui/customanimationspanel.ui" + || rUIFile == "modules/simpress/ui/layoutpanel.ui" + || rUIFile == "modules/simpress/ui/masterpagepanel.ui" + || rUIFile == "modules/simpress/ui/slidetransitionspanel.ui" + || rUIFile == "modules/simpress/ui/tabledesignpanel.ui" + || rUIFile == "modules/simpress/ui/navigatorpanel.ui" + || rUIFile == "modules/simpress/ui/sidebarslidebackground.ui" + || rUIFile == "modules/scalc/ui/sidebaralignment.ui" + || rUIFile == "modules/scalc/ui/sidebarcellappearance.ui" + || rUIFile == "modules/scalc/ui/sidebarnumberformat.ui" + || rUIFile == "modules/scalc/ui/navigatorpanel.ui" + || rUIFile == "modules/scalc/ui/functionpanel.ui" + || rUIFile == "modules/swriter/ui/pagestylespanel.ui" + || rUIFile == "modules/swriter/ui/pageformatpanel.ui" + || rUIFile == "modules/swriter/ui/pageheaderpanel.ui" + || rUIFile == "modules/swriter/ui/pagefooterpanel.ui" + || rUIFile == "modules/swriter/ui/sidebarwrap.ui" + || rUIFile == "modules/swriter/ui/navigatorpanel.ui" + || rUIFile == "modules/swriter/ui/managechangessidebar.ui" + || rUIFile == "svx/ui/inspectortextpanel.ui" + || rUIFile == "modules/swriter/ui/sidebarstylepresets.ui" + || rUIFile == "modules/swriter/ui/sidebartheme.ui" + || rUIFile == "modules/swriter/ui/sidebartableedit.ui") + return true; + + return false; +} + bool isInterimBuilderEnabledForNotebookbar(const OUString& rUIFile) { if (rUIFile == "svx/ui/stylespreview.ui" || rUIFile == "modules/scalc/ui/numberbox.ui") diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index c74a6577515d..3a72d45e74be 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -164,6 +164,9 @@ JSDialogNotifyIdle::generateWidgetUpdate(VclPtr<vcl::Window> pWindow) const { std::unique_ptr<tools::JsonWriter> aJsonWriter(new tools::JsonWriter()); + if (!pWindow || !m_aNotifierWindow) + return aJsonWriter; + aJsonWriter->put("jsontype", m_sTypeOfJSON); aJsonWriter->put("action", "update"); aJsonWriter->put("id", m_aNotifierWindow->GetLOKWindowId()); @@ -391,6 +394,7 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR , m_bIsNotebookbar(false) { vcl::Window* pRoot = m_xBuilder->get_widget_root(); + if (pRoot && pRoot->GetParent()) { m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier(); @@ -402,6 +406,41 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON()); } +// used for sidebar panels +JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, + const OUString& rUIFile, sal_uInt64 nLOKWindowId) + : SalInstanceBuilder(extract_sal_widget(pParent), rUIRoot, rUIFile) + , m_nWindowId(nLOKWindowId) + , m_aParentDialog(nullptr) + , m_aContentWindow(nullptr) + , m_sTypeOfJSON("sidebar") + , m_bHasTopLevelDialog(false) + , m_bIsNotebookbar(false) +{ + vcl::Window* pRoot = m_xBuilder->get_widget_root(); + + m_aParentDialog = pRoot->GetParentWithLOKNotifier(); + + if (rUIFile == "sfx/ui/panel.ui") + { + // builder for Panel, get SidebarDockingWindow as m_aContentWindow + m_aContentWindow = pRoot; + for (int i = 0; i < 7 && m_aContentWindow; i++) + m_aContentWindow = m_aContentWindow->GetParent(); + } + else + { + // builder for PanelLayout, get SidebarDockingWindow as m_aContentWindow + m_aContentWindow = pRoot; + for (int i = 0; i < 9 && m_aContentWindow; i++) + m_aContentWindow = m_aContentWindow->GetParent(); + } + + InsertWindowToMap(m_nWindowId); + + initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON()); +} + // used for notebookbar JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile, @@ -477,6 +516,14 @@ JSInstanceBuilder* JSInstanceBuilder::CreateAutofilterWindowBuilder(vcl::Window* return new JSInstanceBuilder(pParent, rUIRoot, rUIFile); } +JSInstanceBuilder* JSInstanceBuilder::CreateSidebarBuilder(weld::Widget* pParent, + const OUString& rUIRoot, + const OUString& rUIFile, + sal_uInt64 nLOKWindowId) +{ + return new JSInstanceBuilder(pParent, rUIRoot, rUIFile, nLOKWindowId); +} + JSInstanceBuilder::~JSInstanceBuilder() { if (m_nWindowId && (m_bHasTopLevelDialog || m_bIsNotebookbar)) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 93724a6e6023..38671daf226b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -164,17 +164,17 @@ namespace } -weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile) +weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile, sal_uInt64 nLOKWindowId) { - bool bUseJSBuilder = false; - if (comphelper::LibreOfficeKit::isActive()) - bUseJSBuilder = jsdialog::isBuilderEnabled(rUIFile, bMobile); + { + if (jsdialog::isBuilderEnabledForSidebar(rUIFile)) + return JSInstanceBuilder::CreateSidebarBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, nLOKWindowId); + if (jsdialog::isBuilderEnabled(rUIFile, bMobile)) + return JSInstanceBuilder::CreateDialogBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile); + } - if (bUseJSBuilder) - return JSInstanceBuilder::CreateDialogBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile); - else - return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile); + return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile); } weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId) |