summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSumit Chauhan <sumitcn25@gmail.com>2019-07-15 22:19:00 +0530
committerSzymon Kłos <szymon.klos@collabora.com>2019-07-19 11:51:36 +0200
commitfbcd5f074ca3dc105f4fe45b6975c6de2bf60f35 (patch)
treec37b2ef5d2534de3bb32581381a3941cc3be3bed /vcl
parent147e820cc1bd7110331a6ea73db678a4a6c324e0 (diff)
Engine to add Extension inside extension tab in NotebookBar
The patch provides backend for adding the extension.Schema for the adding extension in notebookbar can be seen here https://gerrit.libreoffice.org/#/c/75134/ Change-Id: I10f0e83d1aaec5330c80b3b53cf59a21b93be015 Reviewed-on: https://gerrit.libreoffice.org/75650 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/inc/brdwin.hxx7
-rw-r--r--vcl/source/control/notebookbar.cxx12
-rw-r--r--vcl/source/window/NotebookBarAddonsMerger.cxx101
-rw-r--r--vcl/source/window/brdwin.cxx7
-rw-r--r--vcl/source/window/builder.cxx11
-rw-r--r--vcl/source/window/syswin.cxx4
7 files changed, 131 insertions, 12 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 3540606d4b07..25f11f0cbaea 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -159,6 +159,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/mnemonicengine \
vcl/source/window/mouse \
vcl/source/window/msgbox \
+ vcl/source/window/NotebookBarAddonsMerger \
vcl/source/window/popupmenuwindow \
vcl/source/window/printdlg \
vcl/source/window/scrwnd \
diff --git a/vcl/inc/brdwin.hxx b/vcl/inc/brdwin.hxx
index 6a7fbcc2cada..0510006fa3ea 100644
--- a/vcl/inc/brdwin.hxx
+++ b/vcl/inc/brdwin.hxx
@@ -23,6 +23,7 @@
#include <vcl/notebookbar.hxx>
#include <vcl/window.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <vcl/NotebookBarAddonsMerger.hxx>
#include <com/sun/star/frame/XFrame.hpp>
@@ -152,8 +153,10 @@ public:
void SetMenuBarWindow( vcl::Window* pWindow );
void SetMenuBarMode( bool bHide );
- void SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame);
- void CloseNotebookBar();
+ void SetNotebookBar(const OUString& rUIXMLDescription,
+ const css::uno::Reference<css::frame::XFrame>& rFrame,
+ const NotebookBarAddonsItem &aNotebookBarAddonsItem);
+ void CloseNotebookBar();
const VclPtr<NotebookBar>& GetNotebookBar() const { return mpNotebookBar; }
void SetMinOutputSize( long nWidth, long nHeight )
diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx
index 8ea1a51d5989..5d960f1d81d6 100644
--- a/vcl/source/control/notebookbar.cxx
+++ b/vcl/source/control/notebookbar.cxx
@@ -51,17 +51,19 @@ public:
virtual void SAL_CALL disposing(const ::css::lang::EventObject&) override;
};
-
-
-NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame)
- : Control(pParent), m_pEventListener(new NotebookBarContextChangeEventListener(this))
+NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
+ const css::uno::Reference<css::frame::XFrame>& rFrame,
+ const NotebookBarAddonsItem& aNotebookBarAddonsItem)
+ : Control(pParent)
+ , m_pEventListener(new NotebookBarContextChangeEventListener(this))
{
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));
+ 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"
diff --git a/vcl/source/window/NotebookBarAddonsMerger.cxx b/vcl/source/window/NotebookBarAddonsMerger.cxx
new file mode 100644
index 000000000000..9bab4a4ea425
--- /dev/null
+++ b/vcl/source/window/NotebookBarAddonsMerger.cxx
@@ -0,0 +1,101 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/NotebookBarAddonsMerger.hxx>
+#include <vcl/commandinfoprovider.hxx>
+#include <vcl/toolbox.hxx>
+
+static const char MERGE_NOTEBOOKBAR_URL[] = "URL";
+static const char MERGE_NOTEBOOKBAR_TITLE[] = "Title";
+static const char MERGE_NOTEBOOKBAR_IMAGEID[] = "ImageIdentifier";
+static const char MERGE_NOTEBOOKBAR_CONTEXT[] = "Context";
+static const char MERGE_NOTEBOOKBAR_TARGET[] = "Target";
+static const char MERGE_NOTEBOOKBAR_CONTROLTYPE[] = "ControlType";
+static const char MERGE_NOTEBOOKBAR_WIDTH[] = "Width";
+static const char MERGE_NOTEBOOKBAR_STYLE[] = "Style";
+
+NotebookBarAddonsMerger::NotebookBarAddonsMerger(
+ vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& m_xFrame,
+ const NotebookBarAddonsItem& aNotebookBarAddonsItem)
+{
+ MergeNotebookBarAddons(pParent, m_xFrame, aNotebookBarAddonsItem);
+}
+
+void NotebookBarAddonsMerger::MergeNotebookBarAddons(
+ vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& m_xFrame,
+ const NotebookBarAddonsItem& aNotebookBarAddonsItem)
+{
+ std::vector<Image> aImageVec = aNotebookBarAddonsItem.aImageValues;
+ unsigned long nIter = 0;
+ css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> aExtension;
+ for (unsigned long nIdx = 0; nIdx < aNotebookBarAddonsItem.aAddonValues.size(); nIdx++)
+ {
+ aExtension = aNotebookBarAddonsItem.aAddonValues[nIdx];
+
+ for (int nSecIdx = 0; nSecIdx < aExtension.getLength(); nSecIdx++)
+ {
+ AddonNotebookBarItem aAddonNotebookBarItem;
+ const css::uno::Sequence<css::beans::PropertyValue> pExtension = aExtension[nSecIdx];
+ for (int nRes = 0; nRes < pExtension.getLength(); nRes++)
+ {
+ if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_URL)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sCommandURL;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_TITLE)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sLabel;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_IMAGEID)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sImageIdentifier;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_CONTEXT)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sContext;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_TARGET)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sTarget;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_CONTROLTYPE)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sControlType;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_WIDTH)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.nWidth;
+ else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_STYLE)
+ pExtension[nRes].Value >>= aAddonNotebookBarItem.sStyle;
+ }
+
+ sal_uInt16 nItemId = 0;
+ ToolBox* pToolbox = dynamic_cast<ToolBox*>(pParent);
+ if (pToolbox)
+ {
+ Size aSize(0, 0);
+ pToolbox->InsertItem(aAddonNotebookBarItem.sCommandURL, m_xFrame,
+ ToolBoxItemBits::NONE, aSize);
+ nItemId = pToolbox->GetItemId(aAddonNotebookBarItem.sCommandURL);
+ pToolbox->SetItemCommand(nItemId, aAddonNotebookBarItem.sCommandURL);
+ pToolbox->SetQuickHelpText(nItemId, aAddonNotebookBarItem.sLabel);
+ pToolbox->SetItemText(nItemId, aAddonNotebookBarItem.sLabel);
+ if (nIter < aImageVec.size())
+ {
+ Image sImage = aImageVec[nIter];
+ if (!sImage)
+ sImage = vcl::CommandInfoProvider::GetImageForCommand(
+ aAddonNotebookBarItem.sImageIdentifier, m_xFrame);
+ pToolbox->SetItemImage(nItemId, sImage);
+ }
+ nIter++;
+ }
+ pToolbox->InsertSeparator();
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 6315b5dbc918..70976df86988 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -2015,11 +2015,14 @@ void ImplBorderWindow::SetMenuBarMode( bool bHide )
UpdateMenuHeight();
}
-void ImplBorderWindow::SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame)
+void ImplBorderWindow::SetNotebookBar(const OUString& rUIXMLDescription,
+ const css::uno::Reference<css::frame::XFrame>& rFrame,
+ const NotebookBarAddonsItem& aNotebookBarAddonsItem)
{
if (mpNotebookBar)
mpNotebookBar.disposeAndClear();
- mpNotebookBar = VclPtr<NotebookBar>::Create(this, "NotebookBar", rUIXMLDescription, rFrame);
+ mpNotebookBar = VclPtr<NotebookBar>::Create(this, "NotebookBar", rUIXMLDescription, rFrame,
+ aNotebookBarAddonsItem);
Resize();
}
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 835f056999fd..604d9950dece 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -399,8 +399,9 @@ namespace weld
}
}
-VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUString& sUIFile, const OString& sID,
- const css::uno::Reference<css::frame::XFrame>& rFrame, bool bLegacy)
+VclBuilder::VclBuilder(vcl::Window* pParent, const OUString& sUIDir, const OUString& sUIFile,
+ const OString& sID, const css::uno::Reference<css::frame::XFrame>& rFrame,
+ bool bLegacy, const NotebookBarAddonsItem& aNotebookBarAddonsItem)
: m_sID(sID)
, m_sHelpRoot(OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8))
, m_pStringReplace(Translate::GetReadStringHook())
@@ -410,6 +411,7 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
, m_pParserState(new ParserState)
, m_xFrame(rFrame)
{
+ m_pNotebookBarAddonsItem = aNotebookBarAddonsItem;
m_bToplevelHasDeferredInit = pParent &&
((pParent->IsSystemWindow() && static_cast<SystemWindow*>(pParent)->isDeferredInit()) ||
(pParent->IsDockingWindow() && static_cast<DockingWindow*>(pParent)->isDeferredInit()));
@@ -2168,6 +2170,11 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
{
xWindow = VclPtr<ToolBox>::Create(pParent, WB_3DLOOK | WB_TABSTOP);
}
+ else if (name == "NotebookBarAddonsMergePoint")
+ {
+ NotebookBarAddonsMerger aNotebookBarAddonsMerger(pParent,m_xFrame, m_pNotebookBarAddonsItem);
+ return nullptr;
+ }
else if (name == "GtkToolButton" || name == "GtkMenuToolButton" ||
name == "GtkToggleToolButton" || name == "GtkRadioToolButton")
{
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 59d3b2e97189..76d6a7c30b05 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -968,11 +968,13 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar)
void SystemWindow::SetNotebookBar(const OUString& rUIXMLDescription,
const css::uno::Reference<css::frame::XFrame>& rFrame,
+ const NotebookBarAddonsItem& aNotebookBarAddonsItem,
bool bReloadNotebookbar)
{
if (rUIXMLDescription != maNotebookBarUIFile || bReloadNotebookbar)
{
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetNotebookBar(rUIXMLDescription, rFrame);
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())
+ ->SetNotebookBar(rUIXMLDescription, rFrame, aNotebookBarAddonsItem);
maNotebookBarUIFile = rUIXMLDescription;
if(GetNotebookBar())
GetNotebookBar()->SetSystemWindow(this);