LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbapanes.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 37 2.7 %
Date: 2014-11-03 Functions: 2 20 10.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             : #include "vbapanes.hxx"
      20             : #include "vbapane.hxx"
      21             : 
      22             : using namespace ::ooo::vba;
      23             : using namespace ::com::sun::star;
      24             : 
      25             : // I assume there is only one pane in Writer
      26             : typedef ::cppu::WeakImplHelper1<container::XIndexAccess > PanesIndexAccess_Base;
      27             : class PanesIndexAccess : public PanesIndexAccess_Base
      28             : {
      29             : private:
      30             :     uno::Reference< XHelperInterface > mxParent;
      31             :     uno::Reference< uno::XComponentContext > mxContext;
      32             :     uno::Reference< frame::XModel > mxModel;
      33             : 
      34             : public:
      35           0 :     PanesIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) {}
      36           0 :     virtual ~PanesIndexAccess(){}
      37             : 
      38             :     // XIndexAccess
      39           0 :     virtual sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      40             :     {
      41           0 :         return 1;
      42             :     }
      43           0 :     virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      44             :     {
      45           0 :         if( Index != 1 )
      46           0 :             throw lang::IndexOutOfBoundsException();
      47           0 :         return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( mxParent,  mxContext, mxModel ) ) );
      48             :     }
      49           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      50             :     {
      51           0 :         return cppu::UnoType<word::XPane>::get();
      52             :     }
      53           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      54             :     {
      55           0 :         return sal_True;
      56             :     }
      57             : };
      58             : 
      59           0 : class PanesEnumWrapper : public EnumerationHelper_BASE
      60             : {
      61             :     uno::Reference<container::XIndexAccess > m_xIndexAccess;
      62             :     sal_Int32 nIndex;
      63             : public:
      64           0 :     PanesEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
      65           0 :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      66             :     {
      67           0 :         return ( nIndex < m_xIndexAccess->getCount() );
      68             :     }
      69             : 
      70           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      71             :     {
      72           0 :         if ( nIndex < m_xIndexAccess->getCount() )
      73           0 :             return m_xIndexAccess->getByIndex( nIndex++ );
      74           0 :         throw container::NoSuchElementException();
      75             :     }
      76             : };
      77             : 
      78           0 : SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) ),  mxModel( xModel )
      79             : {
      80           0 : }
      81             : // XEnumerationAccess
      82             : uno::Type
      83           0 : SwVbaPanes::getElementType() throw (uno::RuntimeException)
      84             : {
      85           0 :     return cppu::UnoType<word::XPane>::get();
      86             : }
      87             : uno::Reference< container::XEnumeration >
      88           0 : SwVbaPanes::createEnumeration() throw (uno::RuntimeException)
      89             : {
      90           0 :     return new PanesEnumWrapper( m_xIndexAccess );
      91             : }
      92             : 
      93             : uno::Any
      94           0 : SwVbaPanes::createCollectionObject( const css::uno::Any& aSource )
      95             : {
      96           0 :     return aSource;
      97             : }
      98             : 
      99             : OUString
     100           0 : SwVbaPanes::getServiceImplName()
     101             : {
     102           0 :     return OUString("SwVbaPanes");
     103             : }
     104             : 
     105             : css::uno::Sequence<OUString>
     106           0 : SwVbaPanes::getServiceNames()
     107             : {
     108           0 :     static uno::Sequence< OUString > sNames;
     109           0 :     if ( sNames.getLength() == 0 )
     110             :     {
     111           0 :         sNames.realloc( 1 );
     112           0 :         sNames[0] = "ooo.vba.word.Panes";
     113             :     }
     114           0 :     return sNames;
     115           6 : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10