1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_reportdesign.hxx" 30*cdf0e10cSrcweir #include "statusbarcontroller.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <svx/zoomsliderctrl.hxx> 33*cdf0e10cSrcweir #include <svx/zoomctrl.hxx> 34*cdf0e10cSrcweir #include <svx/svxids.hrc> 35*cdf0e10cSrcweir #include <svx/zoomitem.hxx> 36*cdf0e10cSrcweir #include <svx/zoomslideritem.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <vcl/svapp.hxx> 39*cdf0e10cSrcweir #include <vcl/status.hxx> 40*cdf0e10cSrcweir #include <vos/mutex.hxx> 41*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir namespace rptui 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir using namespace svt; 46*cdf0e10cSrcweir using namespace com::sun::star::uno; 47*cdf0e10cSrcweir using namespace com::sun::star::beans; 48*cdf0e10cSrcweir using namespace com::sun::star::lang; 49*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 50*cdf0e10cSrcweir using namespace ::com::sun::star::util; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OStatusbarController::getImplementationName() throw( RuntimeException ) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir return getImplementationName_Static(); 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir //------------------------------------------------------------------------------ 58*cdf0e10cSrcweir ::rtl::OUString OStatusbarController::getImplementationName_Static() throw( RuntimeException ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.StatusbarController")); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir //------------------------------------------------------------------------------ 63*cdf0e10cSrcweir Sequence< ::rtl::OUString> OStatusbarController::getSupportedServiceNames_Static(void) throw( RuntimeException ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir Sequence< ::rtl::OUString> aSupported(1); 66*cdf0e10cSrcweir aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StatusbarController")); 67*cdf0e10cSrcweir return aSupported; 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 70*cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir //------------------------------------------------------------------------- 75*cdf0e10cSrcweir Sequence< ::rtl::OUString> SAL_CALL OStatusbarController::getSupportedServiceNames() throw(RuntimeException) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir // ------------------------------------------------------------------------- 80*cdf0e10cSrcweir Reference< XInterface > OStatusbarController::create(Reference< XComponentContext > const & xContext) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir return *(new OStatusbarController(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController, ::svt::StatusbarController,OStatusbarController_BASE) 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir OStatusbarController::OStatusbarController(const Reference< XMultiServiceFactory >& _rxORB) 87*cdf0e10cSrcweir : m_nSlotId(0) 88*cdf0e10cSrcweir ,m_nId(1) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir m_xServiceManager = _rxORB; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 93*cdf0e10cSrcweir void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir StatusbarController::initialize(_rArguments); 96*cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 97*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir StatusBar* pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow)); 100*cdf0e10cSrcweir if ( pStatusBar ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir const sal_uInt16 nCount = pStatusBar->GetItemCount(); 103*cdf0e10cSrcweir for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos); 106*cdf0e10cSrcweir if ( pStatusBar->GetItemCommand(nItemId) == String(m_aCommandURL) ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir m_nId = nItemId; 109*cdf0e10cSrcweir break; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir m_pController = TStatusbarHelper::createFromQuery(new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar)); 115*cdf0e10cSrcweir } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 116*cdf0e10cSrcweir else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir m_pController = TStatusbarHelper::createFromQuery(new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar)); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if ( m_pController.is() ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir m_pController->initialize(_rArguments); 124*cdf0e10cSrcweir m_pController->update(); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir addStatusListener(m_aCommandURL); 128*cdf0e10cSrcweir update(); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir // XStatusListener 132*cdf0e10cSrcweir void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)throw ( RuntimeException ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 135*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir if ( m_pController.is() ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir Sequence< PropertyValue > aSeq; 142*cdf0e10cSrcweir if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir SvxZoomSliderItem aZoomSlider(100,20,400); 145*cdf0e10cSrcweir aZoomSlider.PutValue(_aEvent.State); 146*cdf0e10cSrcweir static_cast<SvxZoomSliderControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 149*cdf0e10cSrcweir else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir Sequence< PropertyValue > aSeq; 152*cdf0e10cSrcweir if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir SvxZoomItem aZoom; 155*cdf0e10cSrcweir aZoom.PutValue(_aEvent.State); 156*cdf0e10cSrcweir static_cast<SvxZoomStatusBarControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // XStatusbarController 163*cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir return m_pController.is() && m_pController.getRef()->mouseButtonDown(_aEvent); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseMove( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir return m_pController.is() && m_pController.getRef()->mouseMove(_aEvent); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir return m_pController.is() && m_pController.getRef()->mouseButtonUp(_aEvent); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir void SAL_CALL OStatusbarController::command( 179*cdf0e10cSrcweir const ::com::sun::star::awt::Point& aPos, 180*cdf0e10cSrcweir ::sal_Int32 nCommand, 181*cdf0e10cSrcweir ::sal_Bool bMouseEvent, 182*cdf0e10cSrcweir const ::com::sun::star::uno::Any& aData ) 183*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir if ( m_pController.is() ) 186*cdf0e10cSrcweir m_pController.getRef()->command( aPos, nCommand, bMouseEvent, aData ); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir void SAL_CALL OStatusbarController::paint( 190*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics, 191*cdf0e10cSrcweir const ::com::sun::star::awt::Rectangle& rOutputRectangle, 192*cdf0e10cSrcweir ::sal_Int32 nItemId, 193*cdf0e10cSrcweir ::sal_Int32 nStyle ) 194*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir if ( m_pController.is() ) 197*cdf0e10cSrcweir m_pController.getRef()->paint( xGraphics, rOutputRectangle, nItemId, nStyle ); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void SAL_CALL OStatusbarController::click() throw (::com::sun::star::uno::RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if ( m_pController.is() ) 203*cdf0e10cSrcweir m_pController.getRef()->click(); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir void SAL_CALL OStatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir if ( m_pController.is() ) 209*cdf0e10cSrcweir m_pController.getRef()->doubleClick(); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 212*cdf0e10cSrcweir void SAL_CALL OStatusbarController::update() throw ( RuntimeException ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir ::svt::StatusbarController::update(); 215*cdf0e10cSrcweir Reference< XUpdatable > xUp(m_pController.getRef(),UNO_QUERY); 216*cdf0e10cSrcweir if ( xUp.is() ) 217*cdf0e10cSrcweir xUp->update(); 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 220*cdf0e10cSrcweir // XComponent 221*cdf0e10cSrcweir void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir Reference< XComponent > xComp( m_pController.getRef(), UNO_QUERY ); 224*cdf0e10cSrcweir ::comphelper::disposeComponent(xComp); 225*cdf0e10cSrcweir m_pController.dispose(); 226*cdf0e10cSrcweir svt::StatusbarController::dispose(); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir // ============================================================================= 229*cdf0e10cSrcweir } // rptui 230*cdf0e10cSrcweir // ============================================================================= 231