Line data Source code
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 :
22 : #include <tools/diagnose_ex.h>
23 :
24 : static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = NULL;
25 : static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = NULL;
26 : static pfunc_getRefreshToolbars pRefreshToolbars = NULL;
27 : static pfunc_createDockingWindow pCreateDockingWindow = NULL;
28 : static pfunc_isDockingWindowVisible pIsDockingWindowVisible = NULL;
29 : static pfunc_activateToolPanel pActivateToolPanel = NULL;
30 :
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::frame;
33 :
34 : namespace framework
35 : {
36 :
37 303 : pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator )
38 : {
39 303 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
40 303 : pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator;
41 303 : pToolBoxControllerCreator = pSetToolBoxControllerCreator;
42 303 : return pOldSetToolBoxControllerCreator;
43 : }
44 :
45 111234 : svt::ToolboxController* SAL_CALL CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL )
46 : {
47 111234 : pfunc_setToolBoxControllerCreator pFactory = NULL;
48 : {
49 111234 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
50 111234 : pFactory = pToolBoxControllerCreator;
51 : }
52 :
53 111234 : if ( pFactory )
54 111234 : return (*pFactory)( rFrame, pToolbox, nID, aCommandURL );
55 : else
56 0 : return NULL;
57 : }
58 :
59 303 : pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator )
60 : {
61 303 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
62 303 : pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator;
63 303 : pStatusBarControllerCreator = pSetStatusBarControllerCreator;
64 303 : return pOldSetStatusBarControllerCreator;
65 : }
66 :
67 15036 : svt::StatusbarController* SAL_CALL CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL )
68 : {
69 15036 : pfunc_setStatusBarControllerCreator pFactory = NULL;
70 : {
71 15036 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
72 15036 : pFactory = pStatusBarControllerCreator;
73 : }
74 :
75 15036 : if ( pFactory )
76 15036 : return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL );
77 : else
78 0 : return NULL;
79 : }
80 :
81 303 : pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc )
82 : {
83 303 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
84 303 : pfunc_getRefreshToolbars pOldFunc = pRefreshToolbars;
85 303 : pRefreshToolbars = pNewRefreshToolbarsFunc;
86 :
87 303 : return pOldFunc;
88 : }
89 :
90 0 : void SAL_CALL RefreshToolbars( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
91 : {
92 0 : pfunc_getRefreshToolbars pCallback = NULL;
93 : {
94 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
95 0 : pCallback = pRefreshToolbars;
96 : }
97 :
98 0 : if ( pCallback )
99 0 : (*pCallback)( rFrame );
100 0 : }
101 :
102 303 : pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow )
103 : {
104 303 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
105 303 : pfunc_createDockingWindow pOldFunc = pCreateDockingWindow;
106 303 : pCreateDockingWindow = pNewCreateDockingWindow;
107 :
108 303 : return pOldFunc;
109 : }
110 :
111 0 : void SAL_CALL CreateDockingWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const OUString& rResourceURL )
112 : {
113 0 : pfunc_createDockingWindow pFactory = NULL;
114 : {
115 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
116 0 : pFactory = pCreateDockingWindow;
117 : }
118 :
119 0 : if ( pFactory )
120 0 : (*pFactory)( rFrame, rResourceURL );
121 0 : }
122 :
123 303 : pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible)
124 : {
125 303 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
126 303 : pfunc_isDockingWindowVisible pOldFunc = pIsDockingWindowVisible;
127 303 : pIsDockingWindowVisible = pNewIsDockingWindowVisible;
128 :
129 303 : return pOldFunc;
130 : }
131 :
132 0 : bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const OUString& rResourceURL )
133 : {
134 0 : pfunc_isDockingWindowVisible pCall = NULL;
135 : {
136 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
137 0 : pCall = pIsDockingWindowVisible;
138 : }
139 :
140 0 : if ( pCall )
141 0 : return (*pCall)( rFrame, rResourceURL );
142 : else
143 0 : return false;
144 : }
145 :
146 303 : pfunc_activateToolPanel SAL_CALL SetActivateToolPanel( pfunc_activateToolPanel i_pActivator )
147 : {
148 303 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
149 303 : pfunc_activateToolPanel pOldFunc = pActivateToolPanel;
150 303 : pActivateToolPanel = i_pActivator;
151 303 : return pOldFunc;
152 : }
153 :
154 0 : void SAL_CALL ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const OUString& i_rPanelURL )
155 : {
156 0 : pfunc_activateToolPanel pActivator = NULL;
157 : {
158 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
159 0 : pActivator = pActivateToolPanel;
160 : }
161 :
162 0 : ENSURE_OR_RETURN_VOID( pActivator, "framework::ActivateToolPanel: no activator function!" );
163 0 : (*pActivator)( i_rFrame, i_rPanelURL );
164 : }
165 :
166 969 : }
167 :
168 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|