LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbawindow.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 267 434 61.5 %
Date: 2014-04-11 Functions: 49 82 59.8 %
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 <vbahelper/helperdecl.hxx>
      20             : #include "vbawindow.hxx"
      21             : #include "vbaworksheets.hxx"
      22             : #include "vbaworksheet.hxx"
      23             : #include "vbaglobals.hxx"
      24             : #include "vbapane.hxx"
      25             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      26             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      27             : #include <com/sun/star/container/XNamed.hpp>
      28             : #include <com/sun/star/view/DocumentZoomType.hpp>
      29             : #include <com/sun/star/table/CellRangeAddress.hpp>
      30             : #include <ooo/vba/excel/XlWindowState.hpp>
      31             : #include <ooo/vba/excel/XlWindowView.hpp>
      32             : #include <ooo/vba/excel/Constants.hpp>
      33             : #include <com/sun/star/awt/XWindow.hpp>
      34             : #include <com/sun/star/awt/XWindow2.hpp>
      35             : #include <com/sun/star/awt/PosSize.hpp>
      36             : 
      37             : #include <docsh.hxx>
      38             : #include <tabvwsh.hxx>
      39             : #include <docuno.hxx>
      40             : #include <sc.hrc>
      41             : #include <boost/unordered_map.hpp>
      42             : #include <sfx2/viewfrm.hxx>
      43             : #include <vcl/wrkwin.hxx>
      44             : #include "unonames.hxx"
      45             : #include "markdata.hxx"
      46             : 
      47             : using namespace ::com::sun::star;
      48             : using namespace ::ooo::vba;
      49             : using namespace ::ooo::vba::excel::XlWindowState;
      50             : 
      51             : typedef  boost::unordered_map< OUString,
      52             : SCTAB, OUStringHash,
      53             : ::std::equal_to< OUString > > NameIndexHash;
      54             : 
      55             : typedef std::vector< uno::Reference< sheet::XSpreadsheet > > Sheets;
      56             : 
      57             : typedef ::cppu::WeakImplHelper1< container::XEnumeration > Enumeration_BASE;
      58             : 
      59             : typedef ::cppu::WeakImplHelper3< container::XEnumerationAccess
      60             :     , com::sun::star::container::XIndexAccess
      61             :     , com::sun::star::container::XNameAccess
      62             :     > SelectedSheets_BASE;
      63             : 
      64             : 
      65           0 : class SelectedSheetsEnum : public Enumeration_BASE
      66             : {
      67             : public:
      68             :     uno::Reference< uno::XComponentContext > m_xContext;
      69             :     Sheets m_sheets;
      70             :     uno::Reference< frame::XModel > m_xModel;
      71             :     Sheets::const_iterator m_it;
      72             : 
      73           0 :     SelectedSheetsEnum( const uno::Reference< uno::XComponentContext >& xContext, const Sheets& sheets, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) :  m_xContext( xContext ), m_sheets( sheets ), m_xModel( xModel )
      74             :     {
      75           0 :         m_it = m_sheets.begin();
      76           0 :     }
      77             :     // XEnumeration
      78           0 :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      79             :     {
      80           0 :         return m_it != m_sheets.end();
      81             :     }
      82           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      83             :     {
      84           0 :         if ( !hasMoreElements() )
      85             :         {
      86           0 :             throw container::NoSuchElementException();
      87             :         }
      88             :         // #FIXME needs ThisWorkbook as parent
      89           0 :         return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( uno::Reference< XHelperInterface >(), m_xContext, *(m_it++), m_xModel ) ) );
      90             :     }
      91             : 
      92             : 
      93             : };
      94             : 
      95           0 : class SelectedSheetsEnumAccess : public SelectedSheets_BASE
      96             : {
      97             :     uno::Reference< uno::XComponentContext > m_xContext;
      98             :     NameIndexHash namesToIndices;
      99             :     Sheets sheets;
     100             :     uno::Reference< frame::XModel > m_xModel;
     101             : public:
     102           0 :     SelectedSheetsEnumAccess( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ):m_xContext( xContext ), m_xModel( xModel )
     103             :     {
     104           0 :         ScModelObj* pModel = static_cast< ScModelObj* >( m_xModel.get() );
     105           0 :         if ( !pModel )
     106           0 :             throw uno::RuntimeException("Cannot obtain current document", uno::Reference< uno::XInterface >() );
     107           0 :         ScDocShell* pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
     108           0 :         if ( !pDocShell )
     109           0 :             throw uno::RuntimeException("Cannot obtain docshell", uno::Reference< uno::XInterface >() );
     110           0 :         ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     111           0 :         if ( !pViewShell )
     112           0 :             throw uno::RuntimeException("Cannot obtain view shell", uno::Reference< uno::XInterface >() );
     113             : 
     114           0 :         SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
     115           0 :         SCTAB nIndex = 0;
     116           0 :         const ScMarkData& rMarkData = pViewShell->GetViewData()->GetMarkData();
     117           0 :         sheets.reserve( nTabCount );
     118           0 :         uno::Reference <sheet::XSpreadsheetDocument> xSpreadSheet( m_xModel, uno::UNO_QUERY_THROW );
     119           0 :         uno::Reference <container::XIndexAccess> xIndex( xSpreadSheet->getSheets(), uno::UNO_QUERY_THROW );
     120           0 :         ScMarkData::const_iterator itr = rMarkData.begin(), itrEnd = rMarkData.end();
     121           0 :         for (; itr != itrEnd && *itr < nTabCount; ++itr)
     122             :         {
     123           0 :             uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex( *itr ), uno::UNO_QUERY_THROW );
     124           0 :             uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
     125           0 :             sheets.push_back( xSheet );
     126           0 :             namesToIndices[ xNamed->getName() ] = nIndex++;
     127           0 :         }
     128             : 
     129           0 :     }
     130             : 
     131             :     //XEnumerationAccess
     132           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     133             :     {
     134           0 :         return new SelectedSheetsEnum( m_xContext, sheets, m_xModel  );
     135             :     }
     136             :     // XIndexAccess
     137           0 :     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     138             :     {
     139           0 :         return sheets.size();
     140             :     }
     141           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw ( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     142             :     {
     143           0 :         if ( Index < 0
     144           0 :         || static_cast< Sheets::size_type >( Index ) >= sheets.size() )
     145           0 :             throw lang::IndexOutOfBoundsException();
     146             : 
     147           0 :         return uno::makeAny( sheets[ Index ] );
     148             :     }
     149             : 
     150             :     //XElementAccess
     151           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     152             :     {
     153           0 :         return cppu::UnoType<excel::XWorksheet>::get();
     154             :     }
     155             : 
     156           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     157             :     {
     158           0 :         return ( !sheets.empty() );
     159             :     }
     160             : 
     161             :     //XNameAccess
     162           0 :     virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     163             :     {
     164           0 :         NameIndexHash::const_iterator it = namesToIndices.find( aName );
     165           0 :         if ( it == namesToIndices.end() )
     166           0 :             throw container::NoSuchElementException();
     167           0 :         return uno::makeAny( sheets[ it->second ] );
     168             : 
     169             :     }
     170             : 
     171           0 :     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     172             :     {
     173           0 :         uno::Sequence< OUString > names( namesToIndices.size() );
     174           0 :         OUString* pString = names.getArray();
     175           0 :         NameIndexHash::const_iterator it = namesToIndices.begin();
     176           0 :         NameIndexHash::const_iterator it_end = namesToIndices.end();
     177           0 :         for ( ; it != it_end; ++it, ++pString )
     178           0 :             *pString = it->first;
     179           0 :         return names;
     180             :     }
     181             : 
     182           0 :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     183             :     {
     184           0 :         NameIndexHash::const_iterator it = namesToIndices.find( aName );
     185           0 :         return (it != namesToIndices.end());
     186             :     }
     187             : 
     188             : 
     189             : };
     190             : 
     191          59 : ScVbaWindow::ScVbaWindow(
     192             :         const uno::Reference< XHelperInterface >& xParent,
     193             :         const uno::Reference< uno::XComponentContext >& xContext,
     194             :         const uno::Reference< frame::XModel >& xModel,
     195             :         const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) :
     196          59 :     WindowImpl_BASE( xParent, xContext, xModel, xController )
     197             : {
     198          59 :     init();
     199          59 : }
     200             : 
     201           0 : ScVbaWindow::ScVbaWindow(
     202             :         const uno::Sequence< uno::Any >& args,
     203             :         const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) :
     204           0 :     WindowImpl_BASE( args, xContext )
     205             : {
     206           0 :     init();
     207           0 : }
     208             : 
     209             : void
     210          59 : ScVbaWindow::init()
     211             : {
     212             :     /*  This method is called from the constructor, thus the own refcount is
     213             :         still zero. The implementation of ActivePane() uses a UNO reference of
     214             :         this (to set this window as parent of the pane object). This requires
     215             :         the own refcount to be non-zero, otherwise this instance will be
     216             :         desctructed immediately! Guard the call to ActivePane() in try/catch to
     217             :         not miss the decrementation of the reference count on exception. */
     218          59 :     osl_atomic_increment( &m_refCount );
     219             :     try
     220             :     {
     221          59 :        m_xPane = ActivePane();
     222             :     }
     223           0 :     catch( uno::Exception& )
     224             :     {
     225             :     }
     226          59 :     osl_atomic_decrement( &m_refCount );
     227          59 : }
     228             : 
     229             : uno::Reference< beans::XPropertySet >
     230          44 : ScVbaWindow::getControllerProps() throw (uno::RuntimeException)
     231             : {
     232          44 :     return uno::Reference< beans::XPropertySet >( getController(), uno::UNO_QUERY_THROW );
     233             : }
     234             : 
     235             : uno::Reference< beans::XPropertySet >
     236          29 : ScVbaWindow::getFrameProps() throw (uno::RuntimeException)
     237             : {
     238          29 :     return uno::Reference< beans::XPropertySet >( getController()->getFrame(), uno::UNO_QUERY_THROW );
     239             : }
     240             : 
     241             : uno::Reference< awt::XDevice >
     242           6 : ScVbaWindow::getDevice() throw (uno::RuntimeException)
     243             : {
     244           6 :     return uno::Reference< awt::XDevice >( getWindow(), uno::UNO_QUERY_THROW );
     245             : }
     246             : 
     247             : void
     248           6 : ScVbaWindow::Scroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft, bool bLargeScroll ) throw (uno::RuntimeException)
     249             : {
     250           6 :     if( !m_xPane.is() )
     251           0 :         throw uno::RuntimeException();
     252           6 :     if( bLargeScroll )
     253           4 :         m_xPane->LargeScroll( Down, Up, ToRight, ToLeft );
     254             :     else
     255           2 :         m_xPane->SmallScroll( Down, Up, ToRight, ToLeft );
     256           6 : }
     257             : 
     258             : void SAL_CALL
     259           2 : ScVbaWindow::SmallScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException, std::exception)
     260             : {
     261           2 :     Scroll( Down, Up, ToRight, ToLeft );
     262           2 : }
     263             : 
     264             : void SAL_CALL
     265           4 : ScVbaWindow::LargeScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException, std::exception)
     266             : {
     267           4 :     Scroll( Down, Up, ToRight, ToLeft, true );
     268           4 : }
     269             : 
     270             : uno::Any SAL_CALL
     271           0 : ScVbaWindow::SelectedSheets( const uno::Any& aIndex ) throw (uno::RuntimeException, std::exception)
     272             : {
     273           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( new SelectedSheetsEnumAccess( mxContext, m_xModel ) );
     274             :     // #FIXME needs a workbook as a parent
     275           0 :     uno::Reference< excel::XWorksheets > xSheets(  new ScVbaWorksheets( uno::Reference< XHelperInterface >(), mxContext, xEnumAccess, m_xModel ) );
     276           0 :     if ( aIndex.hasValue() )
     277             :     {
     278           0 :         uno::Reference< XCollection > xColl( xSheets, uno::UNO_QUERY_THROW );
     279           0 :         return xColl->Item( aIndex, uno::Any() );
     280             :     }
     281           0 :     return uno::makeAny( xSheets );
     282             : }
     283             : 
     284             : void SAL_CALL
     285           0 : ScVbaWindow::ScrollWorkbookTabs( const uno::Any& /*Sheets*/, const uno::Any& /*Position*/ ) throw (uno::RuntimeException, std::exception)
     286             : {
     287             : // #TODO #FIXME need some implementation to scroll through the tabs
     288             : // but where is this done?
     289             : /*
     290             :     sal_Int32 nSheets = 0;
     291             :     sal_Int32 nPosition = 0;
     292             :     throw uno::RuntimeException("No Implemented", uno::Reference< uno::XInterface >() );
     293             :     sal_Bool bSheets = ( Sheets >>= nSheets );
     294             :     sal_Bool bPosition = ( Position >>= nPosition );
     295             :     if ( bSheets || bPosition ) // at least one param specified
     296             :         if ( bSheets )
     297             :             ;// use sheets
     298             :         else if ( bPosition )
     299             :             ; //use position
     300             : */
     301             : 
     302           0 : }
     303             : 
     304             : uno::Any SAL_CALL
     305          28 : ScVbaWindow::getCaption() throw (uno::RuntimeException, std::exception)
     306             : {
     307          28 :     static OUString sCrud(" - OpenOffice.org Calc" );
     308          28 :     static sal_Int32 nCrudLen = sCrud.getLength();
     309             : 
     310          28 :     OUString sTitle;
     311          28 :     getFrameProps()->getPropertyValue( OUString( SC_UNONAME_TITLE ) ) >>= sTitle;
     312          28 :     sal_Int32 nCrudIndex = sTitle.indexOf( sCrud );
     313             :     // adjust title ( by removing crud )
     314             :     // sCrud string present
     315          28 :     if ( nCrudIndex != -1 )
     316             :     {
     317             :         // and ends with sCrud
     318           0 :         if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() )
     319             :         {
     320           0 :             sTitle = sTitle.copy( 0, nCrudIndex );
     321           0 :             ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
     322           0 :             OUString sName = workbook.getName();
     323             :             // rather bizare hack to make sure the name behavior
     324             :             // is like XL
     325             :             // if the adjusted title == workbook name, use name
     326             :             // if the adjusted title != workbook name but ...
     327             :             //  name == title + extension ( .csv, ,odt, .xls )
     328             :             //  etc. then also use the name
     329             : 
     330           0 :             if ( !sTitle.equals( sName ) )
     331             :             {
     332           0 :                 static OUString sDot(".");
     333             :                 // starts with title
     334           0 :                 if ( sName.startsWith( sTitle ) )
     335             :                     // extention starts immediately after
     336           0 :                     if ( sName.match( sDot, sTitle.getLength() ) )
     337           0 :                         sTitle = sName;
     338           0 :             }
     339             :         }
     340             :     }
     341          28 :     return uno::makeAny( sTitle );
     342             : }
     343             : 
     344             : void SAL_CALL
     345           1 : ScVbaWindow::setCaption( const uno::Any& _caption ) throw (uno::RuntimeException, std::exception)
     346             : {
     347           1 :     getFrameProps()->setPropertyValue( OUString( SC_UNONAME_TITLE ), _caption );
     348           1 : }
     349             : 
     350             : uno::Any SAL_CALL
     351           8 : ScVbaWindow::getScrollRow() throw (uno::RuntimeException, std::exception)
     352             : {
     353           8 :     sal_Int32 nValue = 0;
     354             :     // !! TODO !! get view shell from controller
     355           8 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     356           8 :     if ( pViewShell )
     357             :     {
     358           8 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     359           8 :         nValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich));
     360             :     }
     361             : 
     362           8 :     return uno::makeAny( nValue + 1);
     363             : }
     364             : 
     365             : void SAL_CALL
     366           3 : ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeException, std::exception)
     367             : {
     368             :     // !! TODO !! get view shell from controller
     369           3 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     370           3 :     if ( pViewShell )
     371             :     {
     372           3 :         sal_Int32 scrollRow = 0;
     373           3 :         _scrollrow >>= scrollRow;
     374           3 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     375           3 :         sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich)) + 1;
     376           3 :         pViewShell->ScrollLines(0, scrollRow - nOldValue);
     377             :     }
     378           3 : }
     379             : 
     380             : uno::Any SAL_CALL
     381          10 : ScVbaWindow::getScrollColumn() throw (uno::RuntimeException, std::exception)
     382             : {
     383          10 :     sal_Int32 nValue = 0;
     384             :     // !! TODO !! get view shell from controller
     385          10 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     386          10 :     if ( pViewShell )
     387             :     {
     388          10 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     389          10 :         nValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich));
     390             :     }
     391             : 
     392          10 :     return uno::makeAny( nValue + 1);
     393             : }
     394             : 
     395             : void SAL_CALL
     396           3 : ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::RuntimeException, std::exception)
     397             : {
     398             :     // !! TODO !! get view shell from controller
     399           3 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     400           3 :     if ( pViewShell )
     401             :     {
     402           3 :         sal_Int32 scrollColumn = 0;
     403           3 :         _scrollcolumn >>= scrollColumn;
     404           3 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     405           3 :         sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich)) + 1;
     406           3 :         pViewShell->ScrollLines(scrollColumn - nOldValue, 0);
     407             :     }
     408           3 : }
     409             : 
     410             : uno::Any SAL_CALL
     411           0 : ScVbaWindow::getWindowState() throw (uno::RuntimeException, std::exception)
     412             : {
     413           0 :     sal_Int32 nwindowState = xlNormal;
     414             :     // !! TODO !! get view shell from controller
     415           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     416           0 :     SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
     417           0 :     WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
     418           0 :     if ( pWork )
     419             :     {
     420           0 :         if ( pWork -> IsMaximized())
     421           0 :             nwindowState = xlMaximized;
     422           0 :         else if (pWork -> IsMinimized())
     423           0 :             nwindowState = xlMinimized;
     424             :     }
     425           0 :     return uno::makeAny( nwindowState );
     426             : }
     427             : 
     428             : void SAL_CALL
     429           0 : ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeException, std::exception)
     430             : {
     431           0 :     sal_Int32 nwindowState = xlMaximized;
     432           0 :     _windowstate >>= nwindowState;
     433             :     // !! TODO !! get view shell from controller
     434           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     435           0 :     SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
     436           0 :     WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
     437           0 :     if ( pWork )
     438             :     {
     439           0 :         if ( nwindowState == xlMaximized)
     440           0 :             pWork -> Maximize();
     441           0 :         else if (nwindowState == xlMinimized)
     442           0 :             pWork -> Minimize();
     443           0 :         else if (nwindowState == xlNormal)
     444           0 :             pWork -> Restore();
     445             :         else
     446           0 :             throw uno::RuntimeException("Invalid Parameter", uno::Reference< uno::XInterface >() );
     447             :     }
     448           0 : }
     449             : 
     450             : void
     451           1 : ScVbaWindow::Activate() throw (css::uno::RuntimeException, std::exception)
     452             : {
     453           1 :     ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
     454             : 
     455           1 :     workbook.Activate();
     456           1 : }
     457             : 
     458             : void
     459           0 : ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException, std::exception)
     460             : {
     461           0 :     ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
     462           0 :     workbook.Close(SaveChanges, FileName, RouteWorkBook );
     463           0 : }
     464             : 
     465             : uno::Reference< excel::XPane > SAL_CALL
     466          60 : ScVbaWindow::ActivePane() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     467             : {
     468          60 :     uno::Reference< sheet::XViewPane > xViewPane( getController(), uno::UNO_QUERY_THROW );
     469          60 :     return new ScVbaPane( this, mxContext, m_xModel, xViewPane );
     470             : }
     471             : 
     472             : uno::Reference< excel::XRange > SAL_CALL
     473           6 : ScVbaWindow::ActiveCell(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     474             : {
     475           6 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     476           6 :     return xApplication->getActiveCell();
     477             : }
     478             : 
     479             : uno::Any SAL_CALL
     480           3 : ScVbaWindow::Selection(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     481             : {
     482           3 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     483           3 :     return xApplication->getSelection();
     484             : }
     485             : 
     486             : uno::Reference< excel::XRange > SAL_CALL
     487           0 : ScVbaWindow::RangeSelection() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     488             : {
     489             :     /*  TODO / FIXME: According to documentation, this method returns the range
     490             :         selection even if shapes are selected. */
     491           0 :     return uno::Reference< excel::XRange >( Selection(), uno::UNO_QUERY_THROW );
     492             : }
     493             : 
     494             : sal_Bool SAL_CALL
     495           2 : ScVbaWindow::getDisplayGridlines() throw (uno::RuntimeException, std::exception)
     496             : {
     497           2 :     OUString sName( SC_UNO_SHOWGRID );
     498           2 :     sal_Bool bGrid = sal_True;
     499           2 :     getControllerProps()->getPropertyValue( sName ) >>= bGrid;
     500           2 :     return bGrid;
     501             : }
     502             : 
     503             : 
     504             : void SAL_CALL
     505           2 : ScVbaWindow::setDisplayGridlines( sal_Bool _displaygridlines ) throw (uno::RuntimeException, std::exception)
     506             : {
     507           2 :     OUString sName( SC_UNO_SHOWGRID );
     508           2 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _displaygridlines ));
     509           2 : }
     510             : 
     511             : sal_Bool SAL_CALL
     512           6 : ScVbaWindow::getDisplayHeadings() throw (uno::RuntimeException, std::exception)
     513             : {
     514           6 :     OUString sName( SC_UNO_COLROWHDR );
     515           6 :     sal_Bool bHeading = sal_True;
     516           6 :     getControllerProps()->getPropertyValue( sName ) >>= bHeading;
     517           6 :     return bHeading;
     518             : }
     519             : 
     520             : void SAL_CALL
     521           4 : ScVbaWindow::setDisplayHeadings( sal_Bool _bDisplayHeadings ) throw (uno::RuntimeException, std::exception)
     522             : {
     523           4 :     OUString sName( SC_UNO_COLROWHDR );
     524           4 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayHeadings ));
     525           4 : }
     526             : 
     527             : sal_Bool SAL_CALL
     528           4 : ScVbaWindow::getDisplayHorizontalScrollBar() throw (uno::RuntimeException, std::exception)
     529             : {
     530           4 :     OUString sName( SC_UNO_HORSCROLL );
     531           4 :     sal_Bool bHorizontalScrollBar = sal_True;
     532           4 :     getControllerProps()->getPropertyValue( sName ) >>= bHorizontalScrollBar;
     533           4 :     return bHorizontalScrollBar;
     534             : }
     535             : 
     536             : void SAL_CALL
     537           2 : ScVbaWindow::setDisplayHorizontalScrollBar( sal_Bool _bDisplayHorizontalScrollBar ) throw (uno::RuntimeException, std::exception)
     538             : {
     539           2 :     OUString sName( SC_UNO_HORSCROLL );
     540           2 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayHorizontalScrollBar ));
     541           2 : }
     542             : 
     543             : sal_Bool SAL_CALL
     544           4 : ScVbaWindow::getDisplayOutline() throw (uno::RuntimeException, std::exception)
     545             : {
     546           4 :     OUString sName( SC_UNO_OUTLSYMB );
     547           4 :     sal_Bool bOutline = sal_True;
     548           4 :     getControllerProps()->getPropertyValue( sName ) >>= bOutline;
     549           4 :     return bOutline;
     550             : }
     551             : 
     552             : void SAL_CALL
     553           2 : ScVbaWindow::setDisplayOutline( sal_Bool _bDisplayOutline ) throw (uno::RuntimeException, std::exception)
     554             : {
     555           2 :     OUString sName( SC_UNO_OUTLSYMB );
     556           2 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayOutline ));
     557           2 : }
     558             : 
     559             : sal_Bool SAL_CALL
     560           4 : ScVbaWindow::getDisplayVerticalScrollBar() throw (uno::RuntimeException, std::exception)
     561             : {
     562           4 :     OUString sName( SC_UNO_VERTSCROLL );
     563           4 :     sal_Bool bVerticalScrollBar = sal_True;
     564           4 :     getControllerProps()->getPropertyValue( sName ) >>= bVerticalScrollBar;
     565           4 :     return bVerticalScrollBar;
     566             : }
     567             : 
     568             : void SAL_CALL
     569           2 : ScVbaWindow::setDisplayVerticalScrollBar( sal_Bool _bDisplayVerticalScrollBar ) throw (uno::RuntimeException, std::exception)
     570             : {
     571           2 :     OUString sName( SC_UNO_VERTSCROLL );
     572           2 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayVerticalScrollBar ));
     573           2 : }
     574             : 
     575             : sal_Bool SAL_CALL
     576           4 : ScVbaWindow::getDisplayWorkbookTabs() throw (uno::RuntimeException, std::exception)
     577             : {
     578           4 :     OUString sName( SC_UNO_SHEETTABS );
     579           4 :     sal_Bool bWorkbookTabs = sal_True;
     580           4 :     getControllerProps()->getPropertyValue( sName ) >>= bWorkbookTabs;
     581           4 :     return bWorkbookTabs;
     582             : }
     583             : 
     584             : void SAL_CALL
     585           2 : ScVbaWindow::setDisplayWorkbookTabs( sal_Bool _bDisplayWorkbookTabs ) throw (uno::RuntimeException, std::exception)
     586             : {
     587           2 :     OUString sName( SC_UNO_SHEETTABS );
     588           2 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayWorkbookTabs ));
     589           2 : }
     590             : 
     591             : sal_Bool SAL_CALL
     592           3 : ScVbaWindow::getFreezePanes() throw (uno::RuntimeException, std::exception)
     593             : {
     594           3 :     uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     595           3 :     return xViewFreezable->hasFrozenPanes();
     596             : }
     597             : 
     598             : void SAL_CALL
     599           4 : ScVbaWindow::setFreezePanes( sal_Bool _bFreezePanes ) throw (uno::RuntimeException, std::exception)
     600             : {
     601           4 :     uno::Reference< sheet::XViewPane > xViewPane( getController(), uno::UNO_QUERY_THROW );
     602           8 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( xViewPane, uno::UNO_QUERY_THROW );
     603           8 :     uno::Reference< sheet::XViewFreezable > xViewFreezable( xViewPane, uno::UNO_QUERY_THROW );
     604           4 :     if( _bFreezePanes )
     605             :     {
     606           2 :         if( xViewSplitable->getIsWindowSplit() )
     607             :         {
     608             :             // if there is a split we freeze at the split
     609           1 :             sal_Int32 nColumn = getSplitColumn();
     610           1 :             sal_Int32 nRow = getSplitRow();
     611           1 :             xViewFreezable->freezeAtPosition( nColumn, nRow );
     612             :         }
     613             :         else
     614             :         {
     615             :             // otherwise we freeze in the center of the visible sheet
     616           1 :             table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange();
     617           1 :             sal_Int32 nColumn = aCellRangeAddress.StartColumn + (( aCellRangeAddress.EndColumn - aCellRangeAddress.StartColumn )/2 );
     618           1 :             sal_Int32 nRow = aCellRangeAddress.StartRow + (( aCellRangeAddress.EndRow - aCellRangeAddress.StartRow )/2 );
     619           1 :             xViewFreezable->freezeAtPosition( nColumn, nRow );
     620             :         }
     621             :     }
     622             :     else
     623             :     {
     624             :         //remove the freeze panes
     625           2 :         xViewSplitable->splitAtPosition(0,0);
     626           4 :     }
     627           4 : }
     628             : 
     629             : sal_Bool SAL_CALL
     630           0 : ScVbaWindow::getSplit() throw (uno::RuntimeException, std::exception)
     631             : {
     632           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     633           0 :     return xViewSplitable->getIsWindowSplit();
     634             : }
     635             : 
     636             : void SAL_CALL
     637           3 : ScVbaWindow::setSplit( sal_Bool _bSplit ) throw (uno::RuntimeException, std::exception)
     638             : {
     639           3 :     if( !_bSplit )
     640             :     {
     641           2 :         uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     642           2 :         xViewSplitable->splitAtPosition(0,0);
     643             :     }
     644             :     else
     645             :     {
     646           1 :         uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     647           2 :         uno::Reference< excel::XRange > xRange = ActiveCell();
     648           1 :         sal_Int32 nRow = xRange->getRow();
     649           1 :         sal_Int32 nColumn = xRange->getColumn();
     650           2 :         SplitAtDefinedPosition( nColumn-1, nRow-1 );
     651             :     }
     652           3 : }
     653             : 
     654             : sal_Int32 SAL_CALL
     655           6 : ScVbaWindow::getSplitColumn() throw (uno::RuntimeException, std::exception)
     656             : {
     657           6 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     658           6 :     return xViewSplitable->getSplitColumn();
     659             : }
     660             : 
     661             : void SAL_CALL
     662           1 : ScVbaWindow::setSplitColumn( sal_Int32 _splitcolumn ) throw (uno::RuntimeException, std::exception)
     663             : {
     664           1 :     if( getSplitColumn() != _splitcolumn )
     665             :     {
     666           1 :         uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     667           1 :         sal_Int32 nRow = getSplitRow();
     668           1 :         SplitAtDefinedPosition( _splitcolumn, nRow );
     669             :     }
     670           1 : }
     671             : 
     672             : double SAL_CALL
     673           2 : ScVbaWindow::getSplitHorizontal() throw (uno::RuntimeException, std::exception)
     674             : {
     675           2 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     676           2 :     return PixelsToPoints( getDevice(), xViewSplitable->getSplitHorizontal(), true );
     677             : }
     678             : 
     679             : void SAL_CALL
     680           1 : ScVbaWindow::setSplitHorizontal( double _splithorizontal ) throw (uno::RuntimeException, std::exception)
     681             : {
     682           1 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     683           1 :     double fHoriPixels = PointsToPixels( getDevice(), _splithorizontal, true );
     684           1 :     xViewSplitable->splitAtPosition( static_cast< sal_Int32 >( fHoriPixels ), 0 );
     685           1 : }
     686             : 
     687             : sal_Int32 SAL_CALL
     688           6 : ScVbaWindow::getSplitRow() throw (uno::RuntimeException, std::exception)
     689             : {
     690           6 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     691           6 :     return xViewSplitable->getSplitRow();
     692             : }
     693             : 
     694             : void SAL_CALL
     695           2 : ScVbaWindow::setSplitRow( sal_Int32 _splitrow ) throw (uno::RuntimeException, std::exception)
     696             : {
     697           2 :     if( getSplitRow() != _splitrow )
     698             :     {
     699           2 :         uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     700           2 :         sal_Int32 nColumn = getSplitColumn();
     701           2 :         SplitAtDefinedPosition( nColumn, _splitrow );
     702             :     }
     703           2 : }
     704             : 
     705             : double SAL_CALL
     706           2 : ScVbaWindow::getSplitVertical() throw (uno::RuntimeException, std::exception)
     707             : {
     708           2 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     709           2 :     return PixelsToPoints( getDevice(), xViewSplitable->getSplitVertical(), false );
     710             : }
     711             : 
     712             : void SAL_CALL
     713           1 : ScVbaWindow::setSplitVertical(double _splitvertical ) throw (uno::RuntimeException, std::exception)
     714             : {
     715           1 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     716           1 :     double fVertiPixels = PointsToPixels( getDevice(), _splitvertical, false );
     717           1 :     xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) );
     718           1 : }
     719             : 
     720           4 : void ScVbaWindow::SplitAtDefinedPosition( sal_Int32 nColumns, sal_Int32 nRows )
     721             : {
     722           4 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     723           8 :     uno::Reference< sheet::XViewFreezable > xViewFreezable( xViewSplitable, uno::UNO_QUERY_THROW );
     724             :     // nColumns and nRows means split columns/rows
     725           4 :     if( nColumns == 0 && nRows == 0 )
     726           4 :         return;
     727             : 
     728           4 :     sal_Int32 cellColumn = nColumns + 1;
     729           4 :     sal_Int32 cellRow = nRows + 1;
     730             : 
     731           4 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     732           4 :     if ( pViewShell )
     733             :     {
     734             :         //firstly remove the old splitter
     735           4 :         xViewSplitable->splitAtPosition(0,0);
     736             : 
     737           4 :         uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     738           8 :         uno::Reference< excel::XWorksheet > xSheet( xApplication->getActiveSheet(), uno::UNO_QUERY_THROW );
     739           4 :         xSheet->Cells(uno::makeAny(cellRow), uno::makeAny(cellColumn))->Select();
     740             : 
     741             :         //pViewShell->FreezeSplitters( FALSE );
     742           8 :         dispatchExecute( pViewShell, SID_WINDOW_SPLIT );
     743           4 :     }
     744             : }
     745             : 
     746             : uno::Any SAL_CALL
     747           6 : ScVbaWindow::getZoom() throw (uno::RuntimeException, std::exception)
     748             : {
     749           6 :     uno::Reference< beans::XPropertySet > xProps = getControllerProps();
     750          12 :     OUString sName( SC_UNO_ZOOMTYPE );
     751           6 :     sal_Int16 nZoomType = view::DocumentZoomType::PAGE_WIDTH;
     752           6 :     xProps->getPropertyValue( sName ) >>= nZoomType;
     753           6 :     if( nZoomType == view::DocumentZoomType::PAGE_WIDTH )
     754             :     {
     755           0 :         return uno::makeAny( sal_True );
     756             :     }
     757           6 :     else if( nZoomType == view::DocumentZoomType::BY_VALUE )
     758             :     {
     759           6 :         sName = OUString( SC_UNO_ZOOMVALUE);
     760           6 :         sal_Int16 nZoom = 100;
     761           6 :         xProps->getPropertyValue( sName ) >>= nZoom;
     762           6 :         return uno::makeAny( nZoom );
     763             :     }
     764           6 :     return uno::Any();
     765             : }
     766             : 
     767           2 : void SAL_CALL ScVbaWindow::setZoom(const uno::Any& _zoom)
     768             :     throw (uno::RuntimeException, std::exception)
     769             : {
     770           2 :     sal_Int16 nZoom = 100;
     771           2 :     _zoom >>= nZoom;
     772           2 :     uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( m_xModel, uno::UNO_QUERY_THROW );
     773           4 :     uno::Reference< excel::XWorksheet > xActiveSheet = ActiveSheet();
     774           2 :     SCTAB nTab = 0;
     775           2 :     if ( !ScVbaWorksheets::nameExists (xSpreadDoc, xActiveSheet->getName(), nTab) )
     776           0 :         throw uno::RuntimeException();
     777           4 :     std::vector< SCTAB > vTabs;
     778           2 :     vTabs.push_back( nTab );
     779           4 :     excel::implSetZoom( m_xModel, nZoom, vTabs );
     780           2 : }
     781             : 
     782             : uno::Reference< excel::XWorksheet > SAL_CALL
     783           4 : ScVbaWindow::ActiveSheet(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     784             : {
     785           4 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     786           4 :     return xApplication->getActiveSheet();
     787             : }
     788             : 
     789             : uno::Any SAL_CALL
     790           2 : ScVbaWindow::getView() throw (uno::RuntimeException, std::exception)
     791             : {
     792           2 :     sal_Bool bPageBreak = sal_False;
     793           2 :     sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
     794             : 
     795           2 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     796           2 :     if (pViewShell)
     797           2 :         bPageBreak = pViewShell->GetViewData()->IsPagebreakMode();
     798             : 
     799           2 :     if( bPageBreak )
     800           1 :         nWindowView = excel::XlWindowView::xlPageBreakPreview;
     801             :     else
     802           1 :         nWindowView = excel::XlWindowView::xlNormalView;
     803             : 
     804           2 :     return uno::makeAny( nWindowView );
     805             : }
     806             : 
     807             : void SAL_CALL
     808           2 : ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException, std::exception)
     809             : {
     810           2 :     sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
     811           2 :     _view >>= nWindowView;
     812           2 :     sal_uInt16 nSlot = FID_NORMALVIEWMODE;
     813           2 :     switch ( nWindowView )
     814             :     {
     815             :         case excel::XlWindowView::xlNormalView:
     816           1 :             nSlot = FID_NORMALVIEWMODE;
     817           1 :             break;
     818             :         case excel::XlWindowView::xlPageBreakPreview:
     819           1 :             nSlot = FID_PAGEBREAKMODE;
     820           1 :             break;
     821             :         default:
     822           0 :             DebugHelper::exception(SbERR_BAD_PARAMETER, OUString() );
     823             :     }
     824             :     // !! TODO !! get view shell from controller
     825           2 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     826           2 :     if ( pViewShell )
     827           2 :         dispatchExecute( pViewShell, nSlot );
     828           2 : }
     829             : 
     830             : uno::Reference< excel::XRange > SAL_CALL
     831           0 : ScVbaWindow::getVisibleRange() throw (uno::RuntimeException, std::exception)
     832             : {
     833           0 :     uno::Reference< container::XIndexAccess > xPanesIA( getController(), uno::UNO_QUERY_THROW );
     834           0 :     uno::Reference< sheet::XViewPane > xTopLeftPane( xPanesIA->getByIndex( 0 ), uno::UNO_QUERY_THROW );
     835           0 :     uno::Reference< excel::XPane > xPane( new ScVbaPane( this, mxContext, m_xModel, xTopLeftPane ) );
     836           0 :     return xPane->getVisibleRange();
     837             : }
     838             : 
     839             : sal_Int32 SAL_CALL
     840           0 : ScVbaWindow::PointsToScreenPixelsX(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException, std::exception)
     841             : {
     842           0 :     sal_Int32 nHundredthsofOneMillimeters = Millimeter::getInHundredthsOfOneMillimeter( _points );
     843           0 :     double fConvertFactor = (getDevice()->getInfo().PixelPerMeterX/100000);
     844           0 :     return static_cast<sal_Int32>(fConvertFactor * nHundredthsofOneMillimeters );
     845             : }
     846             : 
     847             : sal_Int32 SAL_CALL
     848           0 : ScVbaWindow::PointsToScreenPixelsY(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException, std::exception)
     849             : {
     850           0 :     sal_Int32 nHundredthsofOneMillimeters = Millimeter::getInHundredthsOfOneMillimeter( _points );
     851           0 :     double fConvertFactor = (getDevice()->getInfo().PixelPerMeterY/100000);
     852           0 :     return static_cast<sal_Int32>(fConvertFactor * nHundredthsofOneMillimeters );
     853             : }
     854             : 
     855             : void SAL_CALL
     856           0 : ScVbaWindow::PrintOut( const css::uno::Any& From, const css::uno::Any&To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::script::BasicErrorException, css::uno::RuntimeException, std::exception)
     857             : {
     858             :     // need test, print current active sheet
     859             :     // !! TODO !! get view shell from controller
     860           0 :     PrintOutHelper( excel::getBestViewShell( m_xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, true );
     861           0 : }
     862             : 
     863             : void SAL_CALL
     864           0 : ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException, std::exception)
     865             : {
     866             :     // need test, print preview current active sheet
     867             :     // !! TODO !! get view shell from controller
     868           0 :     PrintPreviewHelper( EnableChanges, excel::getBestViewShell( m_xModel ) );
     869           0 : }
     870             : 
     871           0 : double SAL_CALL ScVbaWindow::getTabRatio() throw (css::uno::RuntimeException, std::exception)
     872             : {
     873           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     874           0 :     if ( pViewShell && pViewShell->GetViewData() && pViewShell->GetViewData()->GetView() )
     875             :     {
     876           0 :         double fRatio = pViewShell->GetViewData()->GetView()->GetRelTabBarWidth();
     877           0 :         if ( fRatio >= 0.0 && fRatio <= 1.0 )
     878           0 :             return fRatio;
     879             :     }
     880           0 :     return 0.0;
     881             : }
     882             : 
     883           0 : void SAL_CALL ScVbaWindow::setTabRatio( double fRatio ) throw (css::uno::RuntimeException, std::exception)
     884             : {
     885           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     886           0 :     if ( pViewShell && pViewShell->GetViewData() && pViewShell->GetViewData()->GetView() )
     887             :     {
     888           0 :         if ( fRatio >= 0.0 && fRatio <= 1.0 )
     889           0 :             pViewShell->GetViewData()->GetView()->SetRelTabBarWidth( fRatio );
     890             :     }
     891           0 : }
     892             : 
     893             : OUString
     894           0 : ScVbaWindow::getServiceImplName()
     895             : {
     896           0 :     return OUString("ScVbaWindow");
     897             : }
     898             : 
     899             : uno::Sequence< OUString >
     900           0 : ScVbaWindow::getServiceNames()
     901             : {
     902           0 :     static uno::Sequence< OUString > aServiceNames;
     903           0 :     if ( aServiceNames.getLength() == 0 )
     904             :     {
     905           0 :         aServiceNames.realloc( 1 );
     906           0 :         aServiceNames[ 0 ] = "ooo.vba.excel.Window";
     907             :     }
     908           0 :     return aServiceNames;
     909             : }
     910             : namespace window
     911             : {
     912             : namespace sdecl = comphelper::service_decl;
     913           2 : sdecl::vba_service_class_<ScVbaWindow, sdecl::with_args<true> > serviceImpl;
     914           2 : extern sdecl::ServiceDecl const serviceDecl(
     915             :     serviceImpl,
     916             :     "ScVbaWindow",
     917             :     "ooo.vba.excel.Window" );
     918           6 : }
     919             : 
     920             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10