[Libreoffice-commits] core.git: include/vcl vcl/source
Szymon Kłos
eszkadev at gmail.com
Tue Mar 21 16:08:58 UTC 2017
include/vcl/notebookbar.hxx | 3 ++-
vcl/source/control/notebookbar.cxx | 24 +++++++++++++++++++++---
2 files changed, 23 insertions(+), 4 deletions(-)
New commits:
commit 9f3b59a511b15328284f4f25b7ac0cd89ba1a303
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Tue Mar 21 12:55:09 2017 +0100
Notebookbar: multiple context containers support
Possibility to add multiple context containers.
Each container should have name "ContextContainer"
or "ContextContainerX" where X >= 1
Change-Id: Ie689ebde624f766b11d96370d6b108018f9130c9
Reviewed-on: https://gerrit.libreoffice.org/35506
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Szymon Kłos <eszkadev at gmail.com>
diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx
index 4273edc9fabf..bc3885cabd59 100644
--- a/include/vcl/notebookbar.hxx
+++ b/include/vcl/notebookbar.hxx
@@ -15,6 +15,7 @@
#include <vcl/EnumContext.hxx>
#include <sfx2/notebookbar/NotebookbarContextControl.hxx>
#include <com/sun/star/ui/XContextChangeEventListener.hpp>
+#include <vector>
class SystemWindow;
@@ -41,7 +42,7 @@ public:
private:
VclPtr<SystemWindow> m_pSystemWindow;
css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener;
- NotebookbarContextControl* m_pContextContainer;
+ std::vector<NotebookbarContextControl*> m_pContextContainers;
void UpdateBackground();
};
diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx
index f338426aa23a..a96a86d1ac27 100644
--- a/vcl/source/control/notebookbar.cxx
+++ b/vcl/source/control/notebookbar.cxx
@@ -39,7 +39,21 @@ NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rU
// In the Notebookbar's .ui file must exist control handling context
// - implementing NotebookbarContextControl interface with id "ContextContainer"
- m_pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>("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>(rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8)));
+ if (pContextContainer)
+ m_pContextContainers.push_back(pContextContainer);
+ i++;
+ }
+ while( pContextContainer != nullptr );
UpdateBackground();
}
@@ -51,6 +65,7 @@ NotebookBar::~NotebookBar()
void NotebookBar::dispose()
{
+ m_pContextContainers.clear();
if (m_pSystemWindow && m_pSystemWindow->ImplIsInTaskPaneList(this))
m_pSystemWindow->GetTaskPaneList()->RemoveWindow(this);
m_pSystemWindow.clear();
@@ -131,8 +146,11 @@ void NotebookBar::SetSystemWindow(SystemWindow* pSystemWindow)
void SAL_CALL NotebookBarContextChangeEventListener::notifyContextChangeEvent(const css::ui::ContextChangeEventObject& rEvent)
{
- if (mpParent && mpParent->m_pContextContainer)
- mpParent->m_pContextContainer->SetContext(vcl::EnumContext::GetContextEnum(rEvent.ContextName));
+ if (mpParent && mpParent->m_pContextContainers.size() > 0)
+ {
+ for (NotebookbarContextControl* pControl : mpParent->m_pContextContainers)
+ pControl->SetContext(vcl::EnumContext::GetContextEnum(rEvent.ContextName));
+ }
}
More information about the Libreoffice-commits
mailing list