bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / filter / msfilter / msvbahelper.hxx
bloba22f97aadd521d152aafb2f2a13888a344ca9879
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_FILTER_MSFILTER_MSVBAHELPER_HXX
20 #define INCLUDED_FILTER_MSFILTER_MSVBAHELPER_HXX
22 #include <exception>
24 #include <com/sun/star/awt/KeyEvent.hpp>
25 #include <com/sun/star/lang/IllegalArgumentException.hpp>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/script/vba/XVBAMacroResolver.hpp>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <com/sun/star/uno/Exception.hpp>
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <com/sun/star/uno/RuntimeException.hpp>
33 #include <com/sun/star/uno/Sequence.hxx>
34 #include <cppuhelper/implbase.hxx>
35 #include <filter/msfilter/msfilterdllapi.h>
36 #include <rtl/ustring.hxx>
37 #include <sal/types.h>
39 namespace com { namespace sun { namespace star {
40 namespace frame { class XModel; }
41 namespace uno { class XComponentContext; }
42 namespace uno { class XInterface; }
43 } } }
45 class SfxObjectShell;
47 namespace ooo {
48 namespace vba {
51 struct MSFILTER_DLLPUBLIC MacroResolvedInfo
53 SfxObjectShell* mpDocContext;
54 OUString msResolvedMacro;
55 bool mbFound;
57 explicit MacroResolvedInfo( SfxObjectShell* pDocContext = nullptr ) : mpDocContext( pDocContext ), mbFound( false ) {}
60 MSFILTER_DLLPUBLIC OUString makeMacroURL( const OUString& sMacroName );
61 MSFILTER_DLLPUBLIC OUString extractMacroName( const OUString& rMacroUrl );
62 MSFILTER_DLLPUBLIC OUString getDefaultProjectName( SfxObjectShell const * pShell );
63 MSFILTER_DLLPUBLIC OUString resolveVBAMacro( SfxObjectShell const * pShell, const OUString& rLibName, const OUString& rModuleName, const OUString& rMacroName );
64 MSFILTER_DLLPUBLIC MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& rMacroName, bool bSearchGlobalTemplates = false );
65 MSFILTER_DLLPUBLIC bool executeMacro( SfxObjectShell* pShell, const OUString& sMacroName, css::uno::Sequence< css::uno::Any >& aArgs, css::uno::Any& aRet, const css::uno::Any& aCaller );
66 /// @throws css::uno::RuntimeException
67 MSFILTER_DLLPUBLIC css::awt::KeyEvent parseKeyEvent( const OUString& sKey );
68 /// @throws css::uno::RuntimeException
69 MSFILTER_DLLPUBLIC void applyShortCutKeyBinding ( const css::uno::Reference< css::frame::XModel >& rxDoc, const css::awt::KeyEvent& rKeyEvent, const OUString& sMacro );
72 typedef ::cppu::WeakImplHelper<
73 css::lang::XServiceInfo,
74 css::lang::XInitialization,
75 css::script::vba::XVBAMacroResolver > VBAMacroResolverBase;
77 class VBAMacroResolver : public VBAMacroResolverBase
79 public:
80 explicit VBAMacroResolver();
81 virtual ~VBAMacroResolver() override;
83 // com.sun.star.lang.XServiceInfo interface -------------------------------
85 virtual OUString SAL_CALL
86 getImplementationName() override;
88 virtual sal_Bool SAL_CALL
89 supportsService( const OUString& rService ) override;
91 virtual css::uno::Sequence< OUString > SAL_CALL
92 getSupportedServiceNames() override;
94 // com.sun.star.lang.XInitialization interface ----------------------------
96 virtual void SAL_CALL initialize(
97 const css::uno::Sequence< css::uno::Any >& rArgs ) override;
99 // com.sun.star.script.vba.XVBAMacroResolver interface --------------------
101 virtual OUString SAL_CALL
102 resolveVBAMacroToScriptURL( const OUString& rVBAMacroName ) override;
104 virtual OUString SAL_CALL
105 resolveScriptURLtoVBAMacro( const OUString& rScriptURL ) override;
107 private:
108 css::uno::Reference< css::frame::XModel > mxModel;
109 SfxObjectShell* mpObjShell;
110 OUString maProjectName;
113 OUString VBAMacroResolver_getImplementationName();
115 css::uno::Sequence<OUString>
116 VBAMacroResolver_getSupportedServiceNames();
118 /// @throws css::uno::Exception
119 css::uno::Reference<css::uno::XInterface>
120 VBAMacroResolver_createInstance(
121 css::uno::Reference<css::uno::XComponentContext > const & rxContext);
123 } // namespace vba
124 } // namespace ooo
126 #endif
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */