LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbaheadersfooters.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 44 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 20 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             :  * 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 "vbaheadersfooters.hxx"
      20             : #include "vbaheaderfooter.hxx"
      21             : #include <ooo/vba/word/WdHeaderFooterIndex.hpp>
      22             : #include <cppuhelper/implbase.hxx>
      23             : 
      24             : using namespace ::ooo::vba;
      25             : using namespace ::com::sun::star;
      26             : 
      27             : // I assume there is only one headersfooters in Writer
      28             : typedef ::cppu::WeakImplHelper<container::XIndexAccess > HeadersFootersIndexAccess_Base;
      29             : class HeadersFootersIndexAccess : public HeadersFootersIndexAccess_Base
      30             : {
      31             : private:
      32             :     uno::Reference< XHelperInterface > mxParent;
      33             :     uno::Reference< uno::XComponentContext > mxContext;
      34             :     uno::Reference< frame::XModel > mxModel;
      35             :     uno::Reference< beans::XPropertySet > mxPageStyleProps;
      36             :     bool mbHeader;
      37             : 
      38             : public:
      39           0 :     HeadersFootersIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, bool bHeader ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( bHeader ) {}
      40           0 :     virtual ~HeadersFootersIndexAccess(){}
      41             : 
      42             :     // XIndexAccess
      43           0 :     virtual sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      44             :     {
      45             :         // first page, evenpages and primary page
      46           0 :         return 3;
      47             :     }
      48           0 :     virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      49             :     {
      50           0 :         if( Index < 1 || Index > 3 )
      51           0 :             throw lang::IndexOutOfBoundsException();
      52           0 :         return uno::makeAny( uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( mxParent,  mxContext, mxModel, mxPageStyleProps, mbHeader, Index ) ) );
      53             :     }
      54           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      55             :     {
      56           0 :         return cppu::UnoType<word::XHeaderFooter>::get();
      57             :     }
      58           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      59             :     {
      60           0 :         return sal_True;
      61             :     }
      62             : };
      63             : 
      64           0 : class HeadersFootersEnumWrapper : public EnumerationHelper_BASE
      65             : {
      66             :     SwVbaHeadersFooters* pHeadersFooters;
      67             :     sal_Int32 nIndex;
      68             : public:
      69           0 :     explicit HeadersFootersEnumWrapper( SwVbaHeadersFooters* _pHeadersFooters ) : pHeadersFooters( _pHeadersFooters ), nIndex( 0 ) {}
      70           0 :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      71             :     {
      72           0 :         return ( nIndex < pHeadersFooters->getCount() );
      73             :     }
      74             : 
      75           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      76             :     {
      77           0 :         if ( nIndex < pHeadersFooters->getCount() )
      78           0 :             return pHeadersFooters->Item( uno::makeAny( ++nIndex ), uno::Any() );
      79           0 :         throw container::NoSuchElementException();
      80             :     }
      81             : };
      82             : 
      83           0 : SwVbaHeadersFooters::SwVbaHeadersFooters( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, bool isHeader ): SwVbaHeadersFooters_BASE( xParent, xContext, new HeadersFootersIndexAccess( xParent, xContext, xModel, xPageStyleProps, isHeader ) ),  mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( isHeader )
      84             : {
      85           0 : }
      86             : 
      87           0 : ::sal_Int32 SAL_CALL SwVbaHeadersFooters::getCount() throw (uno::RuntimeException)
      88             : {
      89             :     // wdHeaderFooterFirstPage, wdHeaderFooterPrimary and wdHeaderFooterEvenPages
      90           0 :     return 3;
      91             : }
      92             : 
      93           0 : uno::Any SAL_CALL SwVbaHeadersFooters::Item( const uno::Any& Index1, const uno::Any& ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
      94             : {
      95           0 :     sal_Int32 nIndex = 0;
      96           0 :     Index1 >>= nIndex;
      97           0 :     if( ( nIndex < 1 ) || ( nIndex > 3 ) )
      98             :     {
      99           0 :         throw lang::IndexOutOfBoundsException();
     100             :     }
     101           0 :     return uno::makeAny( uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( this,  mxContext, mxModel, mxPageStyleProps, mbHeader, nIndex ) ) );
     102             : }
     103             : 
     104             : // XEnumerationAccess
     105             : uno::Type
     106           0 : SwVbaHeadersFooters::getElementType() throw (uno::RuntimeException)
     107             : {
     108           0 :     return cppu::UnoType<word::XHeaderFooter>::get();
     109             : }
     110             : uno::Reference< container::XEnumeration >
     111             : 
     112           0 : SwVbaHeadersFooters::createEnumeration() throw (uno::RuntimeException)
     113             : {
     114           0 :     return new HeadersFootersEnumWrapper( this );
     115             : }
     116             : 
     117             : uno::Any
     118           0 : SwVbaHeadersFooters::createCollectionObject( const uno::Any& aSource )
     119             : {
     120           0 :     return aSource;
     121             : }
     122             : 
     123             : OUString
     124           0 : SwVbaHeadersFooters::getServiceImplName()
     125             : {
     126           0 :     return OUString("SwVbaHeadersFooters");
     127             : }
     128             : 
     129             : uno::Sequence<OUString>
     130           0 : SwVbaHeadersFooters::getServiceNames()
     131             : {
     132           0 :     static uno::Sequence< OUString > sNames;
     133           0 :     if ( sNames.getLength() == 0 )
     134             :     {
     135           0 :         sNames.realloc( 1 );
     136           0 :         sNames[0] = "ooo.vba.word.HeadersFooters";
     137             :     }
     138           0 :     return sNames;
     139             : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11