include/sfx2/notebookbar/SfxNotebookBar.hxx | 4 + include/vcl/WeldedTabbedNotebookbar.hxx | 34 ++++++++++ include/vcl/notebookbar.hxx | 10 +++ sfx2/source/notebookbar/SfxNotebookBar.cxx | 30 ++++++--- vcl/Library_vcl.mk | 1 vcl/inc/salvtables.hxx | 3 vcl/source/control/WeldedTabbedNotebookbar.cxx | 25 +++++++ vcl/source/control/notebookbar.cxx | 79 ++++++++++++++++++------- 8 files changed, 154 insertions(+), 32 deletions(-)
New commits: commit 699a31ec958a8fdc3ccf4a021298dd7c1c6ee714 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Jun 5 06:42:45 2020 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Jul 2 08:21:10 2020 +0200 notebookbar: build using weld::Builder and provide welded implementation for writer tabbed Change-Id: Id6c71234cb1f40fd3889555785fcdbe84b801edd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96917 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97517 Tested-by: Jenkins diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx index 1a3babd53d9e..4fbda295cace 100644 --- a/include/sfx2/notebookbar/SfxNotebookBar.hxx +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -19,6 +19,7 @@ namespace com::sun::star::uno { template <typename > class Reference; } class SfxBindings; class SfxViewFrame; class SystemWindow; +class WeldedTabbedNotebookbar; namespace sfx2 { @@ -59,6 +60,9 @@ public: private: static bool m_bLock; static bool m_bHide; + static std::unique_ptr<WeldedTabbedNotebookbar> m_pNotebookBarWeldedWrapper; + + DECL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const void*, void); }; } // namespace sfx2 diff --git a/include/vcl/WeldedTabbedNotebookbar.hxx b/include/vcl/WeldedTabbedNotebookbar.hxx new file mode 100644 index 000000000000..b6d29e846ac1 --- /dev/null +++ b/include/vcl/WeldedTabbedNotebookbar.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SFX2_NOTEBOOKBAR_WRITERTABBEDNOTEBOOKBAR_HXX +#define INCLUDED_SFX2_NOTEBOOKBAR_WRITERTABBEDNOTEBOOKBAR_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> +#include <vcl/weld.hxx> +#include <com/sun/star/frame/XFrame.hpp> + +/** Tabbed implementation of NotebookBar for Writer +*/ +class VCL_DLLPUBLIC WeldedTabbedNotebookbar +{ + std::unique_ptr<weld::Builder> m_xBuilder; + + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::Notebook> m_xNotebook; + +public: + WeldedTabbedNotebookbar(VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath, + const css::uno::Reference<css::frame::XFrame>& rFrame); +}; + +#endif // INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx index bfa75d68039f..5086b263c6ab 100644 --- a/include/vcl/notebookbar.hxx +++ b/include/vcl/notebookbar.hxx @@ -47,6 +47,11 @@ public: void ControlListenerForCurrentController(bool bListen); void StopListeningAllControllers(); + bool IsWelded() { return m_bIsWelded; } + VclPtr<vcl::Window>& GetMainContainer() { return m_xVclContentArea; } + OUString GetUIFilePath() { return m_sUIXMLDescription; } + void SetDisposeCallback(const Link<const void*, void> rDisposeCallback); + private: VclPtr<SystemWindow> m_pSystemWindow; css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener; @@ -54,6 +59,11 @@ private: std::vector<NotebookbarContextControl*> m_pContextContainers; css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<vcl::Window> m_xVclContentArea; + bool m_bIsWelded; + OUString m_sUIXMLDescription; + Link<const void*, void> m_rDisposeLink; + AllSettings DefaultSettings; AllSettings PersonaSettings; diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 3a943c28f6fb..78a8d0edc4bf 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -29,6 +29,8 @@ #include <framework/addonsoptions.hxx> #include <vcl/NotebookBarAddonsMerger.hxx> #include <vector> +#include <vcl/WeldedTabbedNotebookbar.hxx> + using namespace sfx2; using namespace css::uno; using namespace css::ui; @@ -41,6 +43,7 @@ const char MERGE_NOTEBOOKBAR_IMAGEID[] = "ImageIdentifier"; bool SfxNotebookBar::m_bLock = false; bool SfxNotebookBar::m_bHide = false; +std::unique_ptr<WeldedTabbedNotebookbar> SfxNotebookBar::m_pNotebookBarWeldedWrapper; static void NotebookbarAddonValues( std::vector<Image>& aImageValues, @@ -355,18 +358,9 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, OUString sCurrentFile; VclPtr<NotebookBar> pNotebookBar = pSysWindow->GetNotebookBar(); if ( pNotebookBar ) - sCurrentFile = OStringToOUString( pNotebookBar->getUIFile(), RTL_TEXTENCODING_ASCII_US ); - - bool bChangedFile = true; - if ( sCurrentFile.getLength() && sNewFile.getLength() ) - { - // delete "/" - sCurrentFile = sCurrentFile.copy( 0, sCurrentFile.getLength() - 1 ); - // delete ".ui" - sNewFile = sNewFile.copy( 0, sNewFile.getLength() - 3 ); + sCurrentFile = pNotebookBar->GetUIFilePath(); - bChangedFile = sNewFile != sCurrentFile; - } + bool bChangedFile = sNewFile != sCurrentFile; if ((!sFile.isEmpty() && bChangedFile) || !pNotebookBar || !pNotebookBar->IsVisible() || bReloadNotebookbar) @@ -387,6 +381,15 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, pSysWindow->SetNotebookBar(aBuf, xFrame, aNotebookBarAddonsItem , bReloadNotebookbar); pNotebookBar = pSysWindow->GetNotebookBar(); pNotebookBar->Show(); + + if ((!m_pNotebookBarWeldedWrapper || bReloadNotebookbar) && pNotebookBar->IsWelded()) + { + m_pNotebookBarWeldedWrapper.reset(new WeldedTabbedNotebookbar(pNotebookBar->GetMainContainer(), + pNotebookBar->GetUIFilePath(), + xFrame)); + pNotebookBar->SetDisposeCallback(LINK(nullptr, SfxNotebookBar, VclDisposeHdl)); + } + pNotebookBar->GetParent()->Resize(); utl::OConfigurationTreeRoot aRoot(lcl_getCurrentImplConfigRoot()); @@ -547,4 +550,9 @@ void SfxNotebookBar::ReloadNotebookBar(const OUString& sUIPath) } } +IMPL_STATIC_LINK_NOARG(SfxNotebookBar, VclDisposeHdl, const void*, void) +{ + m_pNotebookBarWeldedWrapper.reset(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 62c9b91a1604..ac780e92f2b0 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -200,6 +200,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/control/listbox \ vcl/source/control/menubtn \ vcl/source/control/notebookbar \ + vcl/source/control/WeldedTabbedNotebookbar \ vcl/source/control/quickselectionengine \ vcl/source/control/prgsbar \ vcl/source/control/roadmap \ diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index d44ad491a628..fb60a583e538 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -22,8 +22,7 @@ #include <vcl/toolkit/combobox.hxx> #include <vcl/tabctrl.hxx> #include <vcl/layout.hxx> - -class MessageDialog; +#include "messagedialog.hxx" class SalInstanceBuilder : public weld::Builder { diff --git a/vcl/source/control/WeldedTabbedNotebookbar.cxx b/vcl/source/control/WeldedTabbedNotebookbar.cxx new file mode 100644 index 000000000000..9b3c2a849808 --- /dev/null +++ b/vcl/source/control/WeldedTabbedNotebookbar.cxx @@ -0,0 +1,25 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <vcl/WeldedTabbedNotebookbar.hxx> +#include <vcl/svapp.hxx> +#include <jsdialog/jsdialogbuilder.hxx> + +WeldedTabbedNotebookbar::WeldedTabbedNotebookbar( + VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath, + const css::uno::Reference<css::frame::XFrame>& rFrame) + : m_xBuilder(new JSInstanceBuilder(pContainerWindow, VclBuilderContainer::getUIRootDir(), + rUIFilePath, rFrame)) +{ + m_xContainer = m_xBuilder->weld_container("NotebookBar"); + m_xNotebook = m_xBuilder->weld_notebook("ContextContainer"); + m_xNotebook->set_current_page("HomeLabel"); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx index 08f82b49a772..7f4922c54212 100644 --- a/vcl/source/control/notebookbar.cxx +++ b/vcl/source/control/notebookbar.cxx @@ -19,6 +19,7 @@ #include <config_folders.h> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> +#include <comphelper/lok.hxx> static OUString getCustomizedUIRootDir() { @@ -55,36 +56,60 @@ NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rU const NotebookBarAddonsItem& aNotebookBarAddonsItem) : Control(pParent) , m_pEventListener(new NotebookBarContextChangeEventListener(this)) + , m_bIsWelded(false) + , m_sUIXMLDescription(rUIXMLDescription) { + mxFrame = rFrame; + SetStyle(GetStyle() | WB_DIALOGCONTROL); OUString sUIDir = getUIRootDir(); bool doesCustomizedUIExist = doesFileExist(getCustomizedUIRootDir(), rUIXMLDescription); if ( doesCustomizedUIExist ) sUIDir = getCustomizedUIRootDir(); - m_pUIBuilder.reset( - new VclBuilder(this, sUIDir, rUIXMLDescription, rID, rFrame, true, &aNotebookBarAddonsItem)); - mxFrame = rFrame; - // In the Notebookbar's .ui file must exist control handling context - // - implementing NotebookbarContextControl interface with id "ContextContainer" - // or "ContextContainerX" where X is a number >= 1 - NotebookbarContextControl* pContextContainer = nullptr; - int i = 0; - do + + bool bIsWelded = comphelper::LibreOfficeKit::isActive() + && (rUIXMLDescription == "modules/swriter/ui/notebookbar.ui" + || rUIXMLDescription == "modules/scalc/ui/notebookbar.ui" + || rUIXMLDescription == "modules/simpress/ui/notebookbar.ui"); + if (bIsWelded) + { + m_bIsWelded = true; + m_xVclContentArea = VclPtr<VclVBox>::Create(this); + m_xVclContentArea->Show(); + // now access it using GetMainContainer and set dispose callback with SetDisposeCallback + } + else { - OUString aName = "ContextContainer"; - if (i) - aName += OUString::number(i); - - pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>(OUStringToOString(aName, RTL_TEXTENCODING_UTF8))); - if (pContextContainer) - m_pContextContainers.push_back(pContextContainer); - i++; + m_pUIBuilder.reset( + new VclBuilder(this, sUIDir, rUIXMLDescription, rID, rFrame, true, &aNotebookBarAddonsItem)); + + // In the Notebookbar's .ui file must exist control handling context + // - implementing NotebookbarContextControl interface with id "ContextContainer" + // or "ContextContainerX" where X is a number >= 1 + NotebookbarContextControl* pContextContainer = nullptr; + int i = 0; + do + { + OUString aName = "ContextContainer"; + if (i) + aName += OUString::number(i); + + pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>(OUStringToOString(aName, RTL_TEXTENCODING_UTF8))); + if (pContextContainer) + m_pContextContainers.push_back(pContextContainer); + i++; + } + while( pContextContainer != nullptr ); } - while( pContextContainer != nullptr ); UpdateBackground(); } +void NotebookBar::SetDisposeCallback(const Link<const void*, void> rDisposeCallback) +{ + m_rDisposeLink = rDisposeCallback; +} + NotebookBar::~NotebookBar() { disposeOnce(); @@ -96,9 +121,18 @@ void NotebookBar::dispose() if (m_pSystemWindow && m_pSystemWindow->ImplIsInTaskPaneList(this)) m_pSystemWindow->GetTaskPaneList()->RemoveWindow(this); m_pSystemWindow.clear(); - disposeBuilder(); + + if (m_rDisposeLink.IsSet()) + m_rDisposeLink.Call(nullptr); + + if (m_bIsWelded) + m_xVclContentArea.disposeAndClear(); + else + disposeBuilder(); + assert(m_alisteningControllers.empty()); m_pEventListener.clear(); + Control::dispose(); } @@ -162,6 +196,13 @@ void NotebookBar::Resize() pWindow->SetSizePixel(aSize); } } + if(m_bIsWelded) + { + vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); + assert(pChild); + VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); + Control::Resize(); + } Control::Resize(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits