[Libreoffice-commits] core.git: framework/inc framework/source include/sfx2 sfx2/source

2022-06-13 Thread Maxim Monastirsky (via logerrit)
 framework/inc/uielement/toolbarmanager.hxx|   10 +
 framework/inc/uielement/toolbarmerger.hxx |2 
 framework/inc/uielement/toolbarwrapper.hxx|   16 -
 framework/source/uielement/toolbarmanager.cxx |  224 ++
 framework/source/uielement/toolbarmerger.cxx  |8 
 framework/source/uielement/toolbarwrapper.cxx |  116 +
 include/sfx2/notebookbar/SfxNotebookBar.hxx   |2 
 sfx2/source/appl/workwin.cxx  |2 
 sfx2/source/notebookbar/SfxNotebookBar.cxx|5 
 9 files changed, 233 insertions(+), 152 deletions(-)

New commits:
commit 9bc1ffa2153d2474b023e0860d3c9c68ee18727b
Author: Maxim Monastirsky 
AuthorDate: Mon Jun 6 22:50:14 2022 +0300
Commit: Maxim Monastirsky 
CommitDate: Mon Jun 13 18:47:01 2022 +0200

tdf#125040 Make single mode toolbar context aware

This patch modifies the "Standard (Single Mode)" toolbar
to have an optional context-aware section, given that a
corresponding singlemode-.xml files exist.
This is a lot like the "Contextual Single" NB, except
that it's implemented with regular toolbars, so docking/
customization/extensions/uno api etc. are all working.

In addition, the "Single Toolbar" mode was modified to
not show any other contextual toolbar. (But of course the
single mode toolbar itself is perfectly usable outside of
this mode.)

Change-Id: Id746d9df59340a81962a8689b132941deea54b6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135591
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/framework/inc/uielement/toolbarmanager.hxx 
b/framework/inc/uielement/toolbarmanager.hxx
index 1cfddd99ef45..746b40ebc787 100644
--- a/framework/inc/uielement/toolbarmanager.hxx
+++ b/framework/inc/uielement/toolbarmanager.hxx
@@ -94,6 +94,7 @@ public:
 virtual void ConnectCallbacks(ToolBarManager* pManager) = 0;
 virtual void SetMenuType(ToolBoxMenuType eType) = 0;
 virtual void MergeToolbar(ToolBoxItemId & rItemId,
+  sal_uInt16 nFirstItem,
   const OUString& rModuleIdentifier,
   CommandToInfoMap& rCommandMap,
   MergeToolbarInstruction& rInstruction) = 0;
@@ -144,7 +145,9 @@ class ToolBarManager final : public ToolbarManager_Base
 
 void CheckAndUpdateImages();
 void RequestImages();
-void FillToolbar( const css::uno::Reference< 
css::container::XIndexAccess >& rToolBarData );
+void FillToolbar( const css::uno::Reference< 
css::container::XIndexAccess >& rToolBarData,
+  const css::uno::Reference< 
css::container::XIndexAccess >& rContextData,
+  const OUString& rContextToolbarName );
 void FillAddonToolbar( const css::uno::Sequence< css::uno::Sequence< 
css::beans::PropertyValue > >& rAddonToolbar );
 void FillOverflowToolbar( ToolBox const * pParent );
 void notifyRegisteredControllers( const OUString& aUIElementName, 
const OUString& aCommand );
@@ -193,6 +196,9 @@ class ToolBarManager final : public ToolbarManager_Base
 
 private:
 void Init();
+void FillToolbarFromContainer(const css::uno::Reference< 
css::container::XIndexAccess >& rItemContainer,
+  const OUString& rResourceName, 
ToolBoxItemId& nId, ToolBoxItemId& nAddonId);
+void ToggleButton(const OUString& rResourceName, std::u16string_view 
rCommand);
 void AddCustomizeMenuItems(ToolBox const * pToolBar);
 void InitImageManager();
 void RemoveControllers();
@@ -219,12 +225,14 @@ class ToolBarManager final : public ToolbarManager_Base
  m_bUpdateControllers : 1;
 
 sal_Int16 m_eSymbolSize;
+sal_uInt16 m_nContextMinPos;
 
 std::unique_ptr  m_pImpl;
 VclPtr  
m_pToolBar;
 
 OUString 
m_aModuleIdentifier;
 OUString 
m_aResourceName;
+OUString 
m_aContextResourceName;
 
 css::uno::Reference< css::util::XURLTransformer >
m_xURLTransformer;
 css::uno::Reference< css::frame::XFrame >m_xFrame;
diff --git a/framework/inc/uielement/toolbarmerger.hxx 
b/framework/inc/uielement/toolbarmerger.hxx
index 837507baa386..b84ca2005e39 100644
--- a/framework/inc/uielement/toolbarmerger.hxx
+++ b/framework/inc/uielement/toolbarmerger.hxx
@@ -75,7 +75,7 @@ class ToolBarMerger
OUString& rControlType,
sal_uInt16& rWidth );
 
-static ReferenceToolbarPathInfo FindReferencePoint( const ToolBox* 
pToolbar,
+static 

[Libreoffice-commits] core.git: framework/inc framework/source include/sfx2 sfx2/source

2015-07-14 Thread Michael Stahl
 framework/inc/helper/mischelper.hxx |   12 +++
 framework/source/fwe/classes/sfxhelperfunctions.cxx |   10 ++
 framework/source/fwi/helper/mischelper.cxx  |   15 +++
 framework/source/services/ContextChangeEventMultiplexer.cxx |   47 +++-
 include/sfx2/sidebar/SidebarController.hxx  |9 --
 sfx2/source/sidebar/SidebarController.cxx   |   27 +-
 6 files changed, 90 insertions(+), 30 deletions(-)

New commits:
commit 9be8c4f21200aeec5b334d9536b3b7a0b72c24fa
Author: Michael Stahl mst...@redhat.com
Date:   Mon Jul 13 18:54:17 2015 +0200

sfx2: remove the global SidebarController::maSidebarControllerContainer

This global was crashing on exit, unsurprising as it contains UNO
services that reference VCL objects.

It turns out that there is already a UNO singleton
framework::ContextChangeEventMultiplexer that effectively contains this
mapping already, so try to hook that up without creating a public API of
it, which is made quite a bit harder by framework's inexplicable
multitude of libraries.

Change-Id: I4baf67b42c630191fa8879d650eeb62520c331a5

diff --git a/framework/inc/helper/mischelper.hxx 
b/framework/inc/helper/mischelper.hxx
index 6aa0015..7f45aa6 100644
--- a/framework/inc/helper/mischelper.hxx
+++ b/framework/inc/helper/mischelper.hxx
@@ -28,6 +28,7 @@
 #include com/sun/star/container/XContainerListener.hpp
 #include com/sun/star/frame/XFrame.hpp
 #include com/sun/star/uno/XComponentContext.hpp
+#include com/sun/star/ui/XContextChangeEventListener.hpp
 
 #include cppuhelper/implbase1.hxx
 
@@ -36,6 +37,7 @@
 #include rtl/ustring.hxx
 #include fwidllapi.h
 
+#include functional
 #include set
 
 namespace framework
@@ -304,6 +306,16 @@ class WeakDocumentEventListener : public 
::cppu::WeakImplHelper1com::sun::star:
 }
 };
 
+FWI_DLLPUBLIC css::uno::Referencecss::ui::XContextChangeEventListener
+GetFirstListenerWith_Impl(
+css::uno::Referencecss::uno::XInterface const xEventFocus,
+std::functionbool 
(css::uno::Referencecss::ui::XContextChangeEventListener const) const 
rPredicate);
+
+FWI_DLLPUBLIC extern auto (*g_pGetMultiplexerListener)(
+css::uno::Referencecss::uno::XInterface const,
+std::functionbool 
(css::uno::Referencecss::ui::XContextChangeEventListener const) const)
+- css::uno::Referencecss::ui::XContextChangeEventListener;
+
 } // namespace framework
 
 #endif // INCLUDED_FRAMEWORK_INC_HELPER_MISCHELPER_HXX
diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx 
b/framework/source/fwe/classes/sfxhelperfunctions.cxx
index a1f0826..c04105c 100644
--- a/framework/source/fwe/classes/sfxhelperfunctions.cxx
+++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx
@@ -18,6 +18,8 @@
  */
 
 #include framework/sfxhelperfunctions.hxx
+#include framework/ContextChangeEventMultiplexerTunnel.hxx
+#include helper/mischelper.hxx
 
 #include tools/diagnose_ex.h
 
@@ -163,6 +165,14 @@ void SAL_CALL ActivateToolPanel( const 
::com::sun::star::uno::Reference ::com::
 (*pActivator)( i_rFrame, i_rPanelURL );
 }
 
+using namespace ::com::sun::star;
+uno::Referenceui::XContextChangeEventListener GetFirstListenerWith(
+uno::Referenceuno::XInterface const xEventFocus,
+std::functionbool (uno::Referenceui::XContextChangeEventListener 
const) const rPredicate)
+{
+return GetFirstListenerWith_Impl(xEventFocus, rPredicate);
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/fwi/helper/mischelper.cxx 
b/framework/source/fwi/helper/mischelper.cxx
index 5b1e15f..06cc061 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -212,6 +212,21 @@ void FillLangItems( std::set OUString  rLangItems,
 }
 }
 
+auto (*g_pGetMultiplexerListener)(
+uno::Referenceuno::XInterface const,
+std::functionbool (uno::Referenceui::XContextChangeEventListener 
const) const)
+- uno::Referenceui::XContextChangeEventListener = nullptr;
+
+uno::Referenceui::XContextChangeEventListener
+GetFirstListenerWith_Impl(
+uno::Referenceuno::XInterface const xEventFocus,
+std::functionbool (uno::Referenceui::XContextChangeEventListener 
const) const rPredicate)
+{
+assert(g_pGetMultiplexerListener != nullptr); // should not be called too 
early, nor too late
+return g_pGetMultiplexerListener(xEventFocus, rPredicate);
+}
+
+
 } // namespace framework
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx 
b/framework/source/services/ContextChangeEventMultiplexer.cxx
index 6fe88ee..d672704 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include helper/mischelper.hxx
+
 #include