1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef SVTOOLS_COMMONPICKER_HXX 29*cdf0e10cSrcweir #define SVTOOLS_COMMONPICKER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 32*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XControlInformation.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XControlAccess.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 39*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 40*cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx> 41*cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx> 42*cdf0e10cSrcweir #include <comphelper/uno3.hxx> 43*cdf0e10cSrcweir #include <tools/link.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir class SvtFileDialog; 46*cdf0e10cSrcweir class Window; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir namespace comphelper 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir class OWeakEventListenerAdapter; 51*cdf0e10cSrcweir } 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir //......................................................................... 54*cdf0e10cSrcweir namespace svt 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir //......................................................................... 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::ui::dialogs::XControlAccess 59*cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XControlInformation 60*cdf0e10cSrcweir , ::com::sun::star::lang::XEventListener 61*cdf0e10cSrcweir , ::com::sun::star::util::XCancellable 62*cdf0e10cSrcweir , ::com::sun::star::lang::XInitialization 63*cdf0e10cSrcweir > OCommonPicker_Base; 64*cdf0e10cSrcweir /** implements common functionality for the 2 UNO picker components 65*cdf0e10cSrcweir */ 66*cdf0e10cSrcweir class OCommonPicker 67*cdf0e10cSrcweir :public ::comphelper::OBaseMutex 68*cdf0e10cSrcweir ,public OCommonPicker_Base 69*cdf0e10cSrcweir ,public ::comphelper::OPropertyContainer 70*cdf0e10cSrcweir ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker > 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir private: 73*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // <properties> 76*cdf0e10cSrcweir ::rtl::OUString m_sHelpURL; 77*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow; 78*cdf0e10cSrcweir // </properties> 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir SvtFileDialog* m_pDlg; 81*cdf0e10cSrcweir sal_uInt32 m_nCancelEvent; 82*cdf0e10cSrcweir sal_Bool m_bExecuting; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xWindowListenerAdapter; 87*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xParentListenerAdapter; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir protected: 90*cdf0e10cSrcweir ::rtl::OUString m_aTitle; 91*cdf0e10cSrcweir ::rtl::OUString m_aDisplayDirectory; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir protected: 94*cdf0e10cSrcweir inline SvtFileDialog* getDialog() { return m_pDlg; } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; } 97*cdf0e10cSrcweir inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir public: 100*cdf0e10cSrcweir OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir protected: 103*cdf0e10cSrcweir virtual ~OCommonPicker(); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir // overridables 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // will be called with locked SolarMutex 108*cdf0e10cSrcweir virtual SvtFileDialog* implCreateDialog( Window* _pParent ) = 0; 109*cdf0e10cSrcweir virtual sal_Int16 implExecutePicker( ) = 0; 110*cdf0e10cSrcweir // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ... 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir protected: 113*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 114*cdf0e10cSrcweir // disambiguate XInterface 115*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 116*cdf0e10cSrcweir DECLARE_XINTERFACE( ) 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 119*cdf0e10cSrcweir // disambiguate XTypeProvider 120*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 121*cdf0e10cSrcweir DECLARE_XTYPEPROVIDER( ) 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 124*cdf0e10cSrcweir // ComponentHelper/XComponent 125*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 126*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 129*cdf0e10cSrcweir // XEventListner 130*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 131*cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 134*cdf0e10cSrcweir // property set related methods 135*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // XPropertySet pure methods 138*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 139*cdf0e10cSrcweir // OPropertySetHelper pure methods 140*cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 141*cdf0e10cSrcweir // OPropertyArrayUsageHelper pure methods 142*cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir // OPropertySetHelper overridden methods 145*cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 146*cdf0e10cSrcweir sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 149*cdf0e10cSrcweir // XExecutableDialog functions 150*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 151*cdf0e10cSrcweir virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException ); 152*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 155*cdf0e10cSrcweir // XControlAccess functions 156*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 157*cdf0e10cSrcweir 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*cdf0e10cSrcweir 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*cdf0e10cSrcweir 160*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 161*cdf0e10cSrcweir // XControlInformation functions 162*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 163*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException); 164*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isControlSupported( const ::rtl::OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException); 165*cdf0e10cSrcweir 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*cdf0e10cSrcweir 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*cdf0e10cSrcweir 168*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 169*cdf0e10cSrcweir // XCancellable functions 170*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 171*cdf0e10cSrcweir virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 174*cdf0e10cSrcweir // XInitialization functions 175*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir 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*cdf0e10cSrcweir 179*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 180*cdf0e10cSrcweir // misc 181*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 182*cdf0e10cSrcweir void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException) ); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir void prepareDialog(); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir protected: 187*cdf0e10cSrcweir sal_Bool createPicker(); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir /** handle a single argument from the XInitialization::initialize method 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir @return <TRUE/> if the argument could be handled 192*cdf0e10cSrcweir */ 193*cdf0e10cSrcweir virtual sal_Bool implHandleInitializationArgument( 194*cdf0e10cSrcweir const ::rtl::OUString& _rName, 195*cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rValue 196*cdf0e10cSrcweir ) 197*cdf0e10cSrcweir SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) ); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir private: 200*cdf0e10cSrcweir void stopWindowListening(); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir DECL_LINK( OnCancelPicker, void* ); 203*cdf0e10cSrcweir }; 204*cdf0e10cSrcweir //......................................................................... 205*cdf0e10cSrcweir } // namespace svt 206*cdf0e10cSrcweir //......................................................................... 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir #endif // SVTOOLS_COMMONPICKER_HXX 209*cdf0e10cSrcweir 210