LCOV - code coverage report
Current view: top level - toolkit/source/controls/grid - gridcolumn.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 102 122 83.6 %
Date: 2015-06-13 12:38:46 Functions: 32 38 84.2 %
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          27 :     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          27 :         ,m_eHorizontalAlign( HorizontalAlignment_LEFT )
      52             :     {
      53          27 :     }
      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          74 :     GridColumn::~GridColumn()
      75             :     {
      76          74 :     }
      77             : 
      78             : 
      79          80 :     void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, const Any& i_oldValue, const 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          25 :     OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException, std::exception)
     150             :     {
     151          25 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     152          25 :         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          38 :     HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException, std::exception)
     204             :     {
     205          38 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     206          38 :         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          37 :     void SAL_CALL GridColumn::disposing()
     229             :     {
     230          37 :         ::osl::MutexGuard aGuard( m_aMutex );
     231          37 :         m_aIdentifier.clear();
     232          37 :         m_sTitle.clear();
     233          37 :         m_sHelpText.clear();
     234          37 :     }
     235             : 
     236             : 
     237          30 :     ::sal_Int32 SAL_CALL GridColumn::getIndex() throw (RuntimeException, std::exception)
     238             :     {
     239          30 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     240          30 :         return m_nIndex;
     241             :     }
     242             : 
     243             : 
     244          43 :     void GridColumn::setIndex( sal_Int32 const i_index )
     245             :     {
     246          43 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     247          43 :         m_nIndex = i_index;
     248          43 :     }
     249             : 
     250             : 
     251          23 :     ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException, std::exception)
     252             :     {
     253          23 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     254          23 :         return m_nDataColumnIndex;
     255             :     }
     256             : 
     257             : 
     258          24 :     void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException, std::exception)
     259             :     {
     260          24 :         impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" );
     261          24 :     }
     262             : 
     263             : 
     264           1 :     OUString SAL_CALL GridColumn::getImplementationName(  ) throw (RuntimeException, std::exception)
     265             :     {
     266           1 :         return OUString( "org.openoffice.comp.toolkit.GridColumn" );
     267             :     }
     268             : 
     269           0 :     sal_Bool SAL_CALL GridColumn::supportsService( const OUString& i_serviceName ) throw (RuntimeException, std::exception)
     270             :     {
     271           0 :         return cppu::supportsService(this, i_serviceName);
     272             :     }
     273             : 
     274           1 :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL GridColumn::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     275             :     {
     276           1 :         const OUString aServiceName("com.sun.star.awt.grid.GridColumn");
     277           1 :         const Sequence< OUString > aSeq( &aServiceName, 1 );
     278           1 :         return aSeq;
     279             :     }
     280             : 
     281             : 
     282          10 :     Reference< XCloneable > SAL_CALL GridColumn::createClone(  ) throw (RuntimeException, std::exception)
     283             :     {
     284          10 :         return new GridColumn( *this );
     285             :     }
     286             : 
     287             : 
     288          19 :     sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier ) throw(RuntimeException, std::exception)
     289             :     {
     290          19 :         if ( ( i_identifier.getLength() == 16 ) && ( i_identifier == getUnoTunnelId() ) )
     291          19 :             return ::sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
     292           0 :         return 0;
     293             :     }
     294             : 
     295             : 
     296          38 :     Sequence< sal_Int8 > GridColumn::getUnoTunnelId() throw()
     297             :     {
     298          38 :         static ::cppu::OImplementationId const aId;
     299          38 :         return aId.getImplementationId();
     300             :     }
     301             : 
     302             : 
     303          20 :     GridColumn* GridColumn::getImplementation( const Reference< XInterface >& i_component )
     304             :     {
     305          20 :         Reference< XUnoTunnel > const xTunnel( i_component, UNO_QUERY );
     306          20 :         if ( xTunnel.is() )
     307          19 :             return reinterpret_cast< GridColumn* >( ::sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( getUnoTunnelId() ) ) );
     308           1 :         return NULL;
     309             :     }
     310             : }
     311             : 
     312             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     313           1 : org_openoffice_comp_toolkit_GridColumn_get_implementation(
     314             :     css::uno::XComponentContext *,
     315             :     css::uno::Sequence<css::uno::Any> const &)
     316             : {
     317           1 :     return cppu::acquire(new toolkit::GridColumn());
     318             : }
     319             : 
     320             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11