LCOV - code coverage report
Current view: top level - svx/source/table - tablecolumn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 71 120 59.2 %
Date: 2012-08-25 Functions: 7 14 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 48 124 38.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      31                 :            : 
      32                 :            : #include "tablecolumn.hxx"
      33                 :            : #include "tableundo.hxx"
      34                 :            : #include "svx/svdmodel.hxx"
      35                 :            : #include "svx/svdotable.hxx"
      36                 :            : 
      37                 :            : // -----------------------------------------------------------------------------
      38                 :            : 
      39                 :            : using ::rtl::OUString;
      40                 :            : using namespace ::com::sun::star::uno;
      41                 :            : using namespace ::com::sun::star::lang;
      42                 :            : using namespace ::com::sun::star::container;
      43                 :            : using namespace ::com::sun::star::table;
      44                 :            : using namespace ::com::sun::star::beans;
      45                 :            : 
      46                 :            : // -----------------------------------------------------------------------------
      47                 :            : 
      48                 :            : namespace sdr { namespace table {
      49                 :            : 
      50                 :            : const sal_Int32 Property_Width = 0;
      51                 :            : const sal_Int32 Property_OptimalWidth = 1;
      52                 :            : const sal_Int32 Property_IsVisible = 2;
      53                 :            : const sal_Int32 Property_IsStartOfNewPage = 3;
      54                 :            : 
      55                 :            : // -----------------------------------------------------------------------------
      56                 :            : // TableRow
      57                 :            : // -----------------------------------------------------------------------------
      58                 :            : 
      59                 :         24 : TableColumn::TableColumn( const TableModelRef& xTableModel, sal_Int32 nColumn )
      60                 :            : : TableColumnBase( getStaticPropertySetInfo() )
      61                 :            : , mxTableModel( xTableModel )
      62                 :            : , mnColumn( nColumn )
      63                 :            : , mnWidth( 0 )
      64                 :            : , mbOptimalWidth( sal_True )
      65                 :            : , mbIsVisible( sal_True )
      66         [ +  - ]:         24 : , mbIsStartOfNewPage( sal_False )
      67                 :            : {
      68                 :         24 : }
      69                 :            : 
      70                 :            : // -----------------------------------------------------------------------------
      71                 :            : 
      72                 :         24 : TableColumn::~TableColumn()
      73                 :            : {
      74         [ -  + ]:         48 : }
      75                 :            : 
      76                 :            : // -----------------------------------------------------------------------------
      77                 :            : 
      78                 :         24 : void TableColumn::dispose()
      79                 :            : {
      80                 :         24 :     mxTableModel.clear();
      81                 :         24 : }
      82                 :            : 
      83                 :            : // -----------------------------------------------------------------------------
      84                 :            : 
      85                 :          0 : void TableColumn::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
      86                 :            : {
      87         [ #  # ]:          0 :     if( !mxTableModel.is() )
      88         [ #  # ]:          0 :         throw DisposedException();
      89                 :          0 : }
      90                 :            : 
      91                 :            : // -----------------------------------------------------------------------------
      92                 :            : 
      93                 :          0 : TableColumn& TableColumn::operator=( const TableColumn& r )
      94                 :            : {
      95                 :          0 :     mnWidth = r.mnWidth;
      96                 :          0 :     mbOptimalWidth = r.mbOptimalWidth;
      97                 :          0 :     mbIsVisible = r.mbIsVisible;
      98                 :          0 :     mbIsStartOfNewPage = r.mbIsStartOfNewPage;
      99                 :          0 :     maName = r.maName;
     100                 :          0 :     mnColumn = r.mnColumn;
     101                 :            : 
     102                 :          0 :     return *this;
     103                 :            : }
     104                 :            : 
     105                 :            : // -----------------------------------------------------------------------------
     106                 :            : // XCellRange
     107                 :            : // -----------------------------------------------------------------------------
     108                 :            : 
     109                 :          0 : Reference< XCell > SAL_CALL TableColumn::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
     110                 :            : {
     111                 :          0 :     throwIfDisposed();
     112         [ #  # ]:          0 :     if( nColumn != 0 )
     113         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     114                 :            : 
     115                 :          0 :     return mxTableModel->getCellByPosition( mnColumn, nRow );
     116                 :            : }
     117                 :            : 
     118                 :            : // -----------------------------------------------------------------------------
     119                 :            : 
     120                 :          0 : Reference< XCellRange > SAL_CALL TableColumn::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
     121                 :            : {
     122                 :          0 :     throwIfDisposed();
     123 [ #  # ][ #  # ]:          0 :     if( (nTop >= 0 ) && (nLeft == 0) && (nBottom >= nTop) && (nRight == 0)  )
         [ #  # ][ #  # ]
     124                 :            :     {
     125                 :          0 :         return mxTableModel->getCellRangeByPosition( mnColumn, nTop, mnColumn, nBottom );
     126                 :            :     }
     127         [ #  # ]:          0 :     throw IndexOutOfBoundsException();
     128                 :            : }
     129                 :            : 
     130                 :            : // -----------------------------------------------------------------------------
     131                 :            : 
     132                 :          0 : Reference< XCellRange > SAL_CALL TableColumn::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException)
     133                 :            : {
     134                 :          0 :     return Reference< XCellRange >();
     135                 :            : }
     136                 :            : 
     137                 :            : // -----------------------------------------------------------------------------
     138                 :            : // XNamed
     139                 :            : // -----------------------------------------------------------------------------
     140                 :            : 
     141                 :          0 : OUString SAL_CALL TableColumn::getName() throw (RuntimeException)
     142                 :            : {
     143                 :          0 :     return maName;
     144                 :            : }
     145                 :            : 
     146                 :            : // -----------------------------------------------------------------------------
     147                 :            : 
     148                 :          0 : void SAL_CALL TableColumn::setName( const OUString& aName ) throw (RuntimeException)
     149                 :            : {
     150                 :          0 :     maName = aName;
     151                 :          0 : }
     152                 :            : 
     153                 :            : // -----------------------------------------------------------------------------
     154                 :            : // XFastPropertySet
     155                 :            : // -----------------------------------------------------------------------------
     156                 :            : 
     157                 :         66 : void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException)
     158                 :            : {
     159                 :         66 :     bool bOk = false;
     160                 :         66 :     bool bChange = false;
     161                 :            : 
     162                 :         66 :     SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
     163                 :            : 
     164                 :         66 :     TableColumnUndo* pUndo = 0;
     165 [ +  - ][ +  + ]:         66 :     if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
         [ +  - ][ -  + ]
         [ -  + ][ +  - ]
     166                 :            :     {
     167                 :          0 :         TableColumnRef xThis( this );
     168 [ #  # ][ #  # ]:          0 :         pUndo = new TableColumnUndo( xThis );
     169                 :            :     }
     170                 :            : 
     171   [ +  +  -  -  :         66 :     switch( nHandle )
                      - ]
     172                 :            :     {
     173                 :            :     case Property_Width:
     174                 :            :         {
     175                 :         42 :             sal_Int32 nWidth = mnWidth;
     176                 :         42 :             bOk = aValue >>= nWidth;
     177 [ +  + ][ +  - ]:         42 :             if( bOk && (nWidth != mnWidth) )
     178                 :            :             {
     179                 :         30 :                 mnWidth = nWidth;
     180                 :         30 :                 mbOptimalWidth = mnWidth == 0;
     181                 :         42 :                 bChange = true;
     182                 :            :             }
     183                 :            :             break;
     184                 :            :         }
     185                 :            :     case Property_OptimalWidth:
     186                 :            :         {
     187                 :         24 :             sal_Bool bOptimalWidth = mbOptimalWidth;
     188                 :         24 :             bOk = aValue >>= bOptimalWidth;
     189 [ +  + ][ +  - ]:         24 :             if( bOk && (mbOptimalWidth != bOptimalWidth) )
     190                 :            :             {
     191                 :         18 :                 mbOptimalWidth = bOptimalWidth;
     192         [ -  + ]:         18 :                 if( bOptimalWidth )
     193                 :          0 :                     mnWidth = 0;
     194                 :         24 :                 bChange = true;
     195                 :            :             }
     196                 :            :             break;
     197                 :            :         }
     198                 :            :     case Property_IsVisible:
     199                 :            :         {
     200                 :          0 :             sal_Bool bIsVisible = mbIsVisible;
     201                 :          0 :             bOk = aValue >>= bIsVisible;
     202 [ #  # ][ #  # ]:          0 :             if( bOk && (mbIsVisible != bIsVisible) )
     203                 :            :             {
     204                 :          0 :                 mbIsVisible = bIsVisible;
     205                 :          0 :                 bChange = true;
     206                 :            :             }
     207                 :            :             break;
     208                 :            :         }
     209                 :            : 
     210                 :            :     case Property_IsStartOfNewPage:
     211                 :            :         {
     212                 :          0 :             sal_Bool bIsStartOfNewPage = mbIsStartOfNewPage;
     213                 :          0 :             bOk = aValue >>= bIsStartOfNewPage;
     214 [ #  # ][ #  # ]:          0 :             if( bOk && (mbIsStartOfNewPage != bIsStartOfNewPage) )
     215                 :            :             {
     216                 :          0 :                 mbIsStartOfNewPage = bIsStartOfNewPage;
     217                 :          0 :                 bChange = true;
     218                 :            :             }
     219                 :            :             break;
     220                 :            :         }
     221                 :            :     default:
     222         [ #  # ]:          0 :         throw UnknownPropertyException();
     223                 :            :     }
     224         [ -  + ]:         66 :     if( !bOk )
     225         [ #  # ]:          0 :         throw IllegalArgumentException();
     226                 :            : 
     227         [ +  + ]:         66 :     if( bChange )
     228                 :            :     {
     229         [ -  + ]:         48 :         if( pUndo )
     230                 :            :         {
     231                 :          0 :             pModel->AddUndo( pUndo );
     232                 :          0 :             pUndo = 0;
     233                 :            :         }
     234                 :         48 :         mxTableModel->setModified(sal_True);
     235                 :            :     }
     236                 :            : 
     237         [ -  + ]:         66 :     if( pUndo )
     238         [ #  # ]:          0 :         delete pUndo;
     239                 :         66 : }
     240                 :            : 
     241                 :            : // -----------------------------------------------------------------------------
     242                 :            : 
     243                 :        282 : Any SAL_CALL TableColumn::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     244                 :            : {
     245   [ +  +  -  -  :        282 :     switch( nHandle )
                      - ]
     246                 :            :     {
     247                 :        138 :     case Property_Width:            return Any( mnWidth );
     248                 :        144 :     case Property_OptimalWidth:     return Any( mbOptimalWidth );
     249                 :          0 :     case Property_IsVisible:        return Any( mbIsVisible );
     250                 :          0 :     case Property_IsStartOfNewPage: return Any( mbIsStartOfNewPage );
     251         [ #  # ]:        282 :     default:                        throw UnknownPropertyException();
     252                 :            :     }
     253                 :            : }
     254                 :            : 
     255                 :            : // -----------------------------------------------------------------------------
     256                 :            : 
     257                 :         24 : rtl::Reference< ::comphelper::FastPropertySetInfo > TableColumn::getStaticPropertySetInfo()
     258                 :            : {
     259 [ +  + ][ +  - ]:         24 :     static rtl::Reference< ::comphelper::FastPropertySetInfo > xInfo;
     260         [ +  + ]:         24 :     if( !xInfo.is() )
     261                 :            :     {
     262 [ +  - ][ +  - ]:          3 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     263         [ +  - ]:          3 :         if( !xInfo.is() )
     264                 :            :         {
     265         [ +  - ]:          3 :             comphelper::PropertyVector aProperties(6);
     266                 :            : 
     267         [ +  - ]:          3 :             aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
     268                 :          3 :             aProperties[0].Handle = Property_Width;
     269         [ +  - ]:          3 :             aProperties[0].Type = ::getCppuType((const sal_Int32*)0);
     270                 :          3 :             aProperties[0].Attributes = 0;
     271                 :            : 
     272         [ +  - ]:          3 :             aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OptimalWidth" ) );
     273                 :          3 :             aProperties[1].Handle = Property_OptimalWidth;
     274         [ +  - ]:          3 :             aProperties[1].Type = ::getBooleanCppuType();
     275                 :          3 :             aProperties[1].Attributes = 0;
     276                 :            : 
     277         [ +  - ]:          3 :             aProperties[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) );
     278                 :          3 :             aProperties[2].Handle = Property_IsVisible;
     279         [ +  - ]:          3 :             aProperties[2].Type = ::getBooleanCppuType();
     280                 :          3 :             aProperties[2].Attributes = 0;
     281                 :            : 
     282         [ +  - ]:          3 :             aProperties[3].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" ) );
     283                 :          3 :             aProperties[3].Handle = Property_IsStartOfNewPage;
     284         [ +  - ]:          3 :             aProperties[3].Type = ::getBooleanCppuType();
     285                 :          3 :             aProperties[3].Attributes = 0;
     286                 :            : 
     287         [ +  - ]:          3 :             aProperties[4].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
     288                 :          3 :             aProperties[4].Handle = Property_Width;
     289         [ +  - ]:          3 :             aProperties[4].Type = ::getCppuType((const sal_Int32*)0);
     290                 :          3 :             aProperties[4].Attributes = 0;
     291                 :            : 
     292         [ +  - ]:          3 :             aProperties[5].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OptimalSize" ) );
     293                 :          3 :             aProperties[5].Handle = Property_OptimalWidth;
     294         [ +  - ]:          3 :             aProperties[5].Type = ::getBooleanCppuType();
     295                 :          3 :             aProperties[5].Attributes = 0;
     296                 :            : 
     297         [ +  - ]:          3 :             xInfo.set( new ::comphelper::FastPropertySetInfo(aProperties) );
     298         [ +  - ]:          3 :         }
     299                 :            :     }
     300                 :            : 
     301                 :         24 :     return xInfo;
     302                 :            : }
     303                 :            : 
     304                 :            : // -----------------------------------------------------------------------------
     305                 :            : 
     306                 :            : } }
     307                 :            : 
     308                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10