LCOV - code coverage report
Current view: top level - svx/source/table - tablecolumn.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 123 0.0 %
Date: 2014-04-14 Functions: 0 14 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             : 
      21             : #include <com/sun/star/lang/DisposedException.hpp>
      22             : 
      23             : #include "tablecolumn.hxx"
      24             : #include "tableundo.hxx"
      25             : #include "svx/svdmodel.hxx"
      26             : #include "svx/svdotable.hxx"
      27             : 
      28             : 
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::lang;
      32             : using namespace ::com::sun::star::container;
      33             : using namespace ::com::sun::star::table;
      34             : using namespace ::com::sun::star::beans;
      35             : 
      36             : 
      37             : 
      38             : namespace sdr { namespace table {
      39             : 
      40             : const sal_Int32 Property_Width = 0;
      41             : const sal_Int32 Property_OptimalWidth = 1;
      42             : const sal_Int32 Property_IsVisible = 2;
      43             : const sal_Int32 Property_IsStartOfNewPage = 3;
      44             : 
      45             : 
      46             : // TableRow
      47             : 
      48             : 
      49           0 : TableColumn::TableColumn( const TableModelRef& xTableModel, sal_Int32 nColumn )
      50             : : TableColumnBase( getStaticPropertySetInfo() )
      51             : , mxTableModel( xTableModel )
      52             : , mnColumn( nColumn )
      53             : , mnWidth( 0 )
      54             : , mbOptimalWidth( sal_True )
      55             : , mbIsVisible( sal_True )
      56           0 : , mbIsStartOfNewPage( sal_False )
      57             : {
      58           0 : }
      59             : 
      60             : 
      61             : 
      62           0 : TableColumn::~TableColumn()
      63             : {
      64           0 : }
      65             : 
      66             : 
      67             : 
      68           0 : void TableColumn::dispose()
      69             : {
      70           0 :     mxTableModel.clear();
      71           0 : }
      72             : 
      73             : 
      74             : 
      75           0 : void TableColumn::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
      76             : {
      77           0 :     if( !mxTableModel.is() )
      78           0 :         throw DisposedException();
      79           0 : }
      80             : 
      81             : 
      82             : 
      83           0 : TableColumn& TableColumn::operator=( const TableColumn& r )
      84             : {
      85           0 :     mnWidth = r.mnWidth;
      86           0 :     mbOptimalWidth = r.mbOptimalWidth;
      87           0 :     mbIsVisible = r.mbIsVisible;
      88           0 :     mbIsStartOfNewPage = r.mbIsStartOfNewPage;
      89           0 :     maName = r.maName;
      90           0 :     mnColumn = r.mnColumn;
      91             : 
      92           0 :     return *this;
      93             : }
      94             : 
      95             : 
      96             : // XCellRange
      97             : 
      98             : 
      99           0 : Reference< XCell > SAL_CALL TableColumn::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     100             : {
     101           0 :     throwIfDisposed();
     102           0 :     if( nColumn != 0 )
     103           0 :         throw IndexOutOfBoundsException();
     104             : 
     105           0 :     return mxTableModel->getCellByPosition( mnColumn, nRow );
     106             : }
     107             : 
     108             : 
     109             : 
     110           0 : Reference< XCellRange > SAL_CALL TableColumn::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     111             : {
     112           0 :     throwIfDisposed();
     113           0 :     if( (nTop >= 0 ) && (nLeft == 0) && (nBottom >= nTop) && (nRight == 0)  )
     114             :     {
     115           0 :         return mxTableModel->getCellRangeByPosition( mnColumn, nTop, mnColumn, nBottom );
     116             :     }
     117           0 :     throw IndexOutOfBoundsException();
     118             : }
     119             : 
     120             : 
     121             : 
     122           0 : Reference< XCellRange > SAL_CALL TableColumn::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException, std::exception)
     123             : {
     124           0 :     return Reference< XCellRange >();
     125             : }
     126             : 
     127             : 
     128             : // XNamed
     129             : 
     130             : 
     131           0 : OUString SAL_CALL TableColumn::getName() throw (RuntimeException, std::exception)
     132             : {
     133           0 :     return maName;
     134             : }
     135             : 
     136             : 
     137             : 
     138           0 : void SAL_CALL TableColumn::setName( const OUString& aName ) throw (RuntimeException, std::exception)
     139             : {
     140           0 :     maName = aName;
     141           0 : }
     142             : 
     143             : 
     144             : // XFastPropertySet
     145             : 
     146             : 
     147           0 : void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception)
     148             : {
     149           0 :     bool bOk = false;
     150           0 :     bool bChange = false;
     151             : 
     152           0 :     SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
     153             : 
     154           0 :     TableColumnUndo* pUndo = 0;
     155           0 :     if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
     156             :     {
     157           0 :         TableColumnRef xThis( this );
     158           0 :         pUndo = new TableColumnUndo( xThis );
     159             :     }
     160             : 
     161           0 :     switch( nHandle )
     162             :     {
     163             :     case Property_Width:
     164             :         {
     165           0 :             sal_Int32 nWidth = mnWidth;
     166           0 :             bOk = aValue >>= nWidth;
     167           0 :             if( bOk && (nWidth != mnWidth) )
     168             :             {
     169           0 :                 mnWidth = nWidth;
     170           0 :                 mbOptimalWidth = mnWidth == 0;
     171           0 :                 bChange = true;
     172             :             }
     173           0 :             break;
     174             :         }
     175             :     case Property_OptimalWidth:
     176             :         {
     177           0 :             sal_Bool bOptimalWidth = mbOptimalWidth;
     178           0 :             bOk = aValue >>= bOptimalWidth;
     179           0 :             if( bOk && (mbOptimalWidth != bOptimalWidth) )
     180             :             {
     181           0 :                 mbOptimalWidth = bOptimalWidth;
     182           0 :                 if( bOptimalWidth )
     183           0 :                     mnWidth = 0;
     184           0 :                 bChange = true;
     185             :             }
     186           0 :             break;
     187             :         }
     188             :     case Property_IsVisible:
     189             :         {
     190           0 :             sal_Bool bIsVisible = mbIsVisible;
     191           0 :             bOk = aValue >>= bIsVisible;
     192           0 :             if( bOk && (mbIsVisible != bIsVisible) )
     193             :             {
     194           0 :                 mbIsVisible = bIsVisible;
     195           0 :                 bChange = true;
     196             :             }
     197           0 :             break;
     198             :         }
     199             : 
     200             :     case Property_IsStartOfNewPage:
     201             :         {
     202           0 :             sal_Bool bIsStartOfNewPage = mbIsStartOfNewPage;
     203           0 :             bOk = aValue >>= bIsStartOfNewPage;
     204           0 :             if( bOk && (mbIsStartOfNewPage != bIsStartOfNewPage) )
     205             :             {
     206           0 :                 mbIsStartOfNewPage = bIsStartOfNewPage;
     207           0 :                 bChange = true;
     208             :             }
     209           0 :             break;
     210             :         }
     211             :     default:
     212           0 :         throw UnknownPropertyException();
     213             :     }
     214           0 :     if( !bOk )
     215           0 :         throw IllegalArgumentException();
     216             : 
     217           0 :     if( bChange )
     218             :     {
     219           0 :         if( pUndo )
     220             :         {
     221           0 :             pModel->AddUndo( pUndo );
     222           0 :             pUndo = 0;
     223             :         }
     224           0 :         mxTableModel->setModified(sal_True);
     225             :     }
     226             : 
     227           0 :     delete pUndo;
     228           0 : }
     229             : 
     230             : 
     231             : 
     232           0 : Any SAL_CALL TableColumn::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     233             : {
     234           0 :     switch( nHandle )
     235             :     {
     236           0 :     case Property_Width:            return Any( mnWidth );
     237           0 :     case Property_OptimalWidth:     return Any( mbOptimalWidth );
     238           0 :     case Property_IsVisible:        return Any( mbIsVisible );
     239           0 :     case Property_IsStartOfNewPage: return Any( mbIsStartOfNewPage );
     240           0 :     default:                        throw UnknownPropertyException();
     241             :     }
     242             : }
     243             : 
     244             : 
     245             : 
     246           0 : rtl::Reference< FastPropertySetInfo > TableColumn::getStaticPropertySetInfo()
     247             : {
     248           0 :     static rtl::Reference< FastPropertySetInfo > xInfo;
     249           0 :     if( !xInfo.is() )
     250             :     {
     251           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     252           0 :         if( !xInfo.is() )
     253             :         {
     254           0 :             PropertyVector aProperties(6);
     255             : 
     256           0 :             aProperties[0].Name = "Width";
     257           0 :             aProperties[0].Handle = Property_Width;
     258           0 :             aProperties[0].Type = ::getCppuType((const sal_Int32*)0);
     259           0 :             aProperties[0].Attributes = 0;
     260             : 
     261           0 :             aProperties[1].Name = "OptimalWidth";
     262           0 :             aProperties[1].Handle = Property_OptimalWidth;
     263           0 :             aProperties[1].Type = ::getBooleanCppuType();
     264           0 :             aProperties[1].Attributes = 0;
     265             : 
     266           0 :             aProperties[2].Name = "IsVisible";
     267           0 :             aProperties[2].Handle = Property_IsVisible;
     268           0 :             aProperties[2].Type = ::getBooleanCppuType();
     269           0 :             aProperties[2].Attributes = 0;
     270             : 
     271           0 :             aProperties[3].Name = "IsStartOfNewPage";
     272           0 :             aProperties[3].Handle = Property_IsStartOfNewPage;
     273           0 :             aProperties[3].Type = ::getBooleanCppuType();
     274           0 :             aProperties[3].Attributes = 0;
     275             : 
     276           0 :             aProperties[4].Name = "Size";
     277           0 :             aProperties[4].Handle = Property_Width;
     278           0 :             aProperties[4].Type = ::getCppuType((const sal_Int32*)0);
     279           0 :             aProperties[4].Attributes = 0;
     280             : 
     281           0 :             aProperties[5].Name = "OptimalSize";
     282           0 :             aProperties[5].Handle = Property_OptimalWidth;
     283           0 :             aProperties[5].Type = ::getBooleanCppuType();
     284           0 :             aProperties[5].Attributes = 0;
     285             : 
     286           0 :             xInfo.set( new FastPropertySetInfo(aProperties) );
     287           0 :         }
     288             :     }
     289             : 
     290           0 :     return xInfo;
     291             : }
     292             : 
     293             : 
     294             : 
     295             : } }
     296             : 
     297             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10