1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_fpicker.hxx"
26
27 //------------------------------------------------------------------------
28 // includes
29 //------------------------------------------------------------------------
30
31 #include <tchar.h>
32 #include <com/sun/star/lang/DisposedException.hpp>
33 #include <cppuhelper/interfacecontainer.h>
34 #include <osl/diagnose.h>
35
36 #ifndef _FILEPICKER_HXX_
37 #include "filepicker.hxx"
38 #endif
39 #include "WinFileOpenImpl.hxx"
40
41 #include "FPServiceInfo.hxx"
42 #include "..\misc\WinImplHelper.hxx"
43 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
44 #include "filepickereventnotification.hxx"
45
46 #include <comphelper/sequenceasvector.hxx>
47
48 //------------------------------------------------------------------------
49 // namespace directives
50 //------------------------------------------------------------------------
51
52 using namespace com::sun::star;
53
54 using namespace ::com::sun::star::ui::dialogs;
55 using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
56
57 //------------------------------------------------------------------------
58 // defines
59 //------------------------------------------------------------------------
60
61 #define FILE_PICKER_DLL_NAME TEXT("fps.dll")
62
63 //------------------------------------------------------------------------
64 // helper functions
65 //------------------------------------------------------------------------
66
67 namespace
68 {
69 // controlling event notifications
70 const bool STARTUP_SUSPENDED = true;
71 const bool STARTUP_ALIVE = false;
72
FilePicker_getSupportedServiceNames()73 uno::Sequence<rtl::OUString> SAL_CALL FilePicker_getSupportedServiceNames()
74 {
75 uno::Sequence<rtl::OUString> aRet(2);
76 aRet[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker");
77 aRet[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker");
78 return aRet;
79 }
80 }
81
82 //-----------------------------------------------------------------------------------------
83 //
84 //-----------------------------------------------------------------------------------------
85
CFilePicker(const uno::Reference<lang::XMultiServiceFactory> & xServiceMgr)86 CFilePicker::CFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) :
87 cppu::WeakComponentImplHelper10<
88 XFilterManager,
89 XFilterGroupManager,
90 XFilePickerControlAccess,
91 XFilePickerNotifier,
92 XFilePreview,
93 XFilePicker2,
94 lang::XInitialization,
95 util::XCancellable,
96 lang::XEventListener,
97 lang::XServiceInfo>(m_rbHelperMtx),
98 m_xServiceMgr(xServiceMgr),
99 m_aAsyncEventNotifier(rBHelper)
100 {
101 HINSTANCE hInstance = GetModuleHandle(FILE_PICKER_DLL_NAME);
102 OSL_POSTCOND( hInstance, "The name of the service dll must have changed" );
103
104 // create a default FileOpen dialog without any additional ui elements
105 m_pImpl = std::auto_ptr< CWinFileOpenImpl >(
106 new CWinFileOpenImpl(
107 this,
108 true,
109 0,
110 0,
111 hInstance ) );
112 }
113
114 //------------------------------------------------------------------------------------
115 // XFPEventListenerManager
116 //------------------------------------------------------------------------------------
117
addFilePickerListener(const uno::Reference<XFilePickerListener> & xListener)118 void SAL_CALL CFilePicker::addFilePickerListener(const uno::Reference<XFilePickerListener>& xListener)
119 {
120 if ( rBHelper.bDisposed )
121 throw lang::DisposedException(
122 rtl::OUString::createFromAscii( "object is already disposed" ),
123 static_cast< XFilePicker2* >( this ) );
124
125 if ( !rBHelper.bInDispose && !rBHelper.bDisposed )
126 rBHelper.aLC.addInterface( getCppuType( &xListener ), xListener );
127 }
128
129 //-----------------------------------------------------------------------------------------
130 //
131 //-----------------------------------------------------------------------------------------
132
removeFilePickerListener(const uno::Reference<XFilePickerListener> & xListener)133 void SAL_CALL CFilePicker::removeFilePickerListener(const uno::Reference<XFilePickerListener>& xListener )
134 {
135 if ( rBHelper.bDisposed )
136 throw lang::DisposedException(
137 rtl::OUString::createFromAscii( "object is already disposed" ),
138 static_cast< XFilePicker2* >( this ) );
139
140 rBHelper.aLC.removeInterface( getCppuType( &xListener ), xListener );
141 }
142
143 // -------------------------------------------------
144 // XEventListener
145 // -------------------------------------------------
146
disposing(const lang::EventObject & aEvent)147 void SAL_CALL CFilePicker::disposing(const lang::EventObject& aEvent)
148 {
149 uno::Reference<XFilePickerListener> xFilePickerListener(aEvent.Source, ::com::sun::star::uno::UNO_QUERY);
150
151 if (xFilePickerListener.is())
152 removeFilePickerListener(xFilePickerListener);
153 }
154
155 //-----------------------------------------------------------------------------------------
156 //
157 //-----------------------------------------------------------------------------------------
158
fileSelectionChanged(FilePickerEvent aEvent)159 void SAL_CALL CFilePicker::fileSelectionChanged(FilePickerEvent aEvent)
160 {
161 aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this));
162 m_aAsyncEventNotifier.notifyEvent(
163 new CFilePickerParamEventNotification(&XFilePickerListener::fileSelectionChanged,aEvent));
164 }
165
166 //-----------------------------------------------------------------------------------------
167 //
168 //-----------------------------------------------------------------------------------------
169
directoryChanged(FilePickerEvent aEvent)170 void SAL_CALL CFilePicker::directoryChanged(FilePickerEvent aEvent)
171 {
172 aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this));
173 m_aAsyncEventNotifier.notifyEvent(
174 new CFilePickerParamEventNotification(&XFilePickerListener::directoryChanged,aEvent));
175 }
176
177 //-----------------------------------------------------------------------------------------
178 //
179 //-----------------------------------------------------------------------------------------
180
controlStateChanged(FilePickerEvent aEvent)181 void SAL_CALL CFilePicker::controlStateChanged(FilePickerEvent aEvent)
182 {
183 aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this));
184 m_aAsyncEventNotifier.notifyEvent(
185 new CFilePickerParamEventNotification(&XFilePickerListener::controlStateChanged,aEvent));
186 }
187
188 //-----------------------------------------------------------------------------------------
189 //
190 //-----------------------------------------------------------------------------------------
191
dialogSizeChanged()192 void SAL_CALL CFilePicker::dialogSizeChanged()
193 {
194 m_aAsyncEventNotifier.notifyEvent(
195 new CFilePickerEventNotification(&XFilePickerListener::dialogSizeChanged));
196 }
197
198 //-----------------------------------------------------------------------------------------
199 // If there are more then one listener the return value of the last one wins
200 //-----------------------------------------------------------------------------------------
201
helpRequested(FilePickerEvent aEvent) const202 rtl::OUString SAL_CALL CFilePicker::helpRequested(FilePickerEvent aEvent) const
203 {
204 rtl::OUString aHelpText;
205
206 ::cppu::OInterfaceContainerHelper* pICHelper =
207 rBHelper.getContainer( getCppuType((uno::Reference<XFilePickerListener>*)0));
208
209 if (pICHelper)
210 {
211 ::cppu::OInterfaceIteratorHelper iter(*pICHelper);
212
213 while(iter.hasMoreElements())
214 {
215 try
216 {
217 /*
218 if there are multiple listeners responding
219 to this notification the next response
220 overwrittes the one before if it is not empty
221 */
222
223 rtl::OUString temp;
224
225 uno::Reference<XFilePickerListener> xFPListener(iter.next(), uno::UNO_QUERY);
226 if (xFPListener.is())
227 {
228 temp = xFPListener->helpRequested(aEvent);
229 if (temp.getLength())
230 aHelpText = temp;
231 }
232
233 }
234 catch(uno::RuntimeException&)
235 {
236 OSL_ENSURE( false, "RuntimeException during event dispatching" );
237 }
238 }
239 }
240
241 return aHelpText;
242 }
243
244 //-------------------------------------
245 //
246 //-------------------------------------
247
startupEventNotification(bool bStartupSuspended)248 bool CFilePicker::startupEventNotification(bool bStartupSuspended)
249 {
250 return m_aAsyncEventNotifier.startup(bStartupSuspended);
251 }
252
253 //-------------------------------------
254 //
255 //-------------------------------------
256
shutdownEventNotification()257 void CFilePicker::shutdownEventNotification()
258 {
259 m_aAsyncEventNotifier.shutdown();
260 }
261
262 //-------------------------------------
263 //
264 //-------------------------------------
265
suspendEventNotification()266 void CFilePicker::suspendEventNotification()
267 {
268 m_aAsyncEventNotifier.suspend();
269 }
270
271 //-------------------------------------
272 //
273 //-------------------------------------
274
resumeEventNotification()275 void CFilePicker::resumeEventNotification()
276 {
277 m_aAsyncEventNotifier.resume();
278 }
279
280 //------------------------------------------------------------------------------------
281 // XFilePicker functions
282 //------------------------------------------------------------------------------------
283
setMultiSelectionMode(sal_Bool bMode)284 void SAL_CALL CFilePicker::setMultiSelectionMode(sal_Bool bMode)
285 {
286 OSL_ASSERT(0 != m_pImpl.get());
287 osl::MutexGuard aGuard(m_aMutex);
288 m_pImpl->setMultiSelectionMode(bMode);
289 }
290
291 //-----------------------------------------------------------------------------------------
292 //
293 //-----------------------------------------------------------------------------------------
294
setTitle(const rtl::OUString & aTitle)295 void SAL_CALL CFilePicker::setTitle(const rtl::OUString& aTitle)
296 {
297 OSL_ASSERT(0 != m_pImpl.get());
298 osl::MutexGuard aGuard(m_aMutex);
299 m_pImpl->setTitle(aTitle);
300 }
301
302 //-----------------------------------------------------------------------------------------
303 //
304 //-----------------------------------------------------------------------------------------
305
appendFilter(const rtl::OUString & aTitle,const rtl::OUString & aFilter)306 void SAL_CALL CFilePicker::appendFilter(const rtl::OUString& aTitle, const rtl::OUString& aFilter)
307 {
308 OSL_ASSERT(0 != m_pImpl.get());
309 osl::MutexGuard aGuard(m_aMutex);
310 m_pImpl->appendFilter(aTitle, aFilter);
311 }
312
313 //-----------------------------------------------------------------------------------------
314 //
315 //-----------------------------------------------------------------------------------------
316
setCurrentFilter(const rtl::OUString & aTitle)317 void SAL_CALL CFilePicker::setCurrentFilter(const rtl::OUString& aTitle)
318 {
319 OSL_ASSERT(0 != m_pImpl.get());
320 osl::MutexGuard aGuard(m_aMutex);
321 m_pImpl->setCurrentFilter(aTitle);
322 }
323
324 //-----------------------------------------------------------------------------------------
325 //
326 //-----------------------------------------------------------------------------------------
327
getCurrentFilter()328 rtl::OUString SAL_CALL CFilePicker::getCurrentFilter()
329 {
330 OSL_ASSERT(0 != m_pImpl.get());
331 osl::MutexGuard aGuard(m_aMutex);
332 return m_pImpl->getCurrentFilter();
333 }
334
335 //-----------------------------------------------------------------------------------------
336 //
337 //-----------------------------------------------------------------------------------------
338
appendFilterGroup(const rtl::OUString & sGroupTitle,const uno::Sequence<beans::StringPair> & aFilters)339 void SAL_CALL CFilePicker::appendFilterGroup(const rtl::OUString& sGroupTitle, const uno::Sequence<beans::StringPair>& aFilters)
340 {
341 OSL_ASSERT(0 != m_pImpl.get());
342 osl::MutexGuard aGuard(m_aMutex);
343 m_pImpl->appendFilterGroup(sGroupTitle, aFilters);
344 }
345
346 //-----------------------------------------------------------------------------------------
347 //
348 //-----------------------------------------------------------------------------------------
349
setDefaultName(const rtl::OUString & aName)350 void SAL_CALL CFilePicker::setDefaultName(const rtl::OUString& aName)
351 {
352 OSL_ASSERT(0 != m_pImpl.get());
353 osl::MutexGuard aGuard(m_aMutex);
354 m_pImpl->setDefaultName(aName);
355 }
356
357 //-----------------------------------------------------------------------------------------
358 //
359 //-----------------------------------------------------------------------------------------
360
setDisplayDirectory(const rtl::OUString & aDirectory)361 void SAL_CALL CFilePicker::setDisplayDirectory(const rtl::OUString& aDirectory)
362 {
363 OSL_ASSERT(0 != m_pImpl.get());
364 osl::MutexGuard aGuard(m_aMutex);
365 m_pImpl->setDisplayDirectory(aDirectory);
366 }
367
368 //-----------------------------------------------------------------------------------------
369 //
370 //-----------------------------------------------------------------------------------------
371
getDisplayDirectory()372 rtl::OUString SAL_CALL CFilePicker::getDisplayDirectory()
373 {
374 OSL_ASSERT(0 != m_pImpl.get());
375 osl::MutexGuard aGuard(m_aMutex);
376 return m_pImpl->getDisplayDirectory();
377 }
378
379 //-----------------------------------------------------------------------------------------
380 //
381 //-----------------------------------------------------------------------------------------
382
getFiles()383 uno::Sequence<rtl::OUString> SAL_CALL CFilePicker::getFiles()
384 {
385 OSL_ASSERT(0 != m_pImpl.get());
386 osl::MutexGuard aGuard(m_aMutex);
387 return m_pImpl->getFiles();
388 }
389
390 //-----------------------------------------------------------------------------------------
391 //
392 //-----------------------------------------------------------------------------------------
getSelectedFiles()393 uno::Sequence< ::rtl::OUString > SAL_CALL CFilePicker::getSelectedFiles()
394 {
395 OSL_ASSERT(0 != m_pImpl.get());
396 osl::MutexGuard aGuard(m_aMutex);
397
398 const uno::Sequence< ::rtl::OUString > lSource = m_pImpl->getFiles();
399 const ::sal_Int32 c = lSource.getLength();
400 if (c < 2)
401 return lSource;
402
403 const ::rtl::OUString sPath = lSource[0];
404 ::comphelper::SequenceAsVector< ::rtl::OUString > lTarget;
405 ::sal_Int32 i = 1;
406 for (i=1; i<c; ++i)
407 {
408 const ::rtl::OUString sFile = lSource[i];
409 if (sFile.indexOf ('/') > 0)
410 {
411 // a) file contains own path !
412 lTarget.push_back(sFile);
413 }
414 else
415 {
416 // b) file is relative to given path
417 ::rtl::OUStringBuffer sFull(256);
418
419 sFull.append (sPath);
420 sFull.appendAscii("/" );
421 sFull.append (sFile);
422
423 lTarget.push_back(sFull.makeStringAndClear());
424 }
425 }
426
427 return lTarget.getAsConstList();
428 }
429
430 //-----------------------------------------------------------------------------------------
431 //
432 //-----------------------------------------------------------------------------------------
433
execute()434 sal_Int16 SAL_CALL CFilePicker::execute()
435 {
436 OSL_ASSERT(0 != m_pImpl.get());
437
438 sal_Int16 ret;
439
440 if (startupEventNotification(STARTUP_SUSPENDED))
441 {
442 // we should not block in this call else
443 // in the case of an event the client can't
444 // call another function an we run into a
445 // deadlock !!!!!
446 ret = m_pImpl->execute( );
447
448 shutdownEventNotification();
449 }
450 else
451 {
452 OSL_ENSURE(sal_False, "Could not start event notifier thread!");
453
454 throw uno::RuntimeException(
455 rtl::OUString::createFromAscii("Error executing dialog"),
456 static_cast<XFilePicker2*>(this));
457 }
458
459 return ret;
460 }
461
462 //------------------------------------------------------------------------------------
463 // XFilePicker functions
464 //------------------------------------------------------------------------------------
465
setValue(sal_Int16 aControlId,sal_Int16 aControlAction,const uno::Any & aValue)466 void SAL_CALL CFilePicker::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue)
467 {
468 OSL_ASSERT(0 != m_pImpl.get());
469
470 osl::MutexGuard aGuard(m_aMutex);
471 m_pImpl->setValue(aControlId, aControlAction, aValue);
472 }
473
474 //-----------------------------------------------------------------------------------------
475 //
476 //-----------------------------------------------------------------------------------------
477
getValue(sal_Int16 aControlId,sal_Int16 aControlAction)478 uno::Any SAL_CALL CFilePicker::getValue(sal_Int16 aControlId, sal_Int16 aControlAction)
479 {
480 OSL_ASSERT(0 != m_pImpl.get());
481
482 osl::MutexGuard aGuard(m_aMutex);
483 return m_pImpl->getValue(aControlId, aControlAction);
484 }
485
486 //-----------------------------------------------------------------------------------------
487 //
488 //-----------------------------------------------------------------------------------------
489
enableControl(sal_Int16 aControlId,sal_Bool bEnable)490 void SAL_CALL CFilePicker::enableControl(sal_Int16 aControlId, sal_Bool bEnable)
491 {
492 OSL_ASSERT( 0 != m_pImpl.get( ) );
493
494 osl::MutexGuard aGuard( m_aMutex );
495 m_pImpl->enableControl( aControlId, bEnable );
496 }
497
498 //-----------------------------------------------------------------------------------------
499 //
500 //-----------------------------------------------------------------------------------------
501
setLabel(sal_Int16 aControlId,const::rtl::OUString & aLabel)502 void SAL_CALL CFilePicker::setLabel(sal_Int16 aControlId, const ::rtl::OUString& aLabel)
503 {
504 OSL_ASSERT(0 != m_pImpl.get());
505
506 osl::MutexGuard aGuard(m_aMutex);
507 m_pImpl->setLabel(aControlId, aLabel);
508 }
509
510 //-----------------------------------------------------------------------------------------
511 //
512 //-----------------------------------------------------------------------------------------
513
getLabel(sal_Int16 aControlId)514 rtl::OUString SAL_CALL CFilePicker::getLabel(sal_Int16 aControlId)
515 {
516 OSL_ASSERT(0 != m_pImpl.get());
517
518 osl::MutexGuard aGuard(m_aMutex);
519 return m_pImpl->getLabel(aControlId);
520 }
521
522 //------------------------------------------------------------------------------------
523 //
524 //------------------------------------------------------------------------------------
525
getSupportedImageFormats()526 uno::Sequence<sal_Int16> SAL_CALL CFilePicker::getSupportedImageFormats()
527 {
528 OSL_ASSERT(0 != m_pImpl.get());
529
530 osl::MutexGuard aGuard(m_aMutex);
531 return m_pImpl->getSupportedImageFormats();
532 }
533
534 //------------------------------------------------------------------------------------
535 //
536 //------------------------------------------------------------------------------------
537
getTargetColorDepth()538 sal_Int32 SAL_CALL CFilePicker::getTargetColorDepth()
539 {
540 OSL_ASSERT(0 != m_pImpl.get());
541
542 osl::MutexGuard aGuard(m_aMutex);
543 return m_pImpl->getTargetColorDepth();
544 }
545
546 //------------------------------------------------------------------------------------
547 //
548 //------------------------------------------------------------------------------------
549
getAvailableWidth()550 sal_Int32 SAL_CALL CFilePicker::getAvailableWidth()
551 {
552 OSL_ASSERT(0 != m_pImpl.get());
553
554 osl::MutexGuard aGuard(m_aMutex);
555 return m_pImpl->getAvailableWidth();
556 }
557
558 //------------------------------------------------------------------------------------
559 //
560 //------------------------------------------------------------------------------------
561
getAvailableHeight()562 sal_Int32 SAL_CALL CFilePicker::getAvailableHeight()
563 {
564 OSL_ASSERT(0 != m_pImpl.get());
565
566 osl::MutexGuard aGuard(m_aMutex);
567 return m_pImpl->getAvailableHeight();
568 }
569
570 //------------------------------------------------------------------------------------
571 //
572 //------------------------------------------------------------------------------------
573
setImage(sal_Int16 aImageFormat,const uno::Any & aImage)574 void SAL_CALL CFilePicker::setImage(sal_Int16 aImageFormat, const uno::Any& aImage)
575 {
576 OSL_ASSERT(0 != m_pImpl.get());
577
578 osl::MutexGuard aGuard(m_aMutex);
579 m_pImpl->setImage(aImageFormat, aImage);
580 }
581
582 //------------------------------------------------------------------------------------
583 //
584 //------------------------------------------------------------------------------------
585
setShowState(sal_Bool bShowState)586 sal_Bool SAL_CALL CFilePicker::setShowState(sal_Bool bShowState)
587 {
588 OSL_ASSERT(0 != m_pImpl.get());
589
590 osl::MutexGuard aGuard(m_aMutex);
591 return m_pImpl->setShowState(bShowState);
592 }
593
594 //------------------------------------------------------------------------------------
595 //
596 //------------------------------------------------------------------------------------
597
getShowState()598 sal_Bool SAL_CALL CFilePicker::getShowState()
599 {
600 OSL_ASSERT(0 != m_pImpl.get());
601
602 osl::MutexGuard aGuard(m_aMutex);
603 return m_pImpl->getShowState();
604 }
605
606 //------------------------------------------------------------------------------------
607 //
608 //------------------------------------------------------------------------------------
609
initialize(const uno::Sequence<uno::Any> & aArguments)610 void SAL_CALL CFilePicker::initialize(const uno::Sequence<uno::Any>& aArguments)
611 {
612 // parameter checking
613 uno::Any aAny;
614 if ( 0 == aArguments.getLength( ) )
615 throw lang::IllegalArgumentException(
616 rtl::OUString::createFromAscii( "no arguments" ),
617 static_cast<XFilePicker2*>(this), 1);
618
619 aAny = aArguments[0];
620
621 if ( (aAny.getValueType() != ::getCppuType((sal_Int16*)0)) &&
622 (aAny.getValueType() != ::getCppuType((sal_Int8*)0)) )
623 throw lang::IllegalArgumentException(
624 rtl::OUString::createFromAscii("invalid argument type"),
625 static_cast<XFilePicker2*>(this), 1);
626
627 sal_Int16 templateId = -1;
628 aAny >>= templateId;
629
630 sal_Bool bFileOpenDialog = sal_True;
631 sal_uInt32 winResTemplateId = 0;
632 sal_Bool bIsWin2000 = IsWindows2000Platform();
633
634 switch ( templateId )
635 {
636 case FILEOPEN_SIMPLE:
637 bFileOpenDialog = sal_True;
638 break;
639
640 case FILESAVE_SIMPLE:
641 bFileOpenDialog = sal_False;
642 break;
643
644 case FILESAVE_AUTOEXTENSION_PASSWORD:
645 bFileOpenDialog = sal_False;
646 if ( bIsWin2000 )
647 winResTemplateId = TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID;
648 else
649 winResTemplateId = TMPL95_FILESAVE_AUTOEXT_PASSWORD_BOX_ID;
650 break;
651
652 case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
653 bFileOpenDialog = sal_False;
654 if ( bIsWin2000 )
655 winResTemplateId = TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX;
656 else
657 winResTemplateId = TMPL95_AUTOEXT_PASSWORD_FILTEROPTION_BOX;
658 break;
659
660 case FILESAVE_AUTOEXTENSION_SELECTION:
661 bFileOpenDialog = sal_False;
662 if ( bIsWin2000 )
663 winResTemplateId = TMPL2000_AUTOEXT_SELECTION_BOX;
664 else
665 winResTemplateId = TMPL95_AUTOEXT_SELECTION_BOX;
666 break;
667
668 case FILESAVE_AUTOEXTENSION_TEMPLATE:
669 bFileOpenDialog = sal_False;
670 if ( bIsWin2000 )
671 winResTemplateId = TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID;
672 else
673 winResTemplateId = TMPL95_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID;
674 break;
675
676 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
677 if ( bIsWin2000 )
678 winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID;
679 else
680 winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_ID;
681 break;
682
683 case FILEOPEN_PLAY:
684 if ( bIsWin2000 )
685 winResTemplateId = TMPL2000_PLAY_PUSHBUTTON;
686 else
687 winResTemplateId = TMPL95_PLAY_PUSHBUTTON;
688 break;
689
690 case FILEOPEN_READONLY_VERSION:
691 if ( bIsWin2000 )
692 winResTemplateId = TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID;
693 else
694 winResTemplateId = TMPL95_FILEOPEN_READONLY_VERSION_BOX_ID;
695 break;
696
697 case FILEOPEN_LINK_PREVIEW:
698 if ( bIsWin2000 )
699 winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID;
700 else
701 winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID;
702 break;
703
704 case FILESAVE_AUTOEXTENSION:
705 bFileOpenDialog = sal_False;
706 if ( bIsWin2000 )
707 winResTemplateId = TMPL2000_FILESAVE_AUTOEXT;
708 else
709 winResTemplateId = TMPL95_FILESAVE_AUTOEXT;
710 break;
711
712 default:
713 throw lang::IllegalArgumentException(
714 rtl::OUString::createFromAscii( "Unknown template" ),
715 static_cast< XFilePicker2* >( this ),
716 1 );
717 }
718
719 HINSTANCE hInstance = GetModuleHandle( FILE_PICKER_DLL_NAME );
720 OSL_POSTCOND( hInstance, "The name of the service dll must have changed" );
721
722 // create a new impl-class here based on the
723 // given string, if the given string is empty
724 // we do nothing
725 m_pImpl = std::auto_ptr< CWinFileOpenImpl >(
726 new CWinFileOpenImpl(
727 this,
728 bFileOpenDialog,
729 0,
730 winResTemplateId,
731 hInstance ) );
732 }
733
734 //------------------------------------------------------------------------------------
735 //
736 //------------------------------------------------------------------------------------
737
cancel()738 void SAL_CALL CFilePicker::cancel()
739 {
740 OSL_ASSERT(m_pImpl.get());
741
742 osl::MutexGuard aGuard(m_aMutex);
743 m_pImpl->cancel();
744 }
745
746 // -------------------------------------------------
747 // XServiceInfo
748 // -------------------------------------------------
749
getImplementationName()750 rtl::OUString SAL_CALL CFilePicker::getImplementationName()
751 {
752 return rtl::OUString::createFromAscii(FILE_PICKER_IMPL_NAME);
753 }
754
755 // -------------------------------------------------
756 // XServiceInfo
757 // -------------------------------------------------
758
supportsService(const rtl::OUString & ServiceName)759 sal_Bool SAL_CALL CFilePicker::supportsService(const rtl::OUString& ServiceName)
760 {
761 uno::Sequence <rtl::OUString> SupportedServicesNames = FilePicker_getSupportedServiceNames();
762
763 for (sal_Int32 n = SupportedServicesNames.getLength(); n--;)
764 if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
765 return sal_True;
766
767 return sal_False;
768 }
769
770 // -------------------------------------------------
771 // XServiceInfo
772 // -------------------------------------------------
773
getSupportedServiceNames()774 uno::Sequence<rtl::OUString> SAL_CALL CFilePicker::getSupportedServiceNames()
775 {
776 return FilePicker_getSupportedServiceNames();
777 }
778