LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbamenus.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 43 0.0 %
Date: 2014-04-14 Functions: 0 14 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 "vbamenus.hxx"
      10             : #include "vbamenu.hxx"
      11             : #include <ooo/vba/office/MsoControlType.hpp>
      12             : 
      13             : using namespace com::sun::star;
      14             : using namespace ooo::vba;
      15             : 
      16             : 
      17             : typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuEnumeration_BASE;
      18             : 
      19           0 : class MenuEnumeration : public MenuEnumeration_BASE
      20             : {
      21             :     uno::Reference< XHelperInterface > m_xParent;
      22             :     uno::Reference< uno::XComponentContext > m_xContext;
      23             :     uno::Reference< container::XEnumeration > m_xEnumeration;
      24             : public:
      25           0 :     MenuEnumeration( 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 )
      26             :     {
      27           0 :     }
      28           0 :     virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE
      29             :     {
      30           0 :         return m_xEnumeration->hasMoreElements();
      31             :     }
      32           0 :     virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) SAL_OVERRIDE
      33             :     {
      34             :         // FIXME: should be add menu
      35           0 :         if( hasMoreElements() )
      36             :         {
      37           0 :             uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
      38           0 :             if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
      39             :             {
      40           0 :                 uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) );
      41           0 :                 return uno::makeAny( xMenu );
      42             :             }
      43           0 :             nextElement();
      44             :         }
      45             :         else
      46           0 :             throw container::NoSuchElementException();
      47           0 :         return uno::Any();
      48             :     }
      49             : };
      50             : 
      51           0 : ScVbaMenus::ScVbaMenus( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBarControls >& xCommandBarControls ) throw ( uno::RuntimeException ) : Menus_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBarControls( xCommandBarControls )
      52             : {
      53           0 : }
      54             : 
      55             : // XEnumerationAccess
      56             : uno::Type SAL_CALL
      57           0 : ScVbaMenus::getElementType() throw ( uno::RuntimeException )
      58             : {
      59           0 :     return cppu::UnoType<excel::XMenu>::get();
      60             : }
      61             : 
      62             : uno::Reference< container::XEnumeration >
      63           0 : ScVbaMenus::createEnumeration() throw ( uno::RuntimeException )
      64             : {
      65           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBarControls, uno::UNO_QUERY_THROW );
      66           0 :     return uno::Reference< container::XEnumeration >( new MenuEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
      67             : }
      68             : 
      69             : uno::Any
      70           0 : ScVbaMenus::createCollectionObject( const uno::Any& aSource )
      71             : {
      72             :     // make no sense
      73           0 :     return aSource;
      74             : }
      75             : 
      76             : sal_Int32 SAL_CALL
      77           0 : ScVbaMenus::getCount() throw(css::uno::RuntimeException)
      78             : {
      79             :     // FIXME: should check if it is a popup menu
      80           0 :     return m_xCommandBarControls->getCount();
      81             : }
      82             : 
      83             : // ScVbaCollectionBaseImpl
      84             : uno::Any SAL_CALL
      85           0 : ScVbaMenus::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
      86             : {
      87           0 :     uno::Reference< XCommandBarControl > xCommandBarControl( m_xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
      88           0 :     if( xCommandBarControl->getType() != office::MsoControlType::msoControlPopup )
      89           0 :         throw uno::RuntimeException();
      90           0 :     return uno::makeAny( uno::Reference< excel::XMenu > ( new ScVbaMenu( this, mxContext, xCommandBarControl ) ) );
      91             : }
      92             : 
      93           0 : uno::Reference< excel::XMenu > SAL_CALL ScVbaMenus::Add( const OUString& Caption, const css::uno::Any& Before, const css::uno::Any& Restore ) throw (css::script::BasicErrorException, css::uno::RuntimeException, std::exception)
      94             : {
      95           0 :     sal_Int32 nType = office::MsoControlType::msoControlPopup;
      96           0 :     uno::Reference< XCommandBarControl > xCommandBarControl = m_xCommandBarControls->Add( uno::makeAny( nType ), uno::Any(), uno::Any(), Before, Restore );
      97           0 :     xCommandBarControl->setCaption( Caption );
      98           0 :     return uno::Reference< excel::XMenu >( new ScVbaMenu( this, mxContext, xCommandBarControl ) );
      99             : }
     100             : 
     101             : // XHelperInterface
     102             : OUString
     103           0 : ScVbaMenus::getServiceImplName()
     104             : {
     105           0 :     return OUString("ScVbaMenus");
     106             : }
     107             : 
     108             : uno::Sequence<OUString>
     109           0 : ScVbaMenus::getServiceNames()
     110             : {
     111           0 :     static uno::Sequence< OUString > aServiceNames;
     112           0 :     if ( aServiceNames.getLength() == 0 )
     113             :     {
     114           0 :         aServiceNames.realloc( 1 );
     115           0 :         aServiceNames[ 0 ] = "ooo.vba.excel.Menus";
     116             :     }
     117           0 :     return aServiceNames;
     118             : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10