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 SVTOOLS_COMMONPICKER_HXX 29 #define SVTOOLS_COMMONPICKER_HXX 30 31 #include <cppuhelper/compbase5.hxx> 32 #include <com/sun/star/ui/dialogs/XControlInformation.hpp> 33 #include <com/sun/star/ui/dialogs/XControlAccess.hpp> 34 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35 #include <com/sun/star/lang/DisposedException.hpp> 36 #include <com/sun/star/awt/XWindow.hpp> 37 #include <com/sun/star/util/XCancellable.hpp> 38 #include <com/sun/star/lang/XInitialization.hpp> 39 #include <comphelper/broadcasthelper.hxx> 40 #include <comphelper/propertycontainer.hxx> 41 #include <comphelper/proparrhlp.hxx> 42 #include <comphelper/uno3.hxx> 43 #include <tools/link.hxx> 44 45 class SvtFileDialog; 46 class Window; 47 48 namespace comphelper 49 { 50 class OWeakEventListenerAdapter; 51 } 52 53 //......................................................................... 54 namespace svt 55 { 56 //......................................................................... 57 58 typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::ui::dialogs::XControlAccess 59 , ::com::sun::star::ui::dialogs::XControlInformation 60 , ::com::sun::star::lang::XEventListener 61 , ::com::sun::star::util::XCancellable 62 , ::com::sun::star::lang::XInitialization 63 > OCommonPicker_Base; 64 /** implements common functionality for the 2 UNO picker components 65 */ 66 class OCommonPicker 67 :public ::comphelper::OBaseMutex 68 ,public OCommonPicker_Base 69 ,public ::comphelper::OPropertyContainer 70 ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker > 71 { 72 private: 73 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; 74 75 // <properties> 76 ::rtl::OUString m_sHelpURL; 77 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow; 78 // </properties> 79 80 SvtFileDialog* m_pDlg; 81 sal_uInt32 m_nCancelEvent; 82 sal_Bool m_bExecuting; 83 84 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent; 85 86 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xWindowListenerAdapter; 87 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xParentListenerAdapter; 88 89 protected: 90 ::rtl::OUString m_aTitle; 91 ::rtl::OUString m_aDisplayDirectory; 92 93 protected: 94 inline SvtFileDialog* getDialog() { return m_pDlg; } 95 96 inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; } 97 inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; } 98 99 public: 100 OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); 101 102 protected: 103 virtual ~OCommonPicker(); 104 105 // overridables 106 107 // will be called with locked SolarMutex 108 virtual SvtFileDialog* implCreateDialog( Window* _pParent ) = 0; 109 virtual sal_Int16 implExecutePicker( ) = 0; 110 // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ... 111 112 protected: 113 //------------------------------------------------------------------------------------ 114 // disambiguate XInterface 115 //------------------------------------------------------------------------------------ 116 DECLARE_XINTERFACE( ) 117 118 //------------------------------------------------------------------------------------ 119 // disambiguate XTypeProvider 120 //------------------------------------------------------------------------------------ 121 DECLARE_XTYPEPROVIDER( ) 122 123 //------------------------------------------------------------------------------------ 124 // ComponentHelper/XComponent 125 //------------------------------------------------------------------------------------ 126 virtual void SAL_CALL disposing(); 127 128 //------------------------------------------------------------------------------------ 129 // XEventListner 130 //------------------------------------------------------------------------------------ 131 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 132 133 //------------------------------------------------------------------------------------ 134 // property set related methods 135 //------------------------------------------------------------------------------------ 136 137 // XPropertySet pure methods 138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 139 // OPropertySetHelper pure methods 140 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 141 // OPropertyArrayUsageHelper pure methods 142 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 143 144 // OPropertySetHelper overridden methods 145 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 146 sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception); 147 148 //------------------------------------------------------------------------------------ 149 // XExecutableDialog functions 150 //------------------------------------------------------------------------------------ 151 virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException ); 152 virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException ); 153 154 //------------------------------------------------------------------------------------ 155 // XControlAccess functions 156 //------------------------------------------------------------------------------------ 157 virtual void SAL_CALL setControlProperty( const ::rtl::OUString& aControlName, const ::rtl::OUString& aControlProperty, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 158 virtual ::com::sun::star::uno::Any SAL_CALL getControlProperty( const ::rtl::OUString& aControlName, const ::rtl::OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 159 160 //------------------------------------------------------------------------------------ 161 // XControlInformation functions 162 //------------------------------------------------------------------------------------ 163 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException); 164 virtual sal_Bool SAL_CALL isControlSupported( const ::rtl::OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException); 165 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControlProperties( const ::rtl::OUString& aControlName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 166 virtual sal_Bool SAL_CALL isControlPropertySupported( const ::rtl::OUString& aControlName, const ::rtl::OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 167 168 //------------------------------------------------------------------------------------ 169 // XCancellable functions 170 //------------------------------------------------------------------------------------ 171 virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException); 172 173 //------------------------------------------------------------------------------------ 174 // XInitialization functions 175 //------------------------------------------------------------------------------------ 176 177 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); 178 179 //------------------------------------------------------------------------------------ 180 // misc 181 //------------------------------------------------------------------------------------ 182 void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException) ); 183 184 void prepareDialog(); 185 186 protected: 187 sal_Bool createPicker(); 188 189 /** handle a single argument from the XInitialization::initialize method 190 191 @return <TRUE/> if the argument could be handled 192 */ 193 virtual sal_Bool implHandleInitializationArgument( 194 const ::rtl::OUString& _rName, 195 const ::com::sun::star::uno::Any& _rValue 196 ) 197 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) ); 198 199 private: 200 void stopWindowListening(); 201 202 DECL_LINK( OnCancelPicker, void* ); 203 }; 204 //......................................................................... 205 } // namespace svt 206 //......................................................................... 207 208 #endif // SVTOOLS_COMMONPICKER_HXX 209 210