1b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b557fc96SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b557fc96SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b557fc96SAndrew Rist  * distributed with this work for additional information
6b557fc96SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b557fc96SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b557fc96SAndrew Rist  * "License"); you may not use this file except in compliance
9b557fc96SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b557fc96SAndrew Rist  *
11b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b557fc96SAndrew Rist  *
13b557fc96SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b557fc96SAndrew Rist  * software distributed under the License is distributed on an
15b557fc96SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b557fc96SAndrew Rist  * KIND, either express or implied.  See the License for the
17b557fc96SAndrew Rist  * specific language governing permissions and limitations
18b557fc96SAndrew Rist  * under the License.
19b557fc96SAndrew Rist  *
20b557fc96SAndrew Rist  *************************************************************/
21b557fc96SAndrew Rist 
22b557fc96SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
25cdf0e10cSrcweir // includes
26cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
31cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
32cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
33cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
34cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ControlActions.hpp>
35cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <svtools/svtools.hrc>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <vos/mutex.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir #include <vcl/sysdata.hxx>
43cdf0e10cSrcweir #include <vcl/syswin.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "osl/file.h"
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "KDE4FilePicker.hxx"
48cdf0e10cSrcweir #include "FPServiceInfo.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir /* ********* Hack, but needed because of conflicting types... */
51cdf0e10cSrcweir #define Region QtXRegion
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //kde has an enum that uses this...OO does too
54cdf0e10cSrcweir #undef SETTINGS_MOUSE
55*2a4fd18fSdamjan #undef SETTINGS_LOCALE
56*2a4fd18fSdamjan #undef SETTINGS_STYLE
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #include <kfiledialog.h>
59cdf0e10cSrcweir #include <kwindowsystem.h>
60cdf0e10cSrcweir #include <kapplication.h>
61cdf0e10cSrcweir #include <kfilefiltercombo.h>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include <QWidget>
64cdf0e10cSrcweir #include <QCheckBox>
65cdf0e10cSrcweir #include <QGridLayout>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #undef Region
68cdf0e10cSrcweir 
69cdf0e10cSrcweir using namespace ::com::sun::star;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
72cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using namespace ::com::sun::star;
75cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
76cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
77cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds;
78cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds;
79cdf0e10cSrcweir using namespace ::com::sun::star::lang;
80cdf0e10cSrcweir using namespace ::com::sun::star::beans;
81cdf0e10cSrcweir using namespace ::com::sun::star::uno;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
84cdf0e10cSrcweir // helper functions
85cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #include <QDebug>
88cdf0e10cSrcweir 
89cdf0e10cSrcweir namespace
90cdf0e10cSrcweir {
9107a3d7f1SPedro Giffuni     // controlling event notifications
92cdf0e10cSrcweir     const bool STARTUP_SUSPENDED = true;
93cdf0e10cSrcweir     const bool STARTUP_ALIVE     = false;
94cdf0e10cSrcweir 
FilePicker_getSupportedServiceNames()95cdf0e10cSrcweir     uno::Sequence<rtl::OUString> SAL_CALL FilePicker_getSupportedServiceNames()
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         uno::Sequence<rtl::OUString> aRet(3);
98cdf0e10cSrcweir         aRet[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker");
99cdf0e10cSrcweir         aRet[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker");
100cdf0e10cSrcweir         aRet[2] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.KDE4FilePicker");
101cdf0e10cSrcweir         return aRet;
102cdf0e10cSrcweir     }
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
toOUString(const QString & s)105cdf0e10cSrcweir rtl::OUString toOUString(const QString& s)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     // QString stores UTF16, just like OUString
108cdf0e10cSrcweir 	return rtl::OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length());
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
toQString(const rtl::OUString & s)111cdf0e10cSrcweir QString toQString(const rtl::OUString& s)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	return QString::fromUtf16(s.getStr(), s.getLength());
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
117cdf0e10cSrcweir // KDE4FilePicker
118cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
119cdf0e10cSrcweir 
KDE4FilePicker(const uno::Reference<lang::XMultiServiceFactory> & xServiceMgr)120cdf0e10cSrcweir KDE4FilePicker::KDE4FilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr )
121cdf0e10cSrcweir     : cppu::WeakComponentImplHelper8<
122cdf0e10cSrcweir           XFilterManager,
123cdf0e10cSrcweir           XFilterGroupManager,
124cdf0e10cSrcweir           XFilePickerControlAccess,
125cdf0e10cSrcweir           XFilePickerNotifier,
126cdf0e10cSrcweir // TODO   XFilePreview,
127cdf0e10cSrcweir           lang::XInitialization,
128cdf0e10cSrcweir           util::XCancellable,
129cdf0e10cSrcweir           lang::XEventListener,
130cdf0e10cSrcweir           lang::XServiceInfo>( _helperMutex ),
131cdf0e10cSrcweir           m_xServiceMgr( xServiceMgr ),
132cdf0e10cSrcweir 		  _resMgr( CREATEVERSIONRESMGR( fps_office ) )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	_extraControls = new QWidget();
135cdf0e10cSrcweir 	_layout = new QGridLayout(_extraControls);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	_dialog = new KFileDialog(KUrl("~"), QString(""), 0, _extraControls);
138cdf0e10cSrcweir 	_dialog->setMode(KFile::File | KFile::LocalOnly);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	//default mode
141cdf0e10cSrcweir 	_dialog->setOperationMode(KFileDialog::Opening);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
~KDE4FilePicker()144cdf0e10cSrcweir KDE4FilePicker::~KDE4FilePicker()
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	delete _resMgr;
147cdf0e10cSrcweir 	delete _dialog;
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
addFilePickerListener(const uno::Reference<XFilePickerListener> & xListener)150cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::addFilePickerListener( const uno::Reference<XFilePickerListener>& xListener )
151cdf0e10cSrcweir 	throw( uno::RuntimeException )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
154cdf0e10cSrcweir     m_xListener = xListener;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
removeFilePickerListener(const uno::Reference<XFilePickerListener> &)157cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::removeFilePickerListener( const uno::Reference<XFilePickerListener>& )
158cdf0e10cSrcweir 	throw( uno::RuntimeException )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
161cdf0e10cSrcweir     m_xListener.clear();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
setTitle(const rtl::OUString & title)164cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setTitle( const rtl::OUString &title )
165cdf0e10cSrcweir     throw( uno::RuntimeException )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	_dialog->setCaption(toQString(title));
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
execute()170cdf0e10cSrcweir sal_Int16 SAL_CALL KDE4FilePicker::execute()
171cdf0e10cSrcweir     throw( uno::RuntimeException )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	//get the window id of the main OO window to set it for the dialog as a parent
174cdf0e10cSrcweir 	Window *pParentWin = Application::GetDefDialogParent();
175cdf0e10cSrcweir 	if ( pParentWin )
176cdf0e10cSrcweir 	{
177cdf0e10cSrcweir 		const SystemEnvData* pSysData = ((SystemWindow *)pParentWin)->GetSystemData();
178cdf0e10cSrcweir 		if ( pSysData )
179cdf0e10cSrcweir 		{
180cdf0e10cSrcweir 			KWindowSystem::setMainWindow( _dialog, pSysData->aWindow); // unx only
181cdf0e10cSrcweir 		}
182cdf0e10cSrcweir 	}
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	_dialog->clearFilter();
185cdf0e10cSrcweir 	_dialog->setFilter(_filter);
186cdf0e10cSrcweir     _dialog->filterWidget()->setEditable(false);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	//block and wait for user input
189cdf0e10cSrcweir 	if (_dialog->exec() == KFileDialog::Accepted)
190cdf0e10cSrcweir 		return ExecutableDialogResults::OK;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	return ExecutableDialogResults::CANCEL;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
setMultiSelectionMode(sal_Bool multiSelect)195cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setMultiSelectionMode( sal_Bool multiSelect )
196cdf0e10cSrcweir     throw( uno::RuntimeException )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 	if (multiSelect)
199cdf0e10cSrcweir 		_dialog->setMode(KFile::Files | KFile::LocalOnly);
200cdf0e10cSrcweir 	else
201cdf0e10cSrcweir 		_dialog->setMode(KFile::File | KFile::LocalOnly);
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
setDefaultName(const::rtl::OUString & name)204cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setDefaultName( const ::rtl::OUString &name )
205cdf0e10cSrcweir     throw( uno::RuntimeException )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	const QString url = toQString(name);
208cdf0e10cSrcweir 	_dialog->setSelection(url);
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
setDisplayDirectory(const rtl::OUString & dir)211cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setDisplayDirectory( const rtl::OUString &dir )
212cdf0e10cSrcweir     throw( uno::RuntimeException )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	const QString url = toQString(dir);
215cdf0e10cSrcweir 	_dialog->setUrl(KUrl(url));
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
getDisplayDirectory()218cdf0e10cSrcweir rtl::OUString SAL_CALL KDE4FilePicker::getDisplayDirectory()
219cdf0e10cSrcweir     throw( uno::RuntimeException )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir 	QString dir = _dialog->baseUrl().url();
222cdf0e10cSrcweir 	return toOUString(dir);
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
getFiles()225cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()
226cdf0e10cSrcweir     throw( uno::RuntimeException )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir 	QStringList rawFiles = _dialog->selectedFiles();
229cdf0e10cSrcweir 	QStringList files;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	// check if we need to add an extension
232cdf0e10cSrcweir 	QString extension = "";
233cdf0e10cSrcweir 	if ( _dialog->operationMode() == KFileDialog::Saving )
234cdf0e10cSrcweir 	{
235cdf0e10cSrcweir 		QCheckBox *cb = dynamic_cast<QCheckBox*> (
236cdf0e10cSrcweir 			_customWidgets[ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ]);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		if (cb && cb->isChecked())
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			extension = _dialog->currentFilter(); // assuming filter value is like this *.ext
241cdf0e10cSrcweir 			extension.replace("*","");
242cdf0e10cSrcweir 		}
243cdf0e10cSrcweir 	}
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	// Workaround for the double click selection KDE4 bug
246cdf0e10cSrcweir 	// kde file picker returns the file and directories for selectedFiles()
247cdf0e10cSrcweir 	// when a file is double clicked
248cdf0e10cSrcweir 	// make a true list of files
249cdf0e10cSrcweir 	const QString dir = KUrl(rawFiles[0]).directory();
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	bool singleFile = true;
252cdf0e10cSrcweir 	if (rawFiles.size() > 1)
253cdf0e10cSrcweir 	{
254cdf0e10cSrcweir 		singleFile = false;
255cdf0e10cSrcweir 		//for multi file sequences, oo expects the first param to be the directory
256cdf0e10cSrcweir 		//can't treat all cases like multi file because in some instances (inserting image)
257cdf0e10cSrcweir 		//oo WANTS only one entry in the final list
258cdf0e10cSrcweir 		files.append(dir);
259cdf0e10cSrcweir 	}
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	for (sal_uInt16 i = 0; i < rawFiles.size(); ++i)
262cdf0e10cSrcweir 	{
263cdf0e10cSrcweir 		// if the raw file is not the base directory (see above kde bug)
264cdf0e10cSrcweir 		// we add the file to list of avail files
265cdf0e10cSrcweir 		if ((dir + "/") != ( rawFiles[i]))
266cdf0e10cSrcweir 		{
267cdf0e10cSrcweir 			QString filename = KUrl(rawFiles[i]).fileName();
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 			if (singleFile)
270cdf0e10cSrcweir 				filename.prepend(dir + "/");
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 			//prevent extension append if we already have one
273cdf0e10cSrcweir 			if (filename.endsWith(extension))
274cdf0e10cSrcweir 				files.append(filename);
275cdf0e10cSrcweir 			else
276cdf0e10cSrcweir 				files.append(filename + extension);
277cdf0e10cSrcweir 		}
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	// add all files and leading directory to outgoing OO sequence
281cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > seq(files.size());
282cdf0e10cSrcweir 	for (int i = 0; i < files.size(); ++i)
283cdf0e10cSrcweir     {
284cdf0e10cSrcweir         rtl::OUString aFile(toOUString(files[i])), aURL;
285cdf0e10cSrcweir         osl_getFileURLFromSystemPath(aFile.pData, &aURL.pData );
286cdf0e10cSrcweir 		seq[i] = aURL;
287cdf0e10cSrcweir     }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	return seq;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
appendFilter(const::rtl::OUString & title,const::rtl::OUString & filter)292cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::appendFilter( const ::rtl::OUString &title, const ::rtl::OUString &filter )
293cdf0e10cSrcweir     throw( lang::IllegalArgumentException, uno::RuntimeException )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir 	QString t = toQString(title);
296cdf0e10cSrcweir 	QString f = toQString(filter);
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	if (!_filter.isNull())
299cdf0e10cSrcweir 		_filter.append("\n");
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 	//add to hash map for reverse lookup in getCurrentFilter
302cdf0e10cSrcweir 	_filters.insert(f, t);
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	// '/' meed to be escaped to else they are assumed to be mime types by kfiledialog
305cdf0e10cSrcweir 	//see the docs
306cdf0e10cSrcweir 	t.replace("/", "\\/");
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	// openoffice gives us filters separated by ';' qt dialogs just want space separated
309cdf0e10cSrcweir 	f.replace(";", " ");
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 	_filter.append(QString("%1|%2").arg(f).arg(t));
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
setCurrentFilter(const rtl::OUString & title)314cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setCurrentFilter( const rtl::OUString &title )
315cdf0e10cSrcweir     throw( lang::IllegalArgumentException, uno::RuntimeException )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	QString t = toQString(title);
318cdf0e10cSrcweir 	t.replace("/", "\\/");
319cdf0e10cSrcweir 	_dialog->filterWidget()->setCurrentFilter(t);
320cdf0e10cSrcweir }
321cdf0e10cSrcweir 
getCurrentFilter()322cdf0e10cSrcweir rtl::OUString SAL_CALL KDE4FilePicker::getCurrentFilter()
323cdf0e10cSrcweir     throw( uno::RuntimeException )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	QString filter = _filters[_dialog->currentFilter()];
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	//default if not found
328cdf0e10cSrcweir 	if (filter.isNull())
329cdf0e10cSrcweir 		filter = "ODF Text Document (.odt)";
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	return toOUString(filter);
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
appendFilterGroup(const rtl::OUString &,const uno::Sequence<beans::StringPair> & filters)334cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString& , const uno::Sequence<beans::StringPair>& filters)
335cdf0e10cSrcweir     throw( lang::IllegalArgumentException, uno::RuntimeException )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	if (!_filter.isNull())
338cdf0e10cSrcweir 		_filter.append(QString("\n"));
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	const sal_uInt16 length = filters.getLength();
341cdf0e10cSrcweir 	for (sal_uInt16 i = 0; i < length; ++i)
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		beans::StringPair aPair = filters[i];
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 		_filter.append(QString("%1|%2").arg(
346cdf0e10cSrcweir 			toQString(aPair.Second).replace(";", " ")).arg(
347cdf0e10cSrcweir 			toQString(aPair.First).replace("/","\\/")));
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 		if (i != length - 1)
350cdf0e10cSrcweir 			_filter.append('\n');
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
setValue(sal_Int16 controlId,sal_Int16,const uno::Any & value)354cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setValue( sal_Int16 controlId, sal_Int16, const uno::Any &value )
355cdf0e10cSrcweir     throw( uno::RuntimeException )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir 	QWidget* widget = _customWidgets[controlId];
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	if (widget)
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		switch (controlId)
362cdf0e10cSrcweir 		{
363cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION:
364cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD:
365cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS:
366cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_READONLY:
367cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_LINK:
368cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
369cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_SELECTION:
370cdf0e10cSrcweir 			{
371cdf0e10cSrcweir 				QCheckBox* cb = dynamic_cast<QCheckBox*>(widget);
372cdf0e10cSrcweir 				cb->setChecked(value.getValue());
373cdf0e10cSrcweir 				break;
374cdf0e10cSrcweir 			}
375cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY:
376cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION:
377cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE:
378cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE:
379cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL:
380cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL:
381cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL:
382cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR:
383cdf0e10cSrcweir 				break;
384cdf0e10cSrcweir 		}
385cdf0e10cSrcweir 	}
386cdf0e10cSrcweir }
387cdf0e10cSrcweir 
getValue(sal_Int16 controlId,sal_Int16)388cdf0e10cSrcweir uno::Any SAL_CALL KDE4FilePicker::getValue( sal_Int16 controlId, sal_Int16 )
389cdf0e10cSrcweir     throw( uno::RuntimeException )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir 	uno::Any res(false);
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 	QWidget* widget = _customWidgets[controlId];
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	if (widget)
396cdf0e10cSrcweir 	{
397cdf0e10cSrcweir 		switch (controlId)
398cdf0e10cSrcweir 		{
399cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION:
400cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD:
401cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS:
402cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_READONLY:
403cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_LINK:
404cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
405cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_SELECTION:
406cdf0e10cSrcweir 			{
407cdf0e10cSrcweir 				QCheckBox* cb = dynamic_cast<QCheckBox*>(widget);
408cdf0e10cSrcweir 				res = uno::Any(cb->isChecked());
409cdf0e10cSrcweir 				break;
410cdf0e10cSrcweir 			}
411cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY:
412cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION:
413cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE:
414cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE:
415cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL:
416cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL:
417cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL:
418cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR:
419cdf0e10cSrcweir 				break;
420cdf0e10cSrcweir 		}
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	return res;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
enableControl(sal_Int16 controlId,sal_Bool enable)426cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::enableControl( sal_Int16 controlId, sal_Bool enable )
427cdf0e10cSrcweir     throw( uno::RuntimeException )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir 	QWidget* widget = _customWidgets[controlId];
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 	if (widget)
432cdf0e10cSrcweir 	{
433cdf0e10cSrcweir 		widget->setEnabled(enable);
434cdf0e10cSrcweir 	}
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
setLabel(sal_Int16 controlId,const::rtl::OUString & label)437cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::setLabel( sal_Int16 controlId, const ::rtl::OUString &label )
438cdf0e10cSrcweir     throw( uno::RuntimeException )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	QWidget* widget = _customWidgets[controlId];
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 	if (widget)
443cdf0e10cSrcweir 	{
444cdf0e10cSrcweir 		switch (controlId)
445cdf0e10cSrcweir 		{
446cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION:
447cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD:
448cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS:
449cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_READONLY:
450cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_LINK:
451cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
452cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_SELECTION:
453cdf0e10cSrcweir 			{
454cdf0e10cSrcweir 				QCheckBox* cb = dynamic_cast<QCheckBox*>(widget);
455cdf0e10cSrcweir 				cb->setText(toQString(label));
456cdf0e10cSrcweir 				break;
457cdf0e10cSrcweir 			}
458cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY:
459cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION:
460cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE:
461cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE:
462cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL:
463cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL:
464cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL:
465cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR:
466cdf0e10cSrcweir 				break;
467cdf0e10cSrcweir 		}
468cdf0e10cSrcweir 	}
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
getLabel(sal_Int16 controlId)471cdf0e10cSrcweir rtl::OUString SAL_CALL KDE4FilePicker::getLabel(sal_Int16 controlId)
472cdf0e10cSrcweir     throw ( uno::RuntimeException )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	QWidget* widget = _customWidgets[controlId];
475cdf0e10cSrcweir 	QString label;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	if (widget)
478cdf0e10cSrcweir 	{
479cdf0e10cSrcweir 		switch (controlId)
480cdf0e10cSrcweir 		{
481cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION:
482cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD:
483cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS:
484cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_READONLY:
485cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_LINK:
486cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
487cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::CHECKBOX_SELECTION:
488cdf0e10cSrcweir 			{
489cdf0e10cSrcweir 				QCheckBox* cb = dynamic_cast<QCheckBox*>(widget);
490cdf0e10cSrcweir 				label = cb->text();
491cdf0e10cSrcweir 				break;
492cdf0e10cSrcweir 			}
493cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY:
494cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION:
495cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE:
496cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE:
497cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL:
498cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL:
499cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL:
500cdf0e10cSrcweir 			case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR:
501cdf0e10cSrcweir 				break;
502cdf0e10cSrcweir 		}
503cdf0e10cSrcweir 	}
504cdf0e10cSrcweir 	return toOUString(label);
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
addCustomControl(sal_Int16 controlId)507cdf0e10cSrcweir void KDE4FilePicker::addCustomControl(sal_Int16 controlId)
508cdf0e10cSrcweir {
509cdf0e10cSrcweir 	QWidget* widget = 0;
510cdf0e10cSrcweir 	sal_Int32 resId = -1;
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 	switch (controlId)
513cdf0e10cSrcweir 	{
514cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION:
515cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_AUTO_EXTENSION;
516cdf0e10cSrcweir 			break;
517cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD:
518cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_PASSWORD;
519cdf0e10cSrcweir 			break;
520cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS:
521cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_FILTER_OPTIONS;
522cdf0e10cSrcweir 			break;
523cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_READONLY:
524cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_READONLY;
525cdf0e10cSrcweir 			break;
526cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_LINK:
527cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_INSERT_AS_LINK;
528cdf0e10cSrcweir 			break;
529cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
530cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_SHOW_PREVIEW;
531cdf0e10cSrcweir 			break;
532cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_SELECTION:
533cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_SELECTION;
534cdf0e10cSrcweir 			break;
535cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY:
536cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_PLAY;
537cdf0e10cSrcweir 			break;
538cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_VERSION:
539cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_VERSION;
540cdf0e10cSrcweir 			break;
541cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE:
542cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_TEMPLATES;
543cdf0e10cSrcweir 			break;
544cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE:
545cdf0e10cSrcweir 			resId = STR_SVT_FILEPICKER_IMAGE_TEMPLATE;
546cdf0e10cSrcweir 			break;
547cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL:
548cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL:
549cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL:
550cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR:
551cdf0e10cSrcweir 			break;
552cdf0e10cSrcweir 	}
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 	switch (controlId)
555cdf0e10cSrcweir 	{
556cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION:
557cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD:
558cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS:
559cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_READONLY:
560cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_LINK:
561cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
562cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::CHECKBOX_SELECTION:
563cdf0e10cSrcweir 		{
564cdf0e10cSrcweir 			QString label;
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 			if (_resMgr && resId != -1)
567cdf0e10cSrcweir 			{
568cdf0e10cSrcweir 				rtl::OUString s = String(ResId( resId, *_resMgr ));
569cdf0e10cSrcweir 				label = toQString(s);
570cdf0e10cSrcweir 				label.replace("~", "&");
571cdf0e10cSrcweir 			}
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 			widget = new QCheckBox(label, _extraControls);
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 			break;
576cdf0e10cSrcweir 		}
577cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY:
578cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_VERSION:
579cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE:
580cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE:
581cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL:
582cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL:
583cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL:
584cdf0e10cSrcweir 		case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR:
585cdf0e10cSrcweir 			break;
586cdf0e10cSrcweir 	}
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	if (widget)
589cdf0e10cSrcweir 	{
590cdf0e10cSrcweir 		_layout->addWidget(widget);
591cdf0e10cSrcweir 		_customWidgets.insert(controlId, widget);
592cdf0e10cSrcweir 	}
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
initialize(const uno::Sequence<uno::Any> & args)595cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::initialize( const uno::Sequence<uno::Any> &args )
596cdf0e10cSrcweir     throw( uno::Exception, uno::RuntimeException )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	_filter.clear();
599cdf0e10cSrcweir 	_filters.clear();
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     // parameter checking
602cdf0e10cSrcweir     uno::Any arg;
603cdf0e10cSrcweir     if (args.getLength() == 0)
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir         throw lang::IllegalArgumentException(
606cdf0e10cSrcweir                 rtl::OUString::createFromAscii( "no arguments" ),
607cdf0e10cSrcweir                 static_cast< XFilePicker* >( this ), 1 );
608cdf0e10cSrcweir 	}
609cdf0e10cSrcweir 
610cdf0e10cSrcweir     arg = args[0];
611cdf0e10cSrcweir 
612cdf0e10cSrcweir     if (( arg.getValueType() != ::getCppuType((sal_Int16*)0)) &&
613cdf0e10cSrcweir 		( arg.getValueType() != ::getCppuType((sal_Int8*)0)))
614cdf0e10cSrcweir 	{
615cdf0e10cSrcweir         throw lang::IllegalArgumentException(
616cdf0e10cSrcweir                 rtl::OUString::createFromAscii( "invalid argument type" ),
617cdf0e10cSrcweir                 static_cast< XFilePicker* >( this ), 1 );
618cdf0e10cSrcweir 	}
619cdf0e10cSrcweir 
620cdf0e10cSrcweir     sal_Int16 templateId = -1;
621cdf0e10cSrcweir     arg >>= templateId;
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 	//default is opening
624cdf0e10cSrcweir 	KFileDialog::OperationMode operationMode = KFileDialog::Opening;
625cdf0e10cSrcweir 
626cdf0e10cSrcweir     switch ( templateId )
627cdf0e10cSrcweir     {
628cdf0e10cSrcweir         case FILEOPEN_SIMPLE:
629cdf0e10cSrcweir             break;
630cdf0e10cSrcweir 
631cdf0e10cSrcweir         case FILESAVE_SIMPLE:
632cdf0e10cSrcweir             operationMode = KFileDialog::Saving;
633cdf0e10cSrcweir             break;
634cdf0e10cSrcweir 
635cdf0e10cSrcweir         case FILESAVE_AUTOEXTENSION:
636cdf0e10cSrcweir             operationMode = KFileDialog::Saving;
637cdf0e10cSrcweir 			//addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
638cdf0e10cSrcweir             break;
639cdf0e10cSrcweir 
640cdf0e10cSrcweir         case FILESAVE_AUTOEXTENSION_PASSWORD:
641cdf0e10cSrcweir 		{
642cdf0e10cSrcweir             operationMode = KFileDialog::Saving;
643cdf0e10cSrcweir 			//addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
644cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD );
645cdf0e10cSrcweir             break;
646cdf0e10cSrcweir 		}
647cdf0e10cSrcweir         case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
648cdf0e10cSrcweir 		{
649cdf0e10cSrcweir 			operationMode = KFileDialog::Saving;
650cdf0e10cSrcweir 			addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
651cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD );
652cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS );
653cdf0e10cSrcweir             break;
654cdf0e10cSrcweir 		}
655cdf0e10cSrcweir         case FILESAVE_AUTOEXTENSION_SELECTION:
656cdf0e10cSrcweir             operationMode = KFileDialog::Saving;
657cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
658cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_SELECTION );
659cdf0e10cSrcweir             break;
660cdf0e10cSrcweir 
661cdf0e10cSrcweir         case FILESAVE_AUTOEXTENSION_TEMPLATE:
662cdf0e10cSrcweir             operationMode = KFileDialog::Saving;
663cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE );
664cdf0e10cSrcweir             break;
665cdf0e10cSrcweir 
666cdf0e10cSrcweir         case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
667cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK );
668cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW );
669cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE );
670cdf0e10cSrcweir             break;
671cdf0e10cSrcweir 
672cdf0e10cSrcweir         case FILEOPEN_PLAY:
673cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY );
674cdf0e10cSrcweir             break;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir         case FILEOPEN_READONLY_VERSION:
677cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_READONLY );
678cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::LISTBOX_VERSION );
679cdf0e10cSrcweir             break;
680cdf0e10cSrcweir 
681cdf0e10cSrcweir         case FILEOPEN_LINK_PREVIEW:
682cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK );
683cdf0e10cSrcweir             addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW );
684cdf0e10cSrcweir             break;
685cdf0e10cSrcweir 
686cdf0e10cSrcweir         default:
687cdf0e10cSrcweir             throw lang::IllegalArgumentException(
688cdf0e10cSrcweir                     rtl::OUString::createFromAscii( "Unknown template" ),
689cdf0e10cSrcweir                     static_cast< XFilePicker* >( this ),
690cdf0e10cSrcweir                     1 );
691cdf0e10cSrcweir     }
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	_dialog->setOperationMode(operationMode);
694cdf0e10cSrcweir     _dialog->setConfirmOverwrite(true);
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
cancel()697cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::cancel()
698cdf0e10cSrcweir     throw ( uno::RuntimeException )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir 
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
disposing(const lang::EventObject & rEvent)703cdf0e10cSrcweir void SAL_CALL KDE4FilePicker::disposing( const lang::EventObject &rEvent )
704cdf0e10cSrcweir     throw( uno::RuntimeException )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir     uno::Reference<XFilePickerListener> xFilePickerListener( rEvent.Source, uno::UNO_QUERY );
707cdf0e10cSrcweir 
708cdf0e10cSrcweir     if ( xFilePickerListener.is() )
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir         removeFilePickerListener( xFilePickerListener );
711cdf0e10cSrcweir 	}
712cdf0e10cSrcweir }
713cdf0e10cSrcweir 
getImplementationName()714cdf0e10cSrcweir rtl::OUString SAL_CALL KDE4FilePicker::getImplementationName()
715cdf0e10cSrcweir     throw( uno::RuntimeException )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir     return rtl::OUString::createFromAscii( FILE_PICKER_IMPL_NAME );
718cdf0e10cSrcweir }
719cdf0e10cSrcweir 
supportsService(const rtl::OUString & ServiceName)720cdf0e10cSrcweir sal_Bool SAL_CALL KDE4FilePicker::supportsService( const rtl::OUString& ServiceName )
721cdf0e10cSrcweir     throw( uno::RuntimeException )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > SupportedServicesNames = FilePicker_getSupportedServiceNames();
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
726cdf0e10cSrcweir     {
727cdf0e10cSrcweir         if ( SupportedServicesNames[n].compareTo( ServiceName ) == 0 )
728cdf0e10cSrcweir             return sal_True;
729cdf0e10cSrcweir     }
730cdf0e10cSrcweir 
731cdf0e10cSrcweir     return sal_False;
732cdf0e10cSrcweir }
733cdf0e10cSrcweir 
getSupportedServiceNames()734cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getSupportedServiceNames()
735cdf0e10cSrcweir     throw( uno::RuntimeException )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     return FilePicker_getSupportedServiceNames();
738cdf0e10cSrcweir }
739