LCOV - code coverage report
Current view: top level - toolkit/source/controls/grid - gridcolumn.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 93 121 76.9 %
Date: 2014-11-03 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          52 :     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          52 :         ,m_eHorizontalAlign( HorizontalAlignment_LEFT )
      52             :     {
      53          52 :     }
      54             : 
      55             : 
      56          20 :     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          20 :         ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign )
      70             :     {
      71          20 :     }
      72             : 
      73             : 
      74         144 :     GridColumn::~GridColumn()
      75             :     {
      76         144 :     }
      77             : 
      78             : 
      79         160 :     void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, Any i_oldValue, Any i_newValue,
      80             :         ::comphelper::ComponentGuard& i_Guard )
      81             :     {
      82         160 :         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         320 :         );
      87             : 
      88         160 :         ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( cppu::UnoType<XGridColumnListener>::get() );
      89             : 
      90         160 :         i_Guard.clear();
      91         160 :         if( pIter )
      92         176 :             pIter->notifyEach( &XGridColumnListener::columnChanged, aEvent );
      93         160 :     }
      94             : 
      95             : 
      96          40 :     ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException, std::exception)
      97             :     {
      98          40 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
      99          40 :         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         136 :     ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException, std::exception)
     111             :     {
     112         136 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     113         136 :         return m_nColumnWidth;
     114             :     }
     115             : 
     116             : 
     117          80 :     void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     118             :     {
     119          80 :         impl_set( m_nColumnWidth, value, "ColumnWidth" );
     120          80 :     }
     121             : 
     122             : 
     123         104 :     ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException, std::exception)
     124             :     {
     125         104 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     126         104 :         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         104 :     ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException, std::exception)
     137             :     {
     138         104 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     139         104 :         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          40 :     OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException, std::exception)
     150             :     {
     151          40 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     152          40 :         return m_sTitle;
     153             :     }
     154             : 
     155             : 
     156          48 :     void SAL_CALL GridColumn::setTitle(const OUString & value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     157             :     {
     158          48 :         impl_set( m_sTitle, value, "Title" );
     159          48 :     }
     160             : 
     161             : 
     162          40 :     OUString SAL_CALL GridColumn::getHelpText() throw (RuntimeException, std::exception)
     163             :     {
     164          40 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     165          40 :         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         104 :     sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException, std::exception)
     176             :     {
     177         104 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     178         104 :         return m_bResizeable;
     179             :     }
     180             : 
     181             : 
     182          48 :     void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException, std::exception)
     183             :     {
     184          48 :         impl_set( m_bResizeable, bool(value), "Resizeable" );
     185          48 :     }
     186             : 
     187             : 
     188         104 :     ::sal_Int32 SAL_CALL GridColumn::getFlexibility() throw (RuntimeException, std::exception)
     189             :     {
     190         104 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     191         104 :         return m_nFlexibility;
     192             :     }
     193             : 
     194             : 
     195          48 :     void SAL_CALL GridColumn::setFlexibility( ::sal_Int32 i_value ) throw (IllegalArgumentException, RuntimeException, std::exception)
     196             :     {
     197          48 :         if ( i_value < 0 )
     198           0 :             throw IllegalArgumentException( OUString(), *this, 1 );
     199          48 :         impl_set( m_nFlexibility, i_value, "Flexibility" );
     200          48 :     }
     201             : 
     202             : 
     203          40 :     HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException, std::exception)
     204             :     {
     205          40 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     206          40 :         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           6 :     void SAL_CALL GridColumn::addGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException, std::exception)
     217             :     {
     218           6 :         rBHelper.addListener( cppu::UnoType<XGridColumnListener>::get(), xListener );
     219           6 :     }
     220             : 
     221             : 
     222           2 :     void SAL_CALL GridColumn::removeGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException, std::exception)
     223             :     {
     224           2 :         rBHelper.removeListener( cppu::UnoType<XGridColumnListener>::get(), xListener );
     225           2 :     }
     226             : 
     227             : 
     228          72 :     void SAL_CALL GridColumn::disposing()
     229             :     {
     230          72 :         ::osl::MutexGuard aGuard( m_aMutex );
     231          72 :         m_aIdentifier.clear();
     232          72 :         m_sTitle = m_sHelpText = OUString();
     233          72 :     }
     234             : 
     235             : 
     236          60 :     ::sal_Int32 SAL_CALL GridColumn::getIndex() throw (RuntimeException, std::exception)
     237             :     {
     238          60 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     239          60 :         return m_nIndex;
     240             :     }
     241             : 
     242             : 
     243          87 :     void GridColumn::setIndex( sal_Int32 const i_index )
     244             :     {
     245          87 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     246          87 :         m_nIndex = i_index;
     247          87 :     }
     248             : 
     249             : 
     250          46 :     ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException, std::exception)
     251             :     {
     252          46 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     253          46 :         return m_nDataColumnIndex;
     254             :     }
     255             : 
     256             : 
     257          48 :     void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException, std::exception)
     258             :     {
     259          48 :         impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" );
     260          48 :     }
     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          20 :     Reference< XCloneable > SAL_CALL GridColumn::createClone(  ) throw (RuntimeException, std::exception)
     282             :     {
     283          20 :         return new GridColumn( *this );
     284             :     }
     285             : 
     286             : 
     287          39 :     sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier ) throw(RuntimeException, std::exception)
     288             :     {
     289          39 :         if ( ( i_identifier.getLength() == 16 ) && ( i_identifier == getUnoTunnelId() ) )
     290          39 :             return ::sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
     291           0 :         return 0;
     292             :     }
     293             : 
     294             : 
     295          78 :     Sequence< sal_Int8 > GridColumn::getUnoTunnelId() throw()
     296             :     {
     297          78 :         static ::cppu::OImplementationId const aId;
     298          78 :         return aId.getImplementationId();
     299             :     }
     300             : 
     301             : 
     302          41 :     GridColumn* GridColumn::getImplementation( const Reference< XInterface >& i_component )
     303             :     {
     304          41 :         Reference< XUnoTunnel > const xTunnel( i_component, UNO_QUERY );
     305          41 :         if ( xTunnel.is() )
     306          39 :             return reinterpret_cast< GridColumn* >( ::sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( getUnoTunnelId() ) ) );
     307           2 :         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