1 /*************************************************************************
2 * The Contents of this file are made available subject to the terms of
3 * either of the following licenses
5 * - GNU Lesser General Public License Version 2.1
6 * - Sun Industry Standards Source License Version 1.1
8 * Sun Microsystems Inc., October, 2000
10 * GNU Lesser General Public License Version 2.1
11 * =============================================
12 * Copyright 2000 by Sun Microsystems, Inc.
13 * 901 San Antonio Road, Palo Alto, CA 94303, USA
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License version 2.1, as published by the Free Software Foundation.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * Sun Industry Standards Source License Version 1.1
31 * =================================================
32 * The contents of this file are subject to the Sun Industry Standards
33 * Source License Version 1.1 (the "License"); You may not use this file
34 * except in compliance with the License. You may obtain a copy of the
35 * License at http://www.openoffice.org/license.html.
37 * Software provided under this License is provided on an "AS IS" basis,
38 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
39 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
40 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
41 * See the License for the specific provisions governing your rights and
42 * obligations concerning the Software.
44 * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
46 * Copyright: 2000 by Sun Microsystems, Inc.
48 * All Rights Reserved.
50 * Contributor(s): Jan Holesovsky <kendy@openoffice.org>
53 ************************************************************************/
55 //////////////////////////////////////////////////////////////////////////
57 //////////////////////////////////////////////////////////////////////////
59 #include <com/sun/star/lang/DisposedException.hpp>
60 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61 #include <cppuhelper/interfacecontainer.h>
62 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
63 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
64 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
65 #include <com/sun/star/ui/dialogs/ControlActions.hpp>
66 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
68 #include <svtools/svtools.hrc>
70 #include <vos/mutex.hxx>
72 #include <vcl/svapp.hxx>
73 #include <vcl/sysdata.hxx>
74 #include <vcl/syswin.hxx>
76 #include "KDE4FilePicker.hxx"
77 #include "FPServiceInfo.hxx"
79 /* ********* Hack, but needed because of conflicting types... */
80 #define Region QtXRegion
82 //kde has an enum that uses this...OO does too
85 #include <kfiledialog.h>
86 #include <kwindowsystem.h>
87 #include <kapplication.h>
88 #include <kfilefiltercombo.h>
92 #include <QGridLayout>
96 using namespace ::com::sun::star
;
98 using namespace ::com::sun::star::ui::dialogs
;
99 using namespace ::com::sun::star::ui::dialogs::TemplateDescription
;
101 using namespace ::com::sun::star
;
102 using namespace ::com::sun::star::ui::dialogs
;
103 using namespace ::com::sun::star::ui::dialogs::TemplateDescription
;
104 using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds
;
105 using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds
;
106 using namespace ::com::sun::star::lang
;
107 using namespace ::com::sun::star::beans
;
108 using namespace ::com::sun::star::uno
;
110 //////////////////////////////////////////////////////////////////////////
112 //////////////////////////////////////////////////////////////////////////
118 // controling event notifications
119 const bool STARTUP_SUSPENDED
= true;
120 const bool STARTUP_ALIVE
= false;
122 uno::Sequence
<rtl::OUString
> SAL_CALL
FilePicker_getSupportedServiceNames()
124 uno::Sequence
<rtl::OUString
> aRet(3);
125 aRet
[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker");
126 aRet
[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker");
127 aRet
[2] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.KDE4FilePicker");
132 rtl::OUString
toOUString(const QString
& s
)
134 // QString stores UTF16, just like OUString
135 return rtl::OUString(reinterpret_cast<const sal_Unicode
*>(s
.data()), s
.length());
138 QString
toQString(const rtl::OUString
& s
)
140 return QString::fromUtf16(s
.getStr(), s
.getLength());
143 //////////////////////////////////////////////////////////////////////////
145 //////////////////////////////////////////////////////////////////////////
147 KDE4FilePicker::KDE4FilePicker( const uno::Reference
<lang::XMultiServiceFactory
>& xServiceMgr
)
148 : cppu::WeakComponentImplHelper8
<
151 XFilePickerControlAccess
,
153 // TODO XFilePreview,
154 lang::XInitialization
,
156 lang::XEventListener
,
157 lang::XServiceInfo
>( _helperMutex
),
158 m_xServiceMgr( xServiceMgr
),
159 _resMgr( CREATEVERSIONRESMGR( fps_office
) )
161 _extraControls
= new QWidget();
162 _layout
= new QGridLayout(_extraControls
);
164 _dialog
= new KFileDialog(KUrl("~"), QString(""), 0, _extraControls
);
165 _dialog
->setMode(KFile::File
| KFile::LocalOnly
);
168 _dialog
->setOperationMode(KFileDialog::Opening
);
170 _dialog
->setStyleSheet("color: black;");
173 KDE4FilePicker::~KDE4FilePicker()
179 void SAL_CALL
KDE4FilePicker::addFilePickerListener( const uno::Reference
<XFilePickerListener
>& xListener
)
180 throw( uno::RuntimeException
)
182 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
183 m_xListener
= xListener
;
186 void SAL_CALL
KDE4FilePicker::removeFilePickerListener( const uno::Reference
<XFilePickerListener
>& )
187 throw( uno::RuntimeException
)
189 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
193 void SAL_CALL
KDE4FilePicker::setTitle( const rtl::OUString
&title
)
194 throw( uno::RuntimeException
)
196 _dialog
->setCaption(toQString(title
));
199 sal_Int16 SAL_CALL
KDE4FilePicker::execute()
200 throw( uno::RuntimeException
)
202 //get the window id of the main OO window to set it for the dialog as a parent
203 Window
*pParentWin
= Application::GetDefDialogParent();
206 const SystemEnvData
* pSysData
= ((SystemWindow
*)pParentWin
)->GetSystemData();
209 KWindowSystem::setMainWindow( _dialog
, pSysData
->aWindow
); // unx only
213 _dialog
->clearFilter();
214 _dialog
->setFilter(_filter
);
216 //block and wait for user input
217 if (_dialog
->exec() == KFileDialog::Accepted
)
218 return ExecutableDialogResults::OK
;
220 return ExecutableDialogResults::CANCEL
;
223 void SAL_CALL
KDE4FilePicker::setMultiSelectionMode( sal_Bool multiSelect
)
224 throw( uno::RuntimeException
)
227 _dialog
->setMode(KFile::Files
| KFile::LocalOnly
);
229 _dialog
->setMode(KFile::File
| KFile::LocalOnly
);
232 void SAL_CALL
KDE4FilePicker::setDefaultName( const ::rtl::OUString
&name
)
233 throw( uno::RuntimeException
)
235 const QString url
= toQString(name
);
236 _dialog
->setSelection(url
);
239 void SAL_CALL
KDE4FilePicker::setDisplayDirectory( const rtl::OUString
&dir
)
240 throw( uno::RuntimeException
)
242 const QString url
= toQString(dir
);
243 _dialog
->setUrl(KUrl(url
));
246 rtl::OUString SAL_CALL
KDE4FilePicker::getDisplayDirectory()
247 throw( uno::RuntimeException
)
249 QString dir
= _dialog
->baseUrl().url();
250 return toOUString(dir
);
253 uno::Sequence
< ::rtl::OUString
> SAL_CALL
KDE4FilePicker::getFiles()
254 throw( uno::RuntimeException
)
256 QStringList rawFiles
= _dialog
->selectedFiles();
259 // check if we need to add an extension
260 QString extension
= "";
261 if ( _dialog
->operationMode() == KFileDialog::Saving
)
263 QCheckBox
*cb
= dynamic_cast<QCheckBox
*> (
264 _customWidgets
[ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
]);
268 extension
= _dialog
->currentFilter(); // assuming filter value is like this *.ext
269 extension
.replace("*","");
273 // Workaround for the double click selection KDE4 bug
274 // kde file picker returns the file and directories for selectedFiles()
275 // when a file is double clicked
276 // make a true list of files
277 const QString dir
= "file://" + KUrl(rawFiles
[0]).directory();
279 bool singleFile
= true;
280 if (rawFiles
.size() > 1)
283 //for multi file sequences, oo expects the first param to be the directory
284 //can't treat all cases like multi file because in some instances (inserting image)
285 //oo WANTS only one entry in the final list
289 for (USHORT i
= 0; i
< rawFiles
.size(); ++i
)
291 // if the raw file is not the base directory (see above kde bug)
292 // we add the file to list of avail files
293 if ((dir
+ "/") != ("file://" + rawFiles
[i
]))
295 QString filename
= KUrl(rawFiles
[i
]).fileName();
298 filename
.prepend(dir
+ "/");
300 //prevent extension append if we already have one
301 if (filename
.endsWith(extension
))
302 files
.append(filename
);
304 files
.append(filename
+ extension
);
308 // add all files and leading directory to outgoing OO sequence
309 uno::Sequence
< ::rtl::OUString
> seq(files
.size());
310 for (int i
= 0; i
< files
.size(); ++i
)
311 seq
[i
] = toOUString(files
[i
]);
316 void SAL_CALL
KDE4FilePicker::appendFilter( const ::rtl::OUString
&title
, const ::rtl::OUString
&filter
)
317 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
319 QString t
= toQString(title
);
320 QString f
= toQString(filter
);
322 if (!_filter
.isNull())
323 _filter
.append("\n");
325 //add to hash map for reverse lookup in getCurrentFilter
326 _filters
.insert(f
, t
);
328 // '/' meed to be escaped to else they are assumed to be mime types by kfiledialog
330 t
.replace("/", "\\/");
332 // openoffice gives us filters separated by ';' qt dialogs just want space separated
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 t
= toQString(title
);
342 t
.replace("/", "\\/");
343 _dialog
->filterWidget()->setCurrentFilter(t
);
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
>& filters
)
359 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
361 if (!_filter
.isNull())
362 _filter
.append(QString("\n"));
364 const USHORT length
= filters
.getLength();
365 for (USHORT i
= 0; i
< length
; ++i
)
367 beans::StringPair aPair
= filters
[i
];
369 _filter
.append(QString("%1|%2").arg(
370 toQString(aPair
.Second
).replace(";", " ")).arg(
371 toQString(aPair
.First
).replace("/","\\/")));
374 _filter
.append('\n');
378 void SAL_CALL
KDE4FilePicker::setValue( sal_Int16 controlId
, sal_Int16
, const uno::Any
&value
)
379 throw( uno::RuntimeException
)
381 QWidget
* widget
= _customWidgets
[controlId
];
387 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
388 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
389 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
390 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
391 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
392 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
393 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
395 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
396 cb
->setChecked(value
.getValue());
399 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
400 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
401 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
402 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
403 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
404 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
405 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
406 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
412 uno::Any SAL_CALL
KDE4FilePicker::getValue( sal_Int16 controlId
, sal_Int16
)
413 throw( uno::RuntimeException
)
417 QWidget
* widget
= _customWidgets
[controlId
];
423 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
424 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
425 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
426 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
427 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
428 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
429 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
431 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
432 res
= uno::Any(cb
->isChecked());
435 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
436 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
437 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
438 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
439 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
440 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
441 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
442 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
450 void SAL_CALL
KDE4FilePicker::enableControl( sal_Int16 controlId
, sal_Bool enable
)
451 throw( uno::RuntimeException
)
453 QWidget
* widget
= _customWidgets
[controlId
];
457 widget
->setEnabled(enable
);
461 void SAL_CALL
KDE4FilePicker::setLabel( sal_Int16 controlId
, const ::rtl::OUString
&label
)
462 throw( uno::RuntimeException
)
464 QWidget
* widget
= _customWidgets
[controlId
];
470 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
471 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
472 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
473 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
474 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
475 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
476 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
478 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
479 cb
->setText(toQString(label
));
482 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
483 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
484 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
485 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
486 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
487 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
488 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
489 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
495 rtl::OUString SAL_CALL
KDE4FilePicker::getLabel(sal_Int16 controlId
)
496 throw ( uno::RuntimeException
)
498 QWidget
* widget
= _customWidgets
[controlId
];
505 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
506 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
507 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
508 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
509 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
510 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
511 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
513 QCheckBox
* cb
= dynamic_cast<QCheckBox
*>(widget
);
517 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
518 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
519 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
520 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
521 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
522 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
523 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
524 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
528 return toOUString(label
);
531 void KDE4FilePicker::addCustomControl(sal_Int16 controlId
)
534 sal_Int32 resId
= -1;
538 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
539 resId
= STR_SVT_FILEPICKER_AUTO_EXTENSION
;
541 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
542 resId
= STR_SVT_FILEPICKER_PASSWORD
;
544 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
545 resId
= STR_SVT_FILEPICKER_FILTER_OPTIONS
;
547 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
548 resId
= STR_SVT_FILEPICKER_READONLY
;
550 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
551 resId
= STR_SVT_FILEPICKER_INSERT_AS_LINK
;
553 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
554 resId
= STR_SVT_FILEPICKER_SHOW_PREVIEW
;
556 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
557 resId
= STR_SVT_FILEPICKER_SELECTION
;
559 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
560 resId
= STR_SVT_FILEPICKER_PLAY
;
562 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
563 resId
= STR_SVT_FILEPICKER_VERSION
;
565 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
566 resId
= STR_SVT_FILEPICKER_TEMPLATES
;
568 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
569 resId
= STR_SVT_FILEPICKER_IMAGE_TEMPLATE
;
571 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
572 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
573 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
574 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
580 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
:
581 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
:
582 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
:
583 case ExtendedFilePickerElementIds::CHECKBOX_READONLY
:
584 case ExtendedFilePickerElementIds::CHECKBOX_LINK
:
585 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
:
586 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION
:
590 if (_resMgr
&& resId
!= -1)
592 rtl::OUString s
= String(ResId( resId
, *_resMgr
));
593 label
= toQString(s
);
594 label
.replace("~", "&");
597 widget
= new QCheckBox(label
, _extraControls
);
601 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
:
602 case ExtendedFilePickerElementIds::LISTBOX_VERSION
:
603 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
:
604 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
:
605 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL
:
606 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL
:
607 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL
:
608 case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR
:
614 _layout
->addWidget(widget
);
615 _customWidgets
.insert(controlId
, widget
);
619 void SAL_CALL
KDE4FilePicker::initialize( const uno::Sequence
<uno::Any
> &args
)
620 throw( uno::Exception
, uno::RuntimeException
)
625 // parameter checking
627 if (args
.getLength() == 0)
629 throw lang::IllegalArgumentException(
630 rtl::OUString::createFromAscii( "no arguments" ),
631 static_cast< XFilePicker
* >( this ), 1 );
636 if (( arg
.getValueType() != ::getCppuType((sal_Int16
*)0)) &&
637 ( arg
.getValueType() != ::getCppuType((sal_Int8
*)0)))
639 throw lang::IllegalArgumentException(
640 rtl::OUString::createFromAscii( "invalid argument type" ),
641 static_cast< XFilePicker
* >( this ), 1 );
644 sal_Int16 templateId
= -1;
648 KFileDialog::OperationMode operationMode
= KFileDialog::Opening
;
650 switch ( templateId
)
652 case FILEOPEN_SIMPLE
:
655 case FILESAVE_SIMPLE
:
656 operationMode
= KFileDialog::Saving
;
659 case FILESAVE_AUTOEXTENSION
:
660 operationMode
= KFileDialog::Saving
;
661 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
664 case FILESAVE_AUTOEXTENSION_PASSWORD
:
666 operationMode
= KFileDialog::Saving
;
667 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
668 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
);
671 case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS
:
673 operationMode
= KFileDialog::Saving
;
674 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
675 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
);
676 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS
);
679 case FILESAVE_AUTOEXTENSION_SELECTION
:
680 operationMode
= KFileDialog::Saving
;
681 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
);
682 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_SELECTION
);
685 case FILESAVE_AUTOEXTENSION_TEMPLATE
:
686 operationMode
= KFileDialog::Saving
;
687 addCustomControl( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
);
690 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE
:
691 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK
);
692 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
);
693 addCustomControl( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
);
697 addCustomControl( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY
);
700 case FILEOPEN_READONLY_VERSION
:
701 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_READONLY
);
702 addCustomControl( ExtendedFilePickerElementIds::LISTBOX_VERSION
);
705 case FILEOPEN_LINK_PREVIEW
:
706 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK
);
707 addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW
);
711 throw lang::IllegalArgumentException(
712 rtl::OUString::createFromAscii( "Unknown template" ),
713 static_cast< XFilePicker
* >( this ),
717 _dialog
->setOperationMode(operationMode
);
720 void SAL_CALL
KDE4FilePicker::cancel()
721 throw ( uno::RuntimeException
)
726 void SAL_CALL
KDE4FilePicker::disposing( const lang::EventObject
&rEvent
)
727 throw( uno::RuntimeException
)
729 uno::Reference
<XFilePickerListener
> xFilePickerListener( rEvent
.Source
, uno::UNO_QUERY
);
731 if ( xFilePickerListener
.is() )
733 removeFilePickerListener( xFilePickerListener
);
737 rtl::OUString SAL_CALL
KDE4FilePicker::getImplementationName()
738 throw( uno::RuntimeException
)
740 return rtl::OUString::createFromAscii( FILE_PICKER_IMPL_NAME
);
743 sal_Bool SAL_CALL
KDE4FilePicker::supportsService( const rtl::OUString
& ServiceName
)
744 throw( uno::RuntimeException
)
746 uno::Sequence
< ::rtl::OUString
> SupportedServicesNames
= FilePicker_getSupportedServiceNames();
748 for ( sal_Int32 n
= SupportedServicesNames
.getLength(); n
--; )
750 if ( SupportedServicesNames
[n
].compareTo( ServiceName
) == 0 )
757 uno::Sequence
< ::rtl::OUString
> SAL_CALL
KDE4FilePicker::getSupportedServiceNames()
758 throw( uno::RuntimeException
)
760 return FilePicker_getSupportedServiceNames();