LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbatable.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 51 2.0 %
Date: 2014-11-03 Functions: 2 13 15.4 %
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             : 
      20             : #include "vbatable.hxx"
      21             : #include "vbarange.hxx"
      22             : #include <com/sun/star/frame/XModel.hpp>
      23             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      24             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      25             : #include <com/sun/star/text/XTextTable.hpp>
      26             : #include <com/sun/star/text/XTextTablesSupplier.hpp>
      27             : #include <com/sun/star/table/XTableRows.hpp>
      28             : #include <com/sun/star/container/XNamed.hpp>
      29             : #include "vbaborders.hxx"
      30             : #include "vbapalette.hxx"
      31             : #include "vbarows.hxx"
      32             : #include "vbacolumns.hxx"
      33             : 
      34             : using namespace ::ooo::vba;
      35             : using namespace ::com::sun::star;
      36             : 
      37           0 : SwVbaTable::SwVbaTable(  const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rDocument, const  uno::Reference< text::XTextTable >& xTextTable) throw ( uno::RuntimeException ) : SwVbaTable_BASE( rParent, rContext ), mxTextDocument( rDocument )
      38             : {
      39           0 :     mxTextTable.set( xTextTable, uno::UNO_QUERY_THROW );
      40           0 : }
      41             : 
      42             : uno::Reference< word::XRange > SAL_CALL
      43           0 : SwVbaTable::Range(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
      44             : {
      45           0 :     return new SwVbaRange( mxParent, mxContext, mxTextDocument, mxTextTable->getAnchor() );
      46             : }
      47             : 
      48             : void SAL_CALL
      49           0 : SwVbaTable::Select(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
      50             : {
      51           0 :     uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
      52           0 :     uno::Reference< frame::XController > xController = xModel->getCurrentController();
      53             : 
      54           0 :     uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( xController, uno::UNO_QUERY_THROW );
      55           0 :     uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY_THROW );
      56             : 
      57             :     // set the view cursor to the start of the table.
      58           0 :     xSelectionSupplier->select( uno::makeAny( mxTextTable ) );
      59             : 
      60             :     // go to the end of the table and span the view
      61           0 :     uno::Reference< text::XTextViewCursor > xCursor = xViewCursorSupplier->getViewCursor();
      62           0 :     xCursor->gotoEnd(sal_True);
      63             : 
      64           0 : }
      65             : 
      66             : void SAL_CALL
      67           0 : SwVbaTable::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
      68             : {
      69           0 :     uno::Reference< table::XTableRows > xRows( mxTextTable->getRows() );
      70           0 :     xRows->removeByIndex( 0, xRows->getCount() );
      71           0 : }
      72             : 
      73             : uno::Reference< word::XRange > SAL_CALL
      74           0 : SwVbaTable::ConvertToText( const uno::Any& /*Separator*/, const uno::Any& /*NestedTables*/ ) throw (script::BasicErrorException, uno::RuntimeException)
      75             : {
      76             :     // #FIXME the helper api uses the dreaded dispatch mechanism, holding off
      77             :     // implementation while I look for alternative solution
      78           0 :     throw uno::RuntimeException();
      79             : }
      80             : 
      81             : OUString SAL_CALL
      82           0 : SwVbaTable::getName() throw (uno::RuntimeException, std::exception)
      83             : {
      84           0 :     uno::Reference< container::XNamed > xNamed( mxTextTable, uno::UNO_QUERY_THROW );
      85           0 :     return xNamed->getName();
      86             : }
      87             : 
      88             : uno::Any SAL_CALL
      89           0 : SwVbaTable::Borders( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
      90             : {
      91           0 :     uno::Reference< table::XCellRange > aCellRange( mxTextTable, uno::UNO_QUERY_THROW );
      92           0 :     VbaPalette aPalette;
      93           0 :     uno::Reference< XCollection > xCol( new SwVbaBorders( this, mxContext, aCellRange, aPalette ) );
      94           0 :     if ( index.hasValue() )
      95           0 :         return xCol->Item( index, uno::Any() );
      96           0 :     return uno::makeAny( xCol );
      97             : }
      98             : 
      99             : uno::Any SAL_CALL
     100           0 : SwVbaTable::Rows( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
     101             : {
     102           0 :     uno::Reference< table::XTableRows > xTableRows( mxTextTable->getRows(), uno::UNO_QUERY_THROW );
     103           0 :     uno::Reference< XCollection > xCol( new SwVbaRows( this, mxContext, mxTextTable, xTableRows ) );
     104           0 :     if ( index.hasValue() )
     105           0 :         return xCol->Item( index, uno::Any() );
     106           0 :     return uno::makeAny( xCol );
     107             : }
     108             : 
     109             : uno::Any SAL_CALL
     110           0 : SwVbaTable::Columns( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
     111             : {
     112           0 :     uno::Reference< table::XTableColumns > xTableColumns( mxTextTable->getColumns(), uno::UNO_QUERY_THROW );
     113           0 :     uno::Reference< XCollection > xCol( new SwVbaColumns( this, mxContext, mxTextTable, xTableColumns ) );
     114           0 :     if ( index.hasValue() )
     115           0 :         return xCol->Item( index, uno::Any() );
     116           0 :     return uno::makeAny( xCol );
     117             : }
     118             : 
     119             : // XHelperInterface
     120             : OUString
     121           0 : SwVbaTable::getServiceImplName()
     122             : {
     123           0 :     return OUString("SwVbaTable");
     124             : }
     125             : 
     126             : uno::Sequence<OUString>
     127           0 : SwVbaTable::getServiceNames()
     128             : {
     129           0 :     static uno::Sequence< OUString > aServiceNames;
     130           0 :     if ( aServiceNames.getLength() == 0 )
     131             :     {
     132           0 :         aServiceNames.realloc( 1 );
     133           0 :         aServiceNames[ 0 ] = "ooo.vba.word.Table";
     134             :     }
     135           0 :     return aServiceNames;
     136           6 : }
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10