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 "vbaaddin.hxx"
20 : #include <vbahelper/vbahelper.hxx>
21 : #include <tools/diagnose_ex.h>
22 : #include <tools/urlobj.hxx>
23 : #include <osl/file.hxx>
24 :
25 : using namespace ::ooo::vba;
26 : using namespace ::com::sun::star;
27 :
28 0 : SwVbaAddin::SwVbaAddin( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const OUString& rFileURL, sal_Bool bAutoload ) throw ( uno::RuntimeException ) :
29 0 : SwVbaAddin_BASE( rParent, rContext ), msFileURL( rFileURL ), mbAutoload( bAutoload ), mbInstalled( bAutoload )
30 : {
31 0 : }
32 :
33 0 : SwVbaAddin::~SwVbaAddin()
34 : {
35 0 : }
36 :
37 0 : OUString SAL_CALL SwVbaAddin::getName() throw (uno::RuntimeException, std::exception)
38 : {
39 0 : OUString sName;
40 0 : INetURLObject aURL( msFileURL );
41 0 : ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
42 0 : return sName;
43 : }
44 :
45 : void SAL_CALL
46 0 : SwVbaAddin::setName( const OUString& ) throw ( css::uno::RuntimeException, std::exception )
47 : {
48 0 : throw uno::RuntimeException(" Fail to set name", uno::Reference< uno::XInterface >() );
49 : }
50 :
51 0 : OUString SAL_CALL SwVbaAddin::getPath() throw (uno::RuntimeException, std::exception)
52 : {
53 0 : INetURLObject aURL( msFileURL );
54 0 : aURL.CutLastName();
55 0 : return aURL.GetURLPath();
56 : }
57 :
58 0 : sal_Bool SAL_CALL SwVbaAddin::getAutoload() throw (uno::RuntimeException, std::exception)
59 : {
60 0 : return mbAutoload;
61 : }
62 :
63 0 : sal_Bool SAL_CALL SwVbaAddin::getInstalled() throw (uno::RuntimeException, std::exception)
64 : {
65 0 : return mbInstalled;
66 : }
67 :
68 0 : void SAL_CALL SwVbaAddin::setInstalled( sal_Bool _installed ) throw (uno::RuntimeException, std::exception)
69 : {
70 0 : if( _installed != mbInstalled )
71 : {
72 0 : mbInstalled = _installed;
73 : // TODO: should call AutoExec and AutoExit etc.
74 : }
75 0 : }
76 :
77 : OUString
78 0 : SwVbaAddin::getServiceImplName()
79 : {
80 0 : return OUString("SwVbaAddin");
81 : }
82 :
83 : uno::Sequence< OUString >
84 0 : SwVbaAddin::getServiceNames()
85 : {
86 0 : static uno::Sequence< OUString > aServiceNames;
87 0 : if ( aServiceNames.getLength() == 0 )
88 : {
89 0 : aServiceNames.realloc( 1 );
90 0 : aServiceNames[ 0 ] = "ooo.vba.word.Addin";
91 : }
92 0 : return aServiceNames;
93 : }
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|