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