LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/vba - vbapane.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 99 0.0 %
Date: 2012-12-27 Functions: 0 10 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             : 
      20             : #include "vbapane.hxx"
      21             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      22             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      23             : #include <com/sun/star/table/CellRangeAddress.hpp>
      24             : #include "vbarange.hxx"
      25             : 
      26             : using namespace com::sun::star;
      27             : using namespace ooo::vba;
      28             : 
      29           0 : ScVbaPane::ScVbaPane(
      30             :         const css::uno::Reference< ov::XHelperInterface >& xParent,
      31             :         const uno::Reference< uno::XComponentContext >& xContext,
      32             :         const uno::Reference< frame::XModel >& xModel,
      33             :         const uno::Reference< sheet::XViewPane > xViewPane ) throw (uno::RuntimeException) :
      34             :     ScVbaPane_BASE( xParent, xContext ),
      35             :     m_xModel( xModel, uno::UNO_SET_THROW ),
      36           0 :     m_xViewPane( xViewPane, uno::UNO_SET_THROW )
      37             : {
      38           0 : }
      39             : 
      40             : sal_Int32 SAL_CALL
      41           0 : ScVbaPane::getScrollColumn() throw (uno::RuntimeException)
      42             : {
      43           0 :     return ( m_xViewPane->getFirstVisibleColumn() + 1 );
      44             : }
      45             : 
      46             : void SAL_CALL
      47           0 : ScVbaPane::setScrollColumn( sal_Int32 _scrollcolumn ) throw (uno::RuntimeException)
      48             : {
      49           0 :     if( _scrollcolumn < 1 )
      50             :     {
      51             :         throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Column number should not less than 1" )),
      52           0 :                 uno::Reference< uno::XInterface >() );
      53             :     }
      54           0 :     m_xViewPane->setFirstVisibleColumn( _scrollcolumn - 1 );
      55           0 : }
      56             : 
      57             : sal_Int32 SAL_CALL
      58           0 : ScVbaPane::getScrollRow() throw (uno::RuntimeException)
      59             : {
      60           0 :     return ( m_xViewPane->getFirstVisibleRow() + 1 );
      61             : }
      62             : 
      63             : void SAL_CALL
      64           0 : ScVbaPane::setScrollRow( sal_Int32 _scrollrow ) throw (uno::RuntimeException)
      65             : {
      66           0 :     if( _scrollrow < 1 )
      67             :     {
      68             :         throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Row number should not less than 1" )),
      69           0 :                 uno::Reference< uno::XInterface >() );
      70             :     }
      71           0 :     m_xViewPane->setFirstVisibleRow( _scrollrow - 1 );
      72           0 : }
      73             : 
      74             : uno::Reference< excel::XRange > SAL_CALL
      75           0 : ScVbaPane::getVisibleRange() throw (uno::RuntimeException)
      76             : {
      77             :     // TODO: Excel includes partly visible rows/columns, Calc does not
      78           0 :     table::CellRangeAddress aRangeAddr = m_xViewPane->getVisibleRange();
      79           0 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xModel, uno::UNO_QUERY_THROW );
      80           0 :     uno::Reference< container::XIndexAccess > xSheetsIA( xDoc->getSheets(), uno::UNO_QUERY_THROW );
      81           0 :     uno::Reference< sheet::XSpreadsheet > xSheet( xSheetsIA->getByIndex( aRangeAddr.Sheet ), uno::UNO_QUERY_THROW );
      82           0 :     uno::Reference< table::XCellRange > xRange( xSheet->getCellRangeByPosition( aRangeAddr.StartColumn, aRangeAddr.StartRow, aRangeAddr.EndColumn, aRangeAddr.EndRow ), uno::UNO_SET_THROW );
      83             :     // TODO: getParent() returns the window, Range needs the worksheet
      84           0 :     return new ScVbaRange( getParent(), mxContext, xRange );
      85             : }
      86             : 
      87             : //Method
      88             : void SAL_CALL
      89           0 : ScVbaPane::SmallScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
      90             : {
      91           0 :     rtl::OUString messageBuffer;
      92           0 :     sal_Int32 downRows = 0;
      93           0 :     sal_Int32 rightCols = 0;
      94           0 :     table::CellRangeAddress visibleRange = m_xViewPane->getVisibleRange();
      95             : 
      96           0 :     if( Down.hasValue() )
      97             :     {
      98           0 :         sal_Int32 down = 0;
      99           0 :         if( Down >>= down )
     100           0 :             downRows += down;
     101             :         else
     102           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Down\n" ));
     103             :     }
     104           0 :     if( Up.hasValue() )
     105             :     {
     106           0 :         sal_Int32 up = 0;
     107           0 :         if( Up >>= up )
     108           0 :             downRows -= up;
     109             :         else
     110           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Up\n" ));
     111             :     }
     112           0 :     if( ToRight.hasValue() )
     113             :     {
     114           0 :         sal_Int32 right = 0;
     115           0 :         if( ToRight >>= right )
     116           0 :             rightCols += right;
     117             :         else
     118           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToRight\n" ));
     119             :     }
     120           0 :     if( ToLeft.hasValue() )
     121             :     {
     122           0 :         sal_Int32 left = 0;
     123           0 :         if( ToLeft >>= left )
     124           0 :             rightCols -= left;
     125             :         else
     126           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToLeft\n" ));
     127             :     }
     128           0 :     if( !messageBuffer.isEmpty() )
     129           0 :         throw(uno::RuntimeException( messageBuffer, uno::Reference< uno::XInterface >() ) );
     130             : 
     131           0 :     sal_Int32 newStartRow = visibleRange.StartRow + downRows;
     132           0 :     if( newStartRow < 0 )
     133           0 :         newStartRow = 0;
     134           0 :     sal_Int32 newStartCol = visibleRange.StartColumn + rightCols;
     135           0 :     if( newStartCol < 0 )
     136           0 :         newStartCol = 0;
     137           0 :     m_xViewPane->setFirstVisibleRow( newStartRow );
     138           0 :     m_xViewPane->setFirstVisibleColumn( newStartCol );
     139           0 : }
     140             : 
     141             : void SAL_CALL
     142           0 : ScVbaPane::LargeScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
     143             : {
     144           0 :     rtl::OUString messageBuffer;
     145           0 :     table::CellRangeAddress visibleRange = m_xViewPane->getVisibleRange();
     146             : 
     147           0 :     sal_Int32 vertPageSize = 1 + visibleRange.EndRow - visibleRange.StartRow;
     148           0 :     sal_Int32 horizPageSize = 1 + visibleRange.EndColumn - visibleRange.StartColumn;
     149           0 :     sal_Int32 downPages = 0;
     150           0 :     sal_Int32 acrossPages = 0;
     151           0 :     if( Down.hasValue() )
     152             :     {
     153           0 :         sal_Int32 down = 0;
     154           0 :         if( Down >>= down )
     155           0 :             downPages += down;
     156             :         else
     157           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Down\n" ));
     158             :     }
     159           0 :     if( Up.hasValue() )
     160             :     {
     161           0 :         sal_Int32 up = 0;
     162           0 :         if( Up >>= up )
     163           0 :             downPages -= up;
     164             :         else
     165           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Up\n" ));
     166             :     }
     167           0 :     if( ToRight.hasValue() )
     168             :     {
     169           0 :         sal_Int32 right = 0;
     170           0 :         if( ToRight >>= right )
     171           0 :             acrossPages += right;
     172             :         else
     173           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToRight\n" ));
     174             :     }
     175           0 :     if( ToLeft.hasValue() )
     176             :     {
     177           0 :         sal_Int32 left = 0;
     178           0 :         if( ToLeft >>= left )
     179           0 :             acrossPages -= left;
     180             :         else
     181           0 :             messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToLeft\n" ));
     182             :     }
     183           0 :     if( !messageBuffer.isEmpty() )
     184           0 :         throw(uno::RuntimeException( messageBuffer, uno::Reference< uno::XInterface >() ) );
     185             : 
     186           0 :     sal_Int32 newStartRow = visibleRange.StartRow + (downPages * vertPageSize );
     187           0 :     if( newStartRow < 0 )
     188           0 :         newStartRow = 0;
     189           0 :     sal_Int32 newStartCol = visibleRange.StartColumn + (acrossPages * horizPageSize );
     190           0 :     if( newStartCol < 0 )
     191           0 :         newStartCol = 0;
     192           0 :     m_xViewPane->setFirstVisibleRow( newStartRow );
     193           0 :     m_xViewPane->setFirstVisibleColumn( newStartCol );
     194           0 : }
     195             : 
     196             : // XHelperInterface
     197             : 
     198           0 : VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaPane, "ooo.vba.excel.Pane" )
     199             : 
     200             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10