LCOV - code coverage report
Current view: top level - toolkit/source/controls/grid - gridcolumn.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 93 121 76.9 %
Date: 2014-04-11 Functions: 29 38 76.3 %
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 "gridcolumn.hxx"
      21             : 
      22             : #include <com/sun/star/uno/XComponentContext.hpp>
      23             : #include <comphelper/sequence.hxx>
      24             : #include <cppuhelper/supportsservice.hxx>
      25             : #include <cppuhelper/typeprovider.hxx>
      26             : 
      27             : namespace toolkit
      28             : {
      29             :     using namespace ::com::sun::star;
      30             :     using namespace ::com::sun::star::uno;
      31             :     using namespace ::com::sun::star::awt;
      32             :     using namespace ::com::sun::star::awt::grid;
      33             :     using namespace ::com::sun::star::lang;
      34             :     using namespace ::com::sun::star::util;
      35             :     using namespace ::com::sun::star::style;
      36             : 
      37             : 
      38             :     //= DefaultGridColumnModel
      39             : 
      40             : 
      41          26 :     GridColumn::GridColumn()
      42             :         :GridColumn_Base( m_aMutex )
      43             :         ,m_aIdentifier()
      44             :         ,m_nIndex(-1)
      45             :         ,m_nDataColumnIndex(-1)
      46             :         ,m_nColumnWidth(4)
      47             :         ,m_nMaxWidth(0)
      48             :         ,m_nMinWidth(0)
      49             :         ,m_nFlexibility(1)
      50             :         ,m_bResizeable(true)
      51          26 :         ,m_eHorizontalAlign( HorizontalAlignment_LEFT )
      52             :     {
      53          26 :     }
      54             : 
      55             : 
      56          10 :     GridColumn::GridColumn( GridColumn const & i_copySource )
      57             :         :cppu::BaseMutex()
      58             :         ,GridColumn_Base( m_aMutex )
      59             :         ,m_aIdentifier( i_copySource.m_aIdentifier )
      60             :         ,m_nIndex( -1 )
      61             :         ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex )
      62             :         ,m_nColumnWidth( i_copySource.m_nColumnWidth )
      63             :         ,m_nMaxWidth( i_copySource.m_nMaxWidth )
      64             :         ,m_nMinWidth( i_copySource.m_nMinWidth )
      65             :         ,m_nFlexibility( i_copySource.m_nFlexibility )
      66             :         ,m_bResizeable( i_copySource.m_bResizeable )
      67             :         ,m_sTitle( i_copySource.m_sTitle )
      68             :         ,m_sHelpText( i_copySource.m_sHelpText )
      69          10 :         ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign )
      70             :     {
      71          10 :     }
      72             : 
      73             : 
      74          72 :     GridColumn::~GridColumn()
      75             :     {
      76          72 :     }
      77             : 
      78             : 
      79          80 :     void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, Any i_oldValue, Any i_newValue,
      80             :         ::comphelper::ComponentGuard& i_Guard )
      81             :     {
      82          80 :         Reference< XInterface > const xSource( static_cast< ::cppu::OWeakObject* >( this ) );
      83             :         GridColumnEvent const aEvent(
      84             :             xSource, OUString::createFromAscii( i_asciiAttributeName ),
      85             :             i_oldValue, i_newValue, m_nIndex
      86         160 :         );
      87             : 
      88          80 :         ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( cppu::UnoType<XGridColumnListener>::get() );
      89             : 
      90          80 :         i_Guard.clear();
      91          80 :         if( pIter )
      92          88 :             pIter->notifyEach( &XGridColumnListener::columnChanged, aEvent );
      93          80 :     }
      94             : 
      95             : 
      96          20 :     ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException, std::exception)
      97             :     {
      98          20 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
      99          20 :         return m_aIdentifier;
     100             :     }
     101             : 
     102             : 
     103           0 :     void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     104             :     {
     105           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     106           0 :         m_aIdentifier = value;
     107           0 :     }
     108             : 
     109             : 
     110          68 :     ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException, std::exception)
     111             :     {
     112          68 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     113          68 :         return m_nColumnWidth;
     114             :     }
     115             : 
     116             : 
     117          40 :     void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     118             :     {
     119          40 :         impl_set( m_nColumnWidth, value, "ColumnWidth" );
     120          40 :     }
     121             : 
     122             : 
     123          52 :     ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException, std::exception)
     124             :     {
     125          52 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     126          52 :         return m_nMaxWidth;
     127             :     }
     128             : 
     129             : 
     130           0 :     void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     131             :     {
     132           0 :         impl_set( m_nMaxWidth, value, "MaxWidth" );
     133           0 :     }
     134             : 
     135             : 
     136          52 :     ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException, std::exception)
     137             :     {
     138          52 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     139          52 :         return m_nMinWidth;
     140             :     }
     141             : 
     142             : 
     143           0 :     void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     144             :     {
     145           0 :         impl_set( m_nMinWidth, value, "MinWidth" );
     146           0 :     }
     147             : 
     148             : 
     149          22 :     OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException, std::exception)
     150             :     {
     151          22 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     152          22 :         return m_sTitle;
     153             :     }
     154             : 
     155             : 
     156          24 :     void SAL_CALL GridColumn::setTitle(const OUString & value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     157             :     {
     158          24 :         impl_set( m_sTitle, value, "Title" );
     159          24 :     }
     160             : 
     161             : 
     162          20 :     OUString SAL_CALL GridColumn::getHelpText() throw (RuntimeException, std::exception)
     163             :     {
     164          20 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     165          20 :         return m_sHelpText;
     166             :     }
     167             : 
     168             : 
     169           0 :     void SAL_CALL GridColumn::setHelpText( const OUString & value ) throw (RuntimeException, std::exception)
     170             :     {
     171           0 :         impl_set( m_sHelpText, value, "HelpText" );
     172           0 :     }
     173             : 
     174             : 
     175          52 :     sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException, std::exception)
     176             :     {
     177          52 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     178          52 :         return m_bResizeable;
     179             :     }
     180             : 
     181             : 
     182          24 :     void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     183             :     {
     184          24 :         impl_set( m_bResizeable, bool(value), "Resizeable" );
     185          24 :     }
     186             : 
     187             : 
     188          52 :     ::sal_Int32 SAL_CALL GridColumn::getFlexibility() throw (RuntimeException, std::exception)
     189             :     {
     190          52 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     191          52 :         return m_nFlexibility;
     192             :     }
     193             : 
     194             : 
     195          24 :     void SAL_CALL GridColumn::setFlexibility( ::sal_Int32 i_value ) throw (IllegalArgumentException, RuntimeException, std::exception)
     196             :     {
     197          24 :         if ( i_value < 0 )
     198           0 :             throw IllegalArgumentException( OUString(), *this, 1 );
     199          24 :         impl_set( m_nFlexibility, i_value, "Flexibility" );
     200          24 :     }
     201             : 
     202             : 
     203          24 :     HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException, std::exception)
     204             :     {
     205          24 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     206          24 :         return m_eHorizontalAlign;
     207             :     }
     208             : 
     209             : 
     210           0 :     void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException, std::exception)
     211             :     {
     212           0 :         impl_set( m_eHorizontalAlign, align, "HorizontalAlign" );
     213           0 :     }
     214             : 
     215             : 
     216           3 :     void SAL_CALL GridColumn::addGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException, std::exception)
     217             :     {
     218           3 :         rBHelper.addListener( cppu::UnoType<XGridColumnListener>::get(), xListener );
     219           3 :     }
     220             : 
     221             : 
     222           1 :     void SAL_CALL GridColumn::removeGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException, std::exception)
     223             :     {
     224           1 :         rBHelper.removeListener( cppu::UnoType<XGridColumnListener>::get(), xListener );
     225           1 :     }
     226             : 
     227             : 
     228          36 :     void SAL_CALL GridColumn::disposing()
     229             :     {
     230          36 :         ::osl::MutexGuard aGuard( m_aMutex );
     231          36 :         m_aIdentifier.clear();
     232          36 :         m_sTitle = m_sHelpText = OUString();
     233          36 :     }
     234             : 
     235             : 
     236          30 :     ::sal_Int32 SAL_CALL GridColumn::getIndex() throw (RuntimeException, std::exception)
     237             :     {
     238          30 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     239          30 :         return m_nIndex;
     240             :     }
     241             : 
     242             : 
     243          38 :     void GridColumn::setIndex( sal_Int32 const i_index )
     244             :     {
     245          38 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     246          38 :         m_nIndex = i_index;
     247          38 :     }
     248             : 
     249             : 
     250          23 :     ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException, std::exception)
     251             :     {
     252          23 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     253          23 :         return m_nDataColumnIndex;
     254             :     }
     255             : 
     256             : 
     257          24 :     void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException, std::exception)
     258             :     {
     259          24 :         impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" );
     260          24 :     }
     261             : 
     262             : 
     263           0 :     OUString SAL_CALL GridColumn::getImplementationName(  ) throw (RuntimeException, std::exception)
     264             :     {
     265           0 :         return OUString( "org.openoffice.comp.toolkit.GridColumn" );
     266             :     }
     267             : 
     268           0 :     sal_Bool SAL_CALL GridColumn::supportsService( const OUString& i_serviceName ) throw (RuntimeException, std::exception)
     269             :     {
     270           0 :         return cppu::supportsService(this, i_serviceName);
     271             :     }
     272             : 
     273           0 :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL GridColumn::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     274             :     {
     275           0 :         const OUString aServiceName("com.sun.star.awt.grid.GridColumn");
     276           0 :         const Sequence< OUString > aSeq( &aServiceName, 1 );
     277           0 :         return aSeq;
     278             :     }
     279             : 
     280             : 
     281          10 :     Reference< XCloneable > SAL_CALL GridColumn::createClone(  ) throw (RuntimeException, std::exception)
     282             :     {
     283          10 :         return new GridColumn( *this );
     284             :     }
     285             : 
     286             : 
     287          14 :     sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier ) throw(RuntimeException, std::exception)
     288             :     {
     289          14 :         if ( ( i_identifier.getLength() == 16 ) && ( i_identifier == getUnoTunnelId() ) )
     290          14 :             return ::sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
     291           0 :         return 0;
     292             :     }
     293             : 
     294             : 
     295          28 :     Sequence< sal_Int8 > GridColumn::getUnoTunnelId() throw()
     296             :     {
     297          28 :         static ::cppu::OImplementationId const aId;
     298          28 :         return aId.getImplementationId();
     299             :     }
     300             : 
     301             : 
     302          15 :     GridColumn* GridColumn::getImplementation( const Reference< XInterface >& i_component )
     303             :     {
     304          15 :         Reference< XUnoTunnel > const xTunnel( i_component, UNO_QUERY );
     305          15 :         if ( xTunnel.is() )
     306          14 :             return reinterpret_cast< GridColumn* >( ::sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( getUnoTunnelId() ) ) );
     307           1 :         return NULL;
     308             :     }
     309             : }
     310             : 
     311             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     312           0 : org_openoffice_comp_toolkit_GridColumn_get_implementation(
     313             :     css::uno::XComponentContext *,
     314             :     css::uno::Sequence<css::uno::Any> const &)
     315             : {
     316           0 :     return cppu::acquire(new toolkit::GridColumn());
     317             : }
     318             : 
     319             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10