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