LCOV - code coverage report
Current view: top level - toolkit/source/controls - tkscrollbar.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 127 0.0 %
Date: 2014-04-14 Functions: 0 30 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 "toolkit/controls/tkscrollbar.hxx"
      21             : #include "toolkit/helper/property.hxx"
      22             : #include "toolkit/helper/unopropertyarrayhelper.hxx"
      23             : #include <cppuhelper/typeprovider.hxx>
      24             : 
      25             : // for introspection
      26             : #include <toolkit/awt/vclxwindows.hxx>
      27             : 
      28             : 
      29             : namespace toolkit
      30             : {
      31             : 
      32             : 
      33             :     using namespace ::com::sun::star;
      34             : 
      35             : 
      36             :     //= UnoControlScrollBarModel
      37             : 
      38             : 
      39           0 :     UnoControlScrollBarModel::UnoControlScrollBarModel( const uno::Reference< uno::XComponentContext >& i_factory )
      40           0 :         :UnoControlModel( i_factory )
      41             :     {
      42           0 :         UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXScrollBar );
      43           0 :     }
      44             : 
      45             : 
      46           0 :     OUString UnoControlScrollBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      47             :     {
      48           0 :         return OUString::createFromAscii( szServiceName_UnoControlScrollBarModel );
      49             :     }
      50             : 
      51             : 
      52           0 :     uno::Any UnoControlScrollBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
      53             :     {
      54           0 :         switch ( nPropId )
      55             :         {
      56             :         case BASEPROPERTY_LIVE_SCROLL:
      57           0 :             return uno::makeAny( false );
      58             :         case BASEPROPERTY_DEFAULTCONTROL:
      59           0 :             return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlScrollBar ) );
      60             : 
      61             :         default:
      62           0 :             return UnoControlModel::ImplGetDefaultValue( nPropId );
      63             :         }
      64             :     }
      65             : 
      66             : 
      67           0 :     ::cppu::IPropertyArrayHelper& UnoControlScrollBarModel::getInfoHelper()
      68             :     {
      69             :         static UnoPropertyArrayHelper* pHelper = NULL;
      70           0 :         if ( !pHelper )
      71             :         {
      72           0 :             uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
      73           0 :             pHelper = new UnoPropertyArrayHelper( aIDs );
      74             :         }
      75           0 :         return *pHelper;
      76             :     }
      77             : 
      78             : 
      79           0 :     uno::Reference< beans::XPropertySetInfo > UnoControlScrollBarModel::getPropertySetInfo(  ) throw(uno::RuntimeException, std::exception)
      80             :     {
      81           0 :         static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
      82           0 :         return xInfo;
      83             :     }
      84             : 
      85             : 
      86             : 
      87             :     //= UnoControlScrollBarModel
      88             : 
      89           0 :     UnoScrollBarControl::UnoScrollBarControl()
      90             :         :UnoControlBase()
      91           0 :         ,maAdjustmentListeners( *this )
      92             :     {
      93           0 :     }
      94             : 
      95           0 :     OUString UnoScrollBarControl::GetComponentServiceName()
      96             :     {
      97           0 :         return OUString("ScrollBar");
      98             :     }
      99             : 
     100             :     // ::com::sun::star::uno::XInterface
     101           0 :     uno::Any UnoScrollBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
     102             :     {
     103             :         uno::Any aRet = ::cppu::queryInterface( rType,
     104             :                                             (static_cast< awt::XAdjustmentListener* >(this)),
     105           0 :                                             (static_cast< awt::XScrollBar* >(this)) );
     106           0 :         return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
     107             :     }
     108             : 
     109             :     // ::com::sun::star::lang::XTypeProvider
     110           0 :     IMPL_XTYPEPROVIDER_START( UnoScrollBarControl )
     111           0 :         getCppuType( ( uno::Reference< awt::XAdjustmentListener>* ) NULL ),
     112           0 :         getCppuType( ( uno::Reference< awt::XScrollBar>* ) NULL ),
     113             :         UnoControlBase::getTypes()
     114           0 :     IMPL_XTYPEPROVIDER_END
     115             : 
     116           0 :     void UnoScrollBarControl::dispose() throw(uno::RuntimeException, std::exception)
     117             :     {
     118           0 :         lang::EventObject aEvt;
     119           0 :         aEvt.Source = (::cppu::OWeakObject*)this;
     120           0 :         maAdjustmentListeners.disposeAndClear( aEvt );
     121           0 :         UnoControl::dispose();
     122           0 :     }
     123             : 
     124           0 :     void UnoScrollBarControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException, std::exception)
     125             :     {
     126           0 :         UnoControl::createPeer( rxToolkit, rParentPeer );
     127             : 
     128           0 :         uno::Reference < awt::XScrollBar >  xScrollBar( getPeer(), uno::UNO_QUERY );
     129           0 :         xScrollBar->addAdjustmentListener( this );
     130           0 :     }
     131             : 
     132             :     // ::com::sun::star::awt::XAdjustmentListener
     133           0 :     void UnoScrollBarControl::adjustmentValueChanged( const ::com::sun::star::awt::AdjustmentEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     134             :     {
     135           0 :         switch ( rEvent.Type )
     136             :         {
     137             :             case ::com::sun::star::awt::AdjustmentType_ADJUST_LINE:
     138             :             case ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE:
     139             :             case ::com::sun::star::awt::AdjustmentType_ADJUST_ABS:
     140             :             {
     141           0 :                 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     142             : 
     143           0 :                 if ( xScrollBar.is() )
     144             :                 {
     145           0 :                     uno::Any aAny;
     146           0 :                     aAny <<= xScrollBar->getValue();
     147           0 :                     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), aAny, false );
     148           0 :                 }
     149             :             }
     150           0 :             break;
     151             :             default:
     152             :             {
     153             :                 OSL_FAIL( "UnoScrollBarControl::adjustmentValueChanged - unknown Type" );
     154             : 
     155             :             }
     156             :         }
     157             : 
     158           0 :         if ( maAdjustmentListeners.getLength() )
     159           0 :             maAdjustmentListeners.adjustmentValueChanged( rEvent );
     160           0 :     }
     161             : 
     162             :     // ::com::sun::star::awt::XScrollBar
     163           0 :     void UnoScrollBarControl::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     164             :     {
     165           0 :         maAdjustmentListeners.addInterface( l );
     166           0 :     }
     167             : 
     168           0 :     void UnoScrollBarControl::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     169             :     {
     170           0 :         maAdjustmentListeners.removeInterface( l );
     171           0 :     }
     172             : 
     173           0 :     void UnoScrollBarControl::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     174             :     {
     175           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), uno::makeAny( n ), true );
     176           0 :     }
     177             : 
     178           0 :     void UnoScrollBarControl::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     179             :     {
     180           0 :         uno::Any aAny;
     181           0 :         aAny <<= nValue;
     182           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), aAny, true );
     183           0 :         aAny <<= nVisible;
     184           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VISIBLESIZE ), aAny, true );
     185           0 :         aAny <<= nMax;
     186           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE_MAX ), aAny, true );
     187           0 :     }
     188             : 
     189           0 :     sal_Int32 UnoScrollBarControl::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
     190             :     {
     191           0 :         sal_Int32 n = 0;
     192           0 :         if ( getPeer().is() )
     193             :         {
     194           0 :             uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     195           0 :             n = xScrollBar->getValue();
     196             :         }
     197           0 :         return n;
     198             :     }
     199             : 
     200           0 :     void UnoScrollBarControl::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     201             :     {
     202           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE_MAX ), uno::makeAny( n ), true );
     203           0 :     }
     204             : 
     205           0 :     sal_Int32 UnoScrollBarControl::getMaximum() throw(::com::sun::star::uno::RuntimeException, std::exception)
     206             :     {
     207           0 :         sal_Int32 n = 0;
     208           0 :         if ( getPeer().is() )
     209             :         {
     210           0 :             uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     211           0 :             n = xScrollBar->getMaximum();
     212             :         }
     213           0 :         return n;
     214             :     }
     215             : 
     216           0 :     void UnoScrollBarControl::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     217             :     {
     218           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINEINCREMENT ), uno::makeAny( n ), true );
     219           0 :     }
     220             : 
     221           0 :     sal_Int32 UnoScrollBarControl::getLineIncrement() throw(::com::sun::star::uno::RuntimeException, std::exception)
     222             :     {
     223           0 :         sal_Int32 n = 0;
     224           0 :         if ( getPeer().is() )
     225             :         {
     226           0 :             uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     227           0 :             n = xScrollBar->getLineIncrement();
     228             :         }
     229           0 :         return n;
     230             :     }
     231             : 
     232           0 :     void UnoScrollBarControl::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     233             :     {
     234           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BLOCKINCREMENT ), uno::makeAny( n ), true );
     235           0 :     }
     236             : 
     237           0 :     sal_Int32 UnoScrollBarControl::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException, std::exception)
     238             :     {
     239           0 :         sal_Int32 n = 0;
     240           0 :         if ( getPeer().is() )
     241             :         {
     242           0 :             uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     243           0 :             n = xScrollBar->getBlockIncrement();
     244             :         }
     245           0 :         return n;
     246             :     }
     247             : 
     248           0 :     void UnoScrollBarControl::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     249             :     {
     250           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VISIBLESIZE ), uno::makeAny( n ), true );
     251           0 :     }
     252             : 
     253           0 :     sal_Int32 UnoScrollBarControl::getVisibleSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
     254             :     {
     255           0 :         sal_Int32 n = 0;
     256           0 :         if ( getPeer().is() )
     257             :         {
     258           0 :             uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     259           0 :             n = xScrollBar->getVisibleSize();
     260             :         }
     261           0 :         return n;
     262             :     }
     263             : 
     264           0 :     void UnoScrollBarControl::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     265             :     {
     266           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ORIENTATION ), uno::makeAny( n ), true );
     267           0 :     }
     268             : 
     269           0 :     sal_Int32 UnoScrollBarControl::getOrientation() throw(::com::sun::star::uno::RuntimeException, std::exception)
     270             :     {
     271           0 :         sal_Int32 n = 0;
     272           0 :         if ( getPeer().is() )
     273             :         {
     274           0 :             uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
     275           0 :             n = xScrollBar->getOrientation();
     276             :         }
     277           0 :         return n;
     278             :     }
     279             : 
     280             : 
     281             : 
     282             : 
     283             : }  // namespace toolkit
     284             : 
     285             : 
     286             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     287           0 : stardiv_Toolkit_UnoControlScrollBarModel_get_implementation(
     288             :     css::uno::XComponentContext *context,
     289             :     css::uno::Sequence<css::uno::Any> const &)
     290             : {
     291           0 :     return cppu::acquire(new toolkit::UnoControlScrollBarModel(context));
     292             : }
     293             : 
     294             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     295           0 : stardiv_Toolkit_UnoScrollBarControl_get_implementation(
     296             :     css::uno::XComponentContext *,
     297             :     css::uno::Sequence<css::uno::Any> const &)
     298             : {
     299           0 :     return cppu::acquire(new toolkit::UnoScrollBarControl());
     300             : }
     301             : 
     302             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10