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