LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbacells.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 86 0.0 %
Date: 2014-04-14 Functions: 0 27 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 "vbacells.hxx"
      20             : #include "vbacell.hxx"
      21             : #include "wordvbahelper.hxx"
      22             : #include "vbatablehelper.hxx"
      23             : #include "vbarow.hxx"
      24             : 
      25             : using namespace ::ooo::vba;
      26             : using namespace ::com::sun::star;
      27             : 
      28             : typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > CellCollectionHelper_Base;
      29             : 
      30           0 : class CellsEnumWrapper : public EnumerationHelper_BASE
      31             : {
      32             :     uno::Reference< container::XIndexAccess > mxIndexAccess;
      33             :     sal_Int32 nIndex;
      34             : 
      35             : public:
      36           0 :     CellsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 )
      37             :     {
      38           0 :     }
      39           0 :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      40             :     {
      41           0 :         return ( nIndex < mxIndexAccess->getCount() );
      42             :     }
      43             : 
      44           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      45             :     {
      46           0 :         if( nIndex < mxIndexAccess->getCount() )
      47             :         {
      48           0 :             return mxIndexAccess->getByIndex( nIndex++ );
      49             :         }
      50           0 :         throw container::NoSuchElementException();
      51             :     }
      52             : };
      53             : 
      54             : class CellCollectionHelper : public CellCollectionHelper_Base
      55             : {
      56             : private:
      57             :     uno::Reference< XHelperInterface > mxParent;
      58             :     uno::Reference< uno::XComponentContext > mxContext;
      59             :     uno::Reference< css::text::XTextTable > mxTextTable;
      60             :     sal_Int32 mnLeft;
      61             :     sal_Int32 mnTop;
      62             :     sal_Int32 mnRight;
      63             :     sal_Int32 mnBottom;
      64             : 
      65             : public:
      66           0 :     CellCollectionHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw ( css::uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), mnLeft( nLeft ), mnTop( nTop ), mnRight( nRight ), mnBottom( nBottom )
      67             :     {
      68           0 :     }
      69           0 :     virtual ~CellCollectionHelper() {}
      70             : 
      71           0 :     virtual sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      72             :     {
      73           0 :         return ( mnRight - mnLeft + 1 ) * ( mnBottom - mnTop + 1 );
      74             :     }
      75           0 :     virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      76             :     {
      77           0 :         if ( Index < 0 || Index >= getCount() )
      78           0 :             throw css::lang::IndexOutOfBoundsException();
      79             : 
      80           0 :         for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
      81             :         {
      82           0 :             for( sal_Int32 col = mnLeft; col <= mnRight; col++ )
      83             :             {
      84           0 :                 if( Index == ( ( row - mnTop ) * ( mnRight - mnLeft + 1 ) + ( col - mnLeft ) ) )
      85           0 :                     return uno::makeAny( uno::Reference< word::XCell >( new SwVbaCell( mxParent, mxContext, mxTextTable, col, row ) ) );
      86             :             }
      87             :         }
      88           0 :         throw css::lang::IndexOutOfBoundsException();
      89             : 
      90             :     }
      91           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      92             :     {
      93           0 :         return cppu::UnoType<word::XCell>::get();
      94             :     }
      95           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      96             :     {
      97           0 :         return sal_True;
      98             :     }
      99             :     // XEnumerationAccess
     100           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     101             :     {
     102           0 :         return new CellsEnumWrapper( this );
     103             :     }
     104             : };
     105             : 
     106           0 : SwVbaCells::SwVbaCells( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (uno::RuntimeException) : SwVbaCells_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new CellCollectionHelper( xParent, xContext, xTextTable, nLeft, nTop, nRight, nBottom ) ) ), mxTextTable( xTextTable ), mnTop( nTop ), mnBottom( nBottom )
     107             : {
     108           0 : }
     109             : 
     110           0 : ::sal_Int32 SAL_CALL SwVbaCells::getWidth() throw (css::uno::RuntimeException, std::exception)
     111             : {
     112           0 :     uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( 0 ), uno::UNO_QUERY_THROW );
     113           0 :     return xCell->getWidth();
     114             : }
     115             : 
     116           0 : void SAL_CALL SwVbaCells::setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException, std::exception)
     117             : {
     118           0 :     sal_Int32 nIndex = 0;
     119           0 :     while( nIndex < m_xIndexAccess->getCount() )
     120             :     {
     121           0 :         uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW );
     122           0 :         xCell->setWidth( _width );
     123           0 :     }
     124           0 : }
     125             : 
     126           0 : uno::Any SAL_CALL SwVbaCells::getHeight() throw (css::uno::RuntimeException, std::exception)
     127             : {
     128           0 :     uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnTop ) );
     129           0 :     return xRow->getHeight();
     130             : }
     131             : 
     132           0 : void SAL_CALL SwVbaCells::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException, std::exception)
     133             : {
     134           0 :     for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
     135             :     {
     136           0 :         uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) );
     137           0 :         xRow->setHeight( _height );
     138           0 :     }
     139           0 : }
     140             : 
     141           0 : ::sal_Int32 SAL_CALL SwVbaCells::getHeightRule() throw (css::uno::RuntimeException, std::exception)
     142             : {
     143           0 :     uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnTop ) );
     144           0 :     return xRow->getHeightRule();
     145             : }
     146             : 
     147           0 : void SAL_CALL SwVbaCells::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException, std::exception)
     148             : {
     149           0 :     for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
     150             :     {
     151           0 :         uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) );
     152           0 :         xRow->setHeightRule( _heightrule );
     153           0 :     }
     154           0 : }
     155             : 
     156           0 : void SAL_CALL SwVbaCells::SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException, std::exception)
     157             : {
     158           0 :     sal_Int32 nIndex = 0;
     159           0 :     while( nIndex < m_xIndexAccess->getCount() )
     160             :     {
     161           0 :         uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW );
     162           0 :         xCell->SetWidth( width, rulestyle );
     163           0 :     }
     164           0 : }
     165             : 
     166           0 : void SAL_CALL SwVbaCells::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException, std::exception)
     167             : {
     168           0 :     for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
     169             :     {
     170           0 :         uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) );
     171           0 :         xRow->SetHeight( height, heightrule );
     172           0 :     }
     173           0 : }
     174             : 
     175             : // XEnumerationAccess
     176             : uno::Type
     177           0 : SwVbaCells::getElementType() throw (uno::RuntimeException)
     178             : {
     179           0 :     return cppu::UnoType<word::XCell>::get();
     180             : }
     181             : 
     182             : uno::Reference< container::XEnumeration >
     183           0 : SwVbaCells::createEnumeration() throw (uno::RuntimeException)
     184             : {
     185           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
     186           0 :     return xEnumAccess->createEnumeration();
     187             : }
     188             : 
     189             : uno::Any
     190           0 : SwVbaCells::createCollectionObject( const uno::Any& aSource )
     191             : {
     192           0 :     return aSource;
     193             : }
     194             : 
     195             : OUString
     196           0 : SwVbaCells::getServiceImplName()
     197             : {
     198           0 :     return OUString("SwVbaCells");
     199             : }
     200             : 
     201             : uno::Sequence<OUString>
     202           0 : SwVbaCells::getServiceNames()
     203             : {
     204           0 :     static uno::Sequence< OUString > sNames;
     205           0 :     if ( sNames.getLength() == 0 )
     206             :     {
     207           0 :         sNames.realloc( 1 );
     208           0 :         sNames[0] = "ooo.vba.word.Cells";
     209             :     }
     210           0 :     return sNames;
     211             : }
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10