summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-06-05 06:42:45 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-07-02 08:21:10 +0200
commit699a31ec958a8fdc3ccf4a021298dd7c1c6ee714 (patch)
tree74653c3607f9027841c83af5590ae14773a60976 /vcl
parent111b05e412f278037b3c1a852b4ab6d9fca461f9 (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97517 Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/inc/salvtables.hxx3
-rw-r--r--vcl/source/control/WeldedTabbedNotebookbar.cxx25
-rw-r--r--vcl/source/control/notebookbar.cxx79
4 files changed, 87 insertions, 21 deletions
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();
}