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