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 :
20 : #ifndef INCLUDED_SCRIPTING_SOURCE_DLGPROV_DLGPROV_HXX
21 : #define INCLUDED_SCRIPTING_SOURCE_DLGPROV_DLGPROV_HXX
22 :
23 : #include <com/sun/star/awt/XControl.hpp>
24 : #include <com/sun/star/awt/XDialog.hpp>
25 : #include <com/sun/star/awt/XDialogProvider2.hpp>
26 : #include <com/sun/star/awt/XContainerWindowProvider.hpp>
27 : #include <com/sun/star/awt/XUnoControlDialog.hpp>
28 : #include <com/sun/star/beans/XIntrospectionAccess.hpp>
29 : #include <com/sun/star/container/XNameContainer.hpp>
30 : #include <com/sun/star/frame/XModel.hpp>
31 : #include <com/sun/star/lang/XServiceInfo.hpp>
32 : #include <com/sun/star/lang/XInitialization.hpp>
33 : #include <com/sun/star/io/XInputStream.hpp>
34 : #include <com/sun/star/resource/XStringResourceManager.hpp>
35 : #include <com/sun/star/script/XScriptEventsAttacher.hpp>
36 : #include <com/sun/star/uno/XComponentContext.hpp>
37 :
38 : #include <cppuhelper/implbase4.hxx>
39 : #include <osl/mutex.hxx>
40 : #include <memory>
41 :
42 :
43 : namespace dlgprov
44 : {
45 :
46 :
47 :
48 : // mutex
49 :
50 :
51 : ::osl::Mutex& getMutex();
52 :
53 :
54 :
55 : // class DialogProviderImpl
56 :
57 : ::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);
58 : ::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 OUString& i_sURL);
59 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel(
60 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,
61 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
62 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel,
63 : const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager,
64 : const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
65 :
66 : typedef ::cppu::WeakImplHelper4<
67 : ::com::sun::star::lang::XServiceInfo,
68 : ::com::sun::star::lang::XInitialization,
69 : ::com::sun::star::awt::XDialogProvider2,
70 : ::com::sun::star::awt::XContainerWindowProvider > DialogProviderImpl_BASE;
71 :
72 : class DialogProviderImpl : public DialogProviderImpl_BASE
73 : {
74 : private:
75 0 : struct BasicRTLParams
76 : {
77 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInput;
78 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > mxDlgLib;
79 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > mxBasicRTLListener;
80 : };
81 : std::unique_ptr< BasicRTLParams > m_BasicInfo;
82 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
83 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
84 :
85 : OUString msDialogLibName;
86 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModel( const OUString& sURL );
87 :
88 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialog > createDialogControl(
89 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxDialogModel,
90 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent );
91 :
92 : void attachControlEvents( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxControlContainer,
93 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler,
94 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& rxIntrospectionAccess,
95 : bool bDialogProviderMode );
96 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > inspectHandler(
97 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler );
98 : // helper methods
99 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createDialogModel(
100 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
101 : const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager,
102 : const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
103 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception );
104 :
105 : // XDialogProvider / XDialogProvider2 impl method
106 : ::com::sun::star::uno::Reference < ::com::sun::star::awt::XControl > SAL_CALL createDialogImpl(
107 : const OUString& URL,
108 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler,
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent,
110 : bool bDialogProviderMode )
111 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
112 :
113 : public:
114 : DialogProviderImpl(
115 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
116 : virtual ~DialogProviderImpl();
117 :
118 : // XServiceInfo
119 : virtual OUString SAL_CALL getImplementationName( )
120 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
122 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
124 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 :
126 : // XInitialization
127 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
128 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 :
130 : // XDialogProvider
131 : virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialog(
132 : const OUString& URL )
133 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 :
135 : // XDialogProvider2
136 : virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithHandler(
137 : const OUString& URL,
138 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler )
139 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 :
141 : virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithArguments(
142 : const OUString& URL,
143 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
144 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 :
146 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createContainerWindow(
147 : const OUString& URL, const OUString& WindowType,
148 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent,
149 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler )
150 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
151 : };
152 :
153 :
154 : } // namespace dlgprov
155 :
156 :
157 :
158 : // component helper namespace
159 : namespace comp_DialogModelProvider {
160 :
161 : // component and service helper functions:
162 : OUString SAL_CALL _getImplementationName();
163 : css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames();
164 :
165 : } // namespace comp_DialogModelProvider
166 :
167 :
168 :
169 :
170 : #endif // INCLUDED_SCRIPTING_SOURCE_DLGPROV_DLGPROV_HXX
171 :
172 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|