LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbawindow.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 434 0.0 %
Date: 2014-04-14 Functions: 0 82 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 <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           0 : 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           0 :     WindowImpl_BASE( xParent, xContext, xModel, xController )
     197             : {
     198           0 :     init();
     199           0 : }
     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           0 : 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           0 :     osl_atomic_increment( &m_refCount );
     219             :     try
     220             :     {
     221           0 :        m_xPane = ActivePane();
     222             :     }
     223           0 :     catch( uno::Exception& )
     224             :     {
     225             :     }
     226           0 :     osl_atomic_decrement( &m_refCount );
     227           0 : }
     228             : 
     229             : uno::Reference< beans::XPropertySet >
     230           0 : ScVbaWindow::getControllerProps() throw (uno::RuntimeException)
     231             : {
     232           0 :     return uno::Reference< beans::XPropertySet >( getController(), uno::UNO_QUERY_THROW );
     233             : }
     234             : 
     235             : uno::Reference< beans::XPropertySet >
     236           0 : ScVbaWindow::getFrameProps() throw (uno::RuntimeException)
     237             : {
     238           0 :     return uno::Reference< beans::XPropertySet >( getController()->getFrame(), uno::UNO_QUERY_THROW );
     239             : }
     240             : 
     241             : uno::Reference< awt::XDevice >
     242           0 : ScVbaWindow::getDevice() throw (uno::RuntimeException)
     243             : {
     244           0 :     return uno::Reference< awt::XDevice >( getWindow(), uno::UNO_QUERY_THROW );
     245             : }
     246             : 
     247             : void
     248           0 : 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           0 :     if( !m_xPane.is() )
     251           0 :         throw uno::RuntimeException();
     252           0 :     if( bLargeScroll )
     253           0 :         m_xPane->LargeScroll( Down, Up, ToRight, ToLeft );
     254             :     else
     255           0 :         m_xPane->SmallScroll( Down, Up, ToRight, ToLeft );
     256           0 : }
     257             : 
     258             : void SAL_CALL
     259           0 : 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           0 :     Scroll( Down, Up, ToRight, ToLeft );
     262           0 : }
     263             : 
     264             : void SAL_CALL
     265           0 : 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           0 :     Scroll( Down, Up, ToRight, ToLeft, true );
     268           0 : }
     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           0 : ScVbaWindow::getCaption() throw (uno::RuntimeException, std::exception)
     306             : {
     307           0 :     static OUString sCrud(" - OpenOffice.org Calc" );
     308           0 :     static sal_Int32 nCrudLen = sCrud.getLength();
     309             : 
     310           0 :     OUString sTitle;
     311           0 :     getFrameProps()->getPropertyValue( OUString( SC_UNONAME_TITLE ) ) >>= sTitle;
     312           0 :     sal_Int32 nCrudIndex = sTitle.indexOf( sCrud );
     313             :     // adjust title ( by removing crud )
     314             :     // sCrud string present
     315           0 :     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           0 :     return uno::makeAny( sTitle );
     342             : }
     343             : 
     344             : void SAL_CALL
     345           0 : ScVbaWindow::setCaption( const uno::Any& _caption ) throw (uno::RuntimeException, std::exception)
     346             : {
     347           0 :     getFrameProps()->setPropertyValue( OUString( SC_UNONAME_TITLE ), _caption );
     348           0 : }
     349             : 
     350             : uno::Any SAL_CALL
     351           0 : ScVbaWindow::getScrollRow() throw (uno::RuntimeException, std::exception)
     352             : {
     353           0 :     sal_Int32 nValue = 0;
     354             :     // !! TODO !! get view shell from controller
     355           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     356           0 :     if ( pViewShell )
     357             :     {
     358           0 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     359           0 :         nValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich));
     360             :     }
     361             : 
     362           0 :     return uno::makeAny( nValue + 1);
     363             : }
     364             : 
     365             : void SAL_CALL
     366           0 : ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeException, std::exception)
     367             : {
     368             :     // !! TODO !! get view shell from controller
     369           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     370           0 :     if ( pViewShell )
     371             :     {
     372           0 :         sal_Int32 scrollRow = 0;
     373           0 :         _scrollrow >>= scrollRow;
     374           0 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     375           0 :         sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich)) + 1;
     376           0 :         pViewShell->ScrollLines(0, scrollRow - nOldValue);
     377             :     }
     378           0 : }
     379             : 
     380             : uno::Any SAL_CALL
     381           0 : ScVbaWindow::getScrollColumn() throw (uno::RuntimeException, std::exception)
     382             : {
     383           0 :     sal_Int32 nValue = 0;
     384             :     // !! TODO !! get view shell from controller
     385           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     386           0 :     if ( pViewShell )
     387             :     {
     388           0 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     389           0 :         nValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich));
     390             :     }
     391             : 
     392           0 :     return uno::makeAny( nValue + 1);
     393             : }
     394             : 
     395             : void SAL_CALL
     396           0 : ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::RuntimeException, std::exception)
     397             : {
     398             :     // !! TODO !! get view shell from controller
     399           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     400           0 :     if ( pViewShell )
     401             :     {
     402           0 :         sal_Int32 scrollColumn = 0;
     403           0 :         _scrollcolumn >>= scrollColumn;
     404           0 :         ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
     405           0 :         sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich)) + 1;
     406           0 :         pViewShell->ScrollLines(scrollColumn - nOldValue, 0);
     407             :     }
     408           0 : }
     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           0 : ScVbaWindow::Activate() throw (css::uno::RuntimeException, std::exception)
     452             : {
     453           0 :     ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
     454             : 
     455           0 :     workbook.Activate();
     456           0 : }
     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           0 : ScVbaWindow::ActivePane() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     467             : {
     468           0 :     uno::Reference< sheet::XViewPane > xViewPane( getController(), uno::UNO_QUERY_THROW );
     469           0 :     return new ScVbaPane( this, mxContext, m_xModel, xViewPane );
     470             : }
     471             : 
     472             : uno::Reference< excel::XRange > SAL_CALL
     473           0 : ScVbaWindow::ActiveCell(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     474             : {
     475           0 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     476           0 :     return xApplication->getActiveCell();
     477             : }
     478             : 
     479             : uno::Any SAL_CALL
     480           0 : ScVbaWindow::Selection(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     481             : {
     482           0 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     483           0 :     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           0 : ScVbaWindow::getDisplayGridlines() throw (uno::RuntimeException, std::exception)
     496             : {
     497           0 :     OUString sName( SC_UNO_SHOWGRID );
     498           0 :     sal_Bool bGrid = sal_True;
     499           0 :     getControllerProps()->getPropertyValue( sName ) >>= bGrid;
     500           0 :     return bGrid;
     501             : }
     502             : 
     503             : 
     504             : void SAL_CALL
     505           0 : ScVbaWindow::setDisplayGridlines( sal_Bool _displaygridlines ) throw (uno::RuntimeException, std::exception)
     506             : {
     507           0 :     OUString sName( SC_UNO_SHOWGRID );
     508           0 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _displaygridlines ));
     509           0 : }
     510             : 
     511             : sal_Bool SAL_CALL
     512           0 : ScVbaWindow::getDisplayHeadings() throw (uno::RuntimeException, std::exception)
     513             : {
     514           0 :     OUString sName( SC_UNO_COLROWHDR );
     515           0 :     sal_Bool bHeading = sal_True;
     516           0 :     getControllerProps()->getPropertyValue( sName ) >>= bHeading;
     517           0 :     return bHeading;
     518             : }
     519             : 
     520             : void SAL_CALL
     521           0 : ScVbaWindow::setDisplayHeadings( sal_Bool _bDisplayHeadings ) throw (uno::RuntimeException, std::exception)
     522             : {
     523           0 :     OUString sName( SC_UNO_COLROWHDR );
     524           0 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayHeadings ));
     525           0 : }
     526             : 
     527             : sal_Bool SAL_CALL
     528           0 : ScVbaWindow::getDisplayHorizontalScrollBar() throw (uno::RuntimeException, std::exception)
     529             : {
     530           0 :     OUString sName( SC_UNO_HORSCROLL );
     531           0 :     sal_Bool bHorizontalScrollBar = sal_True;
     532           0 :     getControllerProps()->getPropertyValue( sName ) >>= bHorizontalScrollBar;
     533           0 :     return bHorizontalScrollBar;
     534             : }
     535             : 
     536             : void SAL_CALL
     537           0 : ScVbaWindow::setDisplayHorizontalScrollBar( sal_Bool _bDisplayHorizontalScrollBar ) throw (uno::RuntimeException, std::exception)
     538             : {
     539           0 :     OUString sName( SC_UNO_HORSCROLL );
     540           0 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayHorizontalScrollBar ));
     541           0 : }
     542             : 
     543             : sal_Bool SAL_CALL
     544           0 : ScVbaWindow::getDisplayOutline() throw (uno::RuntimeException, std::exception)
     545             : {
     546           0 :     OUString sName( SC_UNO_OUTLSYMB );
     547           0 :     sal_Bool bOutline = sal_True;
     548           0 :     getControllerProps()->getPropertyValue( sName ) >>= bOutline;
     549           0 :     return bOutline;
     550             : }
     551             : 
     552             : void SAL_CALL
     553           0 : ScVbaWindow::setDisplayOutline( sal_Bool _bDisplayOutline ) throw (uno::RuntimeException, std::exception)
     554             : {
     555           0 :     OUString sName( SC_UNO_OUTLSYMB );
     556           0 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayOutline ));
     557           0 : }
     558             : 
     559             : sal_Bool SAL_CALL
     560           0 : ScVbaWindow::getDisplayVerticalScrollBar() throw (uno::RuntimeException, std::exception)
     561             : {
     562           0 :     OUString sName( SC_UNO_VERTSCROLL );
     563           0 :     sal_Bool bVerticalScrollBar = sal_True;
     564           0 :     getControllerProps()->getPropertyValue( sName ) >>= bVerticalScrollBar;
     565           0 :     return bVerticalScrollBar;
     566             : }
     567             : 
     568             : void SAL_CALL
     569           0 : ScVbaWindow::setDisplayVerticalScrollBar( sal_Bool _bDisplayVerticalScrollBar ) throw (uno::RuntimeException, std::exception)
     570             : {
     571           0 :     OUString sName( SC_UNO_VERTSCROLL );
     572           0 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayVerticalScrollBar ));
     573           0 : }
     574             : 
     575             : sal_Bool SAL_CALL
     576           0 : ScVbaWindow::getDisplayWorkbookTabs() throw (uno::RuntimeException, std::exception)
     577             : {
     578           0 :     OUString sName( SC_UNO_SHEETTABS );
     579           0 :     sal_Bool bWorkbookTabs = sal_True;
     580           0 :     getControllerProps()->getPropertyValue( sName ) >>= bWorkbookTabs;
     581           0 :     return bWorkbookTabs;
     582             : }
     583             : 
     584             : void SAL_CALL
     585           0 : ScVbaWindow::setDisplayWorkbookTabs( sal_Bool _bDisplayWorkbookTabs ) throw (uno::RuntimeException, std::exception)
     586             : {
     587           0 :     OUString sName( SC_UNO_SHEETTABS );
     588           0 :     getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayWorkbookTabs ));
     589           0 : }
     590             : 
     591             : sal_Bool SAL_CALL
     592           0 : ScVbaWindow::getFreezePanes() throw (uno::RuntimeException, std::exception)
     593             : {
     594           0 :     uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     595           0 :     return xViewFreezable->hasFrozenPanes();
     596             : }
     597             : 
     598             : void SAL_CALL
     599           0 : ScVbaWindow::setFreezePanes( sal_Bool _bFreezePanes ) throw (uno::RuntimeException, std::exception)
     600             : {
     601           0 :     uno::Reference< sheet::XViewPane > xViewPane( getController(), uno::UNO_QUERY_THROW );
     602           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( xViewPane, uno::UNO_QUERY_THROW );
     603           0 :     uno::Reference< sheet::XViewFreezable > xViewFreezable( xViewPane, uno::UNO_QUERY_THROW );
     604           0 :     if( _bFreezePanes )
     605             :     {
     606           0 :         if( xViewSplitable->getIsWindowSplit() )
     607             :         {
     608             :             // if there is a split we freeze at the split
     609           0 :             sal_Int32 nColumn = getSplitColumn();
     610           0 :             sal_Int32 nRow = getSplitRow();
     611           0 :             xViewFreezable->freezeAtPosition( nColumn, nRow );
     612             :         }
     613             :         else
     614             :         {
     615             :             // otherwise we freeze in the center of the visible sheet
     616           0 :             table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange();
     617           0 :             sal_Int32 nColumn = aCellRangeAddress.StartColumn + (( aCellRangeAddress.EndColumn - aCellRangeAddress.StartColumn )/2 );
     618           0 :             sal_Int32 nRow = aCellRangeAddress.StartRow + (( aCellRangeAddress.EndRow - aCellRangeAddress.StartRow )/2 );
     619           0 :             xViewFreezable->freezeAtPosition( nColumn, nRow );
     620             :         }
     621             :     }
     622             :     else
     623             :     {
     624             :         //remove the freeze panes
     625           0 :         xViewSplitable->splitAtPosition(0,0);
     626           0 :     }
     627           0 : }
     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           0 : ScVbaWindow::setSplit( sal_Bool _bSplit ) throw (uno::RuntimeException, std::exception)
     638             : {
     639           0 :     if( !_bSplit )
     640             :     {
     641           0 :         uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     642           0 :         xViewSplitable->splitAtPosition(0,0);
     643             :     }
     644             :     else
     645             :     {
     646           0 :         uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     647           0 :         uno::Reference< excel::XRange > xRange = ActiveCell();
     648           0 :         sal_Int32 nRow = xRange->getRow();
     649           0 :         sal_Int32 nColumn = xRange->getColumn();
     650           0 :         SplitAtDefinedPosition( nColumn-1, nRow-1 );
     651             :     }
     652           0 : }
     653             : 
     654             : sal_Int32 SAL_CALL
     655           0 : ScVbaWindow::getSplitColumn() throw (uno::RuntimeException, std::exception)
     656             : {
     657           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     658           0 :     return xViewSplitable->getSplitColumn();
     659             : }
     660             : 
     661             : void SAL_CALL
     662           0 : ScVbaWindow::setSplitColumn( sal_Int32 _splitcolumn ) throw (uno::RuntimeException, std::exception)
     663             : {
     664           0 :     if( getSplitColumn() != _splitcolumn )
     665             :     {
     666           0 :         uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     667           0 :         sal_Int32 nRow = getSplitRow();
     668           0 :         SplitAtDefinedPosition( _splitcolumn, nRow );
     669             :     }
     670           0 : }
     671             : 
     672             : double SAL_CALL
     673           0 : ScVbaWindow::getSplitHorizontal() throw (uno::RuntimeException, std::exception)
     674             : {
     675           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     676           0 :     return PixelsToPoints( getDevice(), xViewSplitable->getSplitHorizontal(), true );
     677             : }
     678             : 
     679             : void SAL_CALL
     680           0 : ScVbaWindow::setSplitHorizontal( double _splithorizontal ) throw (uno::RuntimeException, std::exception)
     681             : {
     682           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     683           0 :     double fHoriPixels = PointsToPixels( getDevice(), _splithorizontal, true );
     684           0 :     xViewSplitable->splitAtPosition( static_cast< sal_Int32 >( fHoriPixels ), 0 );
     685           0 : }
     686             : 
     687             : sal_Int32 SAL_CALL
     688           0 : ScVbaWindow::getSplitRow() throw (uno::RuntimeException, std::exception)
     689             : {
     690           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     691           0 :     return xViewSplitable->getSplitRow();
     692             : }
     693             : 
     694             : void SAL_CALL
     695           0 : ScVbaWindow::setSplitRow( sal_Int32 _splitrow ) throw (uno::RuntimeException, std::exception)
     696             : {
     697           0 :     if( getSplitRow() != _splitrow )
     698             :     {
     699           0 :         uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW );
     700           0 :         sal_Int32 nColumn = getSplitColumn();
     701           0 :         SplitAtDefinedPosition( nColumn, _splitrow );
     702             :     }
     703           0 : }
     704             : 
     705             : double SAL_CALL
     706           0 : ScVbaWindow::getSplitVertical() throw (uno::RuntimeException, std::exception)
     707             : {
     708           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     709           0 :     return PixelsToPoints( getDevice(), xViewSplitable->getSplitVertical(), false );
     710             : }
     711             : 
     712             : void SAL_CALL
     713           0 : ScVbaWindow::setSplitVertical(double _splitvertical ) throw (uno::RuntimeException, std::exception)
     714             : {
     715           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     716           0 :     double fVertiPixels = PointsToPixels( getDevice(), _splitvertical, false );
     717           0 :     xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) );
     718           0 : }
     719             : 
     720           0 : void ScVbaWindow::SplitAtDefinedPosition( sal_Int32 nColumns, sal_Int32 nRows )
     721             : {
     722           0 :     uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
     723           0 :     uno::Reference< sheet::XViewFreezable > xViewFreezable( xViewSplitable, uno::UNO_QUERY_THROW );
     724             :     // nColumns and nRows means split columns/rows
     725           0 :     if( nColumns == 0 && nRows == 0 )
     726           0 :         return;
     727             : 
     728           0 :     sal_Int32 cellColumn = nColumns + 1;
     729           0 :     sal_Int32 cellRow = nRows + 1;
     730             : 
     731           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     732           0 :     if ( pViewShell )
     733             :     {
     734             :         //firstly remove the old splitter
     735           0 :         xViewSplitable->splitAtPosition(0,0);
     736             : 
     737           0 :         uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     738           0 :         uno::Reference< excel::XWorksheet > xSheet( xApplication->getActiveSheet(), uno::UNO_QUERY_THROW );
     739           0 :         xSheet->Cells(uno::makeAny(cellRow), uno::makeAny(cellColumn))->Select();
     740             : 
     741             :         //pViewShell->FreezeSplitters( FALSE );
     742           0 :         dispatchExecute( pViewShell, SID_WINDOW_SPLIT );
     743           0 :     }
     744             : }
     745             : 
     746             : uno::Any SAL_CALL
     747           0 : ScVbaWindow::getZoom() throw (uno::RuntimeException, std::exception)
     748             : {
     749           0 :     uno::Reference< beans::XPropertySet > xProps = getControllerProps();
     750           0 :     OUString sName( SC_UNO_ZOOMTYPE );
     751           0 :     sal_Int16 nZoomType = view::DocumentZoomType::PAGE_WIDTH;
     752           0 :     xProps->getPropertyValue( sName ) >>= nZoomType;
     753           0 :     if( nZoomType == view::DocumentZoomType::PAGE_WIDTH )
     754             :     {
     755           0 :         return uno::makeAny( sal_True );
     756             :     }
     757           0 :     else if( nZoomType == view::DocumentZoomType::BY_VALUE )
     758             :     {
     759           0 :         sName = OUString( SC_UNO_ZOOMVALUE);
     760           0 :         sal_Int16 nZoom = 100;
     761           0 :         xProps->getPropertyValue( sName ) >>= nZoom;
     762           0 :         return uno::makeAny( nZoom );
     763             :     }
     764           0 :     return uno::Any();
     765             : }
     766             : 
     767           0 : void SAL_CALL ScVbaWindow::setZoom(const uno::Any& _zoom)
     768             :     throw (uno::RuntimeException, std::exception)
     769             : {
     770           0 :     sal_Int16 nZoom = 100;
     771           0 :     _zoom >>= nZoom;
     772           0 :     uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( m_xModel, uno::UNO_QUERY_THROW );
     773           0 :     uno::Reference< excel::XWorksheet > xActiveSheet = ActiveSheet();
     774           0 :     SCTAB nTab = 0;
     775           0 :     if ( !ScVbaWorksheets::nameExists (xSpreadDoc, xActiveSheet->getName(), nTab) )
     776           0 :         throw uno::RuntimeException();
     777           0 :     std::vector< SCTAB > vTabs;
     778           0 :     vTabs.push_back( nTab );
     779           0 :     excel::implSetZoom( m_xModel, nZoom, vTabs );
     780           0 : }
     781             : 
     782             : uno::Reference< excel::XWorksheet > SAL_CALL
     783           0 : ScVbaWindow::ActiveSheet(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     784             : {
     785           0 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
     786           0 :     return xApplication->getActiveSheet();
     787             : }
     788             : 
     789             : uno::Any SAL_CALL
     790           0 : ScVbaWindow::getView() throw (uno::RuntimeException, std::exception)
     791             : {
     792           0 :     sal_Bool bPageBreak = sal_False;
     793           0 :     sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
     794             : 
     795           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     796           0 :     if (pViewShell)
     797           0 :         bPageBreak = pViewShell->GetViewData()->IsPagebreakMode();
     798             : 
     799           0 :     if( bPageBreak )
     800           0 :         nWindowView = excel::XlWindowView::xlPageBreakPreview;
     801             :     else
     802           0 :         nWindowView = excel::XlWindowView::xlNormalView;
     803             : 
     804           0 :     return uno::makeAny( nWindowView );
     805             : }
     806             : 
     807             : void SAL_CALL
     808           0 : ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException, std::exception)
     809             : {
     810           0 :     sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
     811           0 :     _view >>= nWindowView;
     812           0 :     sal_uInt16 nSlot = FID_NORMALVIEWMODE;
     813           0 :     switch ( nWindowView )
     814             :     {
     815             :         case excel::XlWindowView::xlNormalView:
     816           0 :             nSlot = FID_NORMALVIEWMODE;
     817           0 :             break;
     818             :         case excel::XlWindowView::xlPageBreakPreview:
     819           0 :             nSlot = FID_PAGEBREAKMODE;
     820           0 :             break;
     821             :         default:
     822           0 :             DebugHelper::exception(SbERR_BAD_PARAMETER, OUString() );
     823             :     }
     824             :     // !! TODO !! get view shell from controller
     825           0 :     ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
     826           0 :     if ( pViewShell )
     827           0 :         dispatchExecute( pViewShell, nSlot );
     828           0 : }
     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           0 : sdecl::vba_service_class_<ScVbaWindow, sdecl::with_args<true> > serviceImpl;
     914           0 : extern sdecl::ServiceDecl const serviceDecl(
     915             :     serviceImpl,
     916             :     "ScVbaWindow",
     917             :     "ooo.vba.excel.Window" );
     918           0 : }
     919             : 
     920             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10