diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2017-03-21 12:55:09 +0100 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2017-03-21 16:08:35 +0000 |
commit | 9f3b59a511b15328284f4f25b7ac0cd89ba1a303 (patch) | |
tree | 2626622d74b2d0276fb6ef67ae7d259e39af5f05 /vcl | |
parent | 9abbeb95d41d8fb3e3c4ec74221666e60a44e747 (diff) |
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@libreoffice.org>
Reviewed-by: Szymon Kłos <eszkadev@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/notebookbar.cxx | 24 |
1 files changed, 21 insertions, 3 deletions
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)); + } } |