/src/libreoffice/framework/source/fwe/classes/sfxhelperfunctions.cxx
Line | Count | Source |
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 | | |
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> |
25 | | |
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; |
31 | | |
32 | | using namespace ::com::sun::star::uno; |
33 | | using namespace ::com::sun::star::frame; |
34 | | |
35 | | namespace framework |
36 | | { |
37 | | |
38 | | pfunc_setToolBoxControllerCreator SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator ) |
39 | 27 | { |
40 | 27 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
41 | 27 | pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator; |
42 | 27 | pToolBoxControllerCreator = pSetToolBoxControllerCreator; |
43 | 27 | return pOldSetToolBoxControllerCreator; |
44 | 27 | } |
45 | | |
46 | | rtl::Reference<svt::ToolboxController> CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, ToolBoxItemId nID, const OUString& aCommandURL ) |
47 | 0 | { |
48 | 0 | pfunc_setToolBoxControllerCreator pFactory = nullptr; |
49 | 0 | { |
50 | 0 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
51 | 0 | pFactory = pToolBoxControllerCreator; |
52 | 0 | } |
53 | |
|
54 | 0 | if ( pFactory ) |
55 | 0 | return (*pFactory)( rFrame, pToolbox, nID, aCommandURL ); |
56 | 0 | else |
57 | 0 | return nullptr; |
58 | 0 | } |
59 | | |
60 | | pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator ) |
61 | 27 | { |
62 | 27 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
63 | 27 | pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator; |
64 | 27 | pStatusBarControllerCreator = pSetStatusBarControllerCreator; |
65 | 27 | return pOldSetStatusBarControllerCreator; |
66 | 27 | } |
67 | | |
68 | | rtl::Reference<svt::StatusbarController> CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL ) |
69 | 0 | { |
70 | 0 | pfunc_setStatusBarControllerCreator pFactory = nullptr; |
71 | 0 | { |
72 | 0 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
73 | 0 | pFactory = pStatusBarControllerCreator; |
74 | 0 | } |
75 | |
|
76 | 0 | if ( pFactory ) |
77 | 0 | return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL ); |
78 | 0 | else |
79 | 0 | return nullptr; |
80 | 0 | } |
81 | | |
82 | | pfunc_getRefreshToolbars SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc ) |
83 | 27 | { |
84 | 27 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
85 | 27 | pfunc_getRefreshToolbars pOldFunc = pRefreshToolbars; |
86 | 27 | pRefreshToolbars = pNewRefreshToolbarsFunc; |
87 | | |
88 | 27 | return pOldFunc; |
89 | 27 | } |
90 | | |
91 | | void RefreshToolbars( css::uno::Reference< css::frame::XFrame > const & rFrame ) |
92 | 0 | { |
93 | 0 | pfunc_getRefreshToolbars pCallback = nullptr; |
94 | 0 | { |
95 | 0 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
96 | 0 | pCallback = pRefreshToolbars; |
97 | 0 | } |
98 | |
|
99 | 0 | if ( pCallback ) |
100 | 0 | (*pCallback)( rFrame ); |
101 | 0 | } |
102 | | |
103 | | pfunc_createDockingWindow SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow ) |
104 | 27 | { |
105 | 27 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
106 | 27 | pfunc_createDockingWindow pOldFunc = pCreateDockingWindow; |
107 | 27 | pCreateDockingWindow = pNewCreateDockingWindow; |
108 | | |
109 | 27 | return pOldFunc; |
110 | 27 | } |
111 | | |
112 | | void CreateDockingWindow( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rResourceURL ) |
113 | 0 | { |
114 | 0 | pfunc_createDockingWindow pFactory = nullptr; |
115 | 0 | { |
116 | 0 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
117 | 0 | pFactory = pCreateDockingWindow; |
118 | 0 | } |
119 | |
|
120 | 0 | if ( pFactory ) |
121 | 0 | (*pFactory)( rFrame, rResourceURL ); |
122 | 0 | } |
123 | | |
124 | | pfunc_isDockingWindowVisible SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible) |
125 | 27 | { |
126 | 27 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
127 | 27 | pfunc_isDockingWindowVisible pOldFunc = pIsDockingWindowVisible; |
128 | 27 | pIsDockingWindowVisible = pNewIsDockingWindowVisible; |
129 | | |
130 | 27 | return pOldFunc; |
131 | 27 | } |
132 | | |
133 | | bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rResourceURL ) |
134 | 0 | { |
135 | 0 | pfunc_isDockingWindowVisible pCall = nullptr; |
136 | 0 | { |
137 | 0 | ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); |
138 | 0 | pCall = pIsDockingWindowVisible; |
139 | 0 | } |
140 | |
|
141 | 0 | if ( pCall ) |
142 | 0 | return (*pCall)( rFrame, rResourceURL ); |
143 | 0 | else |
144 | 0 | return false; |
145 | 0 | } |
146 | | |
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) |
152 | 0 | { |
153 | 0 | return GetFirstListenerWith_Impl(xComponentContext, xEventFocus, rPredicate); |
154 | 0 | } |
155 | | |
156 | | } |
157 | | |
158 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |