LCOV - code coverage report
Current view: top level - libreoffice/toolkit/source/controls - tkspinbutton.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 154 0.0 %
Date: 2012-12-27 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/tkspinbutton.hxx"
      21             : #include "toolkit/helper/property.hxx"
      22             : #include "toolkit/helper/unopropertyarrayhelper.hxx"
      23             : #include <com/sun/star/awt/ScrollBarOrientation.hpp>
      24             : 
      25             : 
      26             : #include <cppuhelper/typeprovider.hxx>
      27             : 
      28             : //........................................................................
      29             : namespace toolkit
      30             : {
      31             : //........................................................................
      32             : 
      33             :     using namespace ::com::sun::star::uno;
      34             :     using namespace ::com::sun::star::awt;
      35             :     using namespace ::com::sun::star::lang;
      36             :     using namespace ::com::sun::star::beans;
      37             : 
      38             :     //====================================================================
      39             :     //= UnoSpinButtonModel
      40             :     //====================================================================
      41             :     //--------------------------------------------------------------------
      42           0 :     UnoSpinButtonModel::UnoSpinButtonModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory )
      43           0 :         :UnoControlModel( i_factory )
      44             :     {
      45           0 :         ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
      46           0 :         ImplRegisterProperty( BASEPROPERTY_BORDER );
      47           0 :         ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
      48           0 :         ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
      49           0 :         ImplRegisterProperty( BASEPROPERTY_ENABLED );
      50           0 :         ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
      51           0 :         ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
      52           0 :         ImplRegisterProperty( BASEPROPERTY_HELPURL );
      53           0 :         ImplRegisterProperty( BASEPROPERTY_ORIENTATION );
      54           0 :         ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
      55           0 :         ImplRegisterProperty( BASEPROPERTY_REPEAT );
      56           0 :         ImplRegisterProperty( BASEPROPERTY_REPEAT_DELAY );
      57           0 :         ImplRegisterProperty( BASEPROPERTY_SYMBOL_COLOR );
      58           0 :         ImplRegisterProperty( BASEPROPERTY_SPINVALUE );
      59           0 :         ImplRegisterProperty( BASEPROPERTY_SPINVALUE_MIN );
      60           0 :         ImplRegisterProperty( BASEPROPERTY_SPINVALUE_MAX );
      61           0 :         ImplRegisterProperty( BASEPROPERTY_SPININCREMENT );
      62           0 :         ImplRegisterProperty( BASEPROPERTY_TABSTOP );
      63           0 :         ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
      64           0 :         ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
      65           0 :     }
      66             : 
      67             :     //--------------------------------------------------------------------
      68           0 :     ::rtl::OUString UnoSpinButtonModel::getServiceName( ) throw (RuntimeException)
      69             :     {
      70           0 :         return ::rtl::OUString::createFromAscii( szServiceName_UnoSpinButtonModel );
      71             :     }
      72             : 
      73             :     //--------------------------------------------------------------------
      74           0 :     Any UnoSpinButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
      75             :     {
      76           0 :         switch ( nPropId )
      77             :         {
      78             :         case BASEPROPERTY_DEFAULTCONTROL:
      79           0 :             return makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoSpinButtonControl ) );
      80             : 
      81             :         case BASEPROPERTY_BORDER:
      82           0 :             return makeAny( (sal_Int16) 0 );
      83             : 
      84             :         case BASEPROPERTY_REPEAT:
      85           0 :             return makeAny( (sal_Bool)sal_True );
      86             : 
      87             :         default:
      88           0 :             return UnoControlModel::ImplGetDefaultValue( nPropId );
      89             :         }
      90             :     }
      91             : 
      92             :     //--------------------------------------------------------------------
      93           0 :     ::cppu::IPropertyArrayHelper& UnoSpinButtonModel::getInfoHelper()
      94             :     {
      95             :         static UnoPropertyArrayHelper* pHelper = NULL;
      96           0 :         if ( !pHelper )
      97             :         {
      98           0 :             Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
      99           0 :             pHelper = new UnoPropertyArrayHelper( aIDs );
     100             :         }
     101           0 :         return *pHelper;
     102             :     }
     103             : 
     104             :     //--------------------------------------------------------------------
     105           0 :     Reference< XPropertySetInfo > UnoSpinButtonModel::getPropertySetInfo(  ) throw(RuntimeException)
     106             :     {
     107           0 :         static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     108           0 :         return xInfo;
     109             :     }
     110             : 
     111             :     //--------------------------------------------------------------------
     112           0 :     ::rtl::OUString SAL_CALL UnoSpinButtonModel::getImplementationName(  ) throw(RuntimeException)
     113             :     {
     114           0 :         return ::rtl::OUString( "com.sun.star.comp.toolkit.UnoSpinButtonModel" );
     115             :     }
     116             : 
     117             :     //--------------------------------------------------------------------
     118           0 :     Sequence< ::rtl::OUString > SAL_CALL UnoSpinButtonModel::getSupportedServiceNames() throw(RuntimeException)
     119             :     {
     120           0 :         Sequence< ::rtl::OUString > aServices( UnoControlModel::getSupportedServiceNames() );
     121           0 :         aServices.realloc( aServices.getLength() + 1 );
     122           0 :         aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSpinButtonModel );
     123           0 :         return aServices;
     124             :     }
     125             : 
     126             :     //====================================================================
     127             :     //= UnoSpinButtonControl
     128             :     //====================================================================
     129             :     //--------------------------------------------------------------------
     130           0 :     UnoSpinButtonControl::UnoSpinButtonControl( const Reference< XMultiServiceFactory >& i_factory )
     131             :         :UnoControlBase( i_factory )
     132           0 :         ,maAdjustmentListeners( *this )
     133             :     {
     134           0 :     }
     135             : 
     136             :     //--------------------------------------------------------------------
     137           0 :     ::rtl::OUString UnoSpinButtonControl::GetComponentServiceName()
     138             :     {
     139           0 :         return ::rtl::OUString("SpinButton");
     140             :     }
     141             : 
     142             :     //--------------------------------------------------------------------
     143           0 :     Any UnoSpinButtonControl::queryAggregation( const Type & rType ) throw(RuntimeException)
     144             :     {
     145           0 :         Any aRet = UnoControlBase::queryAggregation( rType );
     146           0 :         if ( !aRet.hasValue() )
     147           0 :             aRet = UnoSpinButtonControl_Base::queryInterface( rType );
     148           0 :         return aRet;
     149             :     }
     150             : 
     151             :     //--------------------------------------------------------------------
     152           0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoSpinButtonControl, UnoControlBase, UnoSpinButtonControl_Base )
     153             : 
     154             :     //--------------------------------------------------------------------
     155           0 :     void UnoSpinButtonControl::dispose() throw(RuntimeException)
     156             :     {
     157           0 :         ::osl::ClearableMutexGuard aGuard( GetMutex() );
     158           0 :         if ( maAdjustmentListeners.getLength() )
     159             :         {
     160           0 :             Reference< XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     161           0 :             if ( xSpinnable.is() )
     162           0 :                 xSpinnable->removeAdjustmentListener( this );
     163             : 
     164           0 :             EventObject aDisposeEvent;
     165           0 :             aDisposeEvent.Source = *this;
     166             : 
     167           0 :             aGuard.clear();
     168           0 :             maAdjustmentListeners.disposeAndClear( aDisposeEvent );
     169             :         }
     170             : 
     171           0 :         UnoControl::dispose();
     172           0 :     }
     173             : 
     174             :     //--------------------------------------------------------------------
     175           0 :     ::rtl::OUString SAL_CALL UnoSpinButtonControl::getImplementationName(  ) throw(RuntimeException)
     176             :     {
     177           0 :         return ::rtl::OUString( "com.sun.star.comp.toolkit.UnoSpinButtonControl" );
     178             :     }
     179             : 
     180             :     //--------------------------------------------------------------------
     181           0 :     Sequence< ::rtl::OUString > SAL_CALL UnoSpinButtonControl::getSupportedServiceNames() throw(RuntimeException)
     182             :     {
     183           0 :         Sequence< ::rtl::OUString > aServices( UnoControlBase::getSupportedServiceNames() );
     184           0 :         aServices.realloc( aServices.getLength() + 1 );
     185           0 :         aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSpinButtonControl );
     186           0 :         return aServices;
     187             :     }
     188             : 
     189             :     //--------------------------------------------------------------------
     190           0 :     void UnoSpinButtonControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer >  & rParentPeer ) throw(RuntimeException)
     191             :     {
     192           0 :         UnoControl::createPeer( rxToolkit, rParentPeer );
     193             : 
     194           0 :         Reference < XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     195           0 :         if ( xSpinnable.is() )
     196           0 :             xSpinnable->addAdjustmentListener( this );
     197           0 :     }
     198             : 
     199             :     //--------------------------------------------------------------------
     200           0 :     void UnoSpinButtonControl::adjustmentValueChanged( const AdjustmentEvent& rEvent ) throw(RuntimeException)
     201             :     {
     202           0 :         switch ( rEvent.Type )
     203             :         {
     204             :             case AdjustmentType_ADJUST_LINE:
     205             :             case AdjustmentType_ADJUST_PAGE:
     206             :             case AdjustmentType_ADJUST_ABS:
     207           0 :                 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE ), makeAny( rEvent.Value ), sal_False );
     208           0 :                 break;
     209             :             default:
     210             :                 OSL_FAIL( "UnoSpinButtonControl::adjustmentValueChanged - unknown Type" );
     211             :         }
     212             : 
     213           0 :         if ( maAdjustmentListeners.getLength() )
     214             :         {
     215           0 :             AdjustmentEvent aEvent( rEvent );
     216           0 :             aEvent.Source = *this;
     217           0 :             maAdjustmentListeners.adjustmentValueChanged( aEvent );
     218             :         }
     219           0 :     }
     220             : 
     221             :     //--------------------------------------------------------------------
     222           0 :     void UnoSpinButtonControl::addAdjustmentListener( const Reference< XAdjustmentListener > & listener ) throw(RuntimeException)
     223             :     {
     224           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     225           0 :         maAdjustmentListeners.addInterface( listener );
     226           0 :     }
     227             : 
     228             :     //--------------------------------------------------------------------
     229           0 :     void UnoSpinButtonControl::removeAdjustmentListener( const Reference< XAdjustmentListener > & listener ) throw(RuntimeException)
     230             :     {
     231           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     232           0 :         maAdjustmentListeners.removeInterface( listener );
     233           0 :     }
     234             : 
     235             :     //--------------------------------------------------------------------
     236           0 :     void SAL_CALL UnoSpinButtonControl::setValue( sal_Int32 value ) throw (RuntimeException)
     237             :     {
     238           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE ), makeAny( value ), sal_True );
     239           0 :     }
     240             : 
     241             :     //--------------------------------------------------------------------
     242           0 :     void SAL_CALL UnoSpinButtonControl::setValues( sal_Int32 minValue, sal_Int32 maxValue, sal_Int32 currentValue ) throw (RuntimeException)
     243             :     {
     244           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE_MIN ), makeAny( minValue ), sal_True );
     245           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE_MAX ), makeAny( maxValue ), sal_True );
     246           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE ), makeAny( currentValue ), sal_True );
     247           0 :     }
     248             : 
     249             :     //--------------------------------------------------------------------
     250           0 :     sal_Int32 SAL_CALL UnoSpinButtonControl::getValue(  ) throw (RuntimeException)
     251             :     {
     252           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     253           0 :         sal_Int32 nValue = 0;
     254             : 
     255           0 :         Reference< XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     256           0 :         if ( xSpinnable.is() )
     257           0 :             nValue = xSpinnable->getValue();
     258             : 
     259           0 :         return nValue;
     260             :     }
     261             : 
     262             :     //--------------------------------------------------------------------
     263           0 :     void SAL_CALL UnoSpinButtonControl::setMinimum( sal_Int32 minValue ) throw (RuntimeException)
     264             :     {
     265           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE_MIN ), makeAny( minValue ), sal_True );
     266           0 :     }
     267             : 
     268             :     //--------------------------------------------------------------------
     269           0 :     void SAL_CALL UnoSpinButtonControl::setMaximum( sal_Int32 maxValue ) throw (RuntimeException)
     270             :     {
     271           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPINVALUE_MAX ), makeAny( maxValue ), sal_True );
     272           0 :     }
     273             : 
     274             :     //--------------------------------------------------------------------
     275           0 :     sal_Int32 SAL_CALL UnoSpinButtonControl::getMinimum(  ) throw (RuntimeException)
     276             :     {
     277           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     278           0 :         sal_Int32 nMin = 0;
     279             : 
     280           0 :         Reference< XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     281           0 :         if ( xSpinnable.is() )
     282           0 :             nMin = xSpinnable->getMinimum();
     283             : 
     284           0 :         return nMin;
     285             :     }
     286             : 
     287             :     //--------------------------------------------------------------------
     288           0 :     sal_Int32 SAL_CALL UnoSpinButtonControl::getMaximum(  ) throw (RuntimeException)
     289             :     {
     290           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     291           0 :         sal_Int32 nMax = 0;
     292             : 
     293           0 :         Reference< XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     294           0 :         if ( xSpinnable.is() )
     295           0 :             nMax = xSpinnable->getMaximum();
     296             : 
     297           0 :         return nMax;
     298             :     }
     299             : 
     300             :     //--------------------------------------------------------------------
     301           0 :     void SAL_CALL UnoSpinButtonControl::setSpinIncrement( sal_Int32 spinIncrement ) throw (RuntimeException)
     302             :     {
     303           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SPININCREMENT ), makeAny( spinIncrement ), sal_True );
     304           0 :     }
     305             : 
     306             :     //--------------------------------------------------------------------
     307           0 :     sal_Int32 SAL_CALL UnoSpinButtonControl::getSpinIncrement(  ) throw (RuntimeException)
     308             :     {
     309           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     310           0 :         sal_Int32 nIncrement = 0;
     311             : 
     312           0 :         Reference< XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     313           0 :         if ( xSpinnable.is() )
     314           0 :             nIncrement = xSpinnable->getSpinIncrement();
     315             : 
     316           0 :         return nIncrement;
     317             :     }
     318             : 
     319             :     //--------------------------------------------------------------------
     320           0 :     void SAL_CALL UnoSpinButtonControl::setOrientation( sal_Int32 orientation ) throw (NoSupportException, RuntimeException)
     321             :     {
     322           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ORIENTATION ), makeAny( orientation ), sal_True );
     323           0 :     }
     324             : 
     325             :     //--------------------------------------------------------------------
     326           0 :     sal_Int32 SAL_CALL UnoSpinButtonControl::getOrientation(  ) throw (RuntimeException)
     327             :     {
     328           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     329           0 :         sal_Int32 nOrientation = ScrollBarOrientation::HORIZONTAL;
     330             : 
     331           0 :         Reference< XSpinValue > xSpinnable( getPeer(), UNO_QUERY );
     332           0 :         if ( xSpinnable.is() )
     333           0 :             nOrientation = xSpinnable->getOrientation();
     334             : 
     335           0 :         return nOrientation;
     336             :     }
     337             : 
     338             : //........................................................................
     339             : }  // namespace toolkit
     340             : //........................................................................
     341             : 
     342             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10