Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _MSVBAHELPER_HXX
29 : : #define _MSVBAHELPER_HXX
30 : :
31 : : #include <sfx2/objsh.hxx>
32 : : #include <cppuhelper/implbase3.hxx>
33 : : #include <com/sun/star/lang/XInitialization.hpp>
34 : : #include <com/sun/star/lang/XServiceInfo.hpp>
35 : : #include <com/sun/star/script/vba/XVBAMacroResolver.hpp>
36 : : #include <com/sun/star/awt/KeyEvent.hpp>
37 : : #include <com/sun/star/frame/XModel.hpp>
38 : : #include "filter/msfilter/msfilterdllapi.h"
39 : : namespace ooo {
40 : : namespace vba {
41 : :
42 : : // ============================================================================
43 : :
44 : 0 : struct MSFILTER_DLLPUBLIC MacroResolvedInfo
45 : : {
46 : : SfxObjectShell* mpDocContext;
47 : : String msResolvedMacro;
48 : : bool mbFound;
49 : :
50 : 0 : inline explicit MacroResolvedInfo( SfxObjectShell* pDocContext = 0 ) : mpDocContext( pDocContext ), mbFound( false ) {}
51 : : };
52 : :
53 : : MSFILTER_DLLPUBLIC String makeMacroURL( const String& sMacroName );
54 : : MSFILTER_DLLPUBLIC ::rtl::OUString extractMacroName( const ::rtl::OUString& rMacroUrl );
55 : : MSFILTER_DLLPUBLIC ::rtl::OUString getDefaultProjectName( SfxObjectShell* pShell );
56 : : MSFILTER_DLLPUBLIC ::rtl::OUString resolveVBAMacro( SfxObjectShell* pShell, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModuleName, const ::rtl::OUString& rMacroName );
57 : : MSFILTER_DLLPUBLIC MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const ::rtl::OUString& rMacroName, bool bSearchGlobalTemplates = false );
58 : : MSFILTER_DLLPUBLIC sal_Bool executeMacro( SfxObjectShell* pShell, const String& 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 );
59 : : MSFILTER_DLLPUBLIC ::com::sun::star::awt::KeyEvent parseKeyEvent( const ::rtl::OUString& sKey ) throw (::com::sun::star::uno::RuntimeException);
60 : : MSFILTER_DLLPUBLIC void applyShortCutKeyBinding ( const ::com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxDoc, const ::com::sun::star::awt::KeyEvent& rKeyEvent, const ::rtl::OUString& sMacro ) throw (::com::sun::star::uno::RuntimeException);
61 : : // ============================================================================
62 : :
63 : : typedef ::cppu::WeakImplHelper3<
64 : : ::com::sun::star::lang::XServiceInfo,
65 : : ::com::sun::star::lang::XInitialization,
66 : : ::com::sun::star::script::vba::XVBAMacroResolver > VBAMacroResolverBase;
67 : :
68 : : class VBAMacroResolver : public VBAMacroResolverBase
69 : : {
70 : : public:
71 : : explicit VBAMacroResolver();
72 : : virtual ~VBAMacroResolver();
73 : :
74 : : // com.sun.star.lang.XServiceInfo interface -------------------------------
75 : :
76 : : virtual ::rtl::OUString SAL_CALL
77 : : getImplementationName() throw (::com::sun::star::uno::RuntimeException);
78 : :
79 : : virtual sal_Bool SAL_CALL
80 : : supportsService( const ::rtl::OUString& rService )
81 : : throw (::com::sun::star::uno::RuntimeException);
82 : :
83 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
84 : : getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
85 : :
86 : : // com.sun.star.lang.XInitialization interface ----------------------------
87 : :
88 : : virtual void SAL_CALL initialize(
89 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs )
90 : : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
91 : :
92 : : // com.sun.star.script.vba.XVBAMacroResolver interface --------------------
93 : :
94 : : virtual ::rtl::OUString SAL_CALL
95 : : resolveVBAMacroToScriptURL( const ::rtl::OUString& rVBAMacroName )
96 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
97 : :
98 : : virtual ::rtl::OUString SAL_CALL
99 : : resolveScriptURLtoVBAMacro( const ::rtl::OUString& rScriptURL )
100 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
101 : :
102 : : private:
103 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel;
104 : : SfxObjectShell* mpObjShell;
105 : : ::rtl::OUString maProjectName;
106 : : };
107 : :
108 : : // ============================================================================
109 : :
110 : : } // namespace vba
111 : : } // namespace ooo
112 : :
113 : : #endif
114 : :
115 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|