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