1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski #ifndef SCRIPTING_DLGPROV_HXX
25*b1cdbd2cSJim Jagielski #define SCRIPTING_DLGPROV_HXX
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski #include <com/sun/star/awt/XControl.hpp>
28*b1cdbd2cSJim Jagielski #include <com/sun/star/awt/XDialog.hpp>
29*b1cdbd2cSJim Jagielski #include <com/sun/star/awt/XDialogProvider2.hpp>
30*b1cdbd2cSJim Jagielski #include <com/sun/star/awt/XContainerWindowProvider.hpp>
31*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XModel.hpp>
32*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XServiceInfo.hpp>
33*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XInitialization.hpp>
34*b1cdbd2cSJim Jagielski #include <com/sun/star/script/XScriptEventsAttacher.hpp>
35*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/XComponentContext.hpp>
36*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/XIntrospectionAccess.hpp>
37*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XNameContainer.hpp>
38*b1cdbd2cSJim Jagielski #include <com/sun/star/io/XInputStream.hpp>
39*b1cdbd2cSJim Jagielski #include <com/sun/star/resource/XStringResourceManager.hpp>
40*b1cdbd2cSJim Jagielski 
41*b1cdbd2cSJim Jagielski #include <cppuhelper/implbase4.hxx>
42*b1cdbd2cSJim Jagielski #include <osl/mutex.hxx>
43*b1cdbd2cSJim Jagielski #include <memory>
44*b1cdbd2cSJim Jagielski 
45*b1cdbd2cSJim Jagielski //.........................................................................
46*b1cdbd2cSJim Jagielski namespace dlgprov
47*b1cdbd2cSJim Jagielski {
48*b1cdbd2cSJim Jagielski //.........................................................................
49*b1cdbd2cSJim Jagielski 
50*b1cdbd2cSJim Jagielski     // =============================================================================
51*b1cdbd2cSJim Jagielski     // mutex
52*b1cdbd2cSJim Jagielski     // =============================================================================
53*b1cdbd2cSJim Jagielski 
54*b1cdbd2cSJim Jagielski     ::osl::Mutex& getMutex();
55*b1cdbd2cSJim Jagielski 
56*b1cdbd2cSJim Jagielski 
57*b1cdbd2cSJim Jagielski     // =============================================================================
58*b1cdbd2cSJim Jagielski     // class DialogProviderImpl
59*b1cdbd2cSJim Jagielski     // =============================================================================
60*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext);
61*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const ::rtl::OUString& i_sURL);
62*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel(
63*b1cdbd2cSJim Jagielski                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,
64*b1cdbd2cSJim Jagielski 				const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
65*b1cdbd2cSJim Jagielski 				const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager,
66*b1cdbd2cSJim Jagielski 				const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
67*b1cdbd2cSJim Jagielski 
68*b1cdbd2cSJim Jagielski     typedef ::cppu::WeakImplHelper4<
69*b1cdbd2cSJim Jagielski         ::com::sun::star::lang::XServiceInfo,
70*b1cdbd2cSJim Jagielski         ::com::sun::star::lang::XInitialization,
71*b1cdbd2cSJim Jagielski         ::com::sun::star::awt::XDialogProvider2,
72*b1cdbd2cSJim Jagielski         ::com::sun::star::awt::XContainerWindowProvider > DialogProviderImpl_BASE;
73*b1cdbd2cSJim Jagielski 
74*b1cdbd2cSJim Jagielski     class DialogProviderImpl : public DialogProviderImpl_BASE
75*b1cdbd2cSJim Jagielski     {
76*b1cdbd2cSJim Jagielski     private:
77*b1cdbd2cSJim Jagielski         struct BasicRTLParams
78*b1cdbd2cSJim Jagielski         {
79*b1cdbd2cSJim Jagielski              ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInput;
80*b1cdbd2cSJim Jagielski              ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > mxDlgLib;
81*b1cdbd2cSJim Jagielski              ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > mxBasicRTLListener;
82*b1cdbd2cSJim Jagielski         };
83*b1cdbd2cSJim Jagielski         std::auto_ptr< BasicRTLParams > m_BasicInfo;
84*b1cdbd2cSJim Jagielski         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
85*b1cdbd2cSJim Jagielski         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >                 m_xModel;
86*b1cdbd2cSJim Jagielski 
87*b1cdbd2cSJim Jagielski 
88*b1cdbd2cSJim Jagielski         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModel( const ::rtl::OUString& sURL );
89*b1cdbd2cSJim Jagielski 
90*b1cdbd2cSJim Jagielski         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > createDialogControl(
91*b1cdbd2cSJim Jagielski             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxDialogModel,
92*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent );
93*b1cdbd2cSJim Jagielski 
94*b1cdbd2cSJim Jagielski         void attachControlEvents( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxControlContainer,
95*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler,
96*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& rxIntrospectionAccess,
97*b1cdbd2cSJim Jagielski 			bool bDialogProviderMode );
98*b1cdbd2cSJim Jagielski 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > inspectHandler(
99*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler );
100*b1cdbd2cSJim Jagielski 	// helper methods
101*b1cdbd2cSJim Jagielski 			::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createControlModel() throw ( ::com::sun::star::uno::Exception );
102*b1cdbd2cSJim Jagielski 			::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createDialogModel(
103*b1cdbd2cSJim Jagielski 				const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
104*b1cdbd2cSJim Jagielski 				const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager,
105*b1cdbd2cSJim Jagielski 				const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
106*b1cdbd2cSJim Jagielski 			::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception );
107*b1cdbd2cSJim Jagielski 
108*b1cdbd2cSJim Jagielski         // XDialogProvider / XDialogProvider2 impl method
109*b1cdbd2cSJim Jagielski 	    virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XControl > SAL_CALL createDialogImpl(
110*b1cdbd2cSJim Jagielski 			const ::rtl::OUString& URL,
111*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler,
112*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent,
113*b1cdbd2cSJim Jagielski 			bool bDialogProviderMode )
114*b1cdbd2cSJim Jagielski 				throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
115*b1cdbd2cSJim Jagielski 
116*b1cdbd2cSJim Jagielski     public:
117*b1cdbd2cSJim Jagielski         DialogProviderImpl(
118*b1cdbd2cSJim Jagielski             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
119*b1cdbd2cSJim Jagielski         virtual ~DialogProviderImpl();
120*b1cdbd2cSJim Jagielski 
121*b1cdbd2cSJim Jagielski         // XServiceInfo
122*b1cdbd2cSJim Jagielski         virtual ::rtl::OUString SAL_CALL getImplementationName(  )
123*b1cdbd2cSJim Jagielski             throw (::com::sun::star::uno::RuntimeException);
124*b1cdbd2cSJim Jagielski         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
125*b1cdbd2cSJim Jagielski             throw (::com::sun::star::uno::RuntimeException);
126*b1cdbd2cSJim Jagielski         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
127*b1cdbd2cSJim Jagielski             throw (::com::sun::star::uno::RuntimeException);
128*b1cdbd2cSJim Jagielski 
129*b1cdbd2cSJim Jagielski         // XInitialization
130*b1cdbd2cSJim Jagielski         virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
131*b1cdbd2cSJim Jagielski             throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
132*b1cdbd2cSJim Jagielski 
133*b1cdbd2cSJim Jagielski         // XDialogProvider
134*b1cdbd2cSJim Jagielski         virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialog(
135*b1cdbd2cSJim Jagielski             const ::rtl::OUString& URL )
136*b1cdbd2cSJim Jagielski             throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
137*b1cdbd2cSJim Jagielski 
138*b1cdbd2cSJim Jagielski         // XDialogProvider2
139*b1cdbd2cSJim Jagielski 	    virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithHandler(
140*b1cdbd2cSJim Jagielski 			const ::rtl::OUString& URL,
141*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler )
142*b1cdbd2cSJim Jagielski             throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
143*b1cdbd2cSJim Jagielski 
144*b1cdbd2cSJim Jagielski         virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithArguments(
145*b1cdbd2cSJim Jagielski 			const ::rtl::OUString& URL,
146*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
147*b1cdbd2cSJim Jagielski 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
148*b1cdbd2cSJim Jagielski 
149*b1cdbd2cSJim Jagielski         virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createContainerWindow(
150*b1cdbd2cSJim Jagielski 			const ::rtl::OUString& URL, const ::rtl::OUString& WindowType,
151*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent,
152*b1cdbd2cSJim Jagielski 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler )
153*b1cdbd2cSJim Jagielski 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
154*b1cdbd2cSJim Jagielski      };
155*b1cdbd2cSJim Jagielski 
156*b1cdbd2cSJim Jagielski //.........................................................................
157*b1cdbd2cSJim Jagielski }	// namespace dlgprov
158*b1cdbd2cSJim Jagielski //.........................................................................
159*b1cdbd2cSJim Jagielski 
160*b1cdbd2cSJim Jagielski #endif // SCRIPTING_DLGPROV_HXX
161