LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbastyles.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 64 3.1 %
Date: 2012-08-25 Functions: 2 17 11.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 128 1.6 %

           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                 :            : #include "vbastyles.hxx"
      29                 :            : #include "vbastyle.hxx"
      30                 :            : #include <ooo/vba/excel/XRange.hpp>
      31                 :            : 
      32                 :            : using namespace ::ooo::vba;
      33                 :            : using namespace ::com::sun::star;
      34                 :            : 
      35                 :          3 : static rtl::OUString SDEFAULTCELLSTYLENAME( RTL_CONSTASCII_USTRINGPARAM("Default") );
      36                 :            : css::uno::Any
      37                 :          0 : lcl_createAPIStyleToVBAObject( const css::uno::Any& aObject, const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel )
      38                 :            : {
      39         [ #  # ]:          0 :     uno::Reference< beans::XPropertySet > xStyleProps( aObject, uno::UNO_QUERY_THROW );
      40 [ #  # ][ #  # ]:          0 :     uno::Reference< excel::XStyle > xStyle( new ScVbaStyle( xParent, xContext, xStyleProps, xModel ) );
                 [ #  # ]
      41         [ #  # ]:          0 :     return uno::makeAny( xStyle );
      42                 :            : }
      43                 :            : 
      44                 :            : 
      45 [ #  # ][ #  # ]:          0 : ScVbaStyles::ScVbaStyles( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException ) : ScVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( ScVbaStyle::getStylesNameContainer( xModel ), uno::UNO_QUERY_THROW ) ), mxModel( xModel ), mxParent( xParent )
      46                 :            : {
      47                 :            :     try
      48                 :            :     {
      49         [ #  # ]:          0 :         mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
      50         [ #  # ]:          0 :         mxNameContainerCellStyles.set( m_xNameAccess, uno::UNO_QUERY_THROW );
      51                 :            :     }
      52   [ #  #  #  # ]:          0 :     catch (uno::Exception& )
      53                 :            :     {
      54         [ #  # ]:          0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
      55                 :            :     }
      56                 :          0 : }
      57                 :            : 
      58                 :            : uno::Sequence< rtl::OUString >
      59                 :          0 : ScVbaStyles::getStyleNames() throw ( uno::RuntimeException )
      60                 :            : {
      61                 :          0 :     return mxNameContainerCellStyles->getElementNames();
      62                 :            : }
      63                 :            : 
      64                 :            : 
      65                 :            : uno::Any
      66                 :          0 : ScVbaStyles::createCollectionObject(const uno::Any& aObject)
      67                 :            : {
      68                 :          0 :     return lcl_createAPIStyleToVBAObject( aObject, mxParent, mxContext, mxModel );
      69                 :            : }
      70                 :            : 
      71                 :            : uno::Type SAL_CALL
      72                 :          0 : ScVbaStyles::getElementType() throw (uno::RuntimeException)
      73                 :            : {
      74                 :          0 :     return excel::XStyle::static_type(0);
      75                 :            : }
      76                 :            : 
      77         [ #  # ]:          0 : class EnumWrapper : public EnumerationHelper_BASE
      78                 :            : {
      79                 :            :         uno::Reference<container::XIndexAccess > m_xIndexAccess;
      80                 :            :         uno::Reference<XHelperInterface > m_xParent;
      81                 :            :         uno::Reference<uno::XComponentContext > m_xContext;
      82                 :            :         uno::Reference<frame::XModel > m_xModel;
      83                 :            : 
      84                 :            :         sal_Int32 nIndex;
      85                 :            : public:
      86                 :          0 :         EnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference<XHelperInterface >& xParent, const uno::Reference<uno::XComponentContext >& xContext, const uno::Reference<frame::XModel >& xModel ) : m_xIndexAccess( xIndexAccess ), m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel ), nIndex( 0 ) {}
      87                 :          0 :         virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
      88                 :            :         {
      89                 :          0 :                 return ( nIndex < m_xIndexAccess->getCount() );
      90                 :            :         }
      91                 :          0 :         virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
      92                 :            :         {
      93         [ #  # ]:          0 :                 if ( nIndex < m_xIndexAccess->getCount() )
      94         [ #  # ]:          0 :                         return lcl_createAPIStyleToVBAObject( m_xIndexAccess->getByIndex( nIndex++ ), m_xParent, m_xContext, m_xModel );
      95         [ #  # ]:          0 :                 throw container::NoSuchElementException();
      96                 :            :         }
      97                 :            : };
      98                 :            : 
      99                 :            : uno::Reference< container::XEnumeration > SAL_CALL
     100                 :          0 : ScVbaStyles::createEnumeration() throw (uno::RuntimeException)
     101                 :            : {
     102 [ #  # ][ #  # ]:          0 :     return new EnumWrapper( m_xIndexAccess, mxParent, mxContext, mxModel );
     103                 :            : }
     104                 :            : 
     105                 :            : uno::Reference< excel::XStyle > SAL_CALL
     106                 :          0 : ScVbaStyles::Add( const ::rtl::OUString& _sName, const uno::Any& _aBasedOn ) throw (script::BasicErrorException, uno::RuntimeException)
     107                 :            : {
     108                 :          0 :     uno::Reference< excel::XStyle > aRet;
     109                 :            :     try
     110                 :            :     {
     111         [ #  # ]:          0 :         rtl::OUString sParentCellStyleName( RTL_CONSTASCII_USTRINGPARAM("Default"));
     112         [ #  # ]:          0 :         if ( _aBasedOn.hasValue() )
     113                 :            :         {
     114                 :          0 :             uno::Reference< excel::XRange > oRange;
     115 [ #  # ][ #  # ]:          0 :             if ( _aBasedOn >>= oRange)
     116                 :            :             {
     117 [ #  # ][ #  # ]:          0 :                 uno::Reference< excel::XStyle > oStyle( oRange->getStyle(), uno::UNO_QUERY_THROW );
                 [ #  # ]
     118         [ #  # ]:          0 :                 if ( oStyle.is() )
     119                 :            :                 {
     120 [ #  # ][ #  # ]:          0 :                     sParentCellStyleName = oStyle->getName();
     121                 :            :                 }
     122                 :            :                 else
     123                 :            :                 {
     124         [ #  # ]:          0 :                     DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString() );
     125                 :          0 :                 }
     126                 :            :             }
     127                 :            :             else
     128                 :            :             {
     129         [ #  # ]:          0 :                 DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
     130                 :          0 :             }
     131                 :            :         }
     132                 :            : 
     133 [ #  # ][ #  # ]:          0 :         uno::Reference< style::XStyle > xStyle( mxMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.CellStyle"))), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
     134                 :            : 
     135 [ #  # ][ #  # ]:          0 :         if (!mxNameContainerCellStyles->hasByName(_sName))
                 [ #  # ]
     136                 :            :         {
     137 [ #  # ][ #  # ]:          0 :             mxNameContainerCellStyles->insertByName(_sName, uno::makeAny( xStyle) );
                 [ #  # ]
     138                 :            :         }
     139         [ #  # ]:          0 :         if (!sParentCellStyleName.equals(SDEFAULTCELLSTYLENAME))
     140                 :            :         {
     141 [ #  # ][ #  # ]:          0 :             xStyle->setParentStyle( sParentCellStyleName );
     142                 :            :         }
     143 [ #  # ][ #  # ]:          0 :         aRet.set( Item( uno::makeAny( _sName ), uno::Any() ), uno::UNO_QUERY_THROW );
                 [ #  # ]
     144                 :            :     }
     145   [ #  #  #  # ]:          0 :     catch (uno::Exception& )
     146                 :            :     {
     147         [ #  # ]:          0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
     148                 :            :     }
     149                 :          0 :     return aRet;
     150                 :            : }
     151                 :            : 
     152                 :            : void
     153                 :          0 : ScVbaStyles::Delete(const rtl::OUString _sStyleName) throw ( script::BasicErrorException )
     154                 :            : {
     155                 :            :     try
     156                 :            :     {
     157 [ #  # ][ #  # ]:          0 :         if (mxNameContainerCellStyles->hasByName( _sStyleName ) )
                 [ #  # ]
     158 [ #  # ][ #  # ]:          0 :             mxNameContainerCellStyles->removeByName( _sStyleName );
     159                 :            :     }
     160         [ #  # ]:          0 :     catch (uno::Exception& )
     161                 :            :     {
     162         [ #  # ]:          0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
     163                 :            :     }
     164                 :          0 : }
     165                 :            : 
     166                 :            : rtl::OUString
     167                 :          0 : ScVbaStyles::getServiceImplName()
     168                 :            : {
     169                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaStyles"));
     170                 :            : }
     171                 :            : 
     172                 :            : uno::Sequence< rtl::OUString >
     173                 :          0 : ScVbaStyles::getServiceNames()
     174                 :            : {
     175 [ #  # ][ #  # ]:          0 :         static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     176         [ #  # ]:          0 :         if ( aServiceNames.getLength() == 0 )
     177                 :            :         {
     178                 :          0 :                 aServiceNames.realloc( 1 );
     179         [ #  # ]:          0 :                 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XStyles" ) );
     180                 :            :         }
     181                 :          0 :         return aServiceNames;
     182 [ +  - ][ +  - ]:          9 : }
     183                 :            : 
     184                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10