LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vbahelper - vbaaccesshelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 19 100.0 %
Date: 2013-07-09 Functions: 5 5 100.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             : #ifndef OOVBAAPI_VBA_ACCESS_HELPER_HXX
      20             : #define OOVBAAPI_VBA_ACCESS_HELPER_HXX
      21             : 
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : #include <basic/basmgr.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : #include <sfx2/docfilt.hxx>
      26             : #include <sfx2/docfile.hxx>
      27             : //#define VBAHELPER_DLLIMPLEMENTATION
      28             : #include <vbahelper/vbadllapi.h>
      29             : #include <memory>
      30             : 
      31             : namespace ooo
      32             : {
      33             :     namespace vba
      34             :     {
      35             : 
      36        4303 :         VBAHELPER_DLLPRIVATE inline css::uno::Reference< css::lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell )
      37             :         {
      38        4303 :             css::uno::Any aUnoVar;
      39        4303 :             if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) )
      40        3640 :                 throw css::lang::IllegalArgumentException();
      41         662 :             css::uno::Reference< css::lang::XMultiServiceFactory > xVBAFactory( aUnoVar, css::uno::UNO_QUERY_THROW );
      42        4303 :             return xVBAFactory;
      43             :         }
      44             : 
      45        4303 :         VBAHELPER_DLLPRIVATE inline css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell,  const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::Exception)
      46             :         {
      47             :             OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" );
      48        4303 :             OUString sVarName( OUString::createFromAscii( _pAsciiName ) );
      49        4303 :             css::uno::Reference< css::uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs  );
      50        4303 :             return xIf;
      51             :         }
      52             : 
      53             : 
      54       44600 :         VBAHELPER_DLLPRIVATE inline bool isAlienDoc( SfxObjectShell& rDocShell, const char* pMimeType )
      55             :         {
      56       44600 :             bool bRes( false );
      57       44600 :             const SfxMedium *pMedium = rDocShell.GetMedium();
      58       44600 :             const SfxFilter *pFilt = pMedium ? pMedium->GetFilter() : NULL;
      59       44600 :             if ( pFilt && pFilt->IsAlienFormat() )
      60        8103 :                 bRes = ( pFilt->GetMimeType().compareToAscii( pMimeType ) == 0 );
      61       44600 :             return bRes;
      62             :         }
      63          16 :         VBAHELPER_DLLPRIVATE inline bool isAlienExcelDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-excel" ); }
      64             :         //VBAHELPER_DLLPRIVATE inline bool isAlienWordDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-word" ); }
      65             :         // word seems to return an erroneous mime type :-/ "application/msword"  not consistent with the excel one
      66       44584 :         VBAHELPER_DLLPRIVATE inline bool isAlienWordDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/msword" ); }
      67             : 
      68             :     } // openoffice
      69             : } // org
      70             : 
      71             : #endif
      72             : 
      73             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10