xref: /trunk/main/framework/source/fwe/classes/sfxhelperfunctions.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
30 
31 #include <framework/sfxhelperfunctions.hxx>
32 
33 #include <tools/diagnose_ex.h>
34 
35 static pfunc_setToolBoxControllerCreator   pToolBoxControllerCreator   = NULL;
36 static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = NULL;
37 static pfunc_getRefreshToolbars            pRefreshToolbars            = NULL;
38 static pfunc_createDockingWindow           pCreateDockingWindow        = NULL;
39 static pfunc_isDockingWindowVisible        pIsDockingWindowVisible     = NULL;
40 static pfunc_activateToolPanel             pActivateToolPanel          = NULL;
41 
42 
43 
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::frame;
46 
47 namespace framework
48 {
49 
50 pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator )
51 {
52     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
53     pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator;
54     pToolBoxControllerCreator = pSetToolBoxControllerCreator;
55     return pOldSetToolBoxControllerCreator;
56 }
57 
58 svt::ToolboxController* SAL_CALL CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL )
59 {
60     pfunc_setToolBoxControllerCreator pFactory = NULL;
61     {
62         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
63         pFactory = pToolBoxControllerCreator;
64     }
65 
66     if ( pFactory )
67         return (*pFactory)( rFrame, pToolbox, nID, aCommandURL );
68     else
69         return NULL;
70 }
71 
72 pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator )
73 {
74     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
75     pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator;
76     pStatusBarControllerCreator = pSetStatusBarControllerCreator;
77     return pOldSetStatusBarControllerCreator;
78 }
79 
80 svt::StatusbarController* SAL_CALL CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const ::rtl::OUString& aCommandURL )
81 {
82     pfunc_setStatusBarControllerCreator pFactory = NULL;
83     {
84         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
85         pFactory = pStatusBarControllerCreator;
86     }
87 
88     if ( pFactory )
89         return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL );
90     else
91         return NULL;
92 }
93 
94 pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc )
95 {
96     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
97     pfunc_getRefreshToolbars pOldFunc = pRefreshToolbars;
98     pRefreshToolbars = pNewRefreshToolbarsFunc;
99 
100     return pOldFunc;
101 }
102 
103 void SAL_CALL RefreshToolbars( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
104 {
105     pfunc_getRefreshToolbars pCallback = NULL;
106     {
107         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
108         pCallback = pRefreshToolbars;
109     }
110 
111     if ( pCallback )
112         (*pCallback)( rFrame );
113 }
114 
115 pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow )
116 {
117     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
118     pfunc_createDockingWindow pOldFunc = pCreateDockingWindow;
119     pCreateDockingWindow = pNewCreateDockingWindow;
120 
121     return pOldFunc;
122 }
123 
124 void SAL_CALL CreateDockingWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL )
125 {
126     pfunc_createDockingWindow pFactory = NULL;
127     {
128         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
129         pFactory = pCreateDockingWindow;
130     }
131 
132     if ( pFactory )
133         (*pFactory)( rFrame, rResourceURL );
134 }
135 
136 pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible)
137 {
138     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
139     pfunc_isDockingWindowVisible pOldFunc = pIsDockingWindowVisible;
140     pIsDockingWindowVisible = pNewIsDockingWindowVisible;
141 
142     return pOldFunc;
143 }
144 
145 bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL )
146 {
147     pfunc_isDockingWindowVisible pCall = NULL;
148     {
149         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
150         pCall = pIsDockingWindowVisible;
151     }
152 
153     if ( pIsDockingWindowVisible )
154         return (*pIsDockingWindowVisible)( rFrame, rResourceURL );
155     else
156         return false;
157 }
158 
159 pfunc_activateToolPanel SAL_CALL SetActivateToolPanel( pfunc_activateToolPanel i_pActivator )
160 {
161     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
162     pfunc_activateToolPanel pOldFunc = pActivateToolPanel;
163     pActivateToolPanel = i_pActivator;
164     return pOldFunc;
165 }
166 
167 void SAL_CALL ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL )
168 {
169     pfunc_activateToolPanel pActivator = NULL;
170     {
171         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
172         pActivator = pActivateToolPanel;
173     }
174 
175     ENSURE_OR_RETURN_VOID( pActivator, "framework::ActivateToolPanel: no activator function!" );
176     (*pActivator)( i_rFrame, i_rPanelURL );
177 }
178 
179 }
180