LCOV - code coverage report
Current view: top level - reportdesign/source/ui/misc - statusbarcontroller.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 96 0.0 %
Date: 2014-04-14 Functions: 0 21 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "statusbarcontroller.hxx"
      21             : 
      22             : #include <cppuhelper/supportsservice.hxx>
      23             : #include <svx/zoomsliderctrl.hxx>
      24             : #include <svx/zoomctrl.hxx>
      25             : #include <svx/svxids.hrc>
      26             : #include <sfx2/zoomitem.hxx>
      27             : #include <svx/zoomslideritem.hxx>
      28             : 
      29             : #include <vcl/svapp.hxx>
      30             : #include <vcl/status.hxx>
      31             : #include <osl/mutex.hxx>
      32             : #include <toolkit/helper/vclunohelper.hxx>
      33             : 
      34             : namespace rptui
      35             : {
      36             :     using namespace svt;
      37             :     using namespace com::sun::star::uno;
      38             :     using namespace com::sun::star::beans;
      39             :     using namespace com::sun::star::lang;
      40             :     using namespace ::com::sun::star::frame;
      41             :     using namespace ::com::sun::star::util;
      42             : 
      43           0 : OUString SAL_CALL OStatusbarController::getImplementationName() throw( RuntimeException, std::exception )
      44             : {
      45           0 :     return getImplementationName_Static();
      46             : }
      47             : 
      48           0 : OUString OStatusbarController::getImplementationName_Static() throw( RuntimeException )
      49             : {
      50           0 :     return OUString("com.sun.star.report.comp.StatusbarController");
      51             : }
      52             : 
      53           0 : Sequence< OUString> OStatusbarController::getSupportedServiceNames_Static(void) throw( RuntimeException )
      54             : {
      55           0 :     Sequence< OUString> aSupported(1);
      56           0 :     aSupported[0] = "com.sun.star.frame.StatusbarController";
      57           0 :     return aSupported;
      58             : }
      59             : 
      60           0 : sal_Bool SAL_CALL OStatusbarController::supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception)
      61             : {
      62           0 :     return cppu::supportsService(this, ServiceName);
      63             : }
      64             : 
      65           0 : Sequence< OUString> SAL_CALL OStatusbarController::getSupportedServiceNames() throw(RuntimeException, std::exception)
      66             : {
      67           0 :     return getSupportedServiceNames_Static();
      68             : }
      69             : 
      70           0 : Reference< XInterface > OStatusbarController::create(Reference< XComponentContext > const & xContext)
      71             : {
      72           0 :     return *(new OStatusbarController(xContext));
      73             : }
      74           0 : IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController, ::svt::StatusbarController,OStatusbarController_BASE)
      75             : 
      76           0 : OStatusbarController::OStatusbarController(const Reference< XComponentContext >& rxContext)
      77             : : ::svt::StatusbarController(rxContext, Reference< XFrame >(), OUString(), 0)
      78             : ,m_nSlotId(0)
      79           0 : ,m_nId(1)
      80             : {
      81           0 : }
      82             : 
      83           0 : void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException, std::exception)
      84             : {
      85           0 :     StatusbarController::initialize(_rArguments);
      86           0 :     SolarMutexGuard aSolarMutexGuard;
      87           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      88             : 
      89           0 :     StatusBar* pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow));
      90           0 :     if ( pStatusBar )
      91             :     {
      92           0 :         const sal_uInt16 nCount = pStatusBar->GetItemCount();
      93           0 :         for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
      94             :         {
      95           0 :             const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos);
      96           0 :             if ( pStatusBar->GetItemCommand(nItemId) == m_aCommandURL )
      97             :             {
      98           0 :                 m_nId = nItemId;
      99           0 :                 break;
     100             :             }
     101             :         }
     102             : 
     103           0 :         SfxStatusBarControl *pController = 0;
     104           0 :         if ( m_aCommandURL == ".uno:ZoomSlider" )
     105             :         {
     106           0 :             pController = new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar);
     107             :         }
     108           0 :         else if ( m_aCommandURL == ".uno:Zoom" )
     109             :         {
     110           0 :             pController = new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar);
     111             :         }
     112             : 
     113           0 :         if ( pController )
     114             :         {
     115           0 :             m_rController.set( pController );
     116           0 :             if ( m_rController.is() )
     117             :             {
     118           0 :                 m_rController->initialize(_rArguments);
     119           0 :                 m_rController->update();
     120             :             }
     121             :         }
     122             : 
     123           0 :         addStatusListener(m_aCommandURL);
     124           0 :         update();
     125           0 :     }
     126           0 : }
     127             : // XStatusListener
     128           0 : void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)throw ( RuntimeException, std::exception )
     129             : {
     130           0 :     SolarMutexGuard aSolarGuard;
     131           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     132             : 
     133           0 :     if ( m_rController.is() )
     134             :     {
     135           0 :         if ( m_aCommandURL == ".uno:ZoomSlider" )
     136             :         {
     137           0 :             Sequence< PropertyValue > aSeq;
     138           0 :             if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 )
     139             :             {
     140           0 :                 SvxZoomSliderItem aZoomSlider(100,20,400);
     141           0 :                 aZoomSlider.PutValue(_aEvent.State);
     142           0 :                 static_cast<SvxZoomSliderControl*>(m_rController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider);
     143           0 :             }
     144             :         }
     145           0 :         else if ( m_aCommandURL == ".uno:Zoom" )
     146             :         {
     147           0 :             Sequence< PropertyValue > aSeq;
     148           0 :             if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 )
     149             :             {
     150           0 :                 SvxZoomItem aZoom;
     151           0 :                 aZoom.PutValue(_aEvent.State);
     152           0 :                 static_cast<SvxZoomStatusBarControl*>(m_rController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom);
     153           0 :             }
     154             :         }
     155           0 :     }
     156           0 : }
     157             : 
     158             : // XStatusbarController
     159           0 : sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException, std::exception)
     160             : {
     161           0 :     return m_rController.is() && m_rController->mouseButtonDown(_aEvent);
     162             : }
     163             : 
     164           0 : sal_Bool SAL_CALL OStatusbarController::mouseMove(    const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException, std::exception)
     165             : {
     166           0 :     return m_rController.is() && m_rController->mouseMove(_aEvent);
     167             : }
     168             : 
     169           0 : sal_Bool SAL_CALL OStatusbarController::mouseButtonUp(    const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException, std::exception)
     170             : {
     171           0 :     return m_rController.is() && m_rController->mouseButtonUp(_aEvent);
     172             : }
     173             : 
     174           0 : void SAL_CALL OStatusbarController::command(
     175             :     const ::com::sun::star::awt::Point& aPos,
     176             :     ::sal_Int32 nCommand,
     177             :     sal_Bool bMouseEvent,
     178             :     const ::com::sun::star::uno::Any& aData )
     179             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     180             : {
     181           0 :     if ( m_rController.is() )
     182           0 :         m_rController->command( aPos, nCommand, bMouseEvent, aData );
     183           0 : }
     184             : 
     185           0 : void SAL_CALL OStatusbarController::paint(
     186             :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
     187             :     const ::com::sun::star::awt::Rectangle& rOutputRectangle,
     188             :     ::sal_Int32 nStyle )
     189             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     190             : {
     191           0 :     if ( m_rController.is() )
     192           0 :         m_rController->paint( xGraphics, rOutputRectangle, nStyle );
     193           0 : }
     194             : 
     195           0 : void SAL_CALL OStatusbarController::click(
     196             :     const ::com::sun::star::awt::Point& aPos )
     197             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     198             : {
     199           0 :     if ( m_rController.is() )
     200           0 :         m_rController->click( aPos );
     201           0 : }
     202             : 
     203           0 : void SAL_CALL OStatusbarController::doubleClick(
     204             :     const ::com::sun::star::awt::Point& aPos )
     205             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     206             : {
     207           0 :     if ( m_rController.is() )
     208           0 :         m_rController->doubleClick( aPos );
     209           0 : }
     210             : 
     211           0 : void SAL_CALL OStatusbarController::update() throw ( RuntimeException, std::exception )
     212             : {
     213           0 :     ::svt::StatusbarController::update();
     214           0 :     if ( m_rController.is() )
     215           0 :         m_rController->update();
     216           0 : }
     217             : 
     218             : // XComponent
     219           0 : void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException, std::exception)
     220             : {
     221           0 :     if ( m_rController.is() )
     222           0 :         ::comphelper::disposeComponent( m_rController );
     223             : 
     224           0 :     svt::StatusbarController::dispose();
     225           0 : }
     226             : 
     227             : } // rptui
     228             : 
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10