Line data Source code
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 : #ifndef INCLUDED_FILTER_MSFILTER_MSVBAHELPER_HXX
20 : #define INCLUDED_FILTER_MSFILTER_MSVBAHELPER_HXX
21 :
22 : #include <sfx2/objsh.hxx>
23 : #include <cppuhelper/implbase3.hxx>
24 : #include <com/sun/star/lang/XInitialization.hpp>
25 : #include <com/sun/star/lang/XServiceInfo.hpp>
26 : #include <com/sun/star/script/vba/XVBAMacroResolver.hpp>
27 : #include <com/sun/star/awt/KeyEvent.hpp>
28 : #include <com/sun/star/frame/XModel.hpp>
29 : #include <filter/msfilter/msfilterdllapi.h>
30 : namespace ooo {
31 : namespace vba {
32 :
33 :
34 :
35 264 : struct MSFILTER_DLLPUBLIC MacroResolvedInfo
36 : {
37 : SfxObjectShell* mpDocContext;
38 : OUString msResolvedMacro;
39 : bool mbFound;
40 :
41 88 : inline explicit MacroResolvedInfo( SfxObjectShell* pDocContext = 0 ) : mpDocContext( pDocContext ), mbFound( false ) {}
42 : };
43 :
44 : MSFILTER_DLLPUBLIC OUString makeMacroURL( const OUString& sMacroName );
45 : MSFILTER_DLLPUBLIC OUString extractMacroName( const OUString& rMacroUrl );
46 : MSFILTER_DLLPUBLIC OUString getDefaultProjectName( SfxObjectShell* pShell );
47 : MSFILTER_DLLPUBLIC OUString resolveVBAMacro( SfxObjectShell* pShell, const OUString& rLibName, const OUString& rModuleName, const OUString& rMacroName );
48 : MSFILTER_DLLPUBLIC MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& rMacroName, bool bSearchGlobalTemplates = false );
49 : MSFILTER_DLLPUBLIC bool executeMacro( SfxObjectShell* pShell, const OUString& sMacroName, com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArgs, com::sun::star::uno::Any& aRet, const com::sun::star::uno::Any& aCaller );
50 : MSFILTER_DLLPUBLIC ::com::sun::star::awt::KeyEvent parseKeyEvent( const OUString& sKey ) throw (::com::sun::star::uno::RuntimeException);
51 : MSFILTER_DLLPUBLIC void applyShortCutKeyBinding ( const ::com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxDoc, const ::com::sun::star::awt::KeyEvent& rKeyEvent, const OUString& sMacro ) throw (::com::sun::star::uno::RuntimeException);
52 :
53 :
54 : typedef ::cppu::WeakImplHelper3<
55 : ::com::sun::star::lang::XServiceInfo,
56 : ::com::sun::star::lang::XInitialization,
57 : ::com::sun::star::script::vba::XVBAMacroResolver > VBAMacroResolverBase;
58 :
59 : class VBAMacroResolver : public VBAMacroResolverBase
60 : {
61 : public:
62 : explicit VBAMacroResolver();
63 : virtual ~VBAMacroResolver();
64 :
65 : // com.sun.star.lang.XServiceInfo interface -------------------------------
66 :
67 : virtual OUString SAL_CALL
68 : getImplementationName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 :
70 : virtual sal_Bool SAL_CALL
71 : supportsService( const OUString& rService )
72 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 :
74 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
75 : getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 :
77 : // com.sun.star.lang.XInitialization interface ----------------------------
78 :
79 : virtual void SAL_CALL initialize(
80 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs )
81 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 :
83 : // com.sun.star.script.vba.XVBAMacroResolver interface --------------------
84 :
85 : virtual OUString SAL_CALL
86 : resolveVBAMacroToScriptURL( const OUString& rVBAMacroName )
87 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : virtual OUString SAL_CALL
90 : resolveScriptURLtoVBAMacro( const OUString& rScriptURL )
91 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 :
93 : private:
94 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel;
95 : SfxObjectShell* mpObjShell;
96 : OUString maProjectName;
97 : };
98 :
99 : OUString SAL_CALL VBAMacroResolver_getImplementationName();
100 :
101 : css::uno::Sequence<OUString> SAL_CALL
102 : VBAMacroResolver_getSupportedServiceNames();
103 :
104 : css::uno::Reference<css::uno::XInterface> SAL_CALL
105 : VBAMacroResolver_createInstance(
106 : css::uno::Reference<css::uno::XComponentContext > const & rxContext)
107 : throw (css::uno::Exception);
108 :
109 : } // namespace vba
110 : } // namespace ooo
111 :
112 : #endif
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|