LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbamenubars.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 42 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 15 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             : #include "vbamenubars.hxx"
      10             : #include "vbamenubar.hxx"
      11             : #include <ooo/vba/excel/XlSheetType.hpp>
      12             : 
      13             : using namespace com::sun::star;
      14             : using namespace ooo::vba;
      15             : 
      16             : typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuBarEnumeration_BASE;
      17             : 
      18           0 : class MenuBarEnumeration : public MenuBarEnumeration_BASE
      19             : {
      20             :     uno::Reference< XHelperInterface > m_xParent;
      21             :     uno::Reference< uno::XComponentContext > m_xContext;
      22             :     uno::Reference< container::XEnumeration > m_xEnumeration;
      23             : public:
      24           0 :     MenuBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
      25             :     {
      26           0 :     }
      27           0 :     virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE
      28             :     {
      29           0 :         return m_xEnumeration->hasMoreElements();
      30             :     }
      31           0 :     virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) SAL_OVERRIDE
      32             :     {
      33             :         // FIXME: should be add menubar
      34           0 :         if( hasMoreElements() )
      35             :         {
      36           0 :             uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
      37           0 :             uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) );
      38           0 :             return uno::makeAny( xMenuBar );
      39             :         }
      40             :         else
      41           0 :             throw container::NoSuchElementException();
      42             :     }
      43             : };
      44             : 
      45           0 : ScVbaMenuBars::ScVbaMenuBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBars >& xCommandBars ) throw ( uno::RuntimeException ) : MenuBars_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBars( xCommandBars )
      46             : {
      47           0 : }
      48             : 
      49           0 : ScVbaMenuBars::~ScVbaMenuBars()
      50             : {
      51           0 : }
      52             : 
      53             : // XEnumerationAccess
      54             : uno::Type SAL_CALL
      55           0 : ScVbaMenuBars::getElementType() throw ( uno::RuntimeException )
      56             : {
      57           0 :     return cppu::UnoType<excel::XMenuBar>::get();
      58             : }
      59             : 
      60             : uno::Reference< container::XEnumeration >
      61           0 : ScVbaMenuBars::createEnumeration() throw ( uno::RuntimeException )
      62             : {
      63           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBars, uno::UNO_QUERY_THROW );
      64           0 :     return uno::Reference< container::XEnumeration >( new MenuBarEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
      65             : }
      66             : 
      67             : uno::Any
      68           0 : ScVbaMenuBars::createCollectionObject( const uno::Any& aSource )
      69             : {
      70             :     // make no sense
      71           0 :     return aSource;
      72             : }
      73             : 
      74             : sal_Int32 SAL_CALL
      75           0 : ScVbaMenuBars::getCount() throw(css::uno::RuntimeException)
      76             : {
      77           0 :     return m_xCommandBars->getCount();
      78             : }
      79             : 
      80             : // ScVbaCollectionBaseImpl
      81             : uno::Any SAL_CALL
      82           0 : ScVbaMenuBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
      83             : {
      84           0 :     sal_Int16 nIndex = 0;
      85           0 :     aIndex >>= nIndex;
      86           0 :     if( nIndex == excel::XlSheetType::xlWorksheet )
      87             :     {
      88           0 :         uno::Any aSource;
      89           0 :         aSource <<= OUString( "Worksheet Menu Bar" );
      90           0 :         uno::Reference< XCommandBar > xCommandBar( m_xCommandBars->Item( aSource, uno::Any() ), uno::UNO_QUERY_THROW );
      91           0 :         uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( this, mxContext, xCommandBar ) );
      92           0 :         return uno::makeAny( xMenuBar );
      93             :     }
      94             : 
      95           0 :     throw uno::RuntimeException("Not implemented" );
      96             : }
      97             : 
      98             : // XHelperInterface
      99             : OUString
     100           0 : ScVbaMenuBars::getServiceImplName()
     101             : {
     102           0 :     return OUString("ScVbaMenuBars");
     103             : }
     104             : 
     105             : uno::Sequence<OUString>
     106           0 : ScVbaMenuBars::getServiceNames()
     107             : {
     108           0 :     static uno::Sequence< OUString > aServiceNames;
     109           0 :     if ( aServiceNames.getLength() == 0 )
     110             :     {
     111           0 :         aServiceNames.realloc( 1 );
     112           0 :         aServiceNames[ 0 ] = "ooo.vba.excel.MenuBars";
     113             :     }
     114           0 :     return aServiceNames;
     115             : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11