LibreOffice Module sw (master)  1
vbaaddin.cxx
Go to the documentation of this file.
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/urlobj.hxx>
22 #include <osl/file.hxx>
23 
24 using namespace ::ooo::vba;
25 using namespace ::com::sun::star;
26 
27 SwVbaAddin::SwVbaAddin( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const OUString& rFileURL ) :
28  SwVbaAddin_BASE( rParent, rContext ), msFileURL( rFileURL ), mbInstalled( true )
29 {
30 }
31 
33 {
34 }
35 
36 OUString SAL_CALL SwVbaAddin::getName()
37 {
38  OUString sName;
40  ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
41  return sName;
42 }
43 
44 void SAL_CALL
45 SwVbaAddin::setName( const OUString& )
46 {
47  throw uno::RuntimeException(" Fail to set name" );
48 }
49 
50 OUString SAL_CALL SwVbaAddin::getPath()
51 {
53  aURL.CutLastName();
54  return aURL.GetURLPath();
55 }
56 
58 {
59  return true;
60 }
61 
63 {
64  return mbInstalled;
65 }
66 
67 void SAL_CALL SwVbaAddin::setInstalled( sal_Bool _installed )
68 {
69  if( bool(_installed) != mbInstalled )
70  {
71  mbInstalled = _installed;
72  // TODO: should call AutoExec and AutoExit etc.
73  }
74 }
75 
76 OUString
78 {
79  return "SwVbaAddin";
80 }
81 
82 uno::Sequence< OUString >
84 {
85  static uno::Sequence< OUString > const aServiceNames
86  {
87  "ooo.vba.word.Addin"
88  };
89  return aServiceNames;
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
URL aURL
void CutLastName()
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
Sequence< OUString > aServiceNames
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual sal_Bool SAL_CALL getAutoload() override
Definition: vbaaddin.cxx:57
SwVbaAddin(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const OUString &rFileURL)
Definition: vbaaddin.cxx:27
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaaddin.cxx:83
const char * sName
virtual OUString getServiceImplName() override
Definition: vbaaddin.cxx:77
unsigned char sal_Bool
SwMasterUsrPref & rParent
Definition: usrpref.hxx:109
virtual sal_Bool SAL_CALL getInstalled() override
Definition: vbaaddin.cxx:62
virtual void SAL_CALL setInstalled(sal_Bool _installed) override
Definition: vbaaddin.cxx:67
virtual OUString SAL_CALL getPath() override
Definition: vbaaddin.cxx:50
bool mbInstalled
Definition: vbaaddin.hxx:31
virtual OUString SAL_CALL getName() override
Definition: vbaaddin.cxx:36
virtual void SAL_CALL setName(const OUString &_name) override
Definition: vbaaddin.cxx:45
OUString msFileURL
Definition: vbaaddin.hxx:30
virtual ~SwVbaAddin() override
Definition: vbaaddin.cxx:32