1b557fc96SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b557fc96SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b557fc96SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b557fc96SAndrew Rist * distributed with this work for additional information 6b557fc96SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b557fc96SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b557fc96SAndrew Rist * "License"); you may not use this file except in compliance 9b557fc96SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b557fc96SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b557fc96SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b557fc96SAndrew Rist * software distributed under the License is distributed on an 15b557fc96SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b557fc96SAndrew Rist * KIND, either express or implied. See the License for the 17b557fc96SAndrew Rist * specific language governing permissions and limitations 18b557fc96SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b557fc96SAndrew Rist *************************************************************/ 21b557fc96SAndrew Rist 22b557fc96SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_fpicker.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "OfficeFilePicker.hxx" 28cdf0e10cSrcweir #include "iodlg.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef _LIST_ 31cdf0e10cSrcweir #include <list> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _FUNCTIONAL_ 34cdf0e10cSrcweir #include <functional> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _ALGORITHM_ 37cdf0e10cSrcweir #include <algorithm> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <tools/urlobj.hxx> 40cdf0e10cSrcweir #include <tools/debug.hxx> 41cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 42cdf0e10cSrcweir #include "svl/svstdarr.hxx" 43cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 44cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/FilePickerEvent.hpp> 45cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp> 46cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> 47cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 48cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 49cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 50cdf0e10cSrcweir #include <com/sun/star/beans/StringPair.hpp> 51cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 52cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 53cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 54cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 55cdf0e10cSrcweir #include <comphelper/sequence.hxx> 56cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 57cdf0e10cSrcweir #include "vos/mutex.hxx" 58cdf0e10cSrcweir #ifndef _SV_APP_HXX 59cdf0e10cSrcweir #include "vcl/svapp.hxx" 60cdf0e10cSrcweir #endif 61cdf0e10cSrcweir 62cdf0e10cSrcweir // define ---------------------------------------------------------------- 63cdf0e10cSrcweir 64cdf0e10cSrcweir #define MAKE_ANY ::com::sun::star::uno::makeAny 65cdf0e10cSrcweir 66cdf0e10cSrcweir // using ---------------------------------------------------------------- 67cdf0e10cSrcweir 68cdf0e10cSrcweir using namespace ::com::sun::star::container; 69cdf0e10cSrcweir using namespace ::com::sun::star::lang; 70cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 71cdf0e10cSrcweir using namespace ::com::sun::star::uno; 72cdf0e10cSrcweir using namespace ::com::sun::star::beans; 73cdf0e10cSrcweir using namespace ::com::sun::star::awt; 74cdf0e10cSrcweir using namespace ::utl; 75cdf0e10cSrcweir 76cdf0e10cSrcweir //===================================================================== 77cdf0e10cSrcweir 78cdf0e10cSrcweir //===================================================================== 79cdf0e10cSrcweir 80cdf0e10cSrcweir struct FilterEntry 81cdf0e10cSrcweir { 82cdf0e10cSrcweir protected: 83cdf0e10cSrcweir ::rtl::OUString m_sTitle; 84cdf0e10cSrcweir ::rtl::OUString m_sFilter; 85cdf0e10cSrcweir 86cdf0e10cSrcweir UnoFilterList m_aSubFilters; 87cdf0e10cSrcweir 88cdf0e10cSrcweir public: 89cdf0e10cSrcweir FilterEntry( const ::rtl::OUString& _rTitle, const ::rtl::OUString& _rFilter ) 90cdf0e10cSrcweir :m_sTitle( _rTitle ) 91cdf0e10cSrcweir ,m_sFilter( _rFilter ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir FilterEntry( const ::rtl::OUString& _rTitle, const UnoFilterList& _rSubFilters ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir ::rtl::OUString getTitle() const { return m_sTitle; } 98cdf0e10cSrcweir ::rtl::OUString getFilter() const { return m_sFilter; } 99cdf0e10cSrcweir 100cdf0e10cSrcweir /// determines if the filter has sub filter (i.e., the filter is a filter group in real) 101cdf0e10cSrcweir sal_Bool hasSubFilters( ) const; 102cdf0e10cSrcweir 103cdf0e10cSrcweir /** retrieves the filters belonging to the entry 104cdf0e10cSrcweir @return 105cdf0e10cSrcweir the number of sub filters 106cdf0e10cSrcweir */ 107cdf0e10cSrcweir sal_Int32 getSubFilters( UnoFilterList& _rSubFilterList ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir // helpers for iterating the sub filters 110cdf0e10cSrcweir const UnoFilterEntry* beginSubFilters() const { return m_aSubFilters.getConstArray(); } 111cdf0e10cSrcweir const UnoFilterEntry* endSubFilters() const { return m_aSubFilters.getConstArray() + m_aSubFilters.getLength(); } 112cdf0e10cSrcweir }; 113cdf0e10cSrcweir 114cdf0e10cSrcweir //===================================================================== 115cdf0e10cSrcweir 116cdf0e10cSrcweir //--------------------------------------------------------------------- 117cdf0e10cSrcweir FilterEntry::FilterEntry( const ::rtl::OUString& _rTitle, const UnoFilterList& _rSubFilters ) 118cdf0e10cSrcweir :m_sTitle( _rTitle ) 119cdf0e10cSrcweir ,m_aSubFilters( _rSubFilters ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir //--------------------------------------------------------------------- 124cdf0e10cSrcweir sal_Bool FilterEntry::hasSubFilters( ) const 125cdf0e10cSrcweir { 126cdf0e10cSrcweir return ( 0 < m_aSubFilters.getLength() ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //--------------------------------------------------------------------- 130cdf0e10cSrcweir sal_Int32 FilterEntry::getSubFilters( UnoFilterList& _rSubFilterList ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir _rSubFilterList = m_aSubFilters; 133cdf0e10cSrcweir return m_aSubFilters.getLength(); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir // struct ElementEntry_Impl ---------------------------------------------- 137cdf0e10cSrcweir 138cdf0e10cSrcweir struct ElementEntry_Impl 139cdf0e10cSrcweir { 140cdf0e10cSrcweir sal_Int16 m_nElementID; 141cdf0e10cSrcweir sal_Int16 m_nControlAction; 142cdf0e10cSrcweir Any m_aValue; 143cdf0e10cSrcweir rtl::OUString m_aLabel; 144cdf0e10cSrcweir sal_Bool m_bEnabled : 1; 145cdf0e10cSrcweir 146cdf0e10cSrcweir sal_Bool m_bHasValue : 1; 147cdf0e10cSrcweir sal_Bool m_bHasLabel : 1; 148cdf0e10cSrcweir sal_Bool m_bHasEnabled : 1; 149cdf0e10cSrcweir 150cdf0e10cSrcweir ElementEntry_Impl( sal_Int16 nId ); 151cdf0e10cSrcweir 152cdf0e10cSrcweir void setValue( const Any& rVal ) { m_aValue = rVal; m_bHasValue = sal_True; } 153cdf0e10cSrcweir void setAction( sal_Int16 nAction ) { m_nControlAction = nAction; } 154cdf0e10cSrcweir void setLabel( const rtl::OUString& rVal ) { m_aLabel = rVal; m_bHasLabel = sal_True; } 155cdf0e10cSrcweir void setEnabled( sal_Bool bEnabled ) { m_bEnabled = bEnabled; m_bHasEnabled = sal_True; } 156cdf0e10cSrcweir }; 157cdf0e10cSrcweir 158cdf0e10cSrcweir ElementEntry_Impl::ElementEntry_Impl( sal_Int16 nId ) 159cdf0e10cSrcweir : m_nElementID( nId ) 160cdf0e10cSrcweir , m_nControlAction( 0 ) 161cdf0e10cSrcweir , m_bEnabled( sal_False ) 162cdf0e10cSrcweir , m_bHasValue( sal_False ) 163cdf0e10cSrcweir , m_bHasLabel( sal_False ) 164cdf0e10cSrcweir , m_bHasEnabled( sal_False ) 165cdf0e10cSrcweir {} 166cdf0e10cSrcweir 167cdf0e10cSrcweir //------------------------------------------------------------------------------------ 168cdf0e10cSrcweir void SvtFilePicker::prepareExecute() 169cdf0e10cSrcweir { 170cdf0e10cSrcweir // set the default directory 171cdf0e10cSrcweir // --**-- doesn't match the spec yet 172cdf0e10cSrcweir if ( m_aDisplayDirectory.getLength() > 0 || m_aDefaultName.getLength() > 0 ) 173cdf0e10cSrcweir { 174*1aa1f6e5SDamjan Jovanovic sal_Bool isFileSet = sal_False; 175cdf0e10cSrcweir if ( m_aDisplayDirectory.getLength() > 0 ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir 178*1aa1f6e5SDamjan Jovanovic INetURLObject aPath; 179*1aa1f6e5SDamjan Jovanovic INetURLObject givenPath( m_aDisplayDirectory ); 180*1aa1f6e5SDamjan Jovanovic if (!givenPath.HasError()) 181*1aa1f6e5SDamjan Jovanovic aPath = givenPath; 182*1aa1f6e5SDamjan Jovanovic else 183*1aa1f6e5SDamjan Jovanovic { 184*1aa1f6e5SDamjan Jovanovic INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); 185*1aa1f6e5SDamjan Jovanovic aPath = aStdDirObj; 186*1aa1f6e5SDamjan Jovanovic } 187cdf0e10cSrcweir if ( m_aDefaultName.getLength() > 0 ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir aPath.insertName( m_aDefaultName ); 190cdf0e10cSrcweir getDialog()->SetHasFilename( true ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir String sPath = aPath.GetMainURL( INetURLObject::NO_DECODE ); 193*1aa1f6e5SDamjan Jovanovic getDialog()->SetPath( sPath ); 194*1aa1f6e5SDamjan Jovanovic isFileSet = sal_True; 195cdf0e10cSrcweir } 196*1aa1f6e5SDamjan Jovanovic if ( !isFileSet && m_aDefaultName.getLength() > 0 ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir getDialog()->SetPath( m_aDefaultName ); 199cdf0e10cSrcweir getDialog()->SetHasFilename( true ); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir else 203cdf0e10cSrcweir { 204cdf0e10cSrcweir // Default-Standard-Dir setzen 205cdf0e10cSrcweir INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); 206cdf0e10cSrcweir getDialog()->SetPath( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE ) ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir // set the control values and set the control labels, too 210cdf0e10cSrcweir if ( m_pElemList && !m_pElemList->empty() ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir ElementList::iterator aListIter; 215cdf0e10cSrcweir for ( aListIter = m_pElemList->begin(); 216cdf0e10cSrcweir aListIter != m_pElemList->end(); ++aListIter ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir ElementEntry_Impl& rEntry = *aListIter; 219cdf0e10cSrcweir if ( rEntry.m_bHasValue ) 220cdf0e10cSrcweir aAccess.setValue( rEntry.m_nElementID, rEntry.m_nControlAction, rEntry.m_aValue ); 221cdf0e10cSrcweir if ( rEntry.m_bHasLabel ) 222cdf0e10cSrcweir aAccess.setLabel( rEntry.m_nElementID, rEntry.m_aLabel ); 223cdf0e10cSrcweir if ( rEntry.m_bHasEnabled ) 224cdf0e10cSrcweir aAccess.enableControl( rEntry.m_nElementID, rEntry.m_bEnabled ); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir getDialog()->updateListboxLabelSizes(); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir if ( m_pFilterList && !m_pFilterList->empty() ) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir for ( FilterList::iterator aListIter = m_pFilterList->begin(); 233cdf0e10cSrcweir aListIter != m_pFilterList->end(); 234cdf0e10cSrcweir ++aListIter 235cdf0e10cSrcweir ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir if ( aListIter->hasSubFilters() ) 238cdf0e10cSrcweir { // it's a filter group 239cdf0e10cSrcweir UnoFilterList aSubFilters; 240cdf0e10cSrcweir aListIter->getSubFilters( aSubFilters ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir getDialog()->AddFilterGroup( aListIter->getTitle(), aSubFilters ); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir else 245cdf0e10cSrcweir // it's a single filter 246cdf0e10cSrcweir getDialog()->AddFilter( aListIter->getTitle(), aListIter->getFilter() ); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir // set the default filter 251cdf0e10cSrcweir if ( m_aCurrentFilter.getLength() > 0 ) 252cdf0e10cSrcweir getDialog()->SetCurFilter( m_aCurrentFilter ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir //----------------------------------------------------------------------------- 257cdf0e10cSrcweir IMPL_LINK( SvtFilePicker, DialogClosedHdl, Dialog*, pDlg ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir if ( m_xDlgClosedListener.is() ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir sal_Int16 nRet = static_cast< sal_Int16 >( pDlg->GetResult() ); 262cdf0e10cSrcweir ::com::sun::star::ui::dialogs::DialogClosedEvent aEvent( *this, nRet ); 263cdf0e10cSrcweir m_xDlgClosedListener->dialogClosed( aEvent ); 264cdf0e10cSrcweir m_xDlgClosedListener.clear(); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir return 0; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir //------------------------------------------------------------------------------------ 270cdf0e10cSrcweir // SvtFilePicker 271cdf0e10cSrcweir //------------------------------------------------------------------------------------ 272cdf0e10cSrcweir 273cdf0e10cSrcweir //------------------------------------------------------------------------------------ 274cdf0e10cSrcweir WinBits SvtFilePicker::getWinBits( WinBits& rExtraBits ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir // set the winbits for creating the filedialog 277cdf0e10cSrcweir WinBits nBits = 0L; 278cdf0e10cSrcweir rExtraBits = 0L; 279cdf0e10cSrcweir 28007a3d7f1SPedro Giffuni // set the standard bits according to the service name 281cdf0e10cSrcweir if ( m_nServiceType == TemplateDescription::FILEOPEN_SIMPLE ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir nBits = WB_OPEN; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILESAVE_SIMPLE ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir nBits = WB_SAVEAS; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir nBits = WB_SAVEAS; 292cdf0e10cSrcweir rExtraBits = SFX_EXTRA_AUTOEXTENSION; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir nBits = WB_SAVEAS | SFXWB_PASSWORD; 297cdf0e10cSrcweir rExtraBits = SFX_EXTRA_AUTOEXTENSION; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir nBits = WB_SAVEAS | SFXWB_PASSWORD; 302cdf0e10cSrcweir rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_FILTEROPTIONS; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE ) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir nBits = WB_SAVEAS; 307cdf0e10cSrcweir rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_TEMPLATES; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir nBits = WB_SAVEAS; 312cdf0e10cSrcweir rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_SELECTION; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir nBits = WB_OPEN; 318cdf0e10cSrcweir rExtraBits = SFX_EXTRA_INSERTASLINK | SFX_EXTRA_SHOWPREVIEW | SFX_EXTRA_IMAGE_TEMPLATE; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILEOPEN_PLAY ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir nBits = WB_OPEN; 323cdf0e10cSrcweir rExtraBits = SFX_EXTRA_PLAYBUTTON; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILEOPEN_READONLY_VERSION ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir nBits = WB_OPEN | SFXWB_READONLY; 328cdf0e10cSrcweir rExtraBits = SFX_EXTRA_SHOWVERSIONS; 329cdf0e10cSrcweir } 330cdf0e10cSrcweir else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir nBits = WB_OPEN; 333cdf0e10cSrcweir rExtraBits = SFX_EXTRA_INSERTASLINK | SFX_EXTRA_SHOWPREVIEW; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir if ( m_bMultiSelection && ( ( nBits & WB_OPEN ) == WB_OPEN ) ) 336cdf0e10cSrcweir nBits |= SFXWB_MULTISELECTION; 337cdf0e10cSrcweir 338cdf0e10cSrcweir return nBits; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir //------------------------------------------------------------------------------------ 342cdf0e10cSrcweir void SvtFilePicker::notify( sal_Int16 _nEventId, sal_Int16 _nControlId ) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir if ( !m_xListener.is() ) 345cdf0e10cSrcweir return; 346cdf0e10cSrcweir 347cdf0e10cSrcweir FilePickerEvent aEvent( *this, _nControlId ); 348cdf0e10cSrcweir 349cdf0e10cSrcweir switch ( _nEventId ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir case FILE_SELECTION_CHANGED: 352cdf0e10cSrcweir m_xListener->fileSelectionChanged( aEvent ); 353cdf0e10cSrcweir break; 354cdf0e10cSrcweir case DIRECTORY_CHANGED: 355cdf0e10cSrcweir m_xListener->directoryChanged( aEvent ); 356cdf0e10cSrcweir break; 357cdf0e10cSrcweir case HELP_REQUESTED: 358cdf0e10cSrcweir m_xListener->helpRequested( aEvent ); 359cdf0e10cSrcweir break; 360cdf0e10cSrcweir case CTRL_STATE_CHANGED: 361cdf0e10cSrcweir m_xListener->controlStateChanged( aEvent ); 362cdf0e10cSrcweir break; 363cdf0e10cSrcweir case DIALOG_SIZE_CHANGED: 364cdf0e10cSrcweir m_xListener->dialogSizeChanged(); 365cdf0e10cSrcweir break; 366cdf0e10cSrcweir default: 367cdf0e10cSrcweir DBG_ERRORFILE( "SvtFilePicker::notify(): Unknown event id!" ); 368cdf0e10cSrcweir break; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir //------------------------------------------------------------------------------------ 373cdf0e10cSrcweir namespace { 374cdf0e10cSrcweir //................................................................................ 375cdf0e10cSrcweir struct FilterTitleMatch : public ::std::unary_function< FilterEntry, bool > 376cdf0e10cSrcweir { 377cdf0e10cSrcweir protected: 378cdf0e10cSrcweir const ::rtl::OUString& rTitle; 379cdf0e10cSrcweir 380cdf0e10cSrcweir public: 381cdf0e10cSrcweir FilterTitleMatch( const ::rtl::OUString& _rTitle ) : rTitle( _rTitle ) { } 382cdf0e10cSrcweir 383cdf0e10cSrcweir //............................................................................ 384cdf0e10cSrcweir bool operator () ( const FilterEntry& _rEntry ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir sal_Bool bMatch; 387cdf0e10cSrcweir if ( !_rEntry.hasSubFilters() ) 388cdf0e10cSrcweir // a real filter 389cdf0e10cSrcweir bMatch = ( _rEntry.getTitle() == rTitle ); 390cdf0e10cSrcweir else 391cdf0e10cSrcweir // a filter group -> search the sub filters 392cdf0e10cSrcweir bMatch = 393cdf0e10cSrcweir _rEntry.endSubFilters() != ::std::find_if( 394cdf0e10cSrcweir _rEntry.beginSubFilters(), 395cdf0e10cSrcweir _rEntry.endSubFilters(), 396cdf0e10cSrcweir *this 397cdf0e10cSrcweir ); 398cdf0e10cSrcweir 399cdf0e10cSrcweir return bMatch ? true : false; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir bool operator () ( const UnoFilterEntry& _rEntry ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir return _rEntry.First == rTitle ? true : false; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir }; 406cdf0e10cSrcweir } 407cdf0e10cSrcweir 408cdf0e10cSrcweir //------------------------------------------------------------------------------------ 409cdf0e10cSrcweir sal_Bool SvtFilePicker::FilterNameExists( const ::rtl::OUString& rTitle ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir sal_Bool bRet = sal_False; 412cdf0e10cSrcweir 413cdf0e10cSrcweir if ( m_pFilterList ) 414cdf0e10cSrcweir bRet = 415cdf0e10cSrcweir m_pFilterList->end() != ::std::find_if( 416cdf0e10cSrcweir m_pFilterList->begin(), 417cdf0e10cSrcweir m_pFilterList->end(), 418cdf0e10cSrcweir FilterTitleMatch( rTitle ) 419cdf0e10cSrcweir ); 420cdf0e10cSrcweir 421cdf0e10cSrcweir return bRet; 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir //------------------------------------------------------------------------------------ 425cdf0e10cSrcweir sal_Bool SvtFilePicker::FilterNameExists( const UnoFilterList& _rGroupedFilters ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir sal_Bool bRet = sal_False; 428cdf0e10cSrcweir 429cdf0e10cSrcweir if ( m_pFilterList ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir const UnoFilterEntry* pStart = _rGroupedFilters.getConstArray(); 432cdf0e10cSrcweir const UnoFilterEntry* pEnd = pStart + _rGroupedFilters.getLength(); 433cdf0e10cSrcweir for ( ; pStart != pEnd; ++pStart ) 434cdf0e10cSrcweir if ( m_pFilterList->end() != ::std::find_if( m_pFilterList->begin(), m_pFilterList->end(), FilterTitleMatch( pStart->First ) ) ) 435cdf0e10cSrcweir break; 436cdf0e10cSrcweir 437cdf0e10cSrcweir bRet = pStart != pEnd; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir return bRet; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir //------------------------------------------------------------------------------------ 444cdf0e10cSrcweir void SvtFilePicker::ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir if ( !m_pFilterList ) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir m_pFilterList = new FilterList; 449cdf0e10cSrcweir 450cdf0e10cSrcweir // set the first filter to the current filter 451cdf0e10cSrcweir if ( ! m_aCurrentFilter.getLength() ) 452cdf0e10cSrcweir m_aCurrentFilter = _rInitialCurrentFilter; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir //------------------------------------------------------------------------------------ 457cdf0e10cSrcweir // class SvtFilePicker 458cdf0e10cSrcweir //------------------------------------------------------------------------------------ 459cdf0e10cSrcweir SvtFilePicker::SvtFilePicker( const Reference < XMultiServiceFactory >& xFactory ) 460cdf0e10cSrcweir :OCommonPicker( xFactory ) 461cdf0e10cSrcweir ,m_pFilterList ( NULL ) 462cdf0e10cSrcweir ,m_pElemList ( NULL ) 463cdf0e10cSrcweir ,m_bMultiSelection ( sal_False ) 464cdf0e10cSrcweir ,m_nServiceType ( TemplateDescription::FILEOPEN_SIMPLE ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir SvtFilePicker::~SvtFilePicker() 469cdf0e10cSrcweir { 470cdf0e10cSrcweir if ( m_pFilterList && !m_pFilterList->empty() ) 471cdf0e10cSrcweir m_pFilterList->erase( m_pFilterList->begin(), m_pFilterList->end() ); 472cdf0e10cSrcweir delete m_pFilterList; 473cdf0e10cSrcweir 474cdf0e10cSrcweir if ( m_pElemList && !m_pElemList->empty() ) 475cdf0e10cSrcweir m_pElemList->erase( m_pElemList->begin(), m_pElemList->end() ); 476cdf0e10cSrcweir delete m_pElemList; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir //------------------------------------------------------------------------------------ 480cdf0e10cSrcweir sal_Int16 SvtFilePicker::implExecutePicker( ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir getDialog()->SetFileCallback( this ); 483cdf0e10cSrcweir 484cdf0e10cSrcweir prepareExecute(); 485cdf0e10cSrcweir 486cdf0e10cSrcweir getDialog()->EnableAutocompletion( sal_True ); 487cdf0e10cSrcweir // now we are ready to execute the dialog 488cdf0e10cSrcweir sal_Int16 nRet = getDialog()->Execute(); 489cdf0e10cSrcweir 490cdf0e10cSrcweir // the execution of the dialog yields, so it is possible the at this point the window or the dialog is closed 491cdf0e10cSrcweir if ( getDialog() ) 492cdf0e10cSrcweir getDialog()->SetFileCallback( NULL ); 493cdf0e10cSrcweir 494cdf0e10cSrcweir return nRet; 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir //------------------------------------------------------------------------------------ 498cdf0e10cSrcweir SvtFileDialog* SvtFilePicker::implCreateDialog( Window* _pParent ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir WinBits nExtraBits; 501cdf0e10cSrcweir WinBits nBits = getWinBits( nExtraBits ); 502cdf0e10cSrcweir 503cdf0e10cSrcweir SvtFileDialog* dialog = new SvtFileDialog( _pParent, nBits, nExtraBits ); 504cdf0e10cSrcweir 505cdf0e10cSrcweir // Set StandardDir if present 506cdf0e10cSrcweir if ( m_aStandardDir.getLength() > 0) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir String sStandardDir = String( m_aStandardDir ); 509cdf0e10cSrcweir dialog->SetStandardDir( sStandardDir ); 510cdf0e10cSrcweir dialog->SetBlackList( m_aBlackList ); 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir return dialog; 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir //------------------------------------------------------------------------------------ 517cdf0e10cSrcweir // disambiguate XInterface 518cdf0e10cSrcweir //------------------------------------------------------------------------------------ 519cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( SvtFilePicker, OCommonPicker, SvtFilePicker_Base ) 520cdf0e10cSrcweir 521cdf0e10cSrcweir //------------------------------------------------------------------------------------ 522cdf0e10cSrcweir // disambiguate XTypeProvider 523cdf0e10cSrcweir //------------------------------------------------------------------------------------ 524cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvtFilePicker, OCommonPicker, SvtFilePicker_Base ) 525cdf0e10cSrcweir 526cdf0e10cSrcweir //------------------------------------------------------------------------------------ 527cdf0e10cSrcweir // XExecutableDialog functions 528cdf0e10cSrcweir //------------------------------------------------------------------------------------ 529cdf0e10cSrcweir 530cdf0e10cSrcweir //------------------------------------------------------------------------------------ 531cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir OCommonPicker::setTitle( _rTitle ); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir //------------------------------------------------------------------------------------ 537cdf0e10cSrcweir sal_Int16 SAL_CALL SvtFilePicker::execute( ) throw (RuntimeException) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir return OCommonPicker::execute(); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir //------------------------------------------------------------------------------------ 543cdf0e10cSrcweir // XAsynchronousExecutableDialog functions 544cdf0e10cSrcweir //------------------------------------------------------------------------------------ 545cdf0e10cSrcweir 546cdf0e10cSrcweir //------------------------------------------------------------------------------------ 547cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setDialogTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir setTitle( _rTitle ); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir //------------------------------------------------------------------------------------ 553cdf0e10cSrcweir void SAL_CALL SvtFilePicker::startExecuteModal( const Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (RuntimeException) 554cdf0e10cSrcweir { 555cdf0e10cSrcweir m_xDlgClosedListener = xListener; 556cdf0e10cSrcweir prepareDialog(); 557cdf0e10cSrcweir prepareExecute(); 558cdf0e10cSrcweir getDialog()->EnableAutocompletion( sal_True ); 559cdf0e10cSrcweir getDialog()->StartExecuteModal( LINK( this, SvtFilePicker, DialogClosedHdl ) ); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir //------------------------------------------------------------------------------------ 563cdf0e10cSrcweir // XFilePicker functions 564cdf0e10cSrcweir //------------------------------------------------------------------------------------ 565cdf0e10cSrcweir 566cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setMultiSelectionMode( sal_Bool bMode ) throw( RuntimeException ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir checkAlive(); 569cdf0e10cSrcweir 570cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 571cdf0e10cSrcweir m_bMultiSelection = bMode; 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setDefaultName( const rtl::OUString& aName ) throw( RuntimeException ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir checkAlive(); 577cdf0e10cSrcweir 578cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 579cdf0e10cSrcweir m_aDefaultName = aName; 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setDisplayDirectory( const rtl::OUString& aDirectory ) 583cdf0e10cSrcweir throw( IllegalArgumentException, RuntimeException ) 584cdf0e10cSrcweir { 585cdf0e10cSrcweir checkAlive(); 586cdf0e10cSrcweir 587cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 588cdf0e10cSrcweir m_aDisplayDirectory = aDirectory; 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getDisplayDirectory() throw( RuntimeException ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir checkAlive(); 594cdf0e10cSrcweir 595cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 596cdf0e10cSrcweir if ( getDialog() ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir rtl::OUString aPath = getDialog()->GetPath(); 599cdf0e10cSrcweir 600cdf0e10cSrcweir // #97148# ---- 601cdf0e10cSrcweir if( m_aOldHideDirectory == aPath ) 602cdf0e10cSrcweir return m_aOldDisplayDirectory; 603cdf0e10cSrcweir m_aOldHideDirectory = aPath; 604cdf0e10cSrcweir 605cdf0e10cSrcweir // #102204# ----- 606cdf0e10cSrcweir if( !getDialog()->ContentIsFolder( aPath ) ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir INetURLObject aFolder( aPath ); 609cdf0e10cSrcweir aFolder.CutLastName(); 610cdf0e10cSrcweir aPath = aFolder.GetMainURL( INetURLObject::NO_DECODE ); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir m_aOldDisplayDirectory = aPath; 613cdf0e10cSrcweir return aPath; 614cdf0e10cSrcweir } 615cdf0e10cSrcweir else 616cdf0e10cSrcweir return m_aDisplayDirectory; 617cdf0e10cSrcweir } 618cdf0e10cSrcweir 619cdf0e10cSrcweir Sequence< rtl::OUString > SAL_CALL SvtFilePicker::getFiles() throw( RuntimeException ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir checkAlive(); 622cdf0e10cSrcweir 623cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 624cdf0e10cSrcweir if ( ! getDialog() ) 625cdf0e10cSrcweir { 626cdf0e10cSrcweir Sequence< rtl::OUString > aEmpty; 627cdf0e10cSrcweir return aEmpty; 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir // if there is more than one path we have to return the path to the 631cdf0e10cSrcweir // files first and then the list of the selected entries 632cdf0e10cSrcweir 633cdf0e10cSrcweir SvStringsDtor* pPathList = getDialog()->GetPathList(); 634cdf0e10cSrcweir sal_uInt16 i, nCount = pPathList->Count(); 635cdf0e10cSrcweir sal_uInt16 nTotal = nCount > 1 ? nCount+1: nCount; 636cdf0e10cSrcweir 637cdf0e10cSrcweir Sequence< rtl::OUString > aPath( nTotal ); 638cdf0e10cSrcweir 639cdf0e10cSrcweir if ( nCount == 1 ) 640cdf0e10cSrcweir aPath[0] = rtl::OUString( *pPathList->GetObject( 0 ) ); 641cdf0e10cSrcweir else if ( nCount > 1 ) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir INetURLObject aObj( *pPathList->GetObject( 0 ) ); 644cdf0e10cSrcweir aObj.removeSegment(); 645cdf0e10cSrcweir aPath[0] = aObj.GetMainURL( INetURLObject::NO_DECODE ); 646cdf0e10cSrcweir 647cdf0e10cSrcweir for ( i = 0; i < nCount; /* i++ is done below */ ) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir aObj.SetURL( *pPathList->GetObject(i++) ); 650cdf0e10cSrcweir aPath[i] = aObj.getName(); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir } 653cdf0e10cSrcweir 654cdf0e10cSrcweir delete pPathList; 655cdf0e10cSrcweir return aPath; 656cdf0e10cSrcweir } 657cdf0e10cSrcweir 658cdf0e10cSrcweir //------------------------------------------------------------------------------------ 659cdf0e10cSrcweir // XFilePickerControlAccess functions 660cdf0e10cSrcweir //------------------------------------------------------------------------------------ 661cdf0e10cSrcweir 662cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID, 663cdf0e10cSrcweir sal_Int16 nControlAction, 664cdf0e10cSrcweir const Any& rValue ) 665cdf0e10cSrcweir throw( RuntimeException ) 666cdf0e10cSrcweir { 667cdf0e10cSrcweir checkAlive(); 668cdf0e10cSrcweir 669cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 670cdf0e10cSrcweir if ( getDialog() ) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); 673cdf0e10cSrcweir aAccess.setValue( nElementID, nControlAction, rValue ); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir else 676cdf0e10cSrcweir { 677cdf0e10cSrcweir if ( !m_pElemList ) 678cdf0e10cSrcweir m_pElemList = new ElementList; 679cdf0e10cSrcweir 680cdf0e10cSrcweir sal_Bool bFound = sal_False; 681cdf0e10cSrcweir ElementList::iterator aListIter; 682cdf0e10cSrcweir 683cdf0e10cSrcweir for ( aListIter = m_pElemList->begin(); 684cdf0e10cSrcweir aListIter != m_pElemList->end(); ++aListIter ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir ElementEntry_Impl& rEntry = *aListIter; 687cdf0e10cSrcweir if ( ( rEntry.m_nElementID == nElementID ) && 688cdf0e10cSrcweir ( !rEntry.m_bHasValue || ( rEntry.m_nControlAction == nControlAction ) ) ) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir rEntry.setAction( nControlAction ); 691cdf0e10cSrcweir rEntry.setValue( rValue ); 692cdf0e10cSrcweir bFound = sal_True; 693cdf0e10cSrcweir } 694cdf0e10cSrcweir } 695cdf0e10cSrcweir 696cdf0e10cSrcweir if ( !bFound ) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir ElementEntry_Impl aNew( nElementID ); 699cdf0e10cSrcweir aNew.setAction( nControlAction ); 700cdf0e10cSrcweir aNew.setValue( rValue ); 701cdf0e10cSrcweir m_pElemList->insert( m_pElemList->end(), aNew ); 702cdf0e10cSrcweir } 703cdf0e10cSrcweir } 704cdf0e10cSrcweir } 705cdf0e10cSrcweir 706cdf0e10cSrcweir //------------------------------------------------------------------------------------ 707cdf0e10cSrcweir 708cdf0e10cSrcweir Any SAL_CALL SvtFilePicker::getValue( sal_Int16 nElementID, sal_Int16 nControlAction ) 709cdf0e10cSrcweir throw( RuntimeException ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir checkAlive(); 712cdf0e10cSrcweir 713cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 714cdf0e10cSrcweir Any aAny; 715cdf0e10cSrcweir 716cdf0e10cSrcweir // execute() called? 717cdf0e10cSrcweir if ( getDialog() ) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); 720cdf0e10cSrcweir aAny = aAccess.getValue( nElementID, nControlAction ); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir else if ( m_pElemList && !m_pElemList->empty() ) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir ElementList::iterator aListIter; 725cdf0e10cSrcweir for ( aListIter = m_pElemList->begin(); 726cdf0e10cSrcweir aListIter != m_pElemList->end(); ++aListIter ) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir ElementEntry_Impl& rEntry = *aListIter; 729cdf0e10cSrcweir if ( ( rEntry.m_nElementID == nElementID ) && 730cdf0e10cSrcweir ( rEntry.m_bHasValue ) && 731cdf0e10cSrcweir ( rEntry.m_nControlAction == nControlAction ) ) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir aAny = rEntry.m_aValue; 734cdf0e10cSrcweir break; 735cdf0e10cSrcweir } 736cdf0e10cSrcweir } 737cdf0e10cSrcweir } 738cdf0e10cSrcweir 739cdf0e10cSrcweir return aAny; 740cdf0e10cSrcweir } 741cdf0e10cSrcweir 742cdf0e10cSrcweir 743cdf0e10cSrcweir //------------------------------------------------------------------------------------ 744cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const rtl::OUString& rValue ) 745cdf0e10cSrcweir throw ( RuntimeException ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir checkAlive(); 748cdf0e10cSrcweir 749cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 750cdf0e10cSrcweir if ( getDialog() ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); 753cdf0e10cSrcweir aAccess.setLabel( nLabelID, rValue ); 754cdf0e10cSrcweir } 755cdf0e10cSrcweir else 756cdf0e10cSrcweir { 757cdf0e10cSrcweir if ( !m_pElemList ) 758cdf0e10cSrcweir m_pElemList = new ElementList; 759cdf0e10cSrcweir 760cdf0e10cSrcweir sal_Bool bFound = sal_False; 761cdf0e10cSrcweir ElementList::iterator aListIter; 762cdf0e10cSrcweir 763cdf0e10cSrcweir for ( aListIter = m_pElemList->begin(); 764cdf0e10cSrcweir aListIter != m_pElemList->end(); ++aListIter ) 765cdf0e10cSrcweir { 766cdf0e10cSrcweir ElementEntry_Impl& rEntry = *aListIter; 767cdf0e10cSrcweir if ( rEntry.m_nElementID == nLabelID ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir rEntry.setLabel( rValue ); 770cdf0e10cSrcweir bFound = sal_True; 771cdf0e10cSrcweir } 772cdf0e10cSrcweir } 773cdf0e10cSrcweir 774cdf0e10cSrcweir if ( !bFound ) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir ElementEntry_Impl aNew( nLabelID ); 777cdf0e10cSrcweir aNew.setLabel( rValue ); 778cdf0e10cSrcweir m_pElemList->insert( m_pElemList->end(), aNew ); 779cdf0e10cSrcweir } 780cdf0e10cSrcweir } 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir //------------------------------------------------------------------------------------ 784cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getLabel( sal_Int16 nLabelID ) 785cdf0e10cSrcweir throw ( RuntimeException ) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir checkAlive(); 788cdf0e10cSrcweir 789cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 790cdf0e10cSrcweir rtl::OUString aLabel; 791cdf0e10cSrcweir 792cdf0e10cSrcweir if ( getDialog() ) 793cdf0e10cSrcweir { 794cdf0e10cSrcweir ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); 795cdf0e10cSrcweir aLabel = aAccess.getLabel( nLabelID ); 796cdf0e10cSrcweir } 797cdf0e10cSrcweir else if ( m_pElemList && !m_pElemList->empty() ) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir ElementList::iterator aListIter; 800cdf0e10cSrcweir for ( aListIter = m_pElemList->begin(); 801cdf0e10cSrcweir aListIter != m_pElemList->end(); ++aListIter ) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir ElementEntry_Impl& rEntry = *aListIter; 804cdf0e10cSrcweir if ( rEntry.m_nElementID == nLabelID ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir if ( rEntry.m_bHasLabel ) 807cdf0e10cSrcweir aLabel = rEntry.m_aLabel; 808cdf0e10cSrcweir break; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir } 811cdf0e10cSrcweir } 812cdf0e10cSrcweir 813cdf0e10cSrcweir return aLabel; 814cdf0e10cSrcweir } 815cdf0e10cSrcweir 816cdf0e10cSrcweir //------------------------------------------------------------------------------------ 817cdf0e10cSrcweir void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnable ) 818cdf0e10cSrcweir throw( RuntimeException ) 819cdf0e10cSrcweir { 820cdf0e10cSrcweir checkAlive(); 821cdf0e10cSrcweir 822cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 823cdf0e10cSrcweir if ( getDialog() ) 824cdf0e10cSrcweir { 825cdf0e10cSrcweir ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); 826cdf0e10cSrcweir aAccess.enableControl( nElementID, bEnable ); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir else 829cdf0e10cSrcweir { 830cdf0e10cSrcweir if ( !m_pElemList ) 831cdf0e10cSrcweir m_pElemList = new ElementList; 832cdf0e10cSrcweir 833cdf0e10cSrcweir sal_Bool bFound = sal_False; 834cdf0e10cSrcweir ElementList::iterator aListIter; 835cdf0e10cSrcweir 836cdf0e10cSrcweir for ( aListIter = m_pElemList->begin(); 837cdf0e10cSrcweir aListIter != m_pElemList->end(); ++aListIter ) 838cdf0e10cSrcweir { 839cdf0e10cSrcweir ElementEntry_Impl& rEntry = *aListIter; 840cdf0e10cSrcweir if ( rEntry.m_nElementID == nElementID ) 841cdf0e10cSrcweir { 842cdf0e10cSrcweir rEntry.setEnabled( bEnable ); 843cdf0e10cSrcweir bFound = sal_True; 844cdf0e10cSrcweir } 845cdf0e10cSrcweir } 846cdf0e10cSrcweir 847cdf0e10cSrcweir if ( !bFound ) 848cdf0e10cSrcweir { 849cdf0e10cSrcweir ElementEntry_Impl aNew( nElementID ); 850cdf0e10cSrcweir aNew.setEnabled( bEnable ); 851cdf0e10cSrcweir m_pElemList->insert( m_pElemList->end(), aNew ); 852cdf0e10cSrcweir } 853cdf0e10cSrcweir } 854cdf0e10cSrcweir } 855cdf0e10cSrcweir 856cdf0e10cSrcweir //------------------------------------------------------------------------------------ 857cdf0e10cSrcweir // XFilePickerNotifier functions 858cdf0e10cSrcweir //------------------------------------------------------------------------------------ 859cdf0e10cSrcweir 860cdf0e10cSrcweir void SAL_CALL SvtFilePicker::addFilePickerListener( const Reference< XFilePickerListener >& xListener ) throw ( RuntimeException ) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir checkAlive(); 863cdf0e10cSrcweir 864cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 865cdf0e10cSrcweir m_xListener = xListener; 866cdf0e10cSrcweir } 867cdf0e10cSrcweir 868cdf0e10cSrcweir //------------------------------------------------------------------------------------ 869cdf0e10cSrcweir void SAL_CALL SvtFilePicker::removeFilePickerListener( const Reference< XFilePickerListener >& ) throw ( RuntimeException ) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir checkAlive(); 872cdf0e10cSrcweir 873cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 874cdf0e10cSrcweir m_xListener.clear(); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir 877cdf0e10cSrcweir //------------------------------------------------------------------------------------ 878cdf0e10cSrcweir // XFilePreview functions 879cdf0e10cSrcweir //------------------------------------------------------------------------------------ 880cdf0e10cSrcweir 881cdf0e10cSrcweir Sequence< sal_Int16 > SAL_CALL SvtFilePicker::getSupportedImageFormats() 882cdf0e10cSrcweir throw ( RuntimeException ) 883cdf0e10cSrcweir { 884cdf0e10cSrcweir checkAlive(); 885cdf0e10cSrcweir 886cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 887cdf0e10cSrcweir Sequence< sal_Int16 > aFormats( 1 ); 888cdf0e10cSrcweir 889cdf0e10cSrcweir aFormats[0] = FilePreviewImageFormats::BITMAP; 890cdf0e10cSrcweir 891cdf0e10cSrcweir return aFormats; 892cdf0e10cSrcweir } 893cdf0e10cSrcweir 894cdf0e10cSrcweir //------------------------------------------------------------------------------------ 895cdf0e10cSrcweir sal_Int32 SAL_CALL SvtFilePicker::getTargetColorDepth() throw ( RuntimeException ) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir checkAlive(); 898cdf0e10cSrcweir 899cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 900cdf0e10cSrcweir sal_Int32 nDepth = 0; 901cdf0e10cSrcweir 902cdf0e10cSrcweir if ( getDialog() ) 903cdf0e10cSrcweir nDepth = getDialog()->getTargetColorDepth(); 904cdf0e10cSrcweir 905cdf0e10cSrcweir return nDepth; 906cdf0e10cSrcweir } 907cdf0e10cSrcweir 908cdf0e10cSrcweir //------------------------------------------------------------------------------------ 909cdf0e10cSrcweir sal_Int32 SAL_CALL SvtFilePicker::getAvailableWidth() throw ( RuntimeException ) 910cdf0e10cSrcweir { 911cdf0e10cSrcweir checkAlive(); 912cdf0e10cSrcweir 913cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 914cdf0e10cSrcweir sal_Int32 nWidth = 0; 915cdf0e10cSrcweir 916cdf0e10cSrcweir if ( getDialog() ) 917cdf0e10cSrcweir nWidth = getDialog()->getAvailableWidth(); 918cdf0e10cSrcweir 919cdf0e10cSrcweir return nWidth; 920cdf0e10cSrcweir } 921cdf0e10cSrcweir 922cdf0e10cSrcweir //------------------------------------------------------------------------------------ 923cdf0e10cSrcweir sal_Int32 SAL_CALL SvtFilePicker::getAvailableHeight() throw ( RuntimeException ) 924cdf0e10cSrcweir { 925cdf0e10cSrcweir checkAlive(); 926cdf0e10cSrcweir 927cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 928cdf0e10cSrcweir sal_Int32 nHeigth = 0; 929cdf0e10cSrcweir 930cdf0e10cSrcweir if ( getDialog() ) 931cdf0e10cSrcweir nHeigth = getDialog()->getAvailableHeight(); 932cdf0e10cSrcweir 933cdf0e10cSrcweir return nHeigth; 934cdf0e10cSrcweir } 935cdf0e10cSrcweir 936cdf0e10cSrcweir //------------------------------------------------------------------------------------ 937cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setImage( sal_Int16 aImageFormat, const Any& rImage ) 938cdf0e10cSrcweir throw ( IllegalArgumentException, RuntimeException ) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir checkAlive(); 941cdf0e10cSrcweir 942cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 943cdf0e10cSrcweir if ( getDialog() ) 944cdf0e10cSrcweir getDialog()->setImage( aImageFormat, rImage ); 945cdf0e10cSrcweir } 946cdf0e10cSrcweir 947cdf0e10cSrcweir //------------------------------------------------------------------------------------ 948cdf0e10cSrcweir sal_Bool SAL_CALL SvtFilePicker::setShowState( sal_Bool bShowState ) 949cdf0e10cSrcweir throw ( RuntimeException ) 950cdf0e10cSrcweir { 951cdf0e10cSrcweir checkAlive(); 952cdf0e10cSrcweir 953cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 954cdf0e10cSrcweir sal_Bool bRet = sal_False; 955cdf0e10cSrcweir 956cdf0e10cSrcweir if ( getDialog() ) 957cdf0e10cSrcweir bRet = getDialog()->setShowState( bShowState ); 958cdf0e10cSrcweir 959cdf0e10cSrcweir return bRet; 960cdf0e10cSrcweir } 961cdf0e10cSrcweir 962cdf0e10cSrcweir //------------------------------------------------------------------------------------ 963cdf0e10cSrcweir sal_Bool SAL_CALL SvtFilePicker::getShowState() throw ( RuntimeException ) 964cdf0e10cSrcweir { 965cdf0e10cSrcweir checkAlive(); 966cdf0e10cSrcweir 967cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 968cdf0e10cSrcweir sal_Bool bRet = sal_False; 969cdf0e10cSrcweir 970cdf0e10cSrcweir if ( getDialog() ) 971cdf0e10cSrcweir bRet = getDialog()->getShowState(); 972cdf0e10cSrcweir 973cdf0e10cSrcweir return bRet; 974cdf0e10cSrcweir } 975cdf0e10cSrcweir 976cdf0e10cSrcweir //------------------------------------------------------------------------------------ 977cdf0e10cSrcweir // XFilterGroupManager functions 978cdf0e10cSrcweir //------------------------------------------------------------------------------------ 979cdf0e10cSrcweir 980cdf0e10cSrcweir void SAL_CALL SvtFilePicker::appendFilterGroup( const ::rtl::OUString& sGroupTitle, 981cdf0e10cSrcweir const Sequence< StringPair >& aFilters ) 982cdf0e10cSrcweir throw ( IllegalArgumentException, RuntimeException ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir checkAlive(); 985cdf0e10cSrcweir 986cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 987cdf0e10cSrcweir 988cdf0e10cSrcweir // check the names 989cdf0e10cSrcweir if ( FilterNameExists( aFilters ) ) 990cdf0e10cSrcweir throw IllegalArgumentException( 991cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("filter name exists")), 992cdf0e10cSrcweir static_cast< OWeakObject * >(this), 1); 993cdf0e10cSrcweir 994cdf0e10cSrcweir // ensure that we have a filter list 995cdf0e10cSrcweir ::rtl::OUString sInitialCurrentFilter; 996cdf0e10cSrcweir if ( aFilters.getLength() ) 997cdf0e10cSrcweir sInitialCurrentFilter = aFilters[0].First; 998cdf0e10cSrcweir ensureFilterList( sInitialCurrentFilter ); 999cdf0e10cSrcweir 1000cdf0e10cSrcweir // append the filter 1001cdf0e10cSrcweir m_pFilterList->insert( m_pFilterList->end(), FilterEntry( sGroupTitle, aFilters ) ); 1002cdf0e10cSrcweir } 1003cdf0e10cSrcweir 1004cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1005cdf0e10cSrcweir // XFilterManager functions 1006cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir void SAL_CALL SvtFilePicker::appendFilter( const rtl::OUString& aTitle, 1009cdf0e10cSrcweir const rtl::OUString& aFilter ) 1010cdf0e10cSrcweir throw( IllegalArgumentException, RuntimeException ) 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir checkAlive(); 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1015cdf0e10cSrcweir // check the name 1016cdf0e10cSrcweir if ( FilterNameExists( aTitle ) ) 1017cdf0e10cSrcweir // TODO: a more precise exception message 1018cdf0e10cSrcweir throw IllegalArgumentException(); 1019cdf0e10cSrcweir 1020cdf0e10cSrcweir // ensure that we have a filter list 1021cdf0e10cSrcweir ensureFilterList( aTitle ); 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir // append the filter 1024cdf0e10cSrcweir m_pFilterList->insert( m_pFilterList->end(), FilterEntry( aTitle, aFilter ) ); 1025cdf0e10cSrcweir } 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1028cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setCurrentFilter( const rtl::OUString& aTitle ) 1029cdf0e10cSrcweir throw( IllegalArgumentException, RuntimeException ) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir checkAlive(); 1032cdf0e10cSrcweir 1033cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1034cdf0e10cSrcweir if ( ! FilterNameExists( aTitle ) ) 1035cdf0e10cSrcweir throw IllegalArgumentException(); 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir m_aCurrentFilter = aTitle; 1038cdf0e10cSrcweir 1039cdf0e10cSrcweir if ( getDialog() ) 1040cdf0e10cSrcweir getDialog()->SetCurFilter( aTitle ); 1041cdf0e10cSrcweir } 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1044cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getCurrentFilter() 1045cdf0e10cSrcweir throw( RuntimeException ) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir checkAlive(); 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1050cdf0e10cSrcweir rtl::OUString aFilter = getDialog() ? rtl::OUString( getDialog()->GetCurFilter() ) : 1051cdf0e10cSrcweir rtl::OUString( m_aCurrentFilter ); 1052cdf0e10cSrcweir return aFilter; 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1057cdf0e10cSrcweir // XInitialization functions 1058cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir void SAL_CALL SvtFilePicker::initialize( const Sequence< Any >& _rArguments ) 1061cdf0e10cSrcweir throw ( Exception, RuntimeException ) 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir checkAlive(); 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir Sequence< Any > aArguments( _rArguments.getLength()); 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir m_nServiceType = TemplateDescription::FILEOPEN_SIMPLE; 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir if ( _rArguments.getLength() >= 1 ) 1070cdf0e10cSrcweir { 1071cdf0e10cSrcweir // compatibility: one argument, type sal_Int16 , specifies the service type 1072cdf0e10cSrcweir int index = 0; 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir if (_rArguments[0] >>= m_nServiceType) 1075cdf0e10cSrcweir { 1076cdf0e10cSrcweir // skip the first entry if it was the ServiceType, because it's not needed in OCommonPicker::initialize and it's not a NamedValue 1077cdf0e10cSrcweir NamedValue emptyNamedValue; 1078cdf0e10cSrcweir aArguments[0] <<= emptyNamedValue; 1079cdf0e10cSrcweir index = 1; 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir } 1082cdf0e10cSrcweir for ( int i = index; i < _rArguments.getLength(); i++) 1083cdf0e10cSrcweir { 1084cdf0e10cSrcweir NamedValue namedValue; 1085cdf0e10cSrcweir aArguments[i] <<= _rArguments[i]; 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir if (aArguments[i] >>= namedValue ) 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir if ( namedValue.Name.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StandardDir" ) ) ) ) 1091cdf0e10cSrcweir { 1092cdf0e10cSrcweir ::rtl::OUString sStandardDir; 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir namedValue.Value >>= sStandardDir; 1095cdf0e10cSrcweir 1096cdf0e10cSrcweir // Set the directory for the "back to the default dir" button 1097cdf0e10cSrcweir if ( sStandardDir.getLength() > 0 ) 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir m_aStandardDir = sStandardDir; 1100cdf0e10cSrcweir } 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir else if ( namedValue.Name.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BlackList" ) ) ) ) 1103cdf0e10cSrcweir { 1104cdf0e10cSrcweir namedValue.Value >>= m_aBlackList; 1105cdf0e10cSrcweir } 1106cdf0e10cSrcweir } 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir } 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir // let the base class analyze the sequence (will call into implHandleInitializationArgument) 1111cdf0e10cSrcweir OCommonPicker::initialize( aArguments ); 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir //------------------------------------------------------------------------- 1115cdf0e10cSrcweir sal_Bool SvtFilePicker::implHandleInitializationArgument( const ::rtl::OUString& _rName, const Any& _rValue ) SAL_THROW( ( Exception, RuntimeException ) ) 1116cdf0e10cSrcweir { 1117cdf0e10cSrcweir if ( _rName.equalsAscii( "TemplateDescription" ) ) 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir m_nServiceType = TemplateDescription::FILEOPEN_SIMPLE; 1120cdf0e10cSrcweir OSL_VERIFY( _rValue >>= m_nServiceType ); 1121cdf0e10cSrcweir return sal_True; 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir if ( _rName.equalsAscii( "StandardDir" ) ) 1124cdf0e10cSrcweir { 1125cdf0e10cSrcweir OSL_VERIFY( _rValue >>= m_aStandardDir ); 1126cdf0e10cSrcweir return sal_True; 1127cdf0e10cSrcweir } 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir if ( _rName.equalsAscii( "BlackList" ) ) 1130cdf0e10cSrcweir { 1131cdf0e10cSrcweir OSL_VERIFY( _rValue >>= m_aBlackList ); 1132cdf0e10cSrcweir return sal_True; 1133cdf0e10cSrcweir } 1134cdf0e10cSrcweir 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir 1137cdf0e10cSrcweir return OCommonPicker::implHandleInitializationArgument( _rName, _rValue ); 1138cdf0e10cSrcweir } 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1141cdf0e10cSrcweir // XServiceInfo 1142cdf0e10cSrcweir //------------------------------------------------------------------------------------ 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir /* XServiceInfo */ 1145cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getImplementationName() throw( RuntimeException ) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir return impl_getStaticImplementationName(); 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir /* XServiceInfo */ 1151cdf0e10cSrcweir sal_Bool SAL_CALL SvtFilePicker::supportsService( const rtl::OUString& sServiceName ) throw( RuntimeException ) 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir Sequence< rtl::OUString > seqServiceNames = getSupportedServiceNames(); 1154cdf0e10cSrcweir const rtl::OUString* pArray = seqServiceNames.getConstArray(); 1155cdf0e10cSrcweir for ( sal_Int32 i = 0; i < seqServiceNames.getLength(); i++ ) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir if ( sServiceName == pArray[i] ) 1158cdf0e10cSrcweir { 1159cdf0e10cSrcweir return sal_True ; 1160cdf0e10cSrcweir } 1161cdf0e10cSrcweir } 1162cdf0e10cSrcweir return sal_False ; 1163cdf0e10cSrcweir } 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir /* XServiceInfo */ 1166cdf0e10cSrcweir Sequence< rtl::OUString > SAL_CALL SvtFilePicker::getSupportedServiceNames() throw( RuntimeException ) 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir return impl_getStaticSupportedServiceNames(); 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir /* Helper for XServiceInfo */ 1172cdf0e10cSrcweir Sequence< rtl::OUString > SvtFilePicker::impl_getStaticSupportedServiceNames() 1173cdf0e10cSrcweir { 1174cdf0e10cSrcweir Sequence< rtl::OUString > seqServiceNames( 1 ); 1175cdf0e10cSrcweir rtl::OUString* pArray = seqServiceNames.getArray(); 1176cdf0e10cSrcweir pArray[0] = rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.OfficeFilePicker" ); 1177cdf0e10cSrcweir return seqServiceNames ; 1178cdf0e10cSrcweir } 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir /* Helper for XServiceInfo */ 1181cdf0e10cSrcweir rtl::OUString SvtFilePicker::impl_getStaticImplementationName() 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir return rtl::OUString::createFromAscii( "com.sun.star.svtools.OfficeFilePicker" ); 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir /* Helper for registry */ 1187cdf0e10cSrcweir Reference< XInterface > SAL_CALL SvtFilePicker::impl_createInstance( 1188cdf0e10cSrcweir const Reference< XComponentContext >& rxContext) throw( Exception ) 1189cdf0e10cSrcweir { 1190cdf0e10cSrcweir Reference< XMultiServiceFactory > xServiceManager (rxContext->getServiceManager(), UNO_QUERY_THROW); 1191cdf0e10cSrcweir return Reference< XInterface >( *new SvtFilePicker( xServiceManager ) ); 1192cdf0e10cSrcweir } 1193