1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <framework/sfxhelperfunctions.hxx>
22 #include <tools/diagnose_ex.h>
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
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::frame
;
37 pfunc_setToolBoxControllerCreator SAL_CALL
SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator
)
39 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
40 pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator
= pToolBoxControllerCreator
;
41 pToolBoxControllerCreator
= pSetToolBoxControllerCreator
;
42 return pOldSetToolBoxControllerCreator
;
45 svt::ToolboxController
* SAL_CALL
CreateToolBoxController( const Reference
< XFrame
>& rFrame
, ToolBox
* pToolbox
, unsigned short nID
, const OUString
& aCommandURL
)
47 pfunc_setToolBoxControllerCreator pFactory
= NULL
;
49 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
50 pFactory
= pToolBoxControllerCreator
;
54 return (*pFactory
)( rFrame
, pToolbox
, nID
, aCommandURL
);
59 pfunc_setStatusBarControllerCreator SAL_CALL
SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator
)
61 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
62 pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator
= pSetStatusBarControllerCreator
;
63 pStatusBarControllerCreator
= pSetStatusBarControllerCreator
;
64 return pOldSetStatusBarControllerCreator
;
67 svt::StatusbarController
* SAL_CALL
CreateStatusBarController( const Reference
< XFrame
>& rFrame
, StatusBar
* pStatusBar
, unsigned short nID
, const OUString
& aCommandURL
)
69 pfunc_setStatusBarControllerCreator pFactory
= NULL
;
71 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
72 pFactory
= pStatusBarControllerCreator
;
76 return (*pFactory
)( rFrame
, pStatusBar
, nID
, aCommandURL
);
81 pfunc_getRefreshToolbars SAL_CALL
SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc
)
83 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
84 pfunc_getRefreshToolbars pOldFunc
= pRefreshToolbars
;
85 pRefreshToolbars
= pNewRefreshToolbarsFunc
;
90 void SAL_CALL
RefreshToolbars( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
)
92 pfunc_getRefreshToolbars pCallback
= NULL
;
94 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
95 pCallback
= pRefreshToolbars
;
99 (*pCallback
)( rFrame
);
102 pfunc_createDockingWindow SAL_CALL
SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow
)
104 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
105 pfunc_createDockingWindow pOldFunc
= pCreateDockingWindow
;
106 pCreateDockingWindow
= pNewCreateDockingWindow
;
111 void SAL_CALL
CreateDockingWindow( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
, const OUString
& rResourceURL
)
113 pfunc_createDockingWindow pFactory
= NULL
;
115 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
116 pFactory
= pCreateDockingWindow
;
120 (*pFactory
)( rFrame
, rResourceURL
);
123 pfunc_isDockingWindowVisible SAL_CALL
SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible
)
125 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
126 pfunc_isDockingWindowVisible pOldFunc
= pIsDockingWindowVisible
;
127 pIsDockingWindowVisible
= pNewIsDockingWindowVisible
;
132 bool SAL_CALL
IsDockingWindowVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
, const OUString
& rResourceURL
)
134 pfunc_isDockingWindowVisible pCall
= NULL
;
136 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
137 pCall
= pIsDockingWindowVisible
;
141 return (*pCall
)( rFrame
, rResourceURL
);
146 pfunc_activateToolPanel SAL_CALL
SetActivateToolPanel( pfunc_activateToolPanel i_pActivator
)
148 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
149 pfunc_activateToolPanel pOldFunc
= pActivateToolPanel
;
150 pActivateToolPanel
= i_pActivator
;
154 void SAL_CALL
ActivateToolPanel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rFrame
, const OUString
& i_rPanelURL
)
156 pfunc_activateToolPanel pActivator
= NULL
;
158 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
159 pActivator
= pActivateToolPanel
;
162 ENSURE_OR_RETURN_VOID( pActivator
, "framework::ActivateToolPanel: no activator function!" );
163 (*pActivator
)( i_rFrame
, i_rPanelURL
);
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */