LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbacolumns.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-12-27 Functions: 0 18 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 "vbacolumns.hxx"
      20             : #include "vbacolumn.hxx"
      21             : #include <com/sun/star/text/HoriOrientation.hpp>
      22             : #include <com/sun/star/table/XCellRange.hpp>
      23             : #include <ooo/vba/word/WdConstants.hpp>
      24             : #include <ooo/vba/word/WdRulerStyle.hpp>
      25             : #include "wordvbahelper.hxx"
      26             : #include "vbatablehelper.hxx"
      27             : 
      28             : using namespace ::ooo::vba;
      29             : using namespace ::com::sun::star;
      30             : 
      31           0 : class ColumnsEnumWrapper : public EnumerationHelper_BASE
      32             : {
      33             :     uno::WeakReference< XHelperInterface > mxParent;
      34             :     uno::Reference< uno::XComponentContext > mxContext;
      35             :     uno::Reference< text::XTextTable > mxTextTable;
      36             :     uno::Reference< container::XIndexAccess > mxIndexAccess;
      37             :     sal_Int32 nIndex;
      38             : 
      39             : public:
      40           0 :     ColumnsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 )
      41             :     {
      42           0 :         mxIndexAccess.set( mxTextTable->getColumns(), uno::UNO_QUERY );
      43           0 :     }
      44           0 :     virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
      45             :     {
      46           0 :         return ( nIndex < mxIndexAccess->getCount() );
      47             :     }
      48             : 
      49           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
      50             :     {
      51           0 :         if( nIndex < mxIndexAccess->getCount() )
      52             :         {
      53           0 :             return uno::makeAny( uno::Reference< word::XColumn > ( new SwVbaColumn( mxParent, mxContext, mxTextTable, nIndex++ ) ) );
      54             :         }
      55           0 :         throw container::NoSuchElementException();
      56             :     }
      57             : };
      58             : 
      59           0 : SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns )
      60             : {
      61           0 :     mnStartColumnIndex = 0;
      62           0 :     SwVbaTableHelper aTableHelper( mxTextTable );
      63           0 :     mnEndColumnIndex = aTableHelper.getTabColumnsMaxCount( ) - 1;
      64           0 : }
      65             : 
      66           0 : SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns, sal_Int32 nStartCol, sal_Int32 nEndCol ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns ), mnStartColumnIndex( nStartCol ), mnEndColumnIndex( nEndCol )
      67             : {
      68           0 :     if( mnEndColumnIndex < mnStartColumnIndex )
      69           0 :         throw uno::RuntimeException();
      70           0 : }
      71             : 
      72           0 : uno::Reference< word::XColumn > SwVbaColumns::getColumnAtIndex( sal_Int32 index ) throw (uno::RuntimeException)
      73             : {
      74           0 :     return uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, index ) );
      75             : }
      76             : 
      77           0 : ::sal_Int32 SAL_CALL SwVbaColumns::getWidth() throw (uno::RuntimeException)
      78             : {
      79           0 :     return getColumnAtIndex( mnStartColumnIndex )->getWidth();
      80             : }
      81             : 
      82           0 : void SAL_CALL SwVbaColumns::setWidth( ::sal_Int32 _width ) throw (uno::RuntimeException)
      83             : {
      84           0 :     for( sal_Int32 index = mnStartColumnIndex; index <= mnEndColumnIndex; index++ )
      85             :     {
      86           0 :         getColumnAtIndex( index )->setWidth( _width );
      87             :     }
      88           0 : }
      89             : 
      90           0 : void SAL_CALL SwVbaColumns::Select(  ) throw (uno::RuntimeException)
      91             : {
      92           0 :     SwVbaColumn::SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnStartColumnIndex, mnEndColumnIndex );
      93           0 : }
      94             : 
      95           0 : ::sal_Int32 SAL_CALL SwVbaColumns::getCount() throw (uno::RuntimeException)
      96             : {
      97           0 :     return ( mnEndColumnIndex - mnStartColumnIndex + 1 );
      98             : }
      99             : 
     100           0 : uno::Any SAL_CALL SwVbaColumns::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
     101             : {
     102           0 :     sal_Int32 nIndex = 0;
     103           0 :     if( ( Index1 >>= nIndex ) == sal_True )
     104             :     {
     105           0 :         if( nIndex <= 0 || nIndex > getCount() )
     106             :         {
     107           0 :             throw  lang::IndexOutOfBoundsException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
     108             :         }
     109           0 :         return uno::makeAny( uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, nIndex - 1 ) ) );
     110             :     }
     111           0 :     throw  uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
     112             : }
     113             : 
     114             : // XEnumerationAccess
     115             : uno::Type
     116           0 : SwVbaColumns::getElementType() throw (uno::RuntimeException)
     117             : {
     118           0 :     return word::XColumn::static_type(0);
     119             : }
     120             : uno::Reference< container::XEnumeration >
     121           0 : SwVbaColumns::createEnumeration() throw (uno::RuntimeException)
     122             : {
     123           0 :     return new ColumnsEnumWrapper( this, mxContext, mxTextTable );
     124             : }
     125             : 
     126             : uno::Any
     127           0 : SwVbaColumns::createCollectionObject( const uno::Any& aSource )
     128             : {
     129           0 :     return aSource;
     130             : }
     131             : 
     132             : rtl::OUString
     133           0 : SwVbaColumns::getServiceImplName()
     134             : {
     135           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaColumns"));
     136             : }
     137             : 
     138             : uno::Sequence<rtl::OUString>
     139           0 : SwVbaColumns::getServiceNames()
     140             : {
     141           0 :     static uno::Sequence< rtl::OUString > sNames;
     142           0 :     if ( sNames.getLength() == 0 )
     143             :     {
     144           0 :         sNames.realloc( 1 );
     145           0 :         sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Columns") );
     146             :     }
     147           0 :     return sNames;
     148             : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10