LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbaglobals.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 61 47.5 %
Date: 2012-12-27 Functions: 6 21 28.6 %
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             : #include <sal/macros.h>
      22             : #include <comphelper/unwrapargs.hxx>
      23             : 
      24             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/container/XNameContainer.hpp>
      27             : #include <cppuhelper/bootstrap.hxx>
      28             : #include "vbaapplication.hxx"
      29             : using namespace ::com::sun::star;
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::ooo::vba;
      32             : 
      33             : 
      34           1 : rtl::OUString sDocCtxName( RTL_CONSTASCII_USTRINGPARAM("WordDocumentContext") );
      35             : 
      36             : // =============================================================================
      37             : // SwVbaGlobals
      38             : // =============================================================================
      39             : 
      40           1 : SwVbaGlobals::SwVbaGlobals(  uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : SwVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName )
      41             : {
      42             :     OSL_TRACE("SwVbaGlobals::SwVbaGlobals()");
      43           1 :         uno::Sequence< beans::PropertyValue > aInitArgs( 2 );
      44           1 :         aInitArgs[ 0 ].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Application"));
      45           1 :         aInitArgs[ 0 ].Value = uno::makeAny( getApplication() );
      46           1 :         aInitArgs[ 1 ].Name = sDocCtxName;
      47           1 :         aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) );
      48             : 
      49           1 :         init( aInitArgs );
      50           1 : }
      51             : 
      52           1 : SwVbaGlobals::~SwVbaGlobals()
      53             : {
      54             :     OSL_TRACE("SwVbaGlobals::~SwVbaGlobals");
      55           1 : }
      56             : 
      57             : // =============================================================================
      58             : // XGlobals
      59             : // =============================================================================
      60             : uno::Reference<word::XApplication >
      61           1 : SwVbaGlobals::getApplication() throw (uno::RuntimeException)
      62             : {
      63             :     OSL_TRACE("In SwVbaGlobals::getApplication");
      64           1 :     if ( !mxApplication.is() )
      65           1 :          mxApplication.set( new SwVbaApplication( mxContext) );
      66             : 
      67           1 :        return mxApplication;
      68             : }
      69             : 
      70             : uno::Reference<word::XSystem > SAL_CALL
      71           0 : SwVbaGlobals::getSystem() throw (uno::RuntimeException)
      72             : {
      73           0 :     return getApplication()->getSystem();
      74             : }
      75             : 
      76             : uno::Reference< word::XDocument > SAL_CALL
      77           0 : SwVbaGlobals::getActiveDocument() throw (uno::RuntimeException)
      78             : {
      79           0 :     return getApplication()->getActiveDocument();
      80             : }
      81             : 
      82             : uno::Reference< word::XWindow > SAL_CALL
      83           0 : SwVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
      84             : {
      85           0 :     return getApplication()->getActiveWindow();
      86             : }
      87             : 
      88             : rtl::OUString SAL_CALL
      89           0 : SwVbaGlobals::getName() throw (uno::RuntimeException)
      90             : {
      91           0 :     return getApplication()->getName();
      92             : }
      93             : 
      94             : uno::Reference<word::XOptions > SAL_CALL
      95           0 : SwVbaGlobals::getOptions() throw (uno::RuntimeException)
      96             : {
      97           0 :     return getApplication()->getOptions();
      98             : }
      99             : 
     100             : uno::Any SAL_CALL
     101           0 : SwVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
     102             : {
     103           0 :     return getApplication()->CommandBars( aIndex );
     104             : }
     105             : 
     106             : uno::Any SAL_CALL
     107           0 : SwVbaGlobals::Documents( const uno::Any& index ) throw (uno::RuntimeException)
     108             : {
     109           0 :     return getApplication()->Documents( index );
     110             : }
     111             : 
     112             : uno::Any SAL_CALL
     113           0 : SwVbaGlobals::Addins( const uno::Any& index ) throw (uno::RuntimeException)
     114             : {
     115           0 :     return getApplication()->Addins( index );
     116             : }
     117             : 
     118             : uno::Any SAL_CALL
     119           0 : SwVbaGlobals::Dialogs( const uno::Any& index ) throw (uno::RuntimeException)
     120             : {
     121           0 :     return getApplication()->Dialogs( index );
     122             : }
     123             : 
     124             : uno::Any SAL_CALL
     125           0 : SwVbaGlobals::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException)
     126             : {
     127           0 :     return getApplication()->ListGalleries( index );
     128             : }
     129             : 
     130             : uno::Reference<word::XSelection > SAL_CALL
     131           0 : SwVbaGlobals::getSelection() throw (uno::RuntimeException)
     132             : {
     133           0 :     return getApplication()->getSelection();
     134             : }
     135             : 
     136           0 : float SAL_CALL SwVbaGlobals::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException)
     137             : {
     138           0 :     return getApplication()->CentimetersToPoints( _Centimeters );
     139             : }
     140             : 
     141             : rtl::OUString
     142           0 : SwVbaGlobals::getServiceImplName()
     143             : {
     144           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaGlobals"));
     145             : }
     146             : 
     147             : uno::Sequence< rtl::OUString >
     148           0 : SwVbaGlobals::getServiceNames()
     149             : {
     150           0 :         static uno::Sequence< rtl::OUString > aServiceNames;
     151           0 :         if ( aServiceNames.getLength() == 0 )
     152             :         {
     153           0 :                 aServiceNames.realloc( 1 );
     154           0 :                 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Globals" ) );
     155             :         }
     156           0 :         return aServiceNames;
     157             : }
     158             : 
     159             : uno::Sequence< rtl::OUString >
     160          13 : SwVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
     161             : {
     162             :     static bool bInit = false;
     163          13 :     static uno::Sequence< rtl::OUString > serviceNames( SwVbaGlobals_BASE::getAvailableServiceNames() );
     164          13 :     if ( !bInit )
     165             :     {
     166             :          rtl::OUString names[] = {
     167             :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Document" ) ),
     168             : //            #FIXME #TODO make Application a proper service
     169             : //            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Application" ) ),
     170           2 :         };
     171           1 :         sal_Int32 nWordServices = SAL_N_ELEMENTS( names );
     172           1 :         sal_Int32 startIndex = serviceNames.getLength();
     173           1 :         serviceNames.realloc( serviceNames.getLength() + nWordServices );
     174           2 :         for ( sal_Int32 index = 0; index < nWordServices; ++index )
     175           1 :              serviceNames[ startIndex + index ] = names[ index ];
     176           2 :         bInit = true;
     177             :     }
     178          13 :     return serviceNames;
     179             : }
     180             : 
     181             : namespace globals
     182             : {
     183             : namespace sdecl = comphelper::service_decl;
     184           1 : sdecl::vba_service_class_<SwVbaGlobals, sdecl::with_args<true> > serviceImpl;
     185           1 : extern sdecl::ServiceDecl const serviceDecl(
     186             :     serviceImpl,
     187             :     "SwVbaGlobals",
     188             :     "ooo.vba.word.Globals" );
     189           3 : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10