1*9e0e4191SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9e0e4191SAndrew Rist * distributed with this work for additional information 6*9e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9e0e4191SAndrew Rist * "License"); you may not use this file except in compliance 9*9e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9e0e4191SAndrew Rist * software distributed under the License is distributed on an 15*9e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9e0e4191SAndrew Rist * KIND, either express or implied. See the License for the 17*9e0e4191SAndrew Rist * specific language governing permissions and limitations 18*9e0e4191SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9e0e4191SAndrew Rist *************************************************************/ 21*9e0e4191SAndrew Rist 22*9e0e4191SAndrew 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 } 108cdf0e10cSrcweir if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir m_pController = TStatusbarHelper::createFromQuery(new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar)); 111cdf0e10cSrcweir } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 112cdf0e10cSrcweir else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir m_pController = TStatusbarHelper::createFromQuery(new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar)); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir if ( m_pController.is() ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir m_pController->initialize(_rArguments); 120cdf0e10cSrcweir m_pController->update(); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir addStatusListener(m_aCommandURL); 124cdf0e10cSrcweir update(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir } 127cdf0e10cSrcweir // XStatusListener 128cdf0e10cSrcweir void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)throw ( RuntimeException ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 131cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 132cdf0e10cSrcweir 133cdf0e10cSrcweir if ( m_pController.is() ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir Sequence< PropertyValue > aSeq; 138cdf0e10cSrcweir if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir SvxZoomSliderItem aZoomSlider(100,20,400); 141cdf0e10cSrcweir aZoomSlider.PutValue(_aEvent.State); 142cdf0e10cSrcweir static_cast<SvxZoomSliderControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) 145cdf0e10cSrcweir else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir Sequence< PropertyValue > aSeq; 148cdf0e10cSrcweir if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir SvxZoomItem aZoom; 151cdf0e10cSrcweir aZoom.PutValue(_aEvent.State); 152cdf0e10cSrcweir static_cast<SvxZoomStatusBarControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir } 155cdf0e10cSrcweir } 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir // XStatusbarController 159cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir return m_pController.is() && m_pController.getRef()->mouseButtonDown(_aEvent); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseMove( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir return m_pController.is() && m_pController.getRef()->mouseMove(_aEvent); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir ::sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir return m_pController.is() && m_pController.getRef()->mouseButtonUp(_aEvent); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir void SAL_CALL OStatusbarController::command( 175cdf0e10cSrcweir const ::com::sun::star::awt::Point& aPos, 176cdf0e10cSrcweir ::sal_Int32 nCommand, 177cdf0e10cSrcweir ::sal_Bool bMouseEvent, 178cdf0e10cSrcweir const ::com::sun::star::uno::Any& aData ) 179cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir if ( m_pController.is() ) 182cdf0e10cSrcweir m_pController.getRef()->command( aPos, nCommand, bMouseEvent, aData ); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir void SAL_CALL OStatusbarController::paint( 186cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics, 187cdf0e10cSrcweir const ::com::sun::star::awt::Rectangle& rOutputRectangle, 188cdf0e10cSrcweir ::sal_Int32 nItemId, 189cdf0e10cSrcweir ::sal_Int32 nStyle ) 190cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir if ( m_pController.is() ) 193cdf0e10cSrcweir m_pController.getRef()->paint( xGraphics, rOutputRectangle, nItemId, nStyle ); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir void SAL_CALL OStatusbarController::click() throw (::com::sun::star::uno::RuntimeException) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir if ( m_pController.is() ) 199cdf0e10cSrcweir m_pController.getRef()->click(); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir void SAL_CALL OStatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir if ( m_pController.is() ) 205cdf0e10cSrcweir m_pController.getRef()->doubleClick(); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir // ----------------------------------------------------------------------------- 208cdf0e10cSrcweir void SAL_CALL OStatusbarController::update() throw ( RuntimeException ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir ::svt::StatusbarController::update(); 211cdf0e10cSrcweir Reference< XUpdatable > xUp(m_pController.getRef(),UNO_QUERY); 212cdf0e10cSrcweir if ( xUp.is() ) 213cdf0e10cSrcweir xUp->update(); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir // ----------------------------------------------------------------------------- 216cdf0e10cSrcweir // XComponent 217cdf0e10cSrcweir void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir Reference< XComponent > xComp( m_pController.getRef(), UNO_QUERY ); 220cdf0e10cSrcweir ::comphelper::disposeComponent(xComp); 221cdf0e10cSrcweir m_pController.dispose(); 222cdf0e10cSrcweir svt::StatusbarController::dispose(); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir // ============================================================================= 225cdf0e10cSrcweir } // rptui 226cdf0e10cSrcweir // ============================================================================= 227