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 #pragma once 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <cppuhelper/compbase8.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 38*cdf0e10cSrcweir //#include <com/sun/star/ui/dialogs/XFilePreview.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <osl/conditn.hxx> 42*cdf0e10cSrcweir #include <osl/mutex.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <QString> 47*cdf0e10cSrcweir #include <QHash> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir class KFileDialog; 50*cdf0e10cSrcweir class QWidget; 51*cdf0e10cSrcweir class QLayout; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir class ResMgr; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir class KDE4FilePicker : 56*cdf0e10cSrcweir public cppu::WeakComponentImplHelper8< 57*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilterManager, 58*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilterGroupManager, 59*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilePickerControlAccess, 60*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilePickerNotifier, 61*cdf0e10cSrcweir // TODO ::com::sun::star::ui::dialogs::XFilePreview, 62*cdf0e10cSrcweir ::com::sun::star::lang::XInitialization, 63*cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 64*cdf0e10cSrcweir ::com::sun::star::lang::XEventListener, 65*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo > 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir protected: 68*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr; // to instanciate own services 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > m_xListener; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir ResMgr *_resMgr; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir //the dialog to display 75*cdf0e10cSrcweir KFileDialog* _dialog; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir osl::Mutex _helperMutex; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir //running filter string to add to dialog 80*cdf0e10cSrcweir QString _filter; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir //filter for reverse lookup of filter text 83*cdf0e10cSrcweir QHash<QString, QString> _filters; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir //mapping of SAL control ID's to created custom controls 86*cdf0e10cSrcweir QHash<sal_Int16, QWidget*> _customWidgets; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //widget to contain extra custom controls 89*cdf0e10cSrcweir QWidget* _extraControls; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir //layout for extra custom controls 92*cdf0e10cSrcweir QLayout* _layout; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir public: 95*cdf0e10cSrcweir KDE4FilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr ); 96*cdf0e10cSrcweir virtual ~KDE4FilePicker(); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir // XFilePickerNotifier 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException ); 101*cdf0e10cSrcweir virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException ); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir // XExecutableDialog functions 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir virtual void SAL_CALL setTitle( const ::rtl::OUString &rTitle ) throw( ::com::sun::star::uno::RuntimeException ); 106*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir // XFilePicker functions 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException ); 111*cdf0e10cSrcweir virtual void SAL_CALL setDefaultName( const ::rtl::OUString &rName ) throw( ::com::sun::star::uno::RuntimeException ); 112*cdf0e10cSrcweir virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString &rDirectory ) throw( ::com::sun::star::uno::RuntimeException ); 113*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException ); 114*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException ); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // XFilterManager functions 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual void SAL_CALL appendFilter( const ::rtl::OUString &rTitle, const ::rtl::OUString &rFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 119*cdf0e10cSrcweir virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString &rTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 120*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir // XFilterGroupManager functions 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString &rGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > &rFilters ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // XFilePickerControlAccess functions 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any &rValue ) throw (::com::sun::star::uno::RuntimeException); 129*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) throw (::com::sun::star::uno::RuntimeException); 130*cdf0e10cSrcweir virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); 131*cdf0e10cSrcweir virtual void SAL_CALL setLabel( sal_Int16 nControlId, const ::rtl::OUString &rLabel ) throw (::com::sun::star::uno::RuntimeException); 132*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId ) throw (::com::sun::star::uno::RuntimeException); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir /* TODO XFilePreview 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException); 137*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException); 138*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException); 139*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException); 140*cdf0e10cSrcweir virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any &rImage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 141*cdf0e10cSrcweir virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException); 142*cdf0e10cSrcweir virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException); 143*cdf0e10cSrcweir */ 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // XInitialization 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > &rArguments ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // XCancellable 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir virtual void SAL_CALL cancel( ) throw( ::com::sun::star::uno::RuntimeException ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // XEventListener 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject &rEvent ) throw( ::com::sun::star::uno::RuntimeException ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // XServiceInfo 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 160*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString &rServiceName ) throw( ::com::sun::star::uno::RuntimeException ); 161*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir private: 164*cdf0e10cSrcweir // prevent copy and assignment 165*cdf0e10cSrcweir KDE4FilePicker( const KDE4FilePicker& ); 166*cdf0e10cSrcweir KDE4FilePicker& operator=( const KDE4FilePicker& ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir //add a custom control widget to the file dialog 169*cdf0e10cSrcweir void addCustomControl(sal_Int16 controlId); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir }; 172