1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <framework/sfxhelperfunctions.hxx>
21 #include <framework/ContextChangeEventMultiplexerTunnel.hxx>
22 #include <helper/mischelper.hxx>
23 #include <svtools/toolboxcontroller.hxx>
24 #include <svtools/statusbarcontroller.hxx>
26 static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator
= nullptr;
27 static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator
= nullptr;
28 static pfunc_getRefreshToolbars pRefreshToolbars
= nullptr;
29 static pfunc_createDockingWindow pCreateDockingWindow
= nullptr;
30 static pfunc_isDockingWindowVisible pIsDockingWindowVisible
= nullptr;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::frame
;
38 pfunc_setToolBoxControllerCreator
SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator
)
40 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
41 pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator
= pToolBoxControllerCreator
;
42 pToolBoxControllerCreator
= pSetToolBoxControllerCreator
;
43 return pOldSetToolBoxControllerCreator
;
46 rtl::Reference
<svt::ToolboxController
> CreateToolBoxController( const Reference
< XFrame
>& rFrame
, ToolBox
* pToolbox
, ToolBoxItemId nID
, const OUString
& aCommandURL
)
48 pfunc_setToolBoxControllerCreator pFactory
= nullptr;
50 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
51 pFactory
= pToolBoxControllerCreator
;
55 return (*pFactory
)( rFrame
, pToolbox
, nID
, aCommandURL
);
60 pfunc_setStatusBarControllerCreator
SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator
)
62 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
63 pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator
= pSetStatusBarControllerCreator
;
64 pStatusBarControllerCreator
= pSetStatusBarControllerCreator
;
65 return pOldSetStatusBarControllerCreator
;
68 rtl::Reference
<svt::StatusbarController
> CreateStatusBarController( const Reference
< XFrame
>& rFrame
, StatusBar
* pStatusBar
, unsigned short nID
, const OUString
& aCommandURL
)
70 pfunc_setStatusBarControllerCreator pFactory
= nullptr;
72 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
73 pFactory
= pStatusBarControllerCreator
;
77 return (*pFactory
)( rFrame
, pStatusBar
, nID
, aCommandURL
);
82 pfunc_getRefreshToolbars
SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc
)
84 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
85 pfunc_getRefreshToolbars pOldFunc
= pRefreshToolbars
;
86 pRefreshToolbars
= pNewRefreshToolbarsFunc
;
91 void RefreshToolbars( css::uno::Reference
< css::frame::XFrame
> const & rFrame
)
93 pfunc_getRefreshToolbars pCallback
= nullptr;
95 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
96 pCallback
= pRefreshToolbars
;
100 (*pCallback
)( rFrame
);
103 pfunc_createDockingWindow
SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow
)
105 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
106 pfunc_createDockingWindow pOldFunc
= pCreateDockingWindow
;
107 pCreateDockingWindow
= pNewCreateDockingWindow
;
112 void CreateDockingWindow( const css::uno::Reference
< css::frame::XFrame
>& rFrame
, std::u16string_view rResourceURL
)
114 pfunc_createDockingWindow pFactory
= nullptr;
116 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
117 pFactory
= pCreateDockingWindow
;
121 (*pFactory
)( rFrame
, rResourceURL
);
124 pfunc_isDockingWindowVisible
SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible
)
126 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
127 pfunc_isDockingWindowVisible pOldFunc
= pIsDockingWindowVisible
;
128 pIsDockingWindowVisible
= pNewIsDockingWindowVisible
;
133 bool IsDockingWindowVisible( const css::uno::Reference
< css::frame::XFrame
>& rFrame
, std::u16string_view rResourceURL
)
135 pfunc_isDockingWindowVisible pCall
= nullptr;
137 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
138 pCall
= pIsDockingWindowVisible
;
142 return (*pCall
)( rFrame
, rResourceURL
);
147 using namespace ::com::sun::star
;
148 uno::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
)
153 return GetFirstListenerWith_Impl(xComponentContext
, xEventFocus
, rPredicate
);
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */