Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / vcl / unx / kde4 / KDE4FilePicker.hxx
blob7ac1d2e223ad028e65460ca9364d5cd386502af1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <cppuhelper/compbase5.hxx>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
27 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
28 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <osl/conditn.hxx>
32 #include <osl/mutex.hxx>
34 #include <rtl/ustrbuf.hxx>
36 #include <QObject>
37 #include <QString>
38 #include <QHash>
40 class KFileDialog;
41 class QWidget;
42 class QLayout;
44 class ResMgr;
46 typedef ::cppu::WeakComponentImplHelper5
47 < ::com::sun::star::ui::dialogs::XFilePicker2
48 , ::com::sun::star::ui::dialogs::XFilePicker3
49 , ::com::sun::star::ui::dialogs::XFilePickerControlAccess
50 // TODO ::com::sun::star::ui::dialogs::XFilePreview
51 , ::com::sun::star::lang::XInitialization
52 , ::com::sun::star::lang::XServiceInfo
53 > KDE4FilePicker_Base;
55 class KDE4FilePicker
56 : public QObject
57 , public KDE4FilePicker_Base
59 Q_OBJECT
60 protected:
62 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > m_xListener;
64 ResMgr *_resMgr;
66 //the dialog to display
67 KFileDialog* _dialog;
69 osl::Mutex _helperMutex;
71 //running filter string to add to dialog
72 QString _filter;
74 //mapping of SAL control ID's to created custom controls
75 QHash<sal_Int16, QWidget*> _customWidgets;
77 //widget to contain extra custom controls
78 QWidget* _extraControls;
80 //layout for extra custom controls
81 QLayout* _layout;
83 bool allowRemoteUrls;
85 public:
86 KDE4FilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
87 virtual ~KDE4FilePicker();
89 // XFilePickerNotifier
90 virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
91 virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
93 // XExecutableDialog functions
94 virtual void SAL_CALL setTitle( const OUString &rTitle ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
95 virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
97 // XFilePicker functions
98 virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
99 virtual void SAL_CALL setDefaultName( const OUString &rName ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
100 virtual void SAL_CALL setDisplayDirectory( const OUString &rDirectory ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
101 virtual OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
102 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
104 // XFilterManager functions
105 virtual void SAL_CALL appendFilter( const OUString &rTitle, const OUString &rFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
106 virtual void SAL_CALL setCurrentFilter( const OUString &rTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
107 virtual OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
109 // XFilterGroupManager functions
110 virtual void SAL_CALL appendFilterGroup( const 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, std::exception) SAL_OVERRIDE;
112 // XFilePickerControlAccess functions
113 virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any &rValue ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
116 virtual void SAL_CALL setLabel( sal_Int16 nControlId, const OUString &rLabel ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 virtual OUString SAL_CALL getLabel( sal_Int16 nControlId ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 /* TODO XFilePreview
121 virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException);
122 virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException);
123 virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException);
124 virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException);
125 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);
126 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException);
127 virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException);
130 // XFilePicker2 functions
131 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSelectedFiles()
132 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 // XInitialization
135 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, std::exception ) SAL_OVERRIDE;
137 // XCancellable
138 virtual void SAL_CALL cancel( ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
140 // XEventListener
141 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject &rEvent ) throw( ::com::sun::star::uno::RuntimeException );
142 using cppu::WeakComponentImplHelperBase::disposing;
144 // XServiceInfo
145 virtual OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
146 virtual sal_Bool SAL_CALL supportsService( const OUString &rServiceName ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
147 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
149 private Q_SLOTS:
150 // XExecutableDialog functions
151 void setTitleSlot( const OUString &rTitle ) throw( ::com::sun::star::uno::RuntimeException ) { return setTitle( rTitle ); }
152 sal_Int16 executeSlot() throw( ::com::sun::star::uno::RuntimeException ) { return execute(); }
154 // XFilePicker functions
155 void setMultiSelectionModeSlot( bool bMode ) throw( ::com::sun::star::uno::RuntimeException ) { return setMultiSelectionMode( bMode ); }
156 void setDefaultNameSlot( const OUString &rName ) throw( ::com::sun::star::uno::RuntimeException ) { return setDefaultName( rName ); }
157 void setDisplayDirectorySlot( const OUString &rDirectory ) throw( ::com::sun::star::uno::RuntimeException ) { return setDisplayDirectory( rDirectory ); }
158 OUString getDisplayDirectorySlot() throw( ::com::sun::star::uno::RuntimeException ) { return getDisplayDirectory(); }
159 ::com::sun::star::uno::Sequence< OUString > getFilesSlot() throw( ::com::sun::star::uno::RuntimeException ) { return getFiles(); }
161 // XFilterManager functions
162 void appendFilterSlot( const OUString &rTitle, const OUString &rFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) { return appendFilter( rTitle, rFilter ); }
163 void setCurrentFilterSlot( const OUString &rTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) { return setCurrentFilter( rTitle ); }
164 OUString getCurrentFilterSlot() throw( ::com::sun::star::uno::RuntimeException ) { return getCurrentFilter(); }
166 // XFilterGroupManager functions
167 void appendFilterGroupSlot( const 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) { return appendFilterGroup( rGroupTitle, rFilters ); }
169 // XFilePickerControlAccess functions
170 void setValueSlot( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any &rValue ) throw (::com::sun::star::uno::RuntimeException) { return setValue( nControlId, nControlAction, rValue ); }
171 ::com::sun::star::uno::Any getValueSlot( sal_Int16 nControlId, sal_Int16 nControlAction ) throw (::com::sun::star::uno::RuntimeException) { return getValue( nControlId, nControlAction ); }
172 void enableControlSlot( sal_Int16 nControlId, bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ) { return enableControl( nControlId, bEnable ); }
173 void setLabelSlot( sal_Int16 nControlId, const OUString &rLabel ) throw (::com::sun::star::uno::RuntimeException) { return setLabel( nControlId, rLabel ); }
174 OUString getLabelSlot( sal_Int16 nControlId ) throw (::com::sun::star::uno::RuntimeException) { return getLabel( nControlId ); }
176 // XFilePicker2 functions
177 ::com::sun::star::uno::Sequence< OUString > getSelectedFilesSlot() throw (::com::sun::star::uno::RuntimeException) { return getSelectedFiles(); }
179 // XInitialization
180 void initializeSlot( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > &rArguments ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) { return initialize( rArguments ); }
182 Q_SIGNALS:
183 // XExecutableDialog functions
184 void setTitleSignal( const OUString &rTitle );
185 sal_Int16 executeSignal();
187 // XFilePicker functions
188 void setMultiSelectionModeSignal( bool bMode );
189 void setDefaultNameSignal( const OUString &rName );
190 void setDisplayDirectorySignal( const OUString &rDirectory );
191 OUString getDisplayDirectorySignal();
192 ::com::sun::star::uno::Sequence< OUString > getFilesSignal();
194 // XFilterManager functions
195 void appendFilterSignal( const OUString &rTitle, const OUString &rFilter );
196 void setCurrentFilterSignal( const OUString &rTitle );
197 OUString getCurrentFilterSignal();
199 // XFilterGroupManager functions
200 void appendFilterGroupSignal( const OUString &rGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > &rFilters );
202 // XFilePickerControlAccess functions
203 void setValueSignal( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any &rValue );
204 ::com::sun::star::uno::Any getValueSignal( sal_Int16 nControlId, sal_Int16 nControlAction );
205 void enableControlSignal( sal_Int16 nControlId, bool bEnable );
206 void setLabelSignal( sal_Int16 nControlId, const OUString &rLabel );
207 OUString getLabelSignal( sal_Int16 nControlId );
209 // XFilePicker2 functions
210 ::com::sun::star::uno::Sequence< OUString > getSelectedFilesSignal() ;
212 // XInitialization
213 void initializeSignal( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > &rArguments );
215 // Destructor proxy
216 void cleanupProxySignal();
218 // KDE protocol lookup
219 void checkProtocolSignal();
221 private:
222 // prevent copy and assignment
223 KDE4FilePicker( const KDE4FilePicker& );
224 KDE4FilePicker& operator=( const KDE4FilePicker& );
226 //add a custom control widget to the file dialog
227 void addCustomControl(sal_Int16 controlId);
229 private Q_SLOTS:
230 void cleanupProxy();
231 void checkProtocol();
233 // emit XFilePickerListener controlStateChanged event
234 void filterChanged(const QString &filter);
235 // emit XFilePickerListener fileSelectionChanged event
236 void selectionChanged();
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */