1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "vbaaddins.hxx"
20 #include "vbaaddin.hxx"
21 #include <unotools/pathoptions.hxx>
22 #include <sal/log.hxx>
23 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
24 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
26 using namespace ::ooo::vba
;
27 using namespace ::com::sun::star
;
29 static uno::Reference
< container::XIndexAccess
> lcl_getAddinCollection( const uno::Reference
< XHelperInterface
>& xParent
, const uno::Reference
< uno::XComponentContext
>& xContext
)
31 XNamedObjectCollectionHelper
< word::XAddin
>::XNamedVec aAddins
;
33 // first get the autoload addins in the directory STARTUP
34 uno::Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager(), uno::UNO_SET_THROW
);
35 uno::Reference
<ucb::XSimpleFileAccess3
> xSFA(ucb::SimpleFileAccess::create(xContext
));
36 SvtPathOptions aPathOpt
;
37 // FIXME: temporary the STARTUP path is located in $OO/basic3.1/program/addin
38 const OUString
& aAddinPath
= aPathOpt
.GetAddinPath();
39 SAL_INFO("sw.vba", "lcl_getAddinCollection: " << aAddinPath
);
40 if( xSFA
->isFolder( aAddinPath
) )
42 const uno::Sequence
< OUString
> sEntries
= xSFA
->getFolderContents( aAddinPath
, false );
43 for( const OUString
& sUrl
: sEntries
)
45 if( !xSFA
->isFolder( sUrl
) && sUrl
.endsWithIgnoreAsciiCase( ".dot" ) )
47 aAddins
.push_back( uno::Reference
< word::XAddin
>( new SwVbaAddin( xParent
, xContext
, sUrl
) ) );
52 // TODO: second get the customize addins in the org.openoffice.Office.Writer/GlobalTemplateList
54 uno::Reference
< container::XIndexAccess
> xAddinsAccess( new XNamedObjectCollectionHelper
< word::XAddin
>( std::move(aAddins
) ) );
58 SwVbaAddins::SwVbaAddins( const uno::Reference
< XHelperInterface
>& xParent
, const uno::Reference
< uno::XComponentContext
> & xContext
): SwVbaAddins_BASE( xParent
, xContext
, lcl_getAddinCollection( xParent
,xContext
) )
63 SwVbaAddins::getElementType()
65 return cppu::UnoType
<word::XAddin
>::get();
67 uno::Reference
< container::XEnumeration
>
68 SwVbaAddins::createEnumeration()
70 uno::Reference
< container::XEnumerationAccess
> xEnumerationAccess( m_xIndexAccess
, uno::UNO_QUERY_THROW
);
71 return xEnumerationAccess
->createEnumeration();
75 SwVbaAddins::createCollectionObject( const css::uno::Any
& aSource
)
81 SwVbaAddins::getServiceImplName()
86 css::uno::Sequence
<OUString
>
87 SwVbaAddins::getServiceNames()
89 static uno::Sequence
< OUString
> const sNames
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */