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 // controling event notifications 70 const bool STARTUP_SUSPENDED = true; 71 const bool STARTUP_ALIVE = false; 72 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 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 118 void SAL_CALL CFilePicker::addFilePickerListener(const uno::Reference<XFilePickerListener>& xListener) 119 throw(uno::RuntimeException) 120 { 121 if ( rBHelper.bDisposed ) 122 throw lang::DisposedException( 123 rtl::OUString::createFromAscii( "object is already disposed" ), 124 static_cast< XFilePicker2* >( this ) ); 125 126 if ( !rBHelper.bInDispose && !rBHelper.bDisposed ) 127 rBHelper.aLC.addInterface( getCppuType( &xListener ), xListener ); 128 } 129 130 //----------------------------------------------------------------------------------------- 131 // 132 //----------------------------------------------------------------------------------------- 133 134 void SAL_CALL CFilePicker::removeFilePickerListener(const uno::Reference<XFilePickerListener>& xListener ) 135 throw(uno::RuntimeException) 136 { 137 if ( rBHelper.bDisposed ) 138 throw lang::DisposedException( 139 rtl::OUString::createFromAscii( "object is already disposed" ), 140 static_cast< XFilePicker2* >( this ) ); 141 142 rBHelper.aLC.removeInterface( getCppuType( &xListener ), xListener ); 143 } 144 145 // ------------------------------------------------- 146 // XEventListener 147 // ------------------------------------------------- 148 149 void SAL_CALL CFilePicker::disposing(const lang::EventObject& aEvent) throw(uno::RuntimeException) 150 { 151 uno::Reference<XFilePickerListener> xFilePickerListener(aEvent.Source, ::com::sun::star::uno::UNO_QUERY); 152 153 if (xFilePickerListener.is()) 154 removeFilePickerListener(xFilePickerListener); 155 } 156 157 //----------------------------------------------------------------------------------------- 158 // 159 //----------------------------------------------------------------------------------------- 160 161 void SAL_CALL CFilePicker::fileSelectionChanged(FilePickerEvent aEvent) 162 { 163 aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this)); 164 m_aAsyncEventNotifier.notifyEvent( 165 new CFilePickerParamEventNotification(&XFilePickerListener::fileSelectionChanged,aEvent)); 166 } 167 168 //----------------------------------------------------------------------------------------- 169 // 170 //----------------------------------------------------------------------------------------- 171 172 void SAL_CALL CFilePicker::directoryChanged(FilePickerEvent aEvent) 173 { 174 aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this)); 175 m_aAsyncEventNotifier.notifyEvent( 176 new CFilePickerParamEventNotification(&XFilePickerListener::directoryChanged,aEvent)); 177 } 178 179 //----------------------------------------------------------------------------------------- 180 // 181 //----------------------------------------------------------------------------------------- 182 183 void SAL_CALL CFilePicker::controlStateChanged(FilePickerEvent aEvent) 184 { 185 aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this)); 186 m_aAsyncEventNotifier.notifyEvent( 187 new CFilePickerParamEventNotification(&XFilePickerListener::controlStateChanged,aEvent)); 188 } 189 190 //----------------------------------------------------------------------------------------- 191 // 192 //----------------------------------------------------------------------------------------- 193 194 void SAL_CALL CFilePicker::dialogSizeChanged() 195 { 196 m_aAsyncEventNotifier.notifyEvent( 197 new CFilePickerEventNotification(&XFilePickerListener::dialogSizeChanged)); 198 } 199 200 //----------------------------------------------------------------------------------------- 201 // If there are more then one listener the return value of the last one wins 202 //----------------------------------------------------------------------------------------- 203 204 rtl::OUString SAL_CALL CFilePicker::helpRequested(FilePickerEvent aEvent) const 205 { 206 rtl::OUString aHelpText; 207 208 ::cppu::OInterfaceContainerHelper* pICHelper = 209 rBHelper.getContainer( getCppuType((uno::Reference<XFilePickerListener>*)0)); 210 211 if (pICHelper) 212 { 213 ::cppu::OInterfaceIteratorHelper iter(*pICHelper); 214 215 while(iter.hasMoreElements()) 216 { 217 try 218 { 219 /* 220 if there are multiple listeners responding 221 to this notification the next response 222 overwrittes the one before if it is not empty 223 */ 224 225 rtl::OUString temp; 226 227 uno::Reference<XFilePickerListener> xFPListener(iter.next(), uno::UNO_QUERY); 228 if (xFPListener.is()) 229 { 230 temp = xFPListener->helpRequested(aEvent); 231 if (temp.getLength()) 232 aHelpText = temp; 233 } 234 235 } 236 catch(uno::RuntimeException&) 237 { 238 OSL_ENSURE( false, "RuntimeException during event dispatching" ); 239 } 240 } 241 } 242 243 return aHelpText; 244 } 245 246 //------------------------------------- 247 // 248 //------------------------------------- 249 250 bool CFilePicker::startupEventNotification(bool bStartupSuspended) 251 { 252 return m_aAsyncEventNotifier.startup(bStartupSuspended); 253 } 254 255 //------------------------------------- 256 // 257 //------------------------------------- 258 259 void CFilePicker::shutdownEventNotification() 260 { 261 m_aAsyncEventNotifier.shutdown(); 262 } 263 264 //------------------------------------- 265 // 266 //------------------------------------- 267 268 void CFilePicker::suspendEventNotification() 269 { 270 m_aAsyncEventNotifier.suspend(); 271 } 272 273 //------------------------------------- 274 // 275 //------------------------------------- 276 277 void CFilePicker::resumeEventNotification() 278 { 279 m_aAsyncEventNotifier.resume(); 280 } 281 282 //------------------------------------------------------------------------------------ 283 // XFilePicker functions 284 //------------------------------------------------------------------------------------ 285 286 void SAL_CALL CFilePicker::setMultiSelectionMode(sal_Bool bMode) throw(uno::RuntimeException) 287 { 288 OSL_ASSERT(0 != m_pImpl.get()); 289 osl::MutexGuard aGuard(m_aMutex); 290 m_pImpl->setMultiSelectionMode(bMode); 291 } 292 293 //----------------------------------------------------------------------------------------- 294 // 295 //----------------------------------------------------------------------------------------- 296 297 void SAL_CALL CFilePicker::setTitle(const rtl::OUString& aTitle) throw(uno::RuntimeException) 298 { 299 OSL_ASSERT(0 != m_pImpl.get()); 300 osl::MutexGuard aGuard(m_aMutex); 301 m_pImpl->setTitle(aTitle); 302 } 303 304 //----------------------------------------------------------------------------------------- 305 // 306 //----------------------------------------------------------------------------------------- 307 308 void SAL_CALL CFilePicker::appendFilter(const rtl::OUString& aTitle, const rtl::OUString& aFilter) 309 throw(lang::IllegalArgumentException, uno::RuntimeException) 310 { 311 OSL_ASSERT(0 != m_pImpl.get()); 312 osl::MutexGuard aGuard(m_aMutex); 313 m_pImpl->appendFilter(aTitle, aFilter); 314 } 315 316 //----------------------------------------------------------------------------------------- 317 // 318 //----------------------------------------------------------------------------------------- 319 320 void SAL_CALL CFilePicker::setCurrentFilter(const rtl::OUString& aTitle) 321 throw(lang::IllegalArgumentException, uno::RuntimeException) 322 { 323 OSL_ASSERT(0 != m_pImpl.get()); 324 osl::MutexGuard aGuard(m_aMutex); 325 m_pImpl->setCurrentFilter(aTitle); 326 } 327 328 //----------------------------------------------------------------------------------------- 329 // 330 //----------------------------------------------------------------------------------------- 331 332 rtl::OUString SAL_CALL CFilePicker::getCurrentFilter() throw(uno::RuntimeException) 333 { 334 OSL_ASSERT(0 != m_pImpl.get()); 335 osl::MutexGuard aGuard(m_aMutex); 336 return m_pImpl->getCurrentFilter(); 337 } 338 339 //----------------------------------------------------------------------------------------- 340 // 341 //----------------------------------------------------------------------------------------- 342 343 void SAL_CALL CFilePicker::appendFilterGroup(const rtl::OUString& sGroupTitle, const uno::Sequence<beans::StringPair>& aFilters) 344 throw (lang::IllegalArgumentException, uno::RuntimeException) 345 { 346 OSL_ASSERT(0 != m_pImpl.get()); 347 osl::MutexGuard aGuard(m_aMutex); 348 m_pImpl->appendFilterGroup(sGroupTitle, aFilters); 349 } 350 351 //----------------------------------------------------------------------------------------- 352 // 353 //----------------------------------------------------------------------------------------- 354 355 void SAL_CALL CFilePicker::setDefaultName(const rtl::OUString& aName) 356 throw(uno::RuntimeException) 357 { 358 OSL_ASSERT(0 != m_pImpl.get()); 359 osl::MutexGuard aGuard(m_aMutex); 360 m_pImpl->setDefaultName(aName); 361 } 362 363 //----------------------------------------------------------------------------------------- 364 // 365 //----------------------------------------------------------------------------------------- 366 367 void SAL_CALL CFilePicker::setDisplayDirectory(const rtl::OUString& aDirectory) 368 throw(lang::IllegalArgumentException, uno::RuntimeException) 369 { 370 OSL_ASSERT(0 != m_pImpl.get()); 371 osl::MutexGuard aGuard(m_aMutex); 372 m_pImpl->setDisplayDirectory(aDirectory); 373 } 374 375 //----------------------------------------------------------------------------------------- 376 // 377 //----------------------------------------------------------------------------------------- 378 379 rtl::OUString SAL_CALL CFilePicker::getDisplayDirectory() throw(uno::RuntimeException) 380 { 381 OSL_ASSERT(0 != m_pImpl.get()); 382 osl::MutexGuard aGuard(m_aMutex); 383 return m_pImpl->getDisplayDirectory(); 384 } 385 386 //----------------------------------------------------------------------------------------- 387 // 388 //----------------------------------------------------------------------------------------- 389 390 uno::Sequence<rtl::OUString> SAL_CALL CFilePicker::getFiles() throw(uno::RuntimeException) 391 { 392 OSL_ASSERT(0 != m_pImpl.get()); 393 osl::MutexGuard aGuard(m_aMutex); 394 return m_pImpl->getFiles(); 395 } 396 397 //----------------------------------------------------------------------------------------- 398 // 399 //----------------------------------------------------------------------------------------- 400 uno::Sequence< ::rtl::OUString > SAL_CALL CFilePicker::getSelectedFiles() throw (uno::RuntimeException) 401 { 402 OSL_ASSERT(0 != m_pImpl.get()); 403 osl::MutexGuard aGuard(m_aMutex); 404 405 const uno::Sequence< ::rtl::OUString > lSource = m_pImpl->getFiles(); 406 const ::sal_Int32 c = lSource.getLength(); 407 if (c < 2) 408 return lSource; 409 410 const ::rtl::OUString sPath = lSource[0]; 411 ::comphelper::SequenceAsVector< ::rtl::OUString > lTarget; 412 ::sal_Int32 i = 1; 413 for (i=1; i<c; ++i) 414 { 415 const ::rtl::OUString sFile = lSource[i]; 416 if (sFile.indexOf ('/') > 0) 417 { 418 // a) file contains own path ! 419 lTarget.push_back(sFile); 420 } 421 else 422 { 423 // b) file is relative to given path 424 ::rtl::OUStringBuffer sFull(256); 425 426 sFull.append (sPath); 427 sFull.appendAscii("/" ); 428 sFull.append (sFile); 429 430 lTarget.push_back(sFull.makeStringAndClear()); 431 } 432 } 433 434 return lTarget.getAsConstList(); 435 } 436 437 //----------------------------------------------------------------------------------------- 438 // 439 //----------------------------------------------------------------------------------------- 440 441 sal_Int16 SAL_CALL CFilePicker::execute() throw(uno::RuntimeException) 442 { 443 OSL_ASSERT(0 != m_pImpl.get()); 444 445 sal_Int16 ret; 446 447 if (startupEventNotification(STARTUP_SUSPENDED)) 448 { 449 // we should not block in this call else 450 // in the case of an event the client can't 451 // call another function an we run into a 452 // deadlock !!!!! 453 ret = m_pImpl->execute( ); 454 455 shutdownEventNotification(); 456 } 457 else 458 { 459 OSL_ENSURE(sal_False, "Could not start event notifier thread!"); 460 461 throw uno::RuntimeException( 462 rtl::OUString::createFromAscii("Error executing dialog"), 463 static_cast<XFilePicker2*>(this)); 464 } 465 466 return ret; 467 } 468 469 //------------------------------------------------------------------------------------ 470 // XFilePicker functions 471 //------------------------------------------------------------------------------------ 472 473 void SAL_CALL CFilePicker::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue) 474 throw(uno::RuntimeException) 475 { 476 OSL_ASSERT(0 != m_pImpl.get()); 477 478 osl::MutexGuard aGuard(m_aMutex); 479 m_pImpl->setValue(aControlId, aControlAction, aValue); 480 } 481 482 //----------------------------------------------------------------------------------------- 483 // 484 //----------------------------------------------------------------------------------------- 485 486 uno::Any SAL_CALL CFilePicker::getValue(sal_Int16 aControlId, sal_Int16 aControlAction) 487 throw(uno::RuntimeException) 488 { 489 OSL_ASSERT(0 != m_pImpl.get()); 490 491 osl::MutexGuard aGuard(m_aMutex); 492 return m_pImpl->getValue(aControlId, aControlAction); 493 } 494 495 //----------------------------------------------------------------------------------------- 496 // 497 //----------------------------------------------------------------------------------------- 498 499 void SAL_CALL CFilePicker::enableControl(sal_Int16 aControlId, sal_Bool bEnable) 500 throw(uno::RuntimeException) 501 { 502 OSL_ASSERT( 0 != m_pImpl.get( ) ); 503 504 osl::MutexGuard aGuard( m_aMutex ); 505 m_pImpl->enableControl( aControlId, bEnable ); 506 } 507 508 //----------------------------------------------------------------------------------------- 509 // 510 //----------------------------------------------------------------------------------------- 511 512 void SAL_CALL CFilePicker::setLabel(sal_Int16 aControlId, const ::rtl::OUString& aLabel) 513 throw (uno::RuntimeException) 514 { 515 OSL_ASSERT(0 != m_pImpl.get()); 516 517 osl::MutexGuard aGuard(m_aMutex); 518 m_pImpl->setLabel(aControlId, aLabel); 519 } 520 521 //----------------------------------------------------------------------------------------- 522 // 523 //----------------------------------------------------------------------------------------- 524 525 rtl::OUString SAL_CALL CFilePicker::getLabel(sal_Int16 aControlId) 526 throw (uno::RuntimeException) 527 { 528 OSL_ASSERT(0 != m_pImpl.get()); 529 530 osl::MutexGuard aGuard(m_aMutex); 531 return m_pImpl->getLabel(aControlId); 532 } 533 534 //------------------------------------------------------------------------------------ 535 // 536 //------------------------------------------------------------------------------------ 537 538 uno::Sequence<sal_Int16> SAL_CALL CFilePicker::getSupportedImageFormats() throw (uno::RuntimeException) 539 { 540 OSL_ASSERT(0 != m_pImpl.get()); 541 542 osl::MutexGuard aGuard(m_aMutex); 543 return m_pImpl->getSupportedImageFormats(); 544 } 545 546 //------------------------------------------------------------------------------------ 547 // 548 //------------------------------------------------------------------------------------ 549 550 sal_Int32 SAL_CALL CFilePicker::getTargetColorDepth() throw (uno::RuntimeException) 551 { 552 OSL_ASSERT(0 != m_pImpl.get()); 553 554 osl::MutexGuard aGuard(m_aMutex); 555 return m_pImpl->getTargetColorDepth(); 556 } 557 558 //------------------------------------------------------------------------------------ 559 // 560 //------------------------------------------------------------------------------------ 561 562 sal_Int32 SAL_CALL CFilePicker::getAvailableWidth() throw (uno::RuntimeException) 563 { 564 OSL_ASSERT(0 != m_pImpl.get()); 565 566 osl::MutexGuard aGuard(m_aMutex); 567 return m_pImpl->getAvailableWidth(); 568 } 569 570 //------------------------------------------------------------------------------------ 571 // 572 //------------------------------------------------------------------------------------ 573 574 sal_Int32 SAL_CALL CFilePicker::getAvailableHeight() throw (uno::RuntimeException) 575 { 576 OSL_ASSERT(0 != m_pImpl.get()); 577 578 osl::MutexGuard aGuard(m_aMutex); 579 return m_pImpl->getAvailableHeight(); 580 } 581 582 //------------------------------------------------------------------------------------ 583 // 584 //------------------------------------------------------------------------------------ 585 586 void SAL_CALL CFilePicker::setImage(sal_Int16 aImageFormat, const uno::Any& aImage) 587 throw (lang::IllegalArgumentException, uno::RuntimeException) 588 { 589 OSL_ASSERT(0 != m_pImpl.get()); 590 591 osl::MutexGuard aGuard(m_aMutex); 592 m_pImpl->setImage(aImageFormat, aImage); 593 } 594 595 //------------------------------------------------------------------------------------ 596 // 597 //------------------------------------------------------------------------------------ 598 599 sal_Bool SAL_CALL CFilePicker::setShowState(sal_Bool bShowState) throw (uno::RuntimeException) 600 { 601 OSL_ASSERT(0 != m_pImpl.get()); 602 603 osl::MutexGuard aGuard(m_aMutex); 604 return m_pImpl->setShowState(bShowState); 605 } 606 607 //------------------------------------------------------------------------------------ 608 // 609 //------------------------------------------------------------------------------------ 610 611 sal_Bool SAL_CALL CFilePicker::getShowState() throw (uno::RuntimeException) 612 { 613 OSL_ASSERT(0 != m_pImpl.get()); 614 615 osl::MutexGuard aGuard(m_aMutex); 616 return m_pImpl->getShowState(); 617 } 618 619 //------------------------------------------------------------------------------------ 620 // 621 //------------------------------------------------------------------------------------ 622 623 void SAL_CALL CFilePicker::initialize(const uno::Sequence<uno::Any>& aArguments) 624 throw( uno::Exception, uno::RuntimeException) 625 { 626 // parameter checking 627 uno::Any aAny; 628 if ( 0 == aArguments.getLength( ) ) 629 throw lang::IllegalArgumentException( 630 rtl::OUString::createFromAscii( "no arguments" ), 631 static_cast<XFilePicker2*>(this), 1); 632 633 aAny = aArguments[0]; 634 635 if ( (aAny.getValueType() != ::getCppuType((sal_Int16*)0)) && 636 (aAny.getValueType() != ::getCppuType((sal_Int8*)0)) ) 637 throw lang::IllegalArgumentException( 638 rtl::OUString::createFromAscii("invalid argument type"), 639 static_cast<XFilePicker2*>(this), 1); 640 641 sal_Int16 templateId = -1; 642 aAny >>= templateId; 643 644 sal_Bool bFileOpenDialog = sal_True; 645 sal_uInt32 winResTemplateId = 0; 646 sal_Bool bIsWin2000 = IsWindows2000Platform(); 647 648 switch ( templateId ) 649 { 650 case FILEOPEN_SIMPLE: 651 bFileOpenDialog = sal_True; 652 break; 653 654 case FILESAVE_SIMPLE: 655 bFileOpenDialog = sal_False; 656 break; 657 658 case FILESAVE_AUTOEXTENSION_PASSWORD: 659 bFileOpenDialog = sal_False; 660 if ( bIsWin2000 ) 661 winResTemplateId = TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID; 662 else 663 winResTemplateId = TMPL95_FILESAVE_AUTOEXT_PASSWORD_BOX_ID; 664 break; 665 666 case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: 667 bFileOpenDialog = sal_False; 668 if ( bIsWin2000 ) 669 winResTemplateId = TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX; 670 else 671 winResTemplateId = TMPL95_AUTOEXT_PASSWORD_FILTEROPTION_BOX; 672 break; 673 674 case FILESAVE_AUTOEXTENSION_SELECTION: 675 bFileOpenDialog = sal_False; 676 if ( bIsWin2000 ) 677 winResTemplateId = TMPL2000_AUTOEXT_SELECTION_BOX; 678 else 679 winResTemplateId = TMPL95_AUTOEXT_SELECTION_BOX; 680 break; 681 682 case FILESAVE_AUTOEXTENSION_TEMPLATE: 683 bFileOpenDialog = sal_False; 684 if ( bIsWin2000 ) 685 winResTemplateId = TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID; 686 else 687 winResTemplateId = TMPL95_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID; 688 break; 689 690 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: 691 if ( bIsWin2000 ) 692 winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID; 693 else 694 winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_ID; 695 break; 696 697 case FILEOPEN_PLAY: 698 if ( bIsWin2000 ) 699 winResTemplateId = TMPL2000_PLAY_PUSHBUTTON; 700 else 701 winResTemplateId = TMPL95_PLAY_PUSHBUTTON; 702 break; 703 704 case FILEOPEN_READONLY_VERSION: 705 if ( bIsWin2000 ) 706 winResTemplateId = TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID; 707 else 708 winResTemplateId = TMPL95_FILEOPEN_READONLY_VERSION_BOX_ID; 709 break; 710 711 case FILEOPEN_LINK_PREVIEW: 712 if ( bIsWin2000 ) 713 winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID; 714 else 715 winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID; 716 break; 717 718 case FILESAVE_AUTOEXTENSION: 719 bFileOpenDialog = sal_False; 720 if ( bIsWin2000 ) 721 winResTemplateId = TMPL2000_FILESAVE_AUTOEXT; 722 else 723 winResTemplateId = TMPL95_FILESAVE_AUTOEXT; 724 break; 725 726 default: 727 throw lang::IllegalArgumentException( 728 rtl::OUString::createFromAscii( "Unknown template" ), 729 static_cast< XFilePicker2* >( this ), 730 1 ); 731 } 732 733 HINSTANCE hInstance = GetModuleHandle( FILE_PICKER_DLL_NAME ); 734 OSL_POSTCOND( hInstance, "The name of the service dll must have changed" ); 735 736 // create a new impl-class here based on the 737 // given string, if the given string is empty 738 // we do nothing 739 m_pImpl = std::auto_ptr< CWinFileOpenImpl >( 740 new CWinFileOpenImpl( 741 this, 742 bFileOpenDialog, 743 0, 744 winResTemplateId, 745 hInstance ) ); 746 } 747 748 //------------------------------------------------------------------------------------ 749 // 750 //------------------------------------------------------------------------------------ 751 752 void SAL_CALL CFilePicker::cancel() 753 throw(uno::RuntimeException) 754 { 755 OSL_ASSERT(m_pImpl.get()); 756 757 osl::MutexGuard aGuard(m_aMutex); 758 m_pImpl->cancel(); 759 } 760 761 // ------------------------------------------------- 762 // XServiceInfo 763 // ------------------------------------------------- 764 765 rtl::OUString SAL_CALL CFilePicker::getImplementationName() 766 throw(uno::RuntimeException) 767 { 768 return rtl::OUString::createFromAscii(FILE_PICKER_IMPL_NAME); 769 } 770 771 // ------------------------------------------------- 772 // XServiceInfo 773 // ------------------------------------------------- 774 775 sal_Bool SAL_CALL CFilePicker::supportsService(const rtl::OUString& ServiceName) 776 throw(uno::RuntimeException ) 777 { 778 uno::Sequence <rtl::OUString> SupportedServicesNames = FilePicker_getSupportedServiceNames(); 779 780 for (sal_Int32 n = SupportedServicesNames.getLength(); n--;) 781 if (SupportedServicesNames[n].compareTo(ServiceName) == 0) 782 return sal_True; 783 784 return sal_False; 785 } 786 787 // ------------------------------------------------- 788 // XServiceInfo 789 // ------------------------------------------------- 790 791 uno::Sequence<rtl::OUString> SAL_CALL CFilePicker::getSupportedServiceNames() 792 throw(uno::RuntimeException) 793 { 794 return FilePicker_getSupportedServiceNames(); 795 } 796