LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbaapplication.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 65 6.2 %
Date: 2012-12-27 Functions: 3 23 13.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 <stdio.h>
      20             : #include "vbaapplication.hxx"
      21             : #include "vbadocument.hxx"
      22             : #include <osl/file.hxx>
      23             : #include <vbahelper/vbahelper.hxx>
      24             : #include "vbawindow.hxx"
      25             : #include "vbasystem.hxx"
      26             : #include "vbaoptions.hxx"
      27             : #include "vbaselection.hxx"
      28             : #include "vbadocuments.hxx"
      29             : #include "vbaaddins.hxx"
      30             : #include "vbadialogs.hxx"
      31             : #include <ooo/vba/word/WdEnableCancelKey.hpp>
      32             : #include <basic/sbuno.hxx>
      33             : #include <editeng/acorrcfg.hxx>
      34             : #include "wordvbahelper.hxx"
      35             : #include <docsh.hxx>
      36             : #include "vbalistgalleries.hxx"
      37             : 
      38             : using namespace ::ooo;
      39             : using namespace ::ooo::vba;
      40             : using namespace ::com::sun::star;
      41             : 
      42             : using ::com::sun::star::uno::Reference;
      43             : using ::com::sun::star::uno::UNO_QUERY_THROW;
      44             : using ::com::sun::star::uno::UNO_QUERY;
      45             : using ::rtl::OUString;
      46             : 
      47             : // #TODO is this defined somewhere else?
      48             : #if ( defined UNX )
      49             : #define FILE_PATH_SEPERATOR "/"
      50             : #else // windows
      51             : #define FILE_PATH_SEPERATOR "\\"
      52             : #endif
      53             : 
      54             : #define EXCELVERSION "11.0"
      55             : 
      56             : 
      57           1 : SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): SwVbaApplication_BASE( xContext )
      58             : {
      59           1 : }
      60             : 
      61           2 : SwVbaApplication::~SwVbaApplication()
      62             : {
      63           2 : }
      64             : 
      65           0 : SfxObjectShell* SwVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
      66             : {
      67           0 :     return static_cast< SfxObjectShell* >( word::getDocShell( xModel ) );
      68             : }
      69             : 
      70             : rtl::OUString SAL_CALL
      71           0 : SwVbaApplication::getName() throw (uno::RuntimeException)
      72             : {
      73           0 :     static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Word" ) );
      74           0 :     return appName;
      75             : }
      76             : 
      77             : uno::Reference< word::XDocument > SAL_CALL
      78           0 : SwVbaApplication::getActiveDocument() throw (uno::RuntimeException)
      79             : {
      80           0 :     return new SwVbaDocument( this, mxContext, getCurrentDocument() );
      81             : }
      82             : 
      83             : uno::Reference< word::XWindow > SAL_CALL
      84           0 : SwVbaApplication::getActiveWindow() throw (uno::RuntimeException)
      85             : {
      86             :     // #FIXME sofar can't determine Parent
      87           0 :     uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
      88           0 :     uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
      89           0 :     return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController );
      90             : }
      91             : 
      92             : uno::Reference<word::XSystem > SAL_CALL
      93           0 : SwVbaApplication::getSystem() throw (uno::RuntimeException)
      94             : {
      95           0 :     return uno::Reference< word::XSystem >( new SwVbaSystem( mxContext ) );
      96             : }
      97             : 
      98             : uno::Reference<word::XOptions > SAL_CALL
      99           0 : SwVbaApplication::getOptions() throw (uno::RuntimeException)
     100             : {
     101           0 :     return uno::Reference< word::XOptions >( new SwVbaOptions( mxContext ) );
     102             : }
     103             : 
     104             : uno::Any SAL_CALL
     105           0 : SwVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
     106             : {
     107           0 :     return VbaApplicationBase::CommandBars( aIndex );
     108             : }
     109             : 
     110             : uno::Reference< word::XSelection > SAL_CALL
     111           0 : SwVbaApplication::getSelection() throw (uno::RuntimeException)
     112             : {
     113           0 :     return new SwVbaSelection( this, mxContext, getCurrentDocument() );
     114             : }
     115             : 
     116             : uno::Any SAL_CALL
     117           0 : SwVbaApplication::Documents( const uno::Any& index ) throw (uno::RuntimeException)
     118             : {
     119           0 :     uno::Reference< XCollection > xCol( new SwVbaDocuments( this, mxContext ) );
     120           0 :     if ( index.hasValue() )
     121           0 :         return xCol->Item( index, uno::Any() );
     122           0 :     return uno::makeAny( xCol );
     123             : }
     124             : 
     125             : uno::Any SAL_CALL
     126           0 : SwVbaApplication::Addins( const uno::Any& index ) throw (uno::RuntimeException)
     127             : {
     128           0 :     static uno::Reference< XCollection > xCol( new SwVbaAddins( this, mxContext ) );
     129           0 :     if ( index.hasValue() )
     130           0 :         return xCol->Item( index, uno::Any() );
     131           0 :     return uno::makeAny( xCol );
     132             : }
     133             : 
     134             : uno::Any SAL_CALL
     135           0 : SwVbaApplication::Dialogs( const uno::Any& index ) throw (uno::RuntimeException)
     136             : {
     137           0 :     uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentDocument() ));
     138           0 :     if ( index.hasValue() )
     139           0 :         return xCol->Item( index );
     140           0 :     return uno::makeAny( xCol );
     141             : }
     142             : 
     143             : uno::Any SAL_CALL
     144           0 : SwVbaApplication::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException)
     145             : {
     146           0 :     uno::Reference< text::XTextDocument > xTextDoc( getCurrentDocument(), uno::UNO_QUERY_THROW );
     147           0 :     uno::Reference< XCollection > xCol( new SwVbaListGalleries( this, mxContext, xTextDoc ) );
     148           0 :     if ( index.hasValue() )
     149           0 :         return xCol->Item( index, uno::Any() );
     150           0 :     return uno::makeAny( xCol );
     151             : }
     152             : 
     153           0 : sal_Bool SAL_CALL SwVbaApplication::getDisplayAutoCompleteTips() throw (css::uno::RuntimeException)
     154             : {
     155           0 :     return SvxAutoCorrCfg::Get().IsAutoTextTip();
     156             : }
     157             : 
     158           0 : void SAL_CALL SwVbaApplication::setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips ) throw (css::uno::RuntimeException)
     159             : {
     160           0 :     SvxAutoCorrCfg::Get().SetAutoTextTip( _displayAutoCompleteTips );
     161           0 : }
     162             : 
     163           0 : sal_Int32 SAL_CALL SwVbaApplication::getEnableCancelKey() throw (css::uno::RuntimeException)
     164             : {
     165             :     // the default value is wdCancelInterrupt in Word
     166           0 :     return word::WdEnableCancelKey::wdCancelInterrupt;
     167             : }
     168             : 
     169           0 : void SAL_CALL SwVbaApplication::setEnableCancelKey( sal_Int32/* _enableCancelKey */) throw (css::uno::RuntimeException)
     170             : {
     171             :     // seems not supported in Writer
     172           0 : }
     173             : 
     174           0 : float SAL_CALL SwVbaApplication::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException)
     175             : {
     176           0 :     return VbaApplicationBase::CentimetersToPoints( _Centimeters );
     177             : }
     178             : 
     179             : uno::Reference< frame::XModel >
     180           0 : SwVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException)
     181             : {
     182           0 :     return getCurrentWordDoc( mxContext );
     183             : }
     184             : 
     185             : rtl::OUString
     186           0 : SwVbaApplication::getServiceImplName()
     187             : {
     188           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaApplication"));
     189             : }
     190             : 
     191             : uno::Sequence< rtl::OUString >
     192           0 : SwVbaApplication::getServiceNames()
     193             : {
     194           0 :     static uno::Sequence< rtl::OUString > aServiceNames;
     195           0 :     if ( aServiceNames.getLength() == 0 )
     196             :     {
     197           0 :         aServiceNames.realloc( 1 );
     198           0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Application" ) );
     199             :     }
     200           0 :     return aServiceNames;
     201             : }
     202             : 
     203             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10