Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / scripting / source / dlgprov / dlgprov.hxx
blob0a5d4483a7bf646c9252afbd084fbb5a39f2942b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <com/sun/star/awt/XControl.hpp>
23 #include <com/sun/star/awt/XDialog.hpp>
24 #include <com/sun/star/awt/XDialogProvider2.hpp>
25 #include <com/sun/star/awt/XContainerWindowProvider.hpp>
26 #include <com/sun/star/awt/XUnoControlDialog.hpp>
27 #include <com/sun/star/beans/XIntrospectionAccess.hpp>
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/frame/XModel.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/lang/XInitialization.hpp>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #include <com/sun/star/resource/XStringResourceManager.hpp>
34 #include <com/sun/star/script/XScriptListener.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <cppuhelper/implbase.hxx>
38 #include <osl/mutex.hxx>
39 #include <memory>
42 namespace dlgprov
46 // mutex
49 ::osl::Mutex& getMutex();
53 css::uno::Reference< css::container::XNameContainer > lcl_createControlModel(const css::uno::Reference< css::uno::XComponentContext >& i_xContext);
54 css::uno::Reference< css::resource::XStringResourceManager > lcl_getStringResourceManager(const css::uno::Reference< css::uno::XComponentContext >& i_xContext, std::u16string_view i_sURL);
55 /// @throws css::uno::Exception
56 css::uno::Reference< css::container::XNameContainer > lcl_createDialogModel(
57 const css::uno::Reference< css::uno::XComponentContext >& i_xContext,
58 const css::uno::Reference< css::io::XInputStream >& xInput,
59 const css::uno::Reference< css::frame::XModel >& xModel,
60 const css::uno::Reference< css::resource::XStringResourceManager >& xStringResourceManager,
61 const css::uno::Any &aDialogSourceURL);
63 typedef ::cppu::WeakImplHelper<
64 css::lang::XServiceInfo,
65 css::lang::XInitialization,
66 css::awt::XDialogProvider2,
67 css::awt::XContainerWindowProvider > DialogProviderImpl_BASE;
69 class DialogProviderImpl : public DialogProviderImpl_BASE
71 private:
72 struct BasicRTLParams
74 css::uno::Reference< css::io::XInputStream > mxInput;
75 css::uno::Reference< css::container::XNameContainer > mxDlgLib;
76 css::uno::Reference< css::script::XScriptListener > mxBasicRTLListener;
78 std::unique_ptr< BasicRTLParams > m_BasicInfo;
79 css::uno::Reference< css::uno::XComponentContext > m_xContext;
80 css::uno::Reference< css::frame::XModel > m_xModel;
82 OUString msDialogLibName;
83 css::uno::Reference< css::awt::XControlModel > createDialogModel( const OUString& sURL );
85 css::uno::Reference< css::awt::XUnoControlDialog > createDialogControl(
86 const css::uno::Reference< css::awt::XControlModel >& rxDialogModel,
87 const css::uno::Reference< css::awt::XWindowPeer >& xParent );
89 void attachControlEvents( const css::uno::Reference< css::awt::XControl >& rxControlContainer,
90 const css::uno::Reference< css::uno::XInterface >& rxHandler,
91 const css::uno::Reference< css::beans::XIntrospectionAccess >& rxIntrospectionAccess,
92 bool bDialogProviderMode );
93 css::uno::Reference< css::beans::XIntrospectionAccess > inspectHandler(
94 const css::uno::Reference< css::uno::XInterface >& rxHandler );
95 // helper methods
96 /// @throws css::uno::Exception
97 css::uno::Reference< css::container::XNameContainer > createDialogModel(
98 const css::uno::Reference< css::io::XInputStream >& xInput,
99 const css::uno::Reference< css::resource::XStringResourceManager >& xStringResourceManager,
100 const css::uno::Any &aDialogSourceURL);
101 /// @throws css::uno::Exception
102 css::uno::Reference< css::awt::XControlModel > createDialogModelForBasic();
104 // XDialogProvider / XDialogProvider2 impl method
105 /// @throws css::lang::IllegalArgumentException
106 /// @throws css::uno::RuntimeException
107 css::uno::Reference < css::awt::XControl > createDialogImpl(
108 const OUString& URL,
109 const css::uno::Reference< css::uno::XInterface >& xHandler,
110 const css::uno::Reference< css::awt::XWindowPeer >& xParent,
111 bool bDialogProviderMode );
113 public:
114 explicit DialogProviderImpl(
115 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
116 virtual ~DialogProviderImpl() override;
118 // XServiceInfo
119 virtual OUString SAL_CALL getImplementationName( ) override;
120 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
121 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
123 // XInitialization
124 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
126 // XDialogProvider
127 virtual css::uno::Reference < css::awt::XDialog > SAL_CALL createDialog(
128 const OUString& URL ) override;
130 // XDialogProvider2
131 virtual css::uno::Reference < css::awt::XDialog > SAL_CALL createDialogWithHandler(
132 const OUString& URL,
133 const css::uno::Reference< css::uno::XInterface >& xHandler ) override;
135 virtual css::uno::Reference < css::awt::XDialog > SAL_CALL createDialogWithArguments(
136 const OUString& URL,
137 const css::uno::Sequence< css::beans::NamedValue >& Arguments ) override;
139 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createContainerWindow(
140 const OUString& URL, const OUString& WindowType,
141 const css::uno::Reference< css::awt::XWindowPeer >& xParent,
142 const css::uno::Reference< css::uno::XInterface >& xHandler ) override;
146 } // namespace dlgprov
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */