1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SCRIPTING_DLGPROV_HXX 29 #define SCRIPTING_DLGPROV_HXX 30 31 #include <com/sun/star/awt/XControl.hpp> 32 #include <com/sun/star/awt/XDialog.hpp> 33 #include <com/sun/star/awt/XDialogProvider2.hpp> 34 #include <com/sun/star/awt/XContainerWindowProvider.hpp> 35 #include <com/sun/star/frame/XModel.hpp> 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 #include <com/sun/star/lang/XInitialization.hpp> 38 #include <com/sun/star/script/XScriptEventsAttacher.hpp> 39 #include <com/sun/star/uno/XComponentContext.hpp> 40 #include <com/sun/star/beans/XIntrospectionAccess.hpp> 41 #include <com/sun/star/container/XNameContainer.hpp> 42 #include <com/sun/star/io/XInputStream.hpp> 43 #include <com/sun/star/resource/XStringResourceManager.hpp> 44 45 #include <cppuhelper/implbase4.hxx> 46 #include <osl/mutex.hxx> 47 #include <memory> 48 49 //......................................................................... 50 namespace dlgprov 51 { 52 //......................................................................... 53 54 // ============================================================================= 55 // mutex 56 // ============================================================================= 57 58 ::osl::Mutex& getMutex(); 59 60 61 // ============================================================================= 62 // class DialogProviderImpl 63 // ============================================================================= 64 ::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); 65 ::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); 66 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel( 67 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext, 68 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, 69 const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, 70 const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); 71 72 typedef ::cppu::WeakImplHelper4< 73 ::com::sun::star::lang::XServiceInfo, 74 ::com::sun::star::lang::XInitialization, 75 ::com::sun::star::awt::XDialogProvider2, 76 ::com::sun::star::awt::XContainerWindowProvider > DialogProviderImpl_BASE; 77 78 class DialogProviderImpl : public DialogProviderImpl_BASE 79 { 80 private: 81 struct BasicRTLParams 82 { 83 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInput; 84 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > mxDlgLib; 85 ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > mxBasicRTLListener; 86 }; 87 std::auto_ptr< BasicRTLParams > m_BasicInfo; 88 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 89 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; 90 91 92 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModel( const ::rtl::OUString& sURL ); 93 94 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > createDialogControl( 95 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxDialogModel, 96 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent ); 97 98 void attachControlEvents( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxControlContainer, 99 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler, 100 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& rxIntrospectionAccess, 101 bool bDialogProviderMode ); 102 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > inspectHandler( 103 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler ); 104 // helper methods 105 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createControlModel() throw ( ::com::sun::star::uno::Exception ); 106 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createDialogModel( 107 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, 108 const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, 109 const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); 110 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception ); 111 112 // XDialogProvider / XDialogProvider2 impl method 113 virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XControl > SAL_CALL createDialogImpl( 114 const ::rtl::OUString& URL, 115 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler, 116 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, 117 bool bDialogProviderMode ) 118 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 119 120 public: 121 DialogProviderImpl( 122 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); 123 virtual ~DialogProviderImpl(); 124 125 // XServiceInfo 126 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 127 throw (::com::sun::star::uno::RuntimeException); 128 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 129 throw (::com::sun::star::uno::RuntimeException); 130 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 131 throw (::com::sun::star::uno::RuntimeException); 132 133 // XInitialization 134 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 135 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 136 137 // XDialogProvider 138 virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialog( 139 const ::rtl::OUString& URL ) 140 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 141 142 // XDialogProvider2 143 virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithHandler( 144 const ::rtl::OUString& URL, 145 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler ) 146 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 147 148 virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithArguments( 149 const ::rtl::OUString& URL, 150 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) 151 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 152 153 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createContainerWindow( 154 const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, 155 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, 156 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler ) 157 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 158 }; 159 160 //......................................................................... 161 } // namespace dlgprov 162 //......................................................................... 163 164 #endif // SCRIPTING_DLGPROV_HXX 165