update dev300-m58
[ooovba.git] / sw / source / ui / vba / vbaaddin.cxx
blob559643fd6bd7785dbb6a299235a2990f0222d91a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile:
10 * $Revision:
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "vbaaddin.hxx"
31 #include <vbahelper/vbahelper.hxx>
32 #include <tools/diagnose_ex.h>
33 #include <tools/urlobj.hxx>
34 #include <osl/file.hxx>
36 using namespace ::ooo::vba;
37 using namespace ::com::sun::star;
39 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 ) :
40 SwVbaAddin_BASE( rParent, rContext ), msFileURL( rFileURL ), mbAutoload( bAutoload ), mbInstalled( bAutoload )
44 SwVbaAddin::~SwVbaAddin()
48 ::rtl::OUString SAL_CALL SwVbaAddin::getName() throw (uno::RuntimeException)
50 rtl::OUString sName;
51 INetURLObject aURL( msFileURL );
52 ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
53 return sName;
56 void SAL_CALL
57 SwVbaAddin::setName( const rtl::OUString& ) throw ( css::uno::RuntimeException )
59 throw uno::RuntimeException( rtl::OUString(
60 RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() );
63 ::rtl::OUString SAL_CALL SwVbaAddin::getPath() throw (uno::RuntimeException)
65 INetURLObject aURL( msFileURL );
66 aURL.CutLastName();
67 return aURL.GetURLPath();
70 ::sal_Bool SAL_CALL SwVbaAddin::getAutoload() throw (uno::RuntimeException)
72 return mbAutoload;
75 ::sal_Bool SAL_CALL SwVbaAddin::getInstalled() throw (uno::RuntimeException)
77 return mbInstalled;
80 void SAL_CALL SwVbaAddin::setInstalled( ::sal_Bool _installed ) throw (uno::RuntimeException)
82 if( _installed != mbInstalled )
84 mbInstalled = _installed;
85 // TODO: should call AutoExec and AutoExit etc.
89 rtl::OUString&
90 SwVbaAddin::getServiceImplName()
92 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaAddin") );
93 return sImplName;
96 uno::Sequence< rtl::OUString >
97 SwVbaAddin::getServiceNames()
99 static uno::Sequence< rtl::OUString > aServiceNames;
100 if ( aServiceNames.getLength() == 0 )
102 aServiceNames.realloc( 1 );
103 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Addin" ) );
105 return aServiceNames;