xref: /trunk/main/scripting/source/protocolhandler/scripthandler.hxx (revision 45c5a00162811bd03b87fcb4fe9996782f2b59ec)
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 _FRAMEWORK_SCRIPT_SCRIPTHANDLER_HXX
25 #define _FRAMEWORK_SCRIPT_SCRIPTHANDLER_HXX
26 
27 #include <com/sun/star/uno/RuntimeException.hpp>
28 #include <com/sun/star/frame/XDispatchProvider.hpp>
29 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/lang/XInitialization.hpp>
32 #include <cppuhelper/implbase4.hxx>
33 #include <com/sun/star/script/provider/XScriptProvider.hpp>
34 
35 namespace rtl
36 {
37 class OUString;
38 }
39 
40 namespace com { namespace sun { namespace star {
41 
42     namespace document {
43         class XScriptInvocationContext;
44     }
45     namespace uno {
46         class Any;
47         class XComponentContext;
48     }
49     namespace lang {
50         class XMultiServiceFactory;
51         class XSingleServiceFactory;
52     }
53     namespace frame {
54         class XFrame;
55         class XModel;
56         class XDispatch;
57         class XNotifyingDispatch;
58         class XDispatchResultListener;
59         struct DispatchDescriptor;
60     }
61     namespace beans {
62         struct PropertyValue;
63     }
64     namespace util {
65         struct URL;
66     }
67 } } }
68 
69 namespace scripting_protocolhandler
70 {
71 
72 namespace css = ::com::sun::star;
73 
74 class ScriptProtocolHandler :
75 public ::cppu::WeakImplHelper4< css::frame::XDispatchProvider,
76     css::frame::XNotifyingDispatch, css::lang::XServiceInfo, css::lang::XInitialization >
77 {
78 private:
79     bool m_bInitialised;
80     css::uno::Reference < css::uno::XComponentContext >             m_xCtx;
81     css::uno::Reference < css::frame::XFrame >                      m_xFrame;
82     css::uno::Reference < css::script::provider::XScriptProvider >  m_xScriptProvider;
83     css::uno::Reference< css::document::XScriptInvocationContext >  m_xScriptInvocation;
84 
85     void createScriptProvider();
86     bool getScriptInvocation();
87 
88 public:
89     ScriptProtocolHandler( const css::uno::Reference <
90         css::uno::XComponentContext >& xCtx );
91     virtual ~ScriptProtocolHandler();
92 
93     /* XServiceInfo */
94     virtual ::rtl::OUString SAL_CALL getImplementationName();
95     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName );
96     virtual css::uno::Sequence < ::rtl::OUString > SAL_CALL getSupportedServiceNames();
97 
98     /* Helper for XServiceInfo */
99     static css::uno::Sequence < ::rtl::OUString > impl_getStaticSupportedServiceNames();
100     static ::rtl::OUString impl_getStaticImplementationName();
101 
102     /* Helper for registry */
103     static css::uno::Reference < css::uno::XInterface > SAL_CALL
104     impl_createInstance(
105         const css::uno::Reference< css::uno::XComponentContext >& xCtx );
106 
107     /* Implementation for XDispatchProvider */
108     virtual css::uno::Reference < css::frame::XDispatch > SAL_CALL
109     queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& sTargetFrameName,
110                    sal_Int32 eSearchFlags ) ;
111     virtual css::uno::Sequence< css::uno::Reference < css::frame::XDispatch > > SAL_CALL
112     queryDispatches(
113         const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescriptor );
114 
115     /* Implementation for X(Notifying)Dispatch */
116     virtual void SAL_CALL dispatchWithNotification(
117     const css::util::URL& aURL,
118     const css::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs,
119     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& Listener );
120     virtual void SAL_CALL dispatch(
121         const css::util::URL& aURL,
122         const css::uno::Sequence< css::beans::PropertyValue >& lArgs );
123     virtual void SAL_CALL addStatusListener(
124         const css::uno::Reference< css::frame::XStatusListener >& xControl,
125         const css::util::URL& aURL );
126     virtual void SAL_CALL removeStatusListener(
127         const css::uno::Reference< css::frame::XStatusListener >& xControl,
128         const css::util::URL& aURL );
129 
130     /* Implementation for XInitialization */
131     virtual void SAL_CALL initialize(
132         const css::uno::Sequence < css::uno::Any >& aArguments );
133 };
134 
135 }
136 #endif
137