19e0e4191SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file 59e0e4191SAndrew Rist * distributed with this work for additional information 69e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the 89e0e4191SAndrew Rist * "License"); you may not use this file except in compliance 99e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at 109e0e4191SAndrew Rist * 119e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129e0e4191SAndrew Rist * 139e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing, 149e0e4191SAndrew Rist * software distributed under the License is distributed on an 159e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169e0e4191SAndrew Rist * KIND, either express or implied. See the License for the 179e0e4191SAndrew Rist * specific language governing permissions and limitations 189e0e4191SAndrew Rist * under the License. 199e0e4191SAndrew Rist * 209e0e4191SAndrew Rist *************************************************************/ 219e0e4191SAndrew Rist 229e0e4191SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_reportdesign.hxx" 26cdf0e10cSrcweir #include "statusbarcontroller.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <svx/zoomsliderctrl.hxx> 29cdf0e10cSrcweir #include <svx/zoomctrl.hxx> 30cdf0e10cSrcweir #include <svx/svxids.hrc> 31cdf0e10cSrcweir #include <svx/zoomitem.hxx> 32cdf0e10cSrcweir #include <svx/zoomslideritem.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <vcl/svapp.hxx> 35cdf0e10cSrcweir #include <vcl/status.hxx> 36cdf0e10cSrcweir #include <vos/mutex.hxx> 37cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace rptui 40cdf0e10cSrcweir { 41cdf0e10cSrcweir using namespace svt; 42cdf0e10cSrcweir using namespace com::sun::star::uno; 43cdf0e10cSrcweir using namespace com::sun::star::beans; 44cdf0e10cSrcweir using namespace com::sun::star::lang; 45cdf0e10cSrcweir using namespace ::com::sun::star::frame; 46cdf0e10cSrcweir using namespace ::com::sun::star::util; 47cdf0e10cSrcweir 48cdf0e10cSrcweir ::rtl::OUString SAL_CALL OStatusbarController::getImplementationName() throw( RuntimeException ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir return getImplementationName_Static(); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir //------------------------------------------------------------------------------ 54cdf0e10cSrcweir ::rtl::OUString OStatusbarController::getImplementationName_Static() throw( RuntimeException ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.StatusbarController")); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir //------------------------------------------------------------------------------ 59cdf0e10cSrcweir Sequence< ::rtl::OUString> OStatusbarController::getSupportedServiceNames_Static(void) throw( RuntimeException ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir Sequence< ::rtl::OUString> aSupported(1); 62cdf0e10cSrcweir aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StatusbarController")); 63cdf0e10cSrcweir return aSupported; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir // ----------------------------------------------------------------------------- 66cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir //------------------------------------------------------------------------- 71cdf0e10cSrcweir Sequence< ::rtl::OUString> SAL_CALL OStatusbarController::getSupportedServiceNames() throw(RuntimeException) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir return getSupportedServiceNames_Static(); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir // ------------------------------------------------------------------------- 76cdf0e10cSrcweir Reference< XInterface > OStatusbarController::create(Reference< XComponentContext > const & xContext) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir return *(new OStatusbarController(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController, ::svt::StatusbarController,OStatusbarController_BASE) 81cdf0e10cSrcweir 82cdf0e10cSrcweir OStatusbarController::OStatusbarController(const Reference< XMultiServiceFactory >& _rxORB) 83cdf0e10cSrcweir : m_nSlotId(0) 84cdf0e10cSrcweir ,m_nId(1) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir m_xServiceManager = _rxORB; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir // ----------------------------------------------------------------------------- 89cdf0e10cSrcweir void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir StatusbarController::initialize(_rArguments); 92cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 93cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 94cdf0e10cSrcweir 95cdf0e10cSrcweir StatusBar* pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow)); 96cdf0e10cSrcweir if ( pStatusBar ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir const sal_uInt16 nCount = pStatusBar->GetItemCount(); 99cdf0e10cSrcweir for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos); 102cdf0e10cSrcweir if ( pStatusBar->GetItemCommand(nItemId) == String(m_aCommandURL) ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir m_nId = nItemId; 105cdf0e10cSrcweir break; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir } 108*0c02d14eSAriel Constenla-Haile 109*0c02d14eSAriel Constenla-Haile SfxStatusBarControl *pController = 0; 110cdf0e10cSrcweir if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 111*0c02d14eSAriel Constenla-Haile { 112*0c02d14eSAriel Constenla-Haile pController = new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar); 113cdf0e10cSrcweir } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 114cdf0e10cSrcweir else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) 115*0c02d14eSAriel Constenla-Haile { 116*0c02d14eSAriel Constenla-Haile pController = new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119*0c02d14eSAriel Constenla-Haile if ( pController ) 120cdf0e10cSrcweir { 121*0c02d14eSAriel Constenla-Haile m_rController.set( pController ); 122*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 123*0c02d14eSAriel Constenla-Haile { 124*0c02d14eSAriel Constenla-Haile m_rController->initialize(_rArguments); 125*0c02d14eSAriel Constenla-Haile m_rController->update(); 126*0c02d14eSAriel Constenla-Haile } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir addStatusListener(m_aCommandURL); 130cdf0e10cSrcweir update(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir } 133cdf0e10cSrcweir // XStatusListener 134cdf0e10cSrcweir void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)throw ( RuntimeException ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 137cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 138cdf0e10cSrcweir 139*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir Sequence< PropertyValue > aSeq; 144cdf0e10cSrcweir if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir SvxZoomSliderItem aZoomSlider(100,20,400); 147cdf0e10cSrcweir aZoomSlider.PutValue(_aEvent.State); 148*0c02d14eSAriel Constenla-Haile static_cast<SvxZoomSliderControl*>(m_rController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 151cdf0e10cSrcweir else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir Sequence< PropertyValue > aSeq; 154cdf0e10cSrcweir if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir SvxZoomItem aZoom; 157cdf0e10cSrcweir aZoom.PutValue(_aEvent.State); 158*0c02d14eSAriel Constenla-Haile static_cast<SvxZoomStatusBarControl*>(m_rController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir } 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir // XStatusbarController 165cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 166cdf0e10cSrcweir { 167*0c02d14eSAriel Constenla-Haile return m_rController.is() && m_rController->mouseButtonDown(_aEvent); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseMove( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 171cdf0e10cSrcweir { 172*0c02d14eSAriel Constenla-Haile return m_rController.is() && m_rController->mouseMove(_aEvent); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 176cdf0e10cSrcweir { 177*0c02d14eSAriel Constenla-Haile return m_rController.is() && m_rController->mouseButtonUp(_aEvent); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir void SAL_CALL OStatusbarController::command( 181cdf0e10cSrcweir const ::com::sun::star::awt::Point& aPos, 182cdf0e10cSrcweir ::sal_Int32 nCommand, 183cdf0e10cSrcweir ::sal_Bool bMouseEvent, 184cdf0e10cSrcweir const ::com::sun::star::uno::Any& aData ) 185cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 186cdf0e10cSrcweir { 187*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 188*0c02d14eSAriel Constenla-Haile m_rController->command( aPos, nCommand, bMouseEvent, aData ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir void SAL_CALL OStatusbarController::paint( 192cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics, 193cdf0e10cSrcweir const ::com::sun::star::awt::Rectangle& rOutputRectangle, 194cdf0e10cSrcweir ::sal_Int32 nStyle ) 195cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 196cdf0e10cSrcweir { 197*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 198*0c02d14eSAriel Constenla-Haile m_rController->paint( xGraphics, rOutputRectangle, nStyle ); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201*0c02d14eSAriel Constenla-Haile void SAL_CALL OStatusbarController::click( 202*0c02d14eSAriel Constenla-Haile const ::com::sun::star::awt::Point& aPos ) 203*0c02d14eSAriel Constenla-Haile throw (::com::sun::star::uno::RuntimeException) 204cdf0e10cSrcweir { 205*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 206*0c02d14eSAriel Constenla-Haile m_rController->click( aPos ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209*0c02d14eSAriel Constenla-Haile void SAL_CALL OStatusbarController::doubleClick( 210*0c02d14eSAriel Constenla-Haile const ::com::sun::star::awt::Point& aPos ) 211*0c02d14eSAriel Constenla-Haile throw (::com::sun::star::uno::RuntimeException) 212cdf0e10cSrcweir { 213*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 214*0c02d14eSAriel Constenla-Haile m_rController->doubleClick( aPos ); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir // ----------------------------------------------------------------------------- 217cdf0e10cSrcweir void SAL_CALL OStatusbarController::update() throw ( RuntimeException ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir ::svt::StatusbarController::update(); 220*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 221*0c02d14eSAriel Constenla-Haile m_rController->update(); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir // ----------------------------------------------------------------------------- 224cdf0e10cSrcweir // XComponent 225cdf0e10cSrcweir void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException) 226cdf0e10cSrcweir { 227*0c02d14eSAriel Constenla-Haile if ( m_rController.is() ) 228*0c02d14eSAriel Constenla-Haile ::comphelper::disposeComponent( m_rController ); 229*0c02d14eSAriel Constenla-Haile 230cdf0e10cSrcweir svt::StatusbarController::dispose(); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir // ============================================================================= 233cdf0e10cSrcweir } // rptui 234cdf0e10cSrcweir // ============================================================================= 235