1*10ce8018SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*10ce8018SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*10ce8018SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*10ce8018SAndrew Rist * distributed with this work for additional information 6*10ce8018SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*10ce8018SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*10ce8018SAndrew Rist * "License"); you may not use this file except in compliance 9*10ce8018SAndrew Rist * with the License. You may obtain a copy of the License at 10*10ce8018SAndrew Rist * 11*10ce8018SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*10ce8018SAndrew Rist * 13*10ce8018SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*10ce8018SAndrew Rist * software distributed under the License is distributed on an 15*10ce8018SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*10ce8018SAndrew Rist * KIND, either express or implied. See the License for the 17*10ce8018SAndrew Rist * specific language governing permissions and limitations 18*10ce8018SAndrew Rist * under the License. 19*10ce8018SAndrew Rist * 20*10ce8018SAndrew Rist *************************************************************/ 21*10ce8018SAndrew Rist 22*10ce8018SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVTOOLS_COMMONPICKER_HXX 25cdf0e10cSrcweir #define SVTOOLS_COMMONPICKER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 28cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XControlInformation.hpp> 29cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XControlAccess.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 33cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 35cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 36cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx> 37cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx> 38cdf0e10cSrcweir #include <comphelper/uno3.hxx> 39cdf0e10cSrcweir #include <tools/link.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir class SvtFileDialog; 42cdf0e10cSrcweir class Window; 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace comphelper 45cdf0e10cSrcweir { 46cdf0e10cSrcweir class OWeakEventListenerAdapter; 47cdf0e10cSrcweir } 48cdf0e10cSrcweir 49cdf0e10cSrcweir //......................................................................... 50cdf0e10cSrcweir namespace svt 51cdf0e10cSrcweir { 52cdf0e10cSrcweir //......................................................................... 53cdf0e10cSrcweir 54cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::ui::dialogs::XControlAccess 55cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XControlInformation 56cdf0e10cSrcweir , ::com::sun::star::lang::XEventListener 57cdf0e10cSrcweir , ::com::sun::star::util::XCancellable 58cdf0e10cSrcweir , ::com::sun::star::lang::XInitialization 59cdf0e10cSrcweir > OCommonPicker_Base; 60cdf0e10cSrcweir /** implements common functionality for the 2 UNO picker components 61cdf0e10cSrcweir */ 62cdf0e10cSrcweir class OCommonPicker 63cdf0e10cSrcweir :public ::comphelper::OBaseMutex 64cdf0e10cSrcweir ,public OCommonPicker_Base 65cdf0e10cSrcweir ,public ::comphelper::OPropertyContainer 66cdf0e10cSrcweir ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker > 67cdf0e10cSrcweir { 68cdf0e10cSrcweir private: 69cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; 70cdf0e10cSrcweir 71cdf0e10cSrcweir // <properties> 72cdf0e10cSrcweir ::rtl::OUString m_sHelpURL; 73cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow; 74cdf0e10cSrcweir // </properties> 75cdf0e10cSrcweir 76cdf0e10cSrcweir SvtFileDialog* m_pDlg; 77cdf0e10cSrcweir sal_uInt32 m_nCancelEvent; 78cdf0e10cSrcweir sal_Bool m_bExecuting; 79cdf0e10cSrcweir 80cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent; 81cdf0e10cSrcweir 82cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xWindowListenerAdapter; 83cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xParentListenerAdapter; 84cdf0e10cSrcweir 85cdf0e10cSrcweir protected: 86cdf0e10cSrcweir ::rtl::OUString m_aTitle; 87cdf0e10cSrcweir ::rtl::OUString m_aDisplayDirectory; 88cdf0e10cSrcweir 89cdf0e10cSrcweir protected: getDialog()90cdf0e10cSrcweir inline SvtFileDialog* getDialog() { return m_pDlg; } 91cdf0e10cSrcweir GetBroadcastHelper() const92cdf0e10cSrcweir inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; } GetBroadcastHelper()93cdf0e10cSrcweir inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; } 94cdf0e10cSrcweir 95cdf0e10cSrcweir public: 96cdf0e10cSrcweir OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir protected: 99cdf0e10cSrcweir virtual ~OCommonPicker(); 100cdf0e10cSrcweir 101cdf0e10cSrcweir // overridables 102cdf0e10cSrcweir 103cdf0e10cSrcweir // will be called with locked SolarMutex 104cdf0e10cSrcweir virtual SvtFileDialog* implCreateDialog( Window* _pParent ) = 0; 105cdf0e10cSrcweir virtual sal_Int16 implExecutePicker( ) = 0; 106cdf0e10cSrcweir // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ... 107cdf0e10cSrcweir 108cdf0e10cSrcweir protected: 109cdf0e10cSrcweir //------------------------------------------------------------------------------------ 110cdf0e10cSrcweir // disambiguate XInterface 111cdf0e10cSrcweir //------------------------------------------------------------------------------------ 112cdf0e10cSrcweir DECLARE_XINTERFACE( ) 113cdf0e10cSrcweir 114cdf0e10cSrcweir //------------------------------------------------------------------------------------ 115cdf0e10cSrcweir // disambiguate XTypeProvider 116cdf0e10cSrcweir //------------------------------------------------------------------------------------ 117cdf0e10cSrcweir DECLARE_XTYPEPROVIDER( ) 118cdf0e10cSrcweir 119cdf0e10cSrcweir //------------------------------------------------------------------------------------ 120cdf0e10cSrcweir // ComponentHelper/XComponent 121cdf0e10cSrcweir //------------------------------------------------------------------------------------ 122cdf0e10cSrcweir virtual void SAL_CALL disposing(); 123cdf0e10cSrcweir 124cdf0e10cSrcweir //------------------------------------------------------------------------------------ 125cdf0e10cSrcweir // XEventListner 126cdf0e10cSrcweir //------------------------------------------------------------------------------------ 127cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 128cdf0e10cSrcweir 129cdf0e10cSrcweir //------------------------------------------------------------------------------------ 130cdf0e10cSrcweir // property set related methods 131cdf0e10cSrcweir //------------------------------------------------------------------------------------ 132cdf0e10cSrcweir 133cdf0e10cSrcweir // XPropertySet pure methods 134cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 135cdf0e10cSrcweir // OPropertySetHelper pure methods 136cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 137cdf0e10cSrcweir // OPropertyArrayUsageHelper pure methods 138cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 139cdf0e10cSrcweir 140cdf0e10cSrcweir // OPropertySetHelper overridden methods 141cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 142cdf0e10cSrcweir sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception); 143cdf0e10cSrcweir 144cdf0e10cSrcweir //------------------------------------------------------------------------------------ 145cdf0e10cSrcweir // XExecutableDialog functions 146cdf0e10cSrcweir //------------------------------------------------------------------------------------ 147cdf0e10cSrcweir virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException ); 148cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir //------------------------------------------------------------------------------------ 151cdf0e10cSrcweir // XControlAccess functions 152cdf0e10cSrcweir //------------------------------------------------------------------------------------ 153cdf0e10cSrcweir 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); 154cdf0e10cSrcweir 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); 155cdf0e10cSrcweir 156cdf0e10cSrcweir //------------------------------------------------------------------------------------ 157cdf0e10cSrcweir // XControlInformation functions 158cdf0e10cSrcweir //------------------------------------------------------------------------------------ 159cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException); 160cdf0e10cSrcweir virtual sal_Bool SAL_CALL isControlSupported( const ::rtl::OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException); 161cdf0e10cSrcweir 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); 162cdf0e10cSrcweir 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); 163cdf0e10cSrcweir 164cdf0e10cSrcweir //------------------------------------------------------------------------------------ 165cdf0e10cSrcweir // XCancellable functions 166cdf0e10cSrcweir //------------------------------------------------------------------------------------ 167cdf0e10cSrcweir virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException); 168cdf0e10cSrcweir 169cdf0e10cSrcweir //------------------------------------------------------------------------------------ 170cdf0e10cSrcweir // XInitialization functions 171cdf0e10cSrcweir //------------------------------------------------------------------------------------ 172cdf0e10cSrcweir 173cdf0e10cSrcweir 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 ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir //------------------------------------------------------------------------------------ 176cdf0e10cSrcweir // misc 177cdf0e10cSrcweir //------------------------------------------------------------------------------------ 178cdf0e10cSrcweir void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException) ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir void prepareDialog(); 181cdf0e10cSrcweir 182cdf0e10cSrcweir protected: 183cdf0e10cSrcweir sal_Bool createPicker(); 184cdf0e10cSrcweir 185cdf0e10cSrcweir /** handle a single argument from the XInitialization::initialize method 186cdf0e10cSrcweir 187cdf0e10cSrcweir @return <TRUE/> if the argument could be handled 188cdf0e10cSrcweir */ 189cdf0e10cSrcweir virtual sal_Bool implHandleInitializationArgument( 190cdf0e10cSrcweir const ::rtl::OUString& _rName, 191cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rValue 192cdf0e10cSrcweir ) 193cdf0e10cSrcweir SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir private: 196cdf0e10cSrcweir void stopWindowListening(); 197cdf0e10cSrcweir 198cdf0e10cSrcweir DECL_LINK( OnCancelPicker, void* ); 199cdf0e10cSrcweir }; 200cdf0e10cSrcweir //......................................................................... 201cdf0e10cSrcweir } // namespace svt 202cdf0e10cSrcweir //......................................................................... 203cdf0e10cSrcweir 204cdf0e10cSrcweir #endif // SVTOOLS_COMMONPICKER_HXX 205cdf0e10cSrcweir 206