LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbaoleobjects.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 65 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 126 0.0 %

           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                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      30                 :            : #include <com/sun/star/drawing/XControlShape.hpp>
      31                 :            : #include <com/sun/star/container/XNamed.hpp>
      32                 :            : #include <ooo/vba/excel/XOLEObject.hpp>
      33                 :            : 
      34                 :            : #include "vbaoleobject.hxx"
      35                 :            : #include "vbaoleobjects.hxx"
      36                 :            : 
      37                 :            : using namespace com::sun::star;
      38                 :            : using namespace ooo::vba;
      39                 :            : 
      40                 :            : typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
      41                 :            : 
      42         [ #  # ]:          0 : class IndexAccessWrapper : public XIndexAccess_BASE
      43                 :            : {
      44                 :            : typedef std::vector< uno::Reference< drawing::XControlShape > > OLEObjects;
      45                 :            :     OLEObjects vObjects;
      46                 :            : public:
      47                 :          0 :         IndexAccessWrapper(  const uno::Reference< container::XIndexAccess >& xIndexAccess )
      48         [ #  # ]:          0 :     {
      49 [ #  # ][ #  # ]:          0 :         sal_Int32 nLen = xIndexAccess->getCount();
      50         [ #  # ]:          0 :         for ( sal_Int32 index = 0; index < nLen; ++index )
      51                 :            :         {
      52 [ #  # ][ #  # ]:          0 :                 uno::Reference< drawing::XControlShape > xControlShape( xIndexAccess->getByIndex( index), uno::UNO_QUERY);
                 [ #  # ]
      53         [ #  # ]:          0 :             if ( xControlShape.is() )
      54         [ #  # ]:          0 :                 vObjects.push_back( xControlShape );
      55                 :          0 :         }
      56                 :          0 :     }
      57                 :            : 
      58                 :          0 :     virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
      59                 :            :     {
      60                 :          0 :         return vObjects.size();
      61                 :            :     }
      62                 :            : 
      63                 :          0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
      64                 :            :     {
      65 [ #  # ][ #  # ]:          0 :         if ( Index < 0 || Index >= getCount() )
                 [ #  # ]
      66         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
      67                 :          0 :         return uno::makeAny( vObjects[ Index ] );
      68                 :            :     }
      69                 :            : 
      70                 :            :         // Methods XElementAcess
      71                 :          0 :         virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
      72                 :            :         {
      73                 :          0 :             return drawing::XControlShape::static_type(0);
      74                 :            :         }
      75                 :            : 
      76                 :          0 :         virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
      77                 :            :         {
      78                 :          0 :             return ( getCount() > 0 );
      79                 :            :         }
      80                 :            : 
      81                 :            : };
      82                 :            : 
      83         [ #  # ]:          0 : class EnumWrapper : public EnumerationHelper_BASE
      84                 :            : {
      85                 :            : 
      86                 :            :         uno::Reference<XHelperInterface > m_xParent;
      87                 :            :         uno::Reference<uno::XComponentContext > m_xContext;
      88                 :            :         uno::Reference<container::XIndexAccess > m_xIndexAccess;
      89                 :            :         sal_Int32 nIndex;
      90                 :            : public:
      91                 :          0 :         EnumWrapper(  const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< container::XIndexAccess >& xIndexAccess ) :  m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
      92                 :            : 
      93                 :          0 :         virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
      94                 :            :         {
      95                 :          0 :                 return ( nIndex < m_xIndexAccess->getCount() );
      96                 :            :         }
      97                 :            : 
      98                 :          0 :         virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
      99                 :            :         {
     100         [ #  # ]:          0 :                 if ( nIndex < m_xIndexAccess->getCount() )
     101                 :            :         {
     102 [ #  # ][ #  # ]:          0 :             uno::Reference< drawing::XControlShape > xControlShape (  m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW );
                 [ #  # ]
     103 [ #  # ][ #  # ]:          0 :                 return uno::makeAny( uno::Reference< ov::excel::XOLEObject >( new ScVbaOLEObject( m_xParent, m_xContext, xControlShape ) ) );
         [ #  # ][ #  # ]
     104                 :            :         }
     105         [ #  # ]:          0 :                 throw container::NoSuchElementException();
     106                 :            :         }
     107                 :            : };
     108                 :            : 
     109                 :          0 : uno::Reference< container::XIndexAccess > oleObjectIndexWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess )
     110                 :            : {
     111 [ #  # ][ #  # ]:          0 :     return new IndexAccessWrapper( xIndexAccess );
     112                 :            : }
     113                 :            : 
     114                 :          0 : ScVbaOLEObjects::ScVbaOLEObjects( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
     115                 :            :                 const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess )
     116         [ #  # ]:          0 :             : OLEObjectsImpl_BASE( xParent, xContext, oleObjectIndexWrapper( xIndexAccess  ) )
     117                 :            : {
     118                 :          0 : }
     119                 :            : uno::Reference< container::XEnumeration >
     120                 :          0 : ScVbaOLEObjects::createEnumeration() throw (uno::RuntimeException)
     121                 :            : {
     122 [ #  # ][ #  # ]:          0 :     return new EnumWrapper( getParent(), mxContext, m_xIndexAccess );
                 [ #  # ]
     123                 :            : }
     124                 :            : 
     125                 :            : uno::Any
     126                 :          0 : ScVbaOLEObjects::createCollectionObject( const css::uno::Any& aSource )
     127                 :            : {
     128         [ #  # ]:          0 :     if( aSource.hasValue() )
     129                 :            :     {
     130         [ #  # ]:          0 :         uno::Reference< drawing::XControlShape > xControlShape( aSource, uno::UNO_QUERY_THROW );
     131                 :            :     // parent of OLEObject is the same parent as the collection ( e.g. the sheet )
     132 [ #  # ][ #  # ]:          0 :         return uno::makeAny( uno::Reference< ov::excel::XOLEObject >( new ScVbaOLEObject( getParent(), mxContext, xControlShape ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     133                 :            :     }
     134                 :          0 :     return uno::Any();
     135                 :            : }
     136                 :            : 
     137                 :            : uno::Any
     138                 :          0 : ScVbaOLEObjects::getItemByStringIndex( const rtl::OUString& sIndex ) throw (uno::RuntimeException)
     139                 :            : {
     140                 :            :     try
     141                 :            :     {
     142         [ #  # ]:          0 :         return OLEObjectsImpl_BASE::getItemByStringIndex( sIndex );
     143                 :            :     }
     144         [ #  # ]:          0 :     catch (const uno::RuntimeException&)
     145                 :            :     {
     146         [ #  # ]:          0 :         uno::Reference< container::XIndexAccess > xIndexAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
     147   [ #  #  #  # ]:          0 :         sal_Int32 nCount = xIndexAccess->getCount();
     148         [ #  # ]:          0 :         for( int index = 0; index < nCount; index++ )
     149                 :            :         {
     150   [ #  #  #  # ]:          0 :             uno::Any aUnoObj =  xIndexAccess->getByIndex( index );
     151         [ #  # ]:          0 :             uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY_THROW );
     152   [ #  #  #  # ]:          0 :             uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl() );
     153         [ #  # ]:          0 :             uno::Reference< container::XNamed > xNamed( xControlModel, uno::UNO_QUERY_THROW );
     154   [ #  #  #  #  :          0 :             if( sIndex.equals( xNamed->getName() ))
                   #  # ]
     155                 :            :             {
     156         [ #  # ]:          0 :                 return createCollectionObject( aUnoObj );
     157                 :            :             }
     158                 :            : 
     159   [ #  #  #  #  :          0 :         }
             #  #  #  # ]
     160                 :          0 :         return uno::Any();
     161                 :            :     }
     162                 :            : }
     163                 :            : 
     164                 :            : uno::Type
     165                 :          0 : ScVbaOLEObjects::getElementType() throw (uno::RuntimeException)
     166                 :            : {
     167                 :          0 :     return ooo::vba::excel::XOLEObject::static_type(0);
     168                 :            : }
     169                 :            : 
     170                 :            : rtl::OUString
     171                 :          0 : ScVbaOLEObjects::getServiceImplName()
     172                 :            : {
     173                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaOLEObjects"));
     174                 :            : }
     175                 :            : 
     176                 :            : uno::Sequence< rtl::OUString >
     177                 :          0 : ScVbaOLEObjects::getServiceNames()
     178                 :            : {
     179 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     180         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
     181                 :            :     {
     182                 :          0 :         aServiceNames.realloc( 1 );
     183         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.OLEObjects" ) );
     184                 :            :     }
     185                 :          0 :     return aServiceNames;
     186                 :            : }
     187                 :            : 
     188                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10