LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/vba - vbaglobals.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 96 0.0 %
Date: 2012-12-27 Functions: 0 34 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 "vbaglobals.hxx"
      21             : 
      22             : #include <sal/macros.h>
      23             : 
      24             : #include <comphelper/unwrapargs.hxx>
      25             : 
      26             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <cppuhelper/component_context.hxx>
      29             : 
      30             : #include "vbaapplication.hxx"
      31             : #include "vbaworksheet.hxx"
      32             : #include "vbarange.hxx"
      33             : #include <cppuhelper/bootstrap.hxx>
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::ooo::vba;
      37             : 
      38             : 
      39             : 
      40             : // =============================================================================
      41             : // ScVbaGlobals
      42             : // =============================================================================
      43             : 
      44             : //ScVbaGlobals::ScVbaGlobals(  css::uno::Reference< css::uno::XComponentContext >const& rxContext,  ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
      45           0 : rtl::OUString sDocCtxName( "ExcelDocumentContext" );
      46             : 
      47           0 : ScVbaGlobals::ScVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName )
      48             : {
      49             :     OSL_TRACE("ScVbaGlobals::ScVbaGlobals()");
      50             : 
      51           0 :         uno::Sequence< beans::PropertyValue > aInitArgs( 2 );
      52           0 :         aInitArgs[ 0 ].Name = rtl::OUString("Application");
      53           0 :         aInitArgs[ 0 ].Value = uno::makeAny( getApplication() );
      54           0 :         aInitArgs[ 1 ].Name = sDocCtxName;
      55           0 :         aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) );
      56             : 
      57           0 :         init( aInitArgs );
      58           0 : }
      59             : 
      60           0 : ScVbaGlobals::~ScVbaGlobals()
      61             : {
      62             :     OSL_TRACE("ScVbaGlobals::~ScVbaGlobals");
      63           0 : }
      64             : 
      65             : // =============================================================================
      66             : // XGlobals
      67             : // =============================================================================
      68             : uno::Reference<excel::XApplication >
      69           0 : ScVbaGlobals::getApplication() throw (uno::RuntimeException)
      70             : {
      71             : //  OSL_TRACE("In ScVbaGlobals::getApplication");
      72           0 :         if ( !mxApplication.is() )
      73           0 :         mxApplication.set( new ScVbaApplication( mxContext) );
      74           0 :        return mxApplication;
      75             : }
      76             : 
      77             : 
      78             : uno::Reference<excel::XApplication > SAL_CALL
      79           0 : ScVbaGlobals::getExcel() throw (uno::RuntimeException)
      80             : {
      81           0 :        return getApplication();
      82             : }
      83             : 
      84             : 
      85             : 
      86             : uno::Reference< excel::XWorkbook > SAL_CALL
      87           0 : ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException)
      88             : {
      89             : //  OSL_TRACE("In ScVbaGlobals::getActiveWorkbook");
      90           0 :     uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_QUERY);
      91           0 :     if ( xWorkbook.is() )
      92             :     {
      93           0 :         return xWorkbook;
      94             :     }
      95             : // FIXME check if this is correct/desired behavior
      96             :     throw uno::RuntimeException( rtl::OUString(
      97           0 :         "No activeWorkbook available" ), Reference< uno::XInterface >() );
      98             : }
      99             : 
     100             : 
     101             : uno::Reference< excel::XWindow > SAL_CALL
     102           0 : ScVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
     103             : {
     104           0 :     return getApplication()->getActiveWindow();
     105             : }
     106             : 
     107             : uno::Reference< excel::XWorksheet > SAL_CALL
     108           0 : ScVbaGlobals::getActiveSheet() throw (uno::RuntimeException)
     109             : {
     110           0 :     return getApplication()->getActiveSheet();
     111             : }
     112             : 
     113             : uno::Any SAL_CALL
     114           0 : ScVbaGlobals::WorkBooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
     115             : {
     116           0 :     return uno::Any( getApplication()->Workbooks(aIndex) );
     117             : }
     118             : 
     119             : uno::Any SAL_CALL
     120           0 : ScVbaGlobals::WorkSheets(const uno::Any& aIndex) throw (uno::RuntimeException)
     121             : {
     122           0 :     return getApplication()->Worksheets( aIndex );
     123             : }
     124             : uno::Any SAL_CALL
     125           0 : ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
     126             : {
     127           0 :     return WorkSheets( aIndex );
     128             : }
     129             : 
     130             : uno::Any SAL_CALL
     131           0 : ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
     132             : {
     133           0 :     return getApplication()->Range( Cell1, Cell2 );
     134             : }
     135             : 
     136             : uno::Any SAL_CALL
     137           0 : ScVbaGlobals::Names( const css::uno::Any& aIndex ) throw ( uno::RuntimeException )
     138             : {
     139           0 :     return getApplication()->Names( aIndex );
     140             : }
     141             : 
     142             : uno::Reference< excel::XRange > SAL_CALL
     143           0 : ScVbaGlobals::getActiveCell() throw (uno::RuntimeException)
     144             : {
     145           0 :     return getApplication()->getActiveCell();
     146             : }
     147             : 
     148             : uno::Reference< XAssistant > SAL_CALL
     149           0 : ScVbaGlobals::getAssistant() throw (uno::RuntimeException)
     150             : {
     151           0 :     return getApplication()->getAssistant();
     152             : }
     153             : 
     154             : uno::Any SAL_CALL
     155           0 : ScVbaGlobals::getSelection() throw (uno::RuntimeException)
     156             : {
     157           0 :     return getApplication()->getSelection();
     158             : }
     159             : 
     160             : uno::Reference< excel::XWorkbook > SAL_CALL
     161           0 : ScVbaGlobals::getThisWorkbook() throw (uno::RuntimeException)
     162             : {
     163           0 :     return getApplication()->getThisWorkbook();
     164             : }
     165             : void SAL_CALL
     166           0 : ScVbaGlobals::Calculate()  throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException)
     167             : {
     168           0 :     return getApplication()->Calculate();
     169             : }
     170             : 
     171             : uno::Reference< excel::XRange > SAL_CALL
     172           0 : ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex ) throw (uno::RuntimeException)
     173             : {
     174           0 :     return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex );
     175             : }
     176             : uno::Reference< excel::XRange > SAL_CALL
     177           0 : ScVbaGlobals::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException)
     178             : {
     179           0 :     return getApplication()->getActiveSheet()->Columns( aIndex );
     180             : }
     181             : 
     182             : uno::Any SAL_CALL
     183           0 : ScVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
     184             : {
     185           0 :     uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW );
     186           0 :     return xBase->CommandBars( aIndex );
     187             : }
     188             : 
     189             : css::uno::Reference< ov::excel::XRange > SAL_CALL
     190           0 : ScVbaGlobals::Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
     191             : {
     192           0 :     return getApplication()->Union(  Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
     193             : }
     194             : css::uno::Reference< ov::excel::XRange > SAL_CALL
     195           0 : ScVbaGlobals::Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
     196             : {
     197           0 :     return getApplication()->Intersect(  Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
     198             : }
     199             : 
     200             : uno::Any SAL_CALL
     201           0 : ScVbaGlobals::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
     202             : {
     203           0 :     return getApplication()->Evaluate( Name );
     204             : }
     205             : 
     206             : css::uno::Any SAL_CALL
     207           0 : ScVbaGlobals::WorksheetFunction(  ) throw (css::uno::RuntimeException)
     208             : {
     209           0 :     return getApplication()->WorksheetFunction();
     210             : }
     211             : 
     212             : uno::Any SAL_CALL
     213           0 : ScVbaGlobals::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
     214             : {
     215           0 :     return getApplication()->Windows( aIndex );
     216             : }
     217             : 
     218             : uno::Reference< excel::XRange > SAL_CALL
     219           0 : ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException)
     220             : {
     221           0 :     return getApplication()->getActiveSheet()->Rows( aIndex );
     222             : 
     223             : }
     224             : 
     225             : 
     226             : uno::Any SAL_CALL
     227           0 : ScVbaGlobals::getDebug() throw (uno::RuntimeException)
     228             : {
     229             :     try // return empty object on error
     230             :     {
     231           0 :         uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
     232           0 :         uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithContext(
     233           0 :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.Debug" ) ), mxContext );
     234           0 :         return uno::Any( xVBADebug );
     235             :     }
     236           0 :     catch( uno::Exception& )
     237             :     {
     238             :     }
     239           0 :     return uno::Any();
     240             : }
     241             : 
     242             : uno::Any SAL_CALL
     243           0 : ScVbaGlobals::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
     244             : {
     245           0 :     return uno::Any( getApplication()->MenuBars(aIndex) );
     246             : }
     247             : 
     248             : uno::Sequence< ::rtl::OUString > SAL_CALL
     249           0 : ScVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
     250             : {
     251             :     static bool bInit = false;
     252           0 :     static uno::Sequence< rtl::OUString > serviceNames( ScVbaGlobals_BASE::getAvailableServiceNames() );
     253           0 :     if ( !bInit )
     254             :     {
     255             :          rtl::OUString names[] = {
     256             :             ::rtl::OUString(  "ooo.vba.excel.Range"  ),
     257             :             ::rtl::OUString(  "ooo.vba.excel.Workbook"  ),
     258             :             ::rtl::OUString(  "ooo.vba.excel.Window"  ),
     259             :             ::rtl::OUString(  "ooo.vba.excel.Worksheet"  ),
     260             :             ::rtl::OUString(  "ooo.vba.excel.Application"  ),
     261             :             ::rtl::OUString(  "ooo.vba.excel.Hyperlink"  ),
     262             :             ::rtl::OUString(  "com.sun.star.script.vba.VBASpreadsheetEventProcessor"  )
     263           0 :           };
     264           0 :         sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) );
     265           0 :         sal_Int32 startIndex = serviceNames.getLength();
     266           0 :         serviceNames.realloc( serviceNames.getLength() + nExcelServices );
     267           0 :         for ( sal_Int32 index = 0; index < nExcelServices; ++index )
     268           0 :              serviceNames[ startIndex + index ] = names[ index ];
     269           0 :         bInit = true;
     270             :     }
     271           0 :     return serviceNames;
     272             : }
     273             : 
     274             : rtl::OUString
     275           0 : ScVbaGlobals::getServiceImplName()
     276             : {
     277           0 :     return rtl::OUString("ScVbaGlobals");
     278             : }
     279             : 
     280             : uno::Sequence< rtl::OUString >
     281           0 : ScVbaGlobals::getServiceNames()
     282             : {
     283           0 :         static uno::Sequence< rtl::OUString > aServiceNames;
     284           0 :         if ( aServiceNames.getLength() == 0 )
     285             :         {
     286           0 :                 aServiceNames.realloc( 1 );
     287           0 :                 aServiceNames[ 0 ] = rtl::OUString( "ooo.vba.excel.Globals"  );
     288             :         }
     289           0 :         return aServiceNames;
     290             : }
     291             : 
     292             : namespace globals
     293             : {
     294             : namespace sdecl = comphelper::service_decl;
     295           0 : sdecl::vba_service_class_<ScVbaGlobals, sdecl::with_args<true> > serviceImpl;
     296           0 : extern sdecl::ServiceDecl const serviceDecl(
     297             :     serviceImpl,
     298             :     "ScVbaGlobals",
     299             :     "ooo.vba.excel.Globals" );
     300           0 : }
     301             : 
     302             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10