summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-06-17 23:54:00 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-06-27 17:51:56 +0000
commit1df394503f1e62b091453c95c05a212892ae8d58 (patch)
tree4767346ce348cc498df09985b6fa431a45f255d3 /sfx2
parent0c80b4dfd27109def7a5bdc34c3fcc5499db6c0d (diff)
GSoC notebookbar: switching tabs depending on context
+ sfx2::sidebar::EnumContext moved to the vcl module + TabPage contains vector with context values + vcl builder reads control's contexts from the "class" mark + ContextTabControl shows tabs depending on context Change-Id: I661b0d3f35d46ace2a2e8eb1d374148f0c60017d Reviewed-on: https://gerrit.libreoffice.org/26447 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/inc/pch/precompiled_sfx.hxx2
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx39
-rw-r--r--sfx2/source/sidebar/ContextChangeBroadcaster.cxx4
-rw-r--r--sfx2/source/sidebar/EnumContext.cxx232
-rw-r--r--sfx2/source/sidebar/ResourceManager.cxx46
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx4
-rw-r--r--sfx2/source/sidebar/SidebarPanelBase.cxx6
-rw-r--r--sfx2/uiconfig/ui/notebookbar.ui2
9 files changed, 70 insertions, 266 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 2cbeb2673ca1..ad58c6f5f94c 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -261,7 +261,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/sidebar/DeckLayouter \
sfx2/source/sidebar/DeckTitleBar \
sfx2/source/sidebar/DrawHelper \
- sfx2/source/sidebar/EnumContext \
sfx2/source/sidebar/FocusManager \
sfx2/source/sidebar/MenuButton \
sfx2/source/sidebar/IContextChangeReceiver \
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index a6fda69ac1ff..694aaa1a3b1c 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -94,6 +94,7 @@
#include <vcl/dibtools.hxx>
#include <vcl/dllapi.h>
#include <vcl/edit.hxx>
+#include <vcl/EnumContext.hxx>
#include <vcl/fixed.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/font.hxx>
@@ -492,7 +493,6 @@
#include <sfx2/sidebar/DeckDescriptor.hxx>
#include <sfx2/sidebar/DeckTitleBar.hxx>
#include <sfx2/sidebar/DrawHelper.hxx>
-#include <sfx2/sidebar/EnumContext.hxx>
#include <sfx2/sidebar/Paint.hxx>
#include <sfx2/sidebar/Panel.hxx>
#include <sfx2/sidebar/PanelTitleBar.hxx>
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index dd7a41c5baea..5640e46c374e 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -13,8 +13,14 @@
#include <unotools/viewoptions.hxx>
#include <vcl/notebookbar.hxx>
#include <vcl/syswin.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
using namespace sfx2;
+using namespace css::uno;
+using namespace css::ui;
void SfxNotebookBar::ExecMethod(SfxBindings& rBindings)
{
@@ -33,7 +39,7 @@ void SfxNotebookBar::StateMethod(SfxBindings& rBindings, const OUString& rUIFile
}
void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
- const css::uno::Reference<css::frame::XFrame> xFrame,
+ const Reference<css::frame::XFrame> xFrame,
const OUString& rUIFile)
{
assert(pSysWindow);
@@ -42,13 +48,44 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
if (aViewOpt.IsVisible())
{
+ RemoveListeners(pSysWindow);
+
// setup if necessary
pSysWindow->SetNotebookBar(rUIFile, xFrame);
pSysWindow->GetNotebookBar()->Show();
+
+ SfxViewFrame* pView = SfxViewFrame::Current();
+
+ if(pView)
+ {
+ Reference<XContextChangeEventMultiplexer> xMultiplexer
+ = ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext());
+
+ if(xFrame.is() && xMultiplexer.is())
+ {
+ xMultiplexer->addContextChangeEventListener(
+ pSysWindow->GetNotebookBar().get(),
+ xFrame->getController());
+ }
+ }
}
else if (auto pNotebookBar = pSysWindow->GetNotebookBar())
pNotebookBar->Hide();
}
+void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow)
+{
+ Reference<XContextChangeEventMultiplexer> xMultiplexer
+ = ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext());
+
+ if (pSysWindow->GetNotebookBar() && xMultiplexer.is())
+ {
+ xMultiplexer->removeAllContextChangeEventListeners(
+ pSysWindow->GetNotebookBar().get());
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx
index 5ede4a575ad6..0a1bbe044bba 100644
--- a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx
+++ b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sidebar/ContextChangeBroadcaster.hxx>
-#include <sfx2/sidebar/EnumContext.hxx>
+#include <vcl/EnumContext.hxx>
#include <com/sun/star/ui/ContextChangeEventObject.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
@@ -58,7 +58,7 @@ void ContextChangeBroadcaster::Deactivate (const css::uno::Reference<css::frame:
BroadcastContextChange(
rxFrame,
GetModuleName(rxFrame),
- EnumContext::GetContextName(EnumContext::Context_Default));
+ vcl::EnumContext::GetContextName(vcl::EnumContext::Context_Default));
}
}
diff --git a/sfx2/source/sidebar/EnumContext.cxx b/sfx2/source/sidebar/EnumContext.cxx
deleted file mode 100644
index 281e63fd6663..000000000000
--- a/sfx2/source/sidebar/EnumContext.cxx
+++ /dev/null
@@ -1,232 +0,0 @@
-/* -*- 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 <sfx2/sidebar/EnumContext.hxx>
-
-#include <osl/diagnose.h>
-
-#include <map>
-
-namespace sfx2 { namespace sidebar {
-
-namespace {
-
-typedef ::std::map<rtl::OUString,EnumContext::Application> ApplicationMap;
-
-static ApplicationMap maApplicationMap;
-static ::std::vector<rtl::OUString> maApplicationVector;
-
-typedef ::std::map<rtl::OUString,EnumContext::Context> ContextMap;
-
-static ContextMap maContextMap;
-static ::std::vector<rtl::OUString> maContextVector;
-
-}
-
-const sal_Int32 EnumContext::NoMatch = 4;
-const sal_Int32 EnumContext::OptimalMatch = 0; // Neither application nor context name is "any".
-
-EnumContext::EnumContext()
- : meApplication(Application_None),
- meContext(Context_Unknown)
-{
-}
-
-EnumContext::EnumContext (
- const Application eApplication,
- const Context eContext)
- : meApplication(eApplication),
- meContext(eContext)
-{
-}
-
-EnumContext::EnumContext (
- const ::rtl::OUString& rsApplicationName,
- const ::rtl::OUString& rsContextName)
- : meApplication(GetApplicationEnum(rsApplicationName)),
- meContext(GetContextEnum(rsContextName))
-{
-}
-
-sal_Int32 EnumContext::GetCombinedContext_DI() const
-{
- return CombinedEnumContext(GetApplication_DI(), meContext);
-}
-
-EnumContext::Application EnumContext::GetApplication_DI() const
-{
- switch (meApplication)
- {
- case Application_Draw:
- case Application_Impress:
- return Application_DrawImpress;
-
- case Application_Writer:
- case Application_WriterGlobal:
- case Application_WriterWeb:
- case Application_WriterXML:
- case Application_WriterForm:
- case Application_WriterReport:
- return Application_WriterVariants;
-
- default:
- return meApplication;
- }
-}
-
-bool EnumContext::operator== (const EnumContext& rOther)
-{
- return meApplication==rOther.meApplication
- && meContext==rOther.meContext;
-}
-
-bool EnumContext::operator!= (const EnumContext& rOther)
-{
- return meApplication!=rOther.meApplication
- || meContext!=rOther.meContext;
-}
-
-void EnumContext::AddEntry (const ::rtl::OUString& rsName, const Application eApplication)
-{
- maApplicationMap[rsName] = eApplication;
- OSL_ASSERT(eApplication<=LastApplicationEnum);
- if (maApplicationVector.size() <= size_t(eApplication))
- maApplicationVector.resize(eApplication+1);
- maApplicationVector[eApplication]=rsName;
-}
-
-void EnumContext::ProvideApplicationContainers()
-{
- if (maApplicationMap.empty())
- {
- maApplicationVector.resize(static_cast<size_t>(EnumContext::LastApplicationEnum)+1);
- AddEntry("com.sun.star.text.TextDocument", EnumContext::Application_Writer);
- AddEntry("com.sun.star.text.GlobalDocument", EnumContext::Application_WriterGlobal);
- AddEntry("com.sun.star.text.WebDocument", EnumContext::Application_WriterWeb);
- AddEntry("com.sun.star.xforms.XMLFormDocument", EnumContext::Application_WriterXML);
- AddEntry("com.sun.star.sdb.FormDesign", EnumContext::Application_WriterForm);
- AddEntry("com.sun.star.sdb.TextReportDesign", EnumContext::Application_WriterReport);
- AddEntry("com.sun.star.sheet.SpreadsheetDocument", EnumContext::Application_Calc);
- AddEntry("com.sun.star.chart2.ChartDocument", EnumContext::Application_Chart);
- AddEntry("com.sun.star.drawing.DrawingDocument", EnumContext::Application_Draw);
- AddEntry("com.sun.star.presentation.PresentationDocument", EnumContext::Application_Impress);
-
- AddEntry("any", EnumContext::Application_Any);
- AddEntry("none", EnumContext::Application_None);
- }
-}
-
-EnumContext::Application EnumContext::GetApplicationEnum (const ::rtl::OUString& rsApplicationName)
-{
- ProvideApplicationContainers();
-
- ApplicationMap::const_iterator iApplication(
- maApplicationMap.find(rsApplicationName));
- if (iApplication != maApplicationMap.end())
- return iApplication->second;
- else
- return EnumContext::Application_None;
-}
-
-const ::rtl::OUString& EnumContext::GetApplicationName (const Application eApplication)
-{
- ProvideApplicationContainers();
-
- const sal_Int32 nIndex (eApplication);
- if (nIndex<0 || nIndex>= LastApplicationEnum)
- return maApplicationVector[Application_None];
- else
- return maApplicationVector[nIndex];
-}
-
-void EnumContext::AddEntry (const ::rtl::OUString& rsName, const Context eApplication)
-{
- maContextMap[rsName] = eApplication;
- OSL_ASSERT(eApplication<=LastContextEnum);
- if (maContextVector.size() <= size_t(eApplication))
- maContextVector.resize(eApplication+1);
- maContextVector[eApplication] = rsName;
-}
-
-void EnumContext::ProvideContextContainers()
-{
- if (maContextMap.empty())
- {
- maContextVector.resize(static_cast<size_t>(LastContextEnum)+1);
- AddEntry("any", Context_Any);
- AddEntry("default", Context_Default);
- AddEntry("empty", Context_Empty);
- AddEntry("3DObject", Context_3DObject);
- AddEntry("Annotation", Context_Annotation);
- AddEntry("Auditing", Context_Auditing);
- AddEntry("Axis", Context_Axis);
- AddEntry("Cell", Context_Cell);
- AddEntry("Chart", Context_Chart);
- AddEntry("ChartElements", Context_ChartElements);
- AddEntry("Draw", Context_Draw);
- AddEntry("DrawLine", Context_DrawLine);
- AddEntry("DrawPage", Context_DrawPage);
- AddEntry("DrawText", Context_DrawText);
- AddEntry("EditCell", Context_EditCell);
- AddEntry("ErrorBar", Context_ErrorBar);
- AddEntry("Form", Context_Form);
- AddEntry("Frame", Context_Frame);
- AddEntry("Graphic", Context_Graphic);
- AddEntry("Grid", Context_Grid);
- AddEntry("HandoutPage", Context_HandoutPage);
- AddEntry("MasterPage", Context_MasterPage);
- AddEntry("Media", Context_Media);
- AddEntry("MultiObject", Context_MultiObject);
- AddEntry("NotesPage", Context_NotesPage);
- AddEntry("OLE", Context_OLE);
- AddEntry("OutlineText", Context_OutlineText);
- AddEntry("Pivot", Context_Pivot);
- AddEntry("Series", Context_Series);
- AddEntry("SlidesorterPage", Context_SlidesorterPage);
- AddEntry("Table", Context_Table);
- AddEntry("Text", Context_Text);
- AddEntry("TextObject", Context_TextObject);
- AddEntry("Trendline", Context_Trendline);
- }
-}
-
-EnumContext::Context EnumContext::GetContextEnum (const ::rtl::OUString& rsContextName)
-{
- ProvideContextContainers();
-
- ContextMap::const_iterator iContext( maContextMap.find(rsContextName) );
- if (iContext != maContextMap.end())
- return iContext->second;
- else
- return EnumContext::Context_Unknown;
-}
-
-const ::rtl::OUString& EnumContext::GetContextName (const Context eContext)
-{
- ProvideContextContainers();
-
- const sal_Int32 nIndex (eContext);
- if (nIndex<0 || nIndex>= LastContextEnum)
- return maContextVector[Context_Unknown];
- else
- return maContextVector[nIndex];
-}
-
-} } // end of namespace sfx2::sidebar
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index 8958f3b4d5cd..d6a51a01f2e9 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -466,42 +466,42 @@ void ResourceManager::ReadContextList (
// application name may result in more than one value (eg
// DrawImpress will result in two enums, one for Draw and one
// for Impress).
- std::vector<EnumContext::Application> aApplications;
- EnumContext::Application eApplication (EnumContext::GetApplicationEnum(sApplicationName));
+ std::vector<vcl::EnumContext::Application> aApplications;
+ vcl::EnumContext::Application eApplication (vcl::EnumContext::GetApplicationEnum(sApplicationName));
- if (eApplication == EnumContext::Application_None
- && !sApplicationName.equals(EnumContext::GetApplicationName(EnumContext::Application_None)))
+ if (eApplication == vcl::EnumContext::Application_None
+ && !sApplicationName.equals(vcl::EnumContext::GetApplicationName(vcl::EnumContext::Application_None)))
{
// Handle some special names: abbreviations that make
// context descriptions more readable.
if (sApplicationName == "Writer")
- aApplications.push_back(EnumContext::Application_Writer);
+ aApplications.push_back(vcl::EnumContext::Application_Writer);
else if (sApplicationName == "Calc")
- aApplications.push_back(EnumContext::Application_Calc);
+ aApplications.push_back(vcl::EnumContext::Application_Calc);
else if (sApplicationName == "Draw")
- aApplications.push_back(EnumContext::Application_Draw);
+ aApplications.push_back(vcl::EnumContext::Application_Draw);
else if (sApplicationName == "Impress")
- aApplications.push_back(EnumContext::Application_Impress);
+ aApplications.push_back(vcl::EnumContext::Application_Impress);
else if (sApplicationName == "Chart")
- aApplications.push_back(EnumContext::Application_Chart);
+ aApplications.push_back(vcl::EnumContext::Application_Chart);
else if (sApplicationName == "DrawImpress")
{
// A special case among the special names: it is
// common to use the same context descriptions for
// both Draw and Impress. This special case helps to
// avoid duplication in the .xcu file.
- aApplications.push_back(EnumContext::Application_Draw);
- aApplications.push_back(EnumContext::Application_Impress);
+ aApplications.push_back(vcl::EnumContext::Application_Draw);
+ aApplications.push_back(vcl::EnumContext::Application_Impress);
}
else if (sApplicationName == "WriterVariants")
{
// Another special case for all Writer variants.
- aApplications.push_back(EnumContext::Application_Writer);
- aApplications.push_back(EnumContext::Application_WriterGlobal);
- aApplications.push_back(EnumContext::Application_WriterWeb);
- aApplications.push_back(EnumContext::Application_WriterXML);
- aApplications.push_back(EnumContext::Application_WriterForm);
- aApplications.push_back(EnumContext::Application_WriterReport);
+ aApplications.push_back(vcl::EnumContext::Application_Writer);
+ aApplications.push_back(vcl::EnumContext::Application_WriterGlobal);
+ aApplications.push_back(vcl::EnumContext::Application_WriterWeb);
+ aApplications.push_back(vcl::EnumContext::Application_WriterXML);
+ aApplications.push_back(vcl::EnumContext::Application_WriterForm);
+ aApplications.push_back(vcl::EnumContext::Application_WriterReport);
}
else
{
@@ -516,8 +516,8 @@ void ResourceManager::ReadContextList (
}
// Setup the actual context enum.
- const EnumContext::Context eContext (EnumContext::GetContextEnum(sContextName));
- if (eContext == EnumContext::Context_Unknown)
+ const vcl::EnumContext::Context eContext (vcl::EnumContext::GetContextEnum(sContextName));
+ if (eContext == vcl::EnumContext::Context_Unknown)
{
SAL_WARN("sfx.sidebar", "context name " << sContextName << " not recognized");
continue;
@@ -538,15 +538,15 @@ void ResourceManager::ReadContextList (
// Add context descriptors.
- std::vector<EnumContext::Application>::const_iterator iApplication;
+ std::vector<vcl::EnumContext::Application>::const_iterator iApplication;
for (iApplication = aApplications.begin(); iApplication != aApplications.end(); ++iApplication)
{
- if (*iApplication != EnumContext::Application_None)
+ if (*iApplication != vcl::EnumContext::Application_None)
{
rContextList.AddContextDescription(
Context(
- EnumContext::GetApplicationName(*iApplication),
- EnumContext::GetContextName(eContext)),
+ vcl::EnumContext::GetApplicationName(*iApplication),
+ vcl::EnumContext::GetContextName(eContext)),
bIsInitiallyVisible,
sMenuCommand);
}
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 78de65dcc0fb..4685bf67f535 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -683,14 +683,14 @@ void SidebarController::SwitchToDeck (
if (aPanelContextDescriptors.empty())
{
// There are no panels to be displayed in the current context.
- if (EnumContext::GetContextEnum(rContext.msContext) != EnumContext::Context_Empty)
+ if (vcl::EnumContext::GetContextEnum(rContext.msContext) != vcl::EnumContext::Context_Empty)
{
// Switch to the "empty" context and try again.
SwitchToDeck(
rDeckDescriptor,
Context(
rContext.msApplication,
- EnumContext::GetContextName(EnumContext::Context_Empty)));
+ vcl::EnumContext::GetContextName(vcl::EnumContext::Context_Empty)));
return;
}
else
diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx
index e8ed312ba565..ff7708431216 100644
--- a/sfx2/source/sidebar/SidebarPanelBase.cxx
+++ b/sfx2/source/sidebar/SidebarPanelBase.cxx
@@ -104,9 +104,9 @@ void SAL_CALL SidebarPanelBase::notifyContextChangeEvent (
= dynamic_cast<IContextChangeReceiver*>(mpControl.get());
if (pContextChangeReceiver != nullptr)
{
- const EnumContext aContext(
- EnumContext::GetApplicationEnum(rEvent.ApplicationName),
- EnumContext::GetContextEnum(rEvent.ContextName));
+ const vcl::EnumContext aContext(
+ vcl::EnumContext::GetApplicationEnum(rEvent.ApplicationName),
+ vcl::EnumContext::GetContextEnum(rEvent.ContextName));
pContextChangeReceiver->HandleContextChange(aContext);
}
}
diff --git a/sfx2/uiconfig/ui/notebookbar.ui b/sfx2/uiconfig/ui/notebookbar.ui
index 1f7bf46a1294..a0aa02ec23dd 100644
--- a/sfx2/uiconfig/ui/notebookbar.ui
+++ b/sfx2/uiconfig/ui/notebookbar.ui
@@ -11,7 +11,7 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkNotebook" id="notebook1">
+ <object class="vcllo-ContextTabControl" id="notebook1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>