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