LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbaaddins.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 34 2.9 %
Date: 2014-11-03 Functions: 2 9 22.2 %
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 "vbaaddins.hxx"
      20             : #include "vbaaddin.hxx"
      21             : #include <cppuhelper/implbase3.hxx>
      22             : #include <unotools/pathoptions.hxx>
      23             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      24             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      25             : 
      26             : using namespace ::ooo::vba;
      27             : using namespace ::com::sun::star;
      28             : 
      29           0 : static uno::Reference< container::XIndexAccess > lcl_getAddinCollection( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext )
      30             : {
      31           0 :     XNamedObjectCollectionHelper< word::XAddin >::XNamedVec maAddins;
      32             : 
      33             :     // first get the autoload addins in the directory STARTUP
      34           0 :     uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager(), uno::UNO_QUERY_THROW );
      35           0 :     uno::Reference<ucb::XSimpleFileAccess3> xSFA(ucb::SimpleFileAccess::create(xContext));
      36           0 :     SvtPathOptions aPathOpt;
      37             :     // FIXME: temporary the STARTUP path is located in $OO/basic3.1/program/addin
      38           0 :     OUString aAddinPath = aPathOpt.GetAddinPath();
      39             :     OSL_TRACE("lcl_getAddinCollection: %s", OUStringToOString( aAddinPath, RTL_TEXTENCODING_UTF8 ).getStr() );
      40           0 :     if( xSFA->isFolder( aAddinPath ) )
      41             :     {
      42           0 :         uno::Sequence< OUString > sEntries = xSFA->getFolderContents( aAddinPath, sal_False );
      43           0 :         sal_Int32 nEntry = sEntries.getLength();
      44           0 :         for( sal_Int32 index = 0; index < nEntry; ++index )
      45             :         {
      46           0 :             OUString sUrl = sEntries[ index ];
      47           0 :             if( !xSFA->isFolder( sUrl ) && sUrl.endsWithIgnoreAsciiCaseAsciiL( ".dot", 4 ) )
      48             :             {
      49           0 :                 maAddins.push_back( uno::Reference< word::XAddin >( new SwVbaAddin( xParent, xContext, sUrl, true ) ) );
      50             :             }
      51           0 :         }
      52             :     }
      53             : 
      54             :     // TODO: second get the customize addins in the org.openoffice.Office.Writer/GlobalTemplateList
      55             : 
      56           0 :     uno::Reference< container::XIndexAccess > xAddinsAccess( new XNamedObjectCollectionHelper< word::XAddin >( maAddins ) );
      57           0 :     return xAddinsAccess;
      58             : }
      59             : 
      60           0 : SwVbaAddins::SwVbaAddins( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext ) throw (uno::RuntimeException): SwVbaAddins_BASE( xParent, xContext, lcl_getAddinCollection( xParent,xContext ) )
      61             : {
      62           0 : }
      63             : // XEnumerationAccess
      64             : uno::Type
      65           0 : SwVbaAddins::getElementType() throw (uno::RuntimeException)
      66             : {
      67           0 :     return cppu::UnoType<word::XAddin>::get();
      68             : }
      69             : uno::Reference< container::XEnumeration >
      70           0 : SwVbaAddins::createEnumeration() throw (uno::RuntimeException)
      71             : {
      72           0 :     uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
      73           0 :     return xEnumerationAccess->createEnumeration();
      74             : }
      75             : 
      76             : uno::Any
      77           0 : SwVbaAddins::createCollectionObject( const css::uno::Any& aSource )
      78             : {
      79           0 :     return aSource;
      80             : }
      81             : 
      82             : OUString
      83           0 : SwVbaAddins::getServiceImplName()
      84             : {
      85           0 :     return OUString("SwVbaAddins");
      86             : }
      87             : 
      88             : css::uno::Sequence<OUString>
      89           0 : SwVbaAddins::getServiceNames()
      90             : {
      91           0 :     static uno::Sequence< OUString > sNames;
      92           0 :     if ( sNames.getLength() == 0 )
      93             :     {
      94           0 :         sNames.realloc( 1 );
      95           0 :         sNames[0] = "ooo.vba.word.Addins";
      96             :     }
      97           0 :     return sNames;
      98           6 : }
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10