LibreOffice Module framework (master) 1
sfxhelperfunctions.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22#include <helper/mischelper.hxx>
25
31
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::frame;
34
35namespace framework
36{
37
39{
40 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
41 pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator;
42 pToolBoxControllerCreator = pSetToolBoxControllerCreator;
43 return pOldSetToolBoxControllerCreator;
44}
45
46rtl::Reference<svt::ToolboxController> CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, ToolBoxItemId nID, const OUString& aCommandURL )
47{
48 pfunc_setToolBoxControllerCreator pFactory = nullptr;
49 {
50 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
52 }
53
54 if ( pFactory )
55 return (*pFactory)( rFrame, pToolbox, nID, aCommandURL );
56 else
57 return nullptr;
58}
59
61{
62 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
63 pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator;
64 pStatusBarControllerCreator = pSetStatusBarControllerCreator;
65 return pOldSetStatusBarControllerCreator;
66}
67
68rtl::Reference<svt::StatusbarController> CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL )
69{
70 pfunc_setStatusBarControllerCreator pFactory = nullptr;
71 {
72 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
74 }
75
76 if ( pFactory )
77 return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL );
78 else
79 return nullptr;
80}
81
83{
84 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
86 pRefreshToolbars = pNewRefreshToolbarsFunc;
87
88 return pOldFunc;
89}
90
91void RefreshToolbars( css::uno::Reference< css::frame::XFrame > const & rFrame )
92{
93 pfunc_getRefreshToolbars pCallback = nullptr;
94 {
95 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
96 pCallback = pRefreshToolbars;
97 }
98
99 if ( pCallback )
100 (*pCallback)( rFrame );
101}
102
104{
105 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
107 pCreateDockingWindow = pNewCreateDockingWindow;
108
109 return pOldFunc;
110}
111
112void CreateDockingWindow( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rResourceURL )
113{
114 pfunc_createDockingWindow pFactory = nullptr;
115 {
116 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
117 pFactory = pCreateDockingWindow;
118 }
119
120 if ( pFactory )
121 (*pFactory)( rFrame, rResourceURL );
122}
123
125{
126 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
128 pIsDockingWindowVisible = pNewIsDockingWindowVisible;
129
130 return pOldFunc;
131}
132
133bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rResourceURL )
134{
135 pfunc_isDockingWindowVisible pCall = nullptr;
136 {
137 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
139 }
140
141 if ( pCall )
142 return (*pCall)( rFrame, rResourceURL );
143 else
144 return false;
145}
146
147using namespace ::com::sun::star;
148uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith(
149 css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
150 uno::Reference<uno::XInterface> const& xEventFocus,
151 std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
152{
153 return GetFirstListenerWith_Impl(xComponentContext, xEventFocus, rPredicate);
154}
155
156}
157
158/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsDockingWindowVisible(const css::uno::Reference< css::frame::XFrame > &rFrame, std::u16string_view rResourceURL)
pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator(pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator)
void CreateDockingWindow(const css::uno::Reference< css::frame::XFrame > &rFrame, std::u16string_view rResourceURL)
void RefreshToolbars(css::uno::Reference< css::frame::XFrame > const &rFrame)
uno::Reference< ui::XContextChangeEventListener > GetFirstListenerWith_Impl(css::uno::Reference< css::uno::XComponentContext > const &xComponentContext, uno::Reference< uno::XInterface > const &xEventFocus, std::function< bool(uno::Reference< ui::XContextChangeEventListener > const &)> const &rPredicate)
Definition: mischelper.cxx:142
pfunc_createDockingWindow SetDockingWindowCreator(pfunc_createDockingWindow pNewCreateDockingWindow)
rtl::Reference< svt::ToolboxController > CreateToolBoxController(const Reference< XFrame > &rFrame, ToolBox *pToolbox, ToolBoxItemId nID, const OUString &aCommandURL)
uno::Reference< ui::XContextChangeEventListener > GetFirstListenerWith(css::uno::Reference< css::uno::XComponentContext > const &xComponentContext, uno::Reference< uno::XInterface > const &xEventFocus, std::function< bool(uno::Reference< ui::XContextChangeEventListener > const &)> const &rPredicate)
pfunc_setToolBoxControllerCreator SetToolBoxControllerCreator(pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator)
pfunc_isDockingWindowVisible SetIsDockingWindowVisible(pfunc_isDockingWindowVisible pNewIsDockingWindowVisible)
pfunc_getRefreshToolbars SetRefreshToolbars(pfunc_getRefreshToolbars pNewRefreshToolbarsFunc)
rtl::Reference< svt::StatusbarController > CreateStatusBarController(const Reference< XFrame > &rFrame, StatusBar *pStatusBar, unsigned short nID, const OUString &aCommandURL)
static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator
static pfunc_isDockingWindowVisible pIsDockingWindowVisible
static pfunc_getRefreshToolbars pRefreshToolbars
static pfunc_createDockingWindow pCreateDockingWindow
static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator
void(* pfunc_createDockingWindow)(const css::uno::Reference< css::frame::XFrame > &rFrame, std::u16string_view rResourceURL)
bool(* pfunc_isDockingWindowVisible)(const css::uno::Reference< css::frame::XFrame > &rFrame, std::u16string_view rResourceURL)
void(* pfunc_getRefreshToolbars)(css::uno::Reference< css::frame::XFrame > const &rFrame)
rtl::Reference< svt::ToolboxController >(* pfunc_setToolBoxControllerCreator)(const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBox *pToolbox, ToolBoxItemId nID, const OUString &aCommandURL)
rtl::Reference< svt::StatusbarController >(* pfunc_setStatusBarControllerCreator)(const css::uno::Reference< css::frame::XFrame > &rFrame, StatusBar *pStatusBar, unsigned short nID, const OUString &aCommandURL)