1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_framework.hxx"
26 
27 #include <framework/sfxhelperfunctions.hxx>
28 
29 #include <tools/diagnose_ex.h>
30 
31 static pfunc_setToolBoxControllerCreator   pToolBoxControllerCreator   = NULL;
32 static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = NULL;
33 static pfunc_getRefreshToolbars	           pRefreshToolbars            = NULL;
34 static pfunc_createDockingWindow		   pCreateDockingWindow        = NULL;
35 static pfunc_isDockingWindowVisible        pIsDockingWindowVisible     = NULL;
36 static pfunc_activateToolPanel             pActivateToolPanel          = NULL;
37 
38 
39 
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::frame;
42 
43 namespace framework
44 {
45 
SetToolBoxControllerCreator(pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator)46 pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator )
47 {
48 	::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
49     pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator;
50     pToolBoxControllerCreator = pSetToolBoxControllerCreator;
51     return pOldSetToolBoxControllerCreator;
52 }
53 
CreateToolBoxController(const Reference<XFrame> & rFrame,ToolBox * pToolbox,unsigned short nID,const::rtl::OUString & aCommandURL)54 svt::ToolboxController* SAL_CALL CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL )
55 {
56 	pfunc_setToolBoxControllerCreator pFactory = NULL;
57 	{
58 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
59 		pFactory = pToolBoxControllerCreator;
60 	}
61 
62 	if ( pFactory )
63         return (*pFactory)( rFrame, pToolbox, nID, aCommandURL );
64     else
65         return NULL;
66 }
67 
SetStatusBarControllerCreator(pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator)68 pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator )
69 {
70 	::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
71     pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator;
72     pStatusBarControllerCreator = pSetStatusBarControllerCreator;
73     return pOldSetStatusBarControllerCreator;
74 }
75 
CreateStatusBarController(const Reference<XFrame> & rFrame,StatusBar * pStatusBar,unsigned short nID,const::rtl::OUString & aCommandURL)76 svt::StatusbarController* SAL_CALL CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const ::rtl::OUString& aCommandURL )
77 {
78 	pfunc_setStatusBarControllerCreator pFactory = NULL;
79 	{
80 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
81 		pFactory = pStatusBarControllerCreator;
82 	}
83 
84 	if ( pFactory )
85         return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL );
86     else
87         return NULL;
88 }
89 
SetRefreshToolbars(pfunc_getRefreshToolbars pNewRefreshToolbarsFunc)90 pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc )
91 {
92 	::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
93 	pfunc_getRefreshToolbars pOldFunc = pRefreshToolbars;
94 	pRefreshToolbars = pNewRefreshToolbarsFunc;
95 
96 	return pOldFunc;
97 }
98 
RefreshToolbars(::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & rFrame)99 void SAL_CALL RefreshToolbars( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
100 {
101 	pfunc_getRefreshToolbars pCallback = NULL;
102 	{
103 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
104 		pCallback = pRefreshToolbars;
105 	}
106 
107 	if ( pCallback )
108         (*pCallback)( rFrame );
109 }
110 
SetDockingWindowCreator(pfunc_createDockingWindow pNewCreateDockingWindow)111 pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow )
112 {
113 	::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
114 	pfunc_createDockingWindow pOldFunc = pCreateDockingWindow;
115 	pCreateDockingWindow = pNewCreateDockingWindow;
116 
117 	return pOldFunc;
118 }
119 
CreateDockingWindow(const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & rFrame,const::rtl::OUString & rResourceURL)120 void SAL_CALL CreateDockingWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL )
121 {
122 	pfunc_createDockingWindow pFactory = NULL;
123 	{
124 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
125 		pFactory = pCreateDockingWindow;
126 	}
127 
128 	if ( pFactory )
129 		(*pFactory)( rFrame, rResourceURL );
130 }
131 
SetIsDockingWindowVisible(pfunc_isDockingWindowVisible pNewIsDockingWindowVisible)132 pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible)
133 {
134 	::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
135 	pfunc_isDockingWindowVisible pOldFunc = pIsDockingWindowVisible;
136 	pIsDockingWindowVisible = pNewIsDockingWindowVisible;
137 
138 	return pOldFunc;
139 }
140 
IsDockingWindowVisible(const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & rFrame,const::rtl::OUString & rResourceURL)141 bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL )
142 {
143 	pfunc_isDockingWindowVisible pCall = NULL;
144 	{
145 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
146 		pCall = pIsDockingWindowVisible;
147 	}
148 
149 	if ( pIsDockingWindowVisible )
150 		return (*pIsDockingWindowVisible)( rFrame, rResourceURL );
151     else
152         return false;
153 }
154 
SetActivateToolPanel(pfunc_activateToolPanel i_pActivator)155 pfunc_activateToolPanel SAL_CALL SetActivateToolPanel( pfunc_activateToolPanel i_pActivator )
156 {
157 	::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
158 	pfunc_activateToolPanel pOldFunc = pActivateToolPanel;
159 	pActivateToolPanel = i_pActivator;
160 	return pOldFunc;
161 }
162 
ActivateToolPanel(const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & i_rFrame,const::rtl::OUString & i_rPanelURL)163 void SAL_CALL ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL )
164 {
165 	pfunc_activateToolPanel pActivator = NULL;
166 	{
167 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
168 		pActivator = pActivateToolPanel;
169 	}
170 
171     ENSURE_OR_RETURN_VOID( pActivator, "framework::ActivateToolPanel: no activator function!" );
172     (*pActivator)( i_rFrame, i_rPanelURL );
173 }
174 
175 }
176