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

Generated by: LCOV version 1.11