1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #include "vbaaddin.hxx" 28 #include <vbahelper/vbahelper.hxx> 29 #include <tools/diagnose_ex.h> 30 #include <tools/urlobj.hxx> 31 #include <osl/file.hxx> 32 33 using namespace ::ooo::vba; 34 using namespace ::com::sun::star; 35 36 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 ) : 37 SwVbaAddin_BASE( rParent, rContext ), msFileURL( rFileURL ), mbAutoload( bAutoload ), mbInstalled( bAutoload ) 38 { 39 } 40 41 SwVbaAddin::~SwVbaAddin() 42 { 43 } 44 45 ::rtl::OUString SAL_CALL SwVbaAddin::getName() throw (uno::RuntimeException) 46 { 47 rtl::OUString sName; 48 INetURLObject aURL( msFileURL ); 49 ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName ); 50 return sName; 51 } 52 53 void SAL_CALL 54 SwVbaAddin::setName( const rtl::OUString& ) throw ( css::uno::RuntimeException ) 55 { 56 throw uno::RuntimeException( rtl::OUString( 57 RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() ); 58 } 59 60 ::rtl::OUString SAL_CALL SwVbaAddin::getPath() throw (uno::RuntimeException) 61 { 62 INetURLObject aURL( msFileURL ); 63 aURL.CutLastName(); 64 return aURL.GetURLPath(); 65 } 66 67 ::sal_Bool SAL_CALL SwVbaAddin::getAutoload() throw (uno::RuntimeException) 68 { 69 return mbAutoload; 70 } 71 72 ::sal_Bool SAL_CALL SwVbaAddin::getInstalled() throw (uno::RuntimeException) 73 { 74 return mbInstalled; 75 } 76 77 void SAL_CALL SwVbaAddin::setInstalled( ::sal_Bool _installed ) throw (uno::RuntimeException) 78 { 79 if( _installed != mbInstalled ) 80 { 81 mbInstalled = _installed; 82 // TODO: should call AutoExec and AutoExit etc. 83 } 84 } 85 86 rtl::OUString& 87 SwVbaAddin::getServiceImplName() 88 { 89 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaAddin") ); 90 return sImplName; 91 } 92 93 uno::Sequence< rtl::OUString > 94 SwVbaAddin::getServiceNames() 95 { 96 static uno::Sequence< rtl::OUString > aServiceNames; 97 if ( aServiceNames.getLength() == 0 ) 98 { 99 aServiceNames.realloc( 1 ); 100 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Addin" ) ); 101 } 102 return aServiceNames; 103 } 104 105