1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_VBAEVENTSHELPER_HXX
25 #define SC_VBAEVENTSHELPER_HXX
26 
27 #include <rtl/ref.hxx>
28 #include <vbahelper/vbaeventshelperbase.hxx>
29 #include "excelvbahelper.hxx"
30 #include "rangelst.hxx"
31 
32 class ScVbaEventListener;
33 
34 // ============================================================================
35 
36 class ScVbaEventsHelper : public VbaEventsHelperBase
37 {
38 public:
39     ScVbaEventsHelper(
40         const css::uno::Sequence< css::uno::Any >& rArgs,
41         const css::uno::Reference< css::uno::XComponentContext >& rxContext );
42     virtual ~ScVbaEventsHelper();
43 
44     virtual void SAL_CALL notifyEvent( const css::document::EventObject& rEvent ) throw (css::uno::RuntimeException);
45 
46 protected:
47     virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException);
48     virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException);
49     virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bCancel ) throw (css::uno::RuntimeException);
50     virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException);
51 
52 private:
53     /** Checks if selection has been changed compared to selection of last call.
54         @return true, if the selection has been changed. */
55     bool isSelectionChanged( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
56 
57     /** Creates a VBA Worksheet object (the argument must contain a sheet index). */
58     css::uno::Any createWorksheet( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
59     /** Creates a VBA Range object (the argument must contain a UNO range or UNO range list). */
60     css::uno::Any createRange( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
61     /** Creates a VBA Hyperlink object (the argument must contain a UNO cell). */
62     css::uno::Any createHyperlink( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
63     /** Creates a VBA Window object (the argument must contain a model controller). */
64     css::uno::Any createWindow( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
65 
66 private:
67     ::rtl::Reference< ScVbaEventListener > mxListener;
68     css::uno::Any maOldSelection;
69     ScDocShell* mpDocShell;
70     ScDocument* mpDoc;
71     bool mbOpened;
72 };
73 
74 // ============================================================================
75 
76 #endif
77