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

Generated by: LCOV version 1.10