1 /*************************************************************************
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Jan Holesovsky <kendy@openoffice.org>
60 ************************************************************************/
62 //////////////////////////////////////////////////////////////////////////
64 //////////////////////////////////////////////////////////////////////////
66 #include <com/sun/star/lang/DisposedException.hpp>
67 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
68 #include <cppuhelper/interfacecontainer.h>
69 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
70 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
71 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
72 #include <com/sun/star/ui/dialogs/ControlActions.hpp>
73 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
75 #include <svtools/svtools.hrc>
77 #include <vos/mutex.hxx>
79 #include <vcl/svapp.hxx>
80 #include <vcl/sysdata.hxx>
81 #include <vcl/syswin.hxx>
83 #include "KDE4FilePicker.hxx"
84 #include "FPServiceInfo.hxx"
86 /* ********* Hack, but needed because of conflicting types... */
87 #define Region QtXRegion
89 //kde has an enum that uses this...OO does too
92 #include <kfiledialog.h>
93 #include <kwindowsystem.h>
94 #include <kapplication.h>
95 #include <kfilefiltercombo.h>
99 #include <QGridLayout>
103 using namespace ::com::sun::star
;
105 using namespace ::com::sun::star::ui::dialogs
;
106 using namespace ::com::sun::star::ui::dialogs::TemplateDescription
;
108 using namespace ::com::sun::star
;
109 using namespace ::com::sun::star::ui::dialogs
;
110 using namespace ::com::sun::star::ui::dialogs::TemplateDescription
;
111 using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds
;
112 using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds
;
113 using namespace ::com::sun::star::lang
;
114 using namespace ::com::sun::star::beans
;
115 using namespace ::com::sun::star::uno
;
117 //////////////////////////////////////////////////////////////////////////
119 //////////////////////////////////////////////////////////////////////////
125 // controling event notifications
126 const bool STARTUP_SUSPENDED
= true;
127 const bool STARTUP_ALIVE
= false;
129 uno::Sequence
<rtl::OUString
> SAL_CALL
FilePicker_getSupportedServiceNames()
131 uno::Sequence
<rtl::OUString
> aRet(3);
132 aRet
[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker");
133 aRet
[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker");
134 aRet
[2] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.KDE4FilePicker");
139 rtl::OUString
toOUString(const QString
& s
)
141 return rtl::OUString(s
.toUtf8().data(), s
.toUtf8().length(), RTL_TEXTENCODING_UTF8
);
144 QString
toQString(const rtl::OUString
& s
)
146 return QString::fromUtf16(s
.getStr(), s
.getLength());
149 //////////////////////////////////////////////////////////////////////////
151 //////////////////////////////////////////////////////////////////////////
153 KDE4FilePicker::KDE4FilePicker( const uno::Reference
<lang::XMultiServiceFactory
>& xServiceMgr
)
154 : cppu::WeakComponentImplHelper8
<
157 XFilePickerControlAccess
,
159 // TODO XFilePreview,
160 lang::XInitialization
,
162 lang::XEventListener
,
163 lang::XServiceInfo
>( _helperMutex
),
164 m_xServiceMgr( xServiceMgr
),
165 _resMgr( CREATEVERSIONRESMGR( fps_office
) )
167 _extraControls
= new QWidget();
169 _layout
= new QGridLayout(_extraControls
);
171 _dialog
= new KFileDialog(KUrl("~"), QString(""), 0, _extraControls
);
172 _dialog
->setMode(KFile::File
| KFile::LocalOnly
);
175 _dialog
->setOperationMode(KFileDialog::Opening
);
178 KDE4FilePicker::~KDE4FilePicker()
184 void SAL_CALL
KDE4FilePicker::addFilePickerListener( const uno::Reference
<XFilePickerListener
>& xListener
)
185 throw( uno::RuntimeException
)
187 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
188 m_xListener
= xListener
;
191 void SAL_CALL
KDE4FilePicker::removeFilePickerListener( const uno::Reference
<XFilePickerListener
>& )
192 throw( uno::RuntimeException
)
194 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
198 void SAL_CALL
KDE4FilePicker::setTitle( const rtl::OUString
&title
)
199 throw( uno::RuntimeException
)
201 _dialog
->setCaption(toQString(title
));
204 sal_Int16 SAL_CALL
KDE4FilePicker::execute()
205 throw( uno::RuntimeException
)
207 //get the window id of the main OO window to set it for the dialog as a parent
208 Window
*pParentWin
= Application::GetDefDialogParent();
211 const SystemEnvData
* pSysData
= ((SystemWindow
*)pParentWin
)->GetSystemData();
214 KWindowSystem::setMainWindow( _dialog
, pSysData
->aWindow
); // unx only
218 _dialog
->clearFilter();
219 _dialog
->setFilter(_filter
);
223 //nasty hack to get a local qt event loop going to process the dialog
224 //otherwise the dialog returns immediately
225 while (_dialog
->isVisible())
226 kapp
->processEvents(QEventLoop::WaitForMoreEvents
);
228 //block and wait for user input
229 if (_dialog
->result() == KFileDialog::Accepted
)
230 return ExecutableDialogResults::OK
;
232 return ExecutableDialogResults::CANCEL
;
235 void SAL_CALL
KDE4FilePicker::setMultiSelectionMode( sal_Bool multiSelect
)
236 throw( uno::RuntimeException
)
239 _dialog
->setMode(KFile::Files
| KFile::LocalOnly
);
241 _dialog
->setMode(KFile::File
| KFile::LocalOnly
);
244 void SAL_CALL
KDE4FilePicker::setDefaultName( const ::rtl::OUString
&name
)
245 throw( uno::RuntimeException
)
247 const QString url
= toQString(name
);
248 _dialog
->setSelection(url
);
251 void SAL_CALL
KDE4FilePicker::setDisplayDirectory( const rtl::OUString
&dir
)
252 throw( uno::RuntimeException
)
254 const QString url
= toQString(dir
);
255 _dialog
->setUrl(KUrl(url
));
258 rtl::OUString SAL_CALL
KDE4FilePicker::getDisplayDirectory()
259 throw( uno::RuntimeException
)
261 QString dir
= _dialog
->baseUrl().url();
262 return toOUString(dir
);
265 uno::Sequence
< ::rtl::OUString
> SAL_CALL
KDE4FilePicker::getFiles()
266 throw( uno::RuntimeException
)
268 QStringList rawFiles
= _dialog
->selectedFiles();
271 // check if we need to add an extension
272 QString extension
= "";
273 if ( _dialog
->operationMode() == KFileDialog::Saving
)
275 QCheckBox
*cb
= dynamic_cast<QCheckBox
*> (
276 _customWidgets
[ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
]);
280 extension
= _dialog
->currentFilter(); // assuming filter value is like this *.ext
281 extension
.replace("*","");
285 // Workaround for the double click selection KDE4 bug
286 // kde file picker returns the file and directories for selectedFiles()
287 // when a file is double clicked
288 // make a true list of files
289 const QString dir
= "file://" + KUrl(rawFiles
[0]).directory();
291 // by appending the dir, we make OO treat all opens like multifile opens
292 // this makes the code for adding the the OO sequence simpler
295 for (USHORT i
= 0; i
< rawFiles
.size(); ++i
)
297 // if the raw file is not the base directory (see above kde bug)
298 // we add the file to list of avail files
299 if ((dir
+ "/") != ("file://" + rawFiles
[i
]))
301 const QString filename
= KUrl(rawFiles
[i
]).fileName();
303 //prevent extension append if we already have one
304 if (filename
.endsWith(extension
))
305 files
.append(filename
);
307 files
.append(filename
+ extension
);
311 // add all files and leading directory to outgoing OO sequence
312 uno::Sequence
< ::rtl::OUString
> seq(files
.size());
313 for (int i
= 0; i
< files
.size(); ++i
)
314 seq
[i
] = toOUString(files
[i
]);
319 void SAL_CALL
KDE4FilePicker::appendFilter( const ::rtl::OUString
&title
, const ::rtl::OUString
&filter
)
320 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
322 QString t
= toQString(title
);
323 QString f
= toQString(filter
);
325 if (!_filter
.isNull())
326 _filter
.append("\n");
328 //add to hash map for reverse lookup in getCurrentFilter
329 _filters
.insert(f
, t
);
331 // '/' meed to be escaped to else they are assumed to be mime types by kfiledialog
333 t
.replace("/", "\\/");
335 _filter
.append(QString("%1|%2").arg(f
).arg(t
));
338 void SAL_CALL
KDE4FilePicker::setCurrentFilter( const rtl::OUString
&title
)
339 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
341 QString filter
= toQString(title
);
342 filter
.replace("/", "\\/");
343 _dialog
->filterWidget()->setCurrentFilter(filter
);
346 rtl::OUString SAL_CALL
KDE4FilePicker::getCurrentFilter()
347 throw( uno::RuntimeException
)
349 QString filter
= _filters
[_dialog
->currentFilter()];
351 //default if not found
353 filter
= "ODF Text Document (.odt)";
355 return toOUString(filter
);
358 void SAL_CALL
KDE4FilePicker::appendFilterGroup( const rtl::OUString
&, const uno::Sequence
<beans::StringPair
>&)
359 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
361 //TODO ... don't really like this behavior... Shtylman
363 if (!_filter
.isNull())
364 _filter
.append(QString("\n"));
366 for (USHORT i
= 0; i
< filters
.getLength(); ++i
)
368 beans::StringPair aPair
= filters
[i
];
370 _filter
.append(QString("%1|%2").arg(
371 toQString(aPair
.Second
).replace(";", " ")).arg(
372 toQString(aPair
.First
).replace("/","\\/") + "\n" ));
375 if (filters
.getLength() > 0)
376 _filter
.append(QString("*.*|*.*"));
380 void SAL_CALL
KDE4FilePicker::setValue( sal_Int16 controlId
, sal_Int16
, const uno::Any
&value
)
381 throw( uno::RuntimeException
)
383 QWidget
* widget
= _customWidgets
[controlId
];
389 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
390 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
391 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
392 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
393 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
394 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
395 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
397 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
398 cb
->setChecked(value
.getValue());
401 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
402 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
403 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
404 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
405 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
406 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
407 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
408 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
414 uno::Any SAL_CALL
KDE4FilePicker::getValue( sal_Int16 controlId
, sal_Int16
)
415 throw( uno::RuntimeException
)
419 QWidget
* widget
= _customWidgets
[controlId
];
425 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
426 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
427 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
428 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
429 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
430 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
431 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
433 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
434 res
= uno::Any(cb
->isChecked());
437 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
438 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
439 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
440 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
441 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
442 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
443 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
444 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
452 void SAL_CALL
KDE4FilePicker::enableControl( sal_Int16 controlId
, sal_Bool enable
)
453 throw( uno::RuntimeException
)
455 QWidget
* widget
= _customWidgets
[controlId
];
459 widget
->setEnabled(enable
);
463 void SAL_CALL
KDE4FilePicker::setLabel( sal_Int16 controlId
, const ::rtl::OUString
&label
)
464 throw( uno::RuntimeException
)
466 QWidget
* widget
= _customWidgets
[controlId
];
472 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
473 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
474 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
475 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
476 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
477 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
478 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
480 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
481 cb
->setText(toQString(label
));
484 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
485 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
486 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
487 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
488 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
489 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
490 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
491 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
497 rtl::OUString SAL_CALL
KDE4FilePicker::getLabel(sal_Int16 controlId
)
498 throw ( uno::RuntimeException
)
500 QWidget
* widget
= _customWidgets
[controlId
];
507 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
508 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
509 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
510 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
511 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
512 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
513 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
515 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
519 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
520 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
521 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
522 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
523 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
524 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
525 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
526 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
530 return toOUString(label
);
533 void KDE4FilePicker::addCustomControl(sal_Int16 controlId
)
536 sal_Int32 resId
= -1;
540 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
541 resId
= STR_SVT_FILEPICKER_AUTO_EXTENSION
;
543 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
544 resId
= STR_SVT_FILEPICKER_PASSWORD
;
546 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
547 resId
= STR_SVT_FILEPICKER_FILTER_OPTIONS
;
549 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
550 resId
= STR_SVT_FILEPICKER_READONLY
;
552 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
553 resId
= STR_SVT_FILEPICKER_INSERT_AS_LINK
;
555 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
556 resId
= STR_SVT_FILEPICKER_SHOW_PREVIEW
;
558 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
559 resId
= STR_SVT_FILEPICKER_SELECTION
;
561 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
562 resId
= STR_SVT_FILEPICKER_PLAY
;
564 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
565 resId
= STR_SVT_FILEPICKER_VERSION
;
567 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
568 resId
= STR_SVT_FILEPICKER_TEMPLATES
;
570 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
571 resId
= STR_SVT_FILEPICKER_IMAGE_TEMPLATE
;
573 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
574 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
575 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
576 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
582 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
583 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
584 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
585 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
586 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
587 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
588 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
592 if (_resMgr
&& resId
!= -1)
594 rtl::OUString s
= String(ResId( resId
, *_resMgr
));
595 label
= toQString(s
);
596 label
.replace("~", "&");
599 widget
= new QCheckBox(label
, _extraControls
);
603 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
604 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
605 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
606 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
607 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
608 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
609 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
610 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
616 _layout
->addWidget(widget
);
617 _customWidgets
.insert(controlId
, widget
);
621 void SAL_CALL
KDE4FilePicker::initialize( const uno::Sequence
<uno::Any
> &args
)
622 throw( uno::Exception
, uno::RuntimeException
)
627 // parameter checking
629 if (args
.getLength() == 0)
631 throw lang::IllegalArgumentException(
632 rtl::OUString::createFromAscii( "no arguments" ),
633 static_cast< XFilePicker
* >( this ), 1 );
638 if (( arg
.getValueType() != ::getCppuType((sal_Int16
*)0)) &&
639 ( arg
.getValueType() != ::getCppuType((sal_Int8
*)0)))
641 throw lang::IllegalArgumentException(
642 rtl::OUString::createFromAscii( "invalid argument type" ),
643 static_cast< XFilePicker
* >( this ), 1 );
646 sal_Int16 templateId
= -1;
650 KFileDialog::OperationMode operationMode
= KFileDialog::Opening
;
652 switch ( templateId
)
654 case FILEOPEN_SIMPLE
:
657 case FILESAVE_SIMPLE
:
658 operationMode
= KFileDialog::Saving
;
661 case FILESAVE_AUTOEXTENSION
:
662 operationMode
= KFileDialog::Saving
;
663 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
666 case FILESAVE_AUTOEXTENSION_PASSWORD
:
668 operationMode
= KFileDialog::Saving
;
669 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
670 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
);
673 case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS
:
675 operationMode
= KFileDialog::Saving
;
676 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
677 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
);
678 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
);
681 case FILESAVE_AUTOEXTENSION_SELECTION
:
682 operationMode
= KFileDialog::Saving
;
683 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
684 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_SELECTION
);
687 case FILESAVE_AUTOEXTENSION_TEMPLATE
:
688 operationMode
= KFileDialog::Saving
;
689 addCustomControl( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
);
692 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE
:
693 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK
);
694 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
);
695 addCustomControl( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
);
699 addCustomControl( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
);
702 case FILEOPEN_READONLY_VERSION
:
703 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_READONLY
);
704 addCustomControl( ExtendedFilePickerElementIds::LISTBOX_VERSION
);
707 case FILEOPEN_LINK_PREVIEW
:
708 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK
);
709 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
);
713 throw lang::IllegalArgumentException(
714 rtl::OUString::createFromAscii( "Unknown template" ),
715 static_cast< XFilePicker
* >( this ),
719 _dialog
->setOperationMode(operationMode
);
722 void SAL_CALL
KDE4FilePicker::cancel()
723 throw ( uno::RuntimeException
)
728 void SAL_CALL
KDE4FilePicker::disposing( const lang::EventObject
&rEvent
)
729 throw( uno::RuntimeException
)
731 uno::Reference
<XFilePickerListener
> xFilePickerListener( rEvent
.Source
, uno::UNO_QUERY
);
733 if ( xFilePickerListener
.is() )
735 removeFilePickerListener( xFilePickerListener
);
739 rtl::OUString SAL_CALL
KDE4FilePicker::getImplementationName()
740 throw( uno::RuntimeException
)
742 return rtl::OUString::createFromAscii( FILE_PICKER_IMPL_NAME
);
745 sal_Bool SAL_CALL
KDE4FilePicker::supportsService( const rtl::OUString
& ServiceName
)
746 throw( uno::RuntimeException
)
748 uno::Sequence
< ::rtl::OUString
> SupportedServicesNames
= FilePicker_getSupportedServiceNames();
750 for ( sal_Int32 n
= SupportedServicesNames
.getLength(); n
--; )
752 if ( SupportedServicesNames
[n
].compareTo( ServiceName
) == 0 )
759 uno::Sequence
< ::rtl::OUString
> SAL_CALL
KDE4FilePicker::getSupportedServiceNames()
760 throw( uno::RuntimeException
)
762 return FilePicker_getSupportedServiceNames();