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