LCOV - code coverage report
Current view: top level - svx/source/unodraw - tableshape.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 41 59 69.5 %
Date: 2014-11-03 Functions: 9 9 100.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             : #include <sal/config.h>
      21             : 
      22             : #include "UnoGraphicExporter.hxx"
      23             : #include "shapeimpl.hxx"
      24             : #include "svx/unoshprp.hxx"
      25             : #include "svx/svdotable.hxx"
      26             : #include <svx/svdpool.hxx>
      27             : 
      28             : 
      29             : 
      30             : 
      31             : using namespace ::osl;
      32             : using namespace ::cppu;
      33             : using namespace ::sdr::table;
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::lang;
      37             : using namespace ::com::sun::star::container;
      38             : using namespace ::com::sun::star::beans;
      39             : 
      40          28 : SvxTableShape::SvxTableShape( SdrObject* pObj ) throw()
      41          28 : :   SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
      42             : {
      43          28 :     SetShapeType( OUString( "com.sun.star.drawing.TableShape" ) );
      44          28 : }
      45             : 
      46             : 
      47          56 : SvxTableShape::~SvxTableShape() throw()
      48             : {
      49          56 : }
      50             : 
      51             : 
      52             : 
      53          60 : bool SvxTableShape::setPropertyValueImpl(
      54             :     const OUString& rName,
      55             :     const SfxItemPropertySimpleEntry* pProperty,
      56             :     const ::com::sun::star::uno::Any& rValue )
      57             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
      58             : {
      59          60 :     switch( pProperty->nWID )
      60             :     {
      61             :     case OWN_ATTR_TABLETEMPLATE:
      62             :     {
      63           6 :         Reference< XIndexAccess > xTemplate;
      64             : 
      65           6 :         if( !(rValue >>= xTemplate) )
      66           0 :             throw IllegalArgumentException();
      67             : 
      68           6 :         if( mpObj.is() )
      69           6 :             static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
      70             : 
      71           6 :         return true;
      72             :     }
      73             :     case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
      74             :     case OWN_ATTR_TABLETEMPLATE_LASTROW:
      75             :     case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
      76             :     case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
      77             :     case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
      78             :     case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
      79             :     {
      80          36 :         if( mpObj.is() )
      81             :         {
      82          36 :             TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
      83             : 
      84          36 :             switch( pProperty->nWID )
      85             :             {
      86           6 :             case OWN_ATTR_TABLETEMPLATE_FIRSTROW:           rValue >>= aSettings.mbUseFirstRow; break;
      87           6 :             case OWN_ATTR_TABLETEMPLATE_LASTROW:            rValue >>= aSettings.mbUseLastRow; break;
      88           6 :             case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:        rValue >>= aSettings.mbUseFirstColumn; break;
      89           6 :             case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:         rValue >>= aSettings.mbUseLastColumn; break;
      90           6 :             case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:        rValue >>= aSettings.mbUseRowBanding; break;
      91           6 :             case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:    rValue >>= aSettings.mbUseColumnBanding; break;
      92             :             }
      93             : 
      94          36 :             static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
      95             :         }
      96             : 
      97          36 :         return true;
      98             :     }
      99             :     default:
     100             :     {
     101          18 :         return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
     102             :     }
     103             :     }
     104             : }
     105             : 
     106          16 : bool SvxTableShape::getPropertyValueImpl(
     107             :     const OUString& rName,
     108             :     const SfxItemPropertySimpleEntry* pProperty,
     109             :     ::com::sun::star::uno::Any& rValue )
     110             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception)
     111             : {
     112          16 :     switch( pProperty->nWID )
     113             :     {
     114             :     case OWN_ATTR_OLEMODEL:
     115             :     {
     116          12 :         if( mpObj.is() )
     117             :         {
     118          12 :             rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
     119             :         }
     120          12 :         return true;
     121             :     }
     122             :     case OWN_ATTR_TABLETEMPLATE:
     123             :     {
     124           0 :         if( mpObj.is() )
     125             :         {
     126           0 :             rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
     127             :         }
     128           0 :         return true;
     129             :     }
     130             :     case OWN_ATTR_BITMAP:
     131             :     {
     132           0 :         if( mpObj.is() )
     133             :         {
     134           0 :             Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) );
     135           0 :             rValue <<= aGraphic.GetXGraphic();
     136             :         }
     137           0 :         return true;
     138             :     }
     139             :     case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
     140             :     case OWN_ATTR_TABLETEMPLATE_LASTROW:
     141             :     case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
     142             :     case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
     143             :     case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
     144             :     case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
     145             :     {
     146           0 :         if( mpObj.is() )
     147             :         {
     148           0 :             TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
     149             : 
     150           0 :             switch( pProperty->nWID )
     151             :             {
     152           0 :             case OWN_ATTR_TABLETEMPLATE_FIRSTROW:           rValue <<= aSettings.mbUseFirstRow; break;
     153           0 :             case OWN_ATTR_TABLETEMPLATE_LASTROW:            rValue <<= aSettings.mbUseLastRow; break;
     154           0 :             case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:        rValue <<= aSettings.mbUseFirstColumn; break;
     155           0 :             case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:         rValue <<= aSettings.mbUseLastColumn; break;
     156           0 :             case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:        rValue <<= aSettings.mbUseRowBanding; break;
     157           0 :             case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:    rValue <<= aSettings.mbUseColumnBanding; break;
     158             :             }
     159             :         }
     160             : 
     161           0 :         return true;
     162             :     }
     163             :     default:
     164             :     {
     165           4 :         return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
     166             :     }
     167             :     }
     168             : }
     169             : 
     170          12 : void SvxTableShape::lock()
     171             : {
     172          12 :     SvxShape::lock();
     173          12 :     if( mpObj.is() )
     174          12 :         static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
     175          12 : }
     176             : 
     177          12 : void SvxTableShape::unlock()
     178             : {
     179          12 :     if( mpObj.is() )
     180          12 :         static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
     181          12 :     SvxShape::unlock();
     182         663 : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10