merge the formfield patch from ooo-build
[ooovba.git] / framework / source / classes / sfxhelperfunctions.cxx
blobf6d65257addfb365793992234a48f33b79ea47ca
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sfxhelperfunctions.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #ifndef __FRAMEWORK_CLASSES_SFXHELPERFUNCTIONS_CXX_
35 #include <classes/sfxhelperfunctions.hxx>
36 #endif
38 static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = NULL;
39 static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = NULL;
40 static pfunc_getRefreshToolbars pRefreshToolbars = NULL;
41 static pfunc_createDockingWindow pCreateDockingWindow = NULL;
42 static pfunc_isDockingWindowVisible pIsDockingWindowVisible = NULL;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::frame;
49 namespace framework
52 pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator )
54 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
55 pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator;
56 pToolBoxControllerCreator = pSetToolBoxControllerCreator;
57 return pOldSetToolBoxControllerCreator;
60 svt::ToolboxController* SAL_CALL CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL )
62 pfunc_setToolBoxControllerCreator pFactory = NULL;
64 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
65 pFactory = pToolBoxControllerCreator;
68 if ( pFactory )
69 return (*pFactory)( rFrame, pToolbox, nID, aCommandURL );
70 else
71 return NULL;
74 pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator )
76 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
77 pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator;
78 pStatusBarControllerCreator = pSetStatusBarControllerCreator;
79 return pOldSetStatusBarControllerCreator;
82 svt::StatusbarController* SAL_CALL CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const ::rtl::OUString& aCommandURL )
84 pfunc_setStatusBarControllerCreator pFactory = NULL;
86 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
87 pFactory = pStatusBarControllerCreator;
90 if ( pFactory )
91 return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL );
92 else
93 return NULL;
96 pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc )
98 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
99 pfunc_getRefreshToolbars pOldFunc = pRefreshToolbars;
100 pRefreshToolbars = pNewRefreshToolbarsFunc;
102 return pOldFunc;
105 void SAL_CALL RefreshToolbars( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
107 pfunc_getRefreshToolbars pCallback = NULL;
109 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
110 pCallback = pRefreshToolbars;
113 if ( pCallback )
114 (*pCallback)( rFrame );
117 pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow )
119 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
120 pfunc_createDockingWindow pOldFunc = pCreateDockingWindow;
121 pCreateDockingWindow = pNewCreateDockingWindow;
123 return pOldFunc;
126 void SAL_CALL CreateDockingWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL )
128 pfunc_createDockingWindow pFactory = NULL;
130 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
131 pFactory = pCreateDockingWindow;
134 if ( pFactory )
135 (*pFactory)( rFrame, rResourceURL );
138 pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible)
140 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
141 pfunc_isDockingWindowVisible pOldFunc = pIsDockingWindowVisible;
142 pIsDockingWindowVisible = pNewIsDockingWindowVisible;
144 return pOldFunc;
147 bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL )
149 pfunc_isDockingWindowVisible pCall = NULL;
151 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
152 pCall = pIsDockingWindowVisible;
155 if ( pIsDockingWindowVisible )
156 return (*pIsDockingWindowVisible)( rFrame, rResourceURL );
157 else
158 return false;