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