LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbawindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 426 0.7 %
Date: 2012-08-25 Functions: 2 82 2.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 799 0.3 %

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

Generated by: LCOV version 1.10