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 rtl::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 : ::rtl::OUString SAL_CALL SwVbaAddin::getName() throw (uno::RuntimeException)
38 : {
39 0 : rtl::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 rtl::OUString& ) throw ( css::uno::RuntimeException )
47 : {
48 : throw uno::RuntimeException( rtl::OUString(
49 0 : RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() );
50 : }
51 :
52 0 : ::rtl::OUString SAL_CALL SwVbaAddin::getPath() throw (uno::RuntimeException)
53 : {
54 0 : INetURLObject aURL( msFileURL );
55 0 : aURL.CutLastName();
56 0 : return aURL.GetURLPath();
57 : }
58 :
59 0 : ::sal_Bool SAL_CALL SwVbaAddin::getAutoload() throw (uno::RuntimeException)
60 : {
61 0 : return mbAutoload;
62 : }
63 :
64 0 : ::sal_Bool SAL_CALL SwVbaAddin::getInstalled() throw (uno::RuntimeException)
65 : {
66 0 : return mbInstalled;
67 : }
68 :
69 0 : void SAL_CALL SwVbaAddin::setInstalled( ::sal_Bool _installed ) throw (uno::RuntimeException)
70 : {
71 0 : if( _installed != mbInstalled )
72 : {
73 0 : mbInstalled = _installed;
74 : // TODO: should call AutoExec and AutoExit etc.
75 : }
76 0 : }
77 :
78 : rtl::OUString
79 0 : SwVbaAddin::getServiceImplName()
80 : {
81 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaAddin"));
82 : }
83 :
84 : uno::Sequence< rtl::OUString >
85 0 : SwVbaAddin::getServiceNames()
86 : {
87 0 : static uno::Sequence< rtl::OUString > aServiceNames;
88 0 : if ( aServiceNames.getLength() == 0 )
89 : {
90 0 : aServiceNames.realloc( 1 );
91 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Addin" ) );
92 : }
93 0 : return aServiceNames;
94 : }
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|