1b557fc96SAndrew Rist /**************************************************************
2*97fa22caSmseidel  *
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
10*97fa22caSmseidel  *
11b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*97fa22caSmseidel  *
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.
19*97fa22caSmseidel  *
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 
64*97fa22caSmseidel #define MAKE_ANY	::com::sun::star::uno::makeAny
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // using ----------------------------------------------------------------
67cdf0e10cSrcweir 
68*97fa22caSmseidel using namespace		::com::sun::star::container;
69*97fa22caSmseidel using namespace		::com::sun::star::lang;
70*97fa22caSmseidel using namespace		::com::sun::star::ui::dialogs;
71*97fa22caSmseidel using namespace		::com::sun::star::uno;
72*97fa22caSmseidel using namespace		::com::sun::star::beans;
73*97fa22caSmseidel using namespace		::com::sun::star::awt;
74*97fa22caSmseidel 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:
FilterEntryFilterEntry89cdf0e10cSrcweir 	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 
getTitleFilterEntry97cdf0e10cSrcweir 	::rtl::OUString		getTitle() const { return m_sTitle; }
getFilterFilterEntry98cdf0e10cSrcweir 	::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
beginSubFiltersFilterEntry110cdf0e10cSrcweir 	const UnoFilterEntry*	beginSubFilters() const { return m_aSubFilters.getConstArray(); }
endSubFiltersFilterEntry111cdf0e10cSrcweir 	const UnoFilterEntry*	endSubFilters() const { return m_aSubFilters.getConstArray() + m_aSubFilters.getLength(); }
112cdf0e10cSrcweir };
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //=====================================================================
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //---------------------------------------------------------------------
FilterEntry(const::rtl::OUString & _rTitle,const UnoFilterList & _rSubFilters)117cdf0e10cSrcweir FilterEntry::FilterEntry( const ::rtl::OUString& _rTitle, const UnoFilterList& _rSubFilters )
118cdf0e10cSrcweir 	:m_sTitle( _rTitle )
119cdf0e10cSrcweir 	,m_aSubFilters( _rSubFilters )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir //---------------------------------------------------------------------
hasSubFilters() const124cdf0e10cSrcweir sal_Bool FilterEntry::hasSubFilters( ) const
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	return ( 0 < m_aSubFilters.getLength() );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir //---------------------------------------------------------------------
getSubFilters(UnoFilterList & _rSubFilterList)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;
142*97fa22caSmseidel 	Any				m_aValue;
143*97fa22caSmseidel 	rtl::OUString	m_aLabel;
144*97fa22caSmseidel 	sal_Bool		m_bEnabled		: 1;
145cdf0e10cSrcweir 
146*97fa22caSmseidel 	sal_Bool		m_bHasValue		: 1;
147*97fa22caSmseidel 	sal_Bool		m_bHasLabel		: 1;
148*97fa22caSmseidel 	sal_Bool		m_bHasEnabled	: 1;
149cdf0e10cSrcweir 
150*97fa22caSmseidel 					ElementEntry_Impl( sal_Int16 nId );
151cdf0e10cSrcweir 
setValueElementEntry_Impl152*97fa22caSmseidel 	void			setValue( const Any& rVal ) { m_aValue = rVal; m_bHasValue = sal_True; }
setActionElementEntry_Impl153*97fa22caSmseidel 	void			setAction( sal_Int16 nAction ) { m_nControlAction = nAction; }
setLabelElementEntry_Impl154*97fa22caSmseidel 	void			setLabel( const rtl::OUString& rVal ) { m_aLabel = rVal; m_bHasLabel = sal_True; }
setEnabledElementEntry_Impl155*97fa22caSmseidel 	void			setEnabled( sal_Bool bEnabled ) { m_bEnabled = bEnabled; m_bHasEnabled = sal_True; }
156cdf0e10cSrcweir };
157cdf0e10cSrcweir 
ElementEntry_Impl(sal_Int16 nId)158cdf0e10cSrcweir ElementEntry_Impl::ElementEntry_Impl( sal_Int16 nId )
159*97fa22caSmseidel 	: m_nElementID( nId )
160*97fa22caSmseidel 	, m_nControlAction( 0 )
161*97fa22caSmseidel 	, m_bEnabled( sal_False )
162*97fa22caSmseidel 	, m_bHasValue( sal_False )
163*97fa22caSmseidel 	, m_bHasLabel( sal_False )
164*97fa22caSmseidel 	, m_bHasEnabled( sal_False )
165cdf0e10cSrcweir {}
166cdf0e10cSrcweir 
167cdf0e10cSrcweir //------------------------------------------------------------------------------------
prepareExecute()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 	{
1741aa1f6e5SDamjan Jovanovic 		sal_Bool isFileSet = sal_False;
175cdf0e10cSrcweir 		if ( m_aDisplayDirectory.getLength() > 0 )
176cdf0e10cSrcweir 		{
177cdf0e10cSrcweir 
1781aa1f6e5SDamjan Jovanovic 			INetURLObject aPath;
1791aa1f6e5SDamjan Jovanovic 			INetURLObject givenPath( m_aDisplayDirectory );
1801aa1f6e5SDamjan Jovanovic 			if (!givenPath.HasError())
1811aa1f6e5SDamjan Jovanovic 				aPath = givenPath;
1821aa1f6e5SDamjan Jovanovic 			else
1831aa1f6e5SDamjan Jovanovic 			{
1841aa1f6e5SDamjan Jovanovic 				INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
1851aa1f6e5SDamjan Jovanovic 				aPath = aStdDirObj;
1861aa1f6e5SDamjan 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 );
1931aa1f6e5SDamjan Jovanovic 			getDialog()->SetPath( sPath );
1941aa1f6e5SDamjan Jovanovic 			isFileSet = sal_True;
195cdf0e10cSrcweir 		}
1961aa1f6e5SDamjan Jovanovic 		if ( !isFileSet && m_aDefaultName.getLength() > 0 )
197cdf0e10cSrcweir 		{
198cdf0e10cSrcweir 			getDialog()->SetPath( m_aDefaultName );
199cdf0e10cSrcweir 			getDialog()->SetHasFilename( true );
200cdf0e10cSrcweir 		}
201cdf0e10cSrcweir 	}
202cdf0e10cSrcweir 	else
203cdf0e10cSrcweir 	{
204*97fa22caSmseidel 		// set default-standard-dir
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
210*97fa22caSmseidel 	if ( m_pElemList && !m_pElemList->empty() )
211*97fa22caSmseidel 	{
212cdf0e10cSrcweir 		::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
213cdf0e10cSrcweir 
214*97fa22caSmseidel 		ElementList::iterator aListIter;
215cdf0e10cSrcweir 		for ( aListIter = m_pElemList->begin();
216cdf0e10cSrcweir 			  aListIter != m_pElemList->end(); ++aListIter )
217cdf0e10cSrcweir 		{
218cdf0e10cSrcweir 			ElementEntry_Impl& rEntry = *aListIter;
219*97fa22caSmseidel 			if ( rEntry.m_bHasValue )
220cdf0e10cSrcweir 				aAccess.setValue( rEntry.m_nElementID, rEntry.m_nControlAction, rEntry.m_aValue );
221*97fa22caSmseidel 			if ( rEntry.m_bHasLabel )
222cdf0e10cSrcweir 				aAccess.setLabel( rEntry.m_nElementID, rEntry.m_aLabel );
223*97fa22caSmseidel 			if ( rEntry.m_bHasEnabled )
224cdf0e10cSrcweir 				aAccess.enableControl( rEntry.m_nElementID, rEntry.m_bEnabled );
225cdf0e10cSrcweir 		}
226cdf0e10cSrcweir 
227*97fa22caSmseidel 		getDialog()->updateListboxLabelSizes();
228*97fa22caSmseidel 	}
229*97fa22caSmseidel 
230*97fa22caSmseidel 	if ( m_pFilterList && !m_pFilterList->empty() )
231*97fa22caSmseidel 	{
232*97fa22caSmseidel 		for (   FilterList::iterator aListIter = m_pFilterList->begin();
233*97fa22caSmseidel 				aListIter != m_pFilterList->end();
234*97fa22caSmseidel 				++aListIter
235*97fa22caSmseidel 			)
236*97fa22caSmseidel 		{
237*97fa22caSmseidel 			if ( aListIter->hasSubFilters() )
238*97fa22caSmseidel 			{   // it's a filter group
239*97fa22caSmseidel 				UnoFilterList aSubFilters;
240*97fa22caSmseidel 				aListIter->getSubFilters( aSubFilters );
241*97fa22caSmseidel 
242*97fa22caSmseidel 				getDialog()->AddFilterGroup( aListIter->getTitle(), aSubFilters );
243*97fa22caSmseidel 			}
244*97fa22caSmseidel 			else
245*97fa22caSmseidel 				// it's a single filter
246*97fa22caSmseidel 				getDialog()->AddFilter( aListIter->getTitle(), aListIter->getFilter() );
247*97fa22caSmseidel 		}
248*97fa22caSmseidel 	}
249*97fa22caSmseidel 
250*97fa22caSmseidel 	// set the default filter
251*97fa22caSmseidel 	if ( m_aCurrentFilter.getLength() > 0 )
252*97fa22caSmseidel 		getDialog()->SetCurFilter( m_aCurrentFilter );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir //-----------------------------------------------------------------------------
IMPL_LINK(SvtFilePicker,DialogClosedHdl,Dialog *,pDlg)257cdf0e10cSrcweir IMPL_LINK( SvtFilePicker, DialogClosedHdl, Dialog*, pDlg )
258cdf0e10cSrcweir {
259*97fa22caSmseidel 	if ( m_xDlgClosedListener.is() )
260*97fa22caSmseidel 	{
261*97fa22caSmseidel 		sal_Int16 nRet = static_cast< sal_Int16 >( pDlg->GetResult() );
262*97fa22caSmseidel 		::com::sun::star::ui::dialogs::DialogClosedEvent aEvent( *this, nRet );
263*97fa22caSmseidel 		m_xDlgClosedListener->dialogClosed( aEvent );
264*97fa22caSmseidel 		m_xDlgClosedListener.clear();
265*97fa22caSmseidel 	}
266*97fa22caSmseidel 	return 0;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir //------------------------------------------------------------------------------------
270cdf0e10cSrcweir // SvtFilePicker
271cdf0e10cSrcweir //------------------------------------------------------------------------------------
272cdf0e10cSrcweir 
273cdf0e10cSrcweir //------------------------------------------------------------------------------------
getWinBits(WinBits & rExtraBits)274cdf0e10cSrcweir WinBits SvtFilePicker::getWinBits( WinBits& rExtraBits )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	// set the winbits for creating the filedialog
277cdf0e10cSrcweir 	WinBits nBits = 0L;
278*97fa22caSmseidel 	rExtraBits = 0L;
279cdf0e10cSrcweir 
28007a3d7f1SPedro Giffuni 	// set the standard bits according to the service name
281*97fa22caSmseidel 	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;
292*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_AUTOEXTENSION;
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 	else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD )
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir 		nBits = WB_SAVEAS | SFXWB_PASSWORD;
297*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_AUTOEXTENSION;
298cdf0e10cSrcweir 	}
299*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS )
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 		nBits = WB_SAVEAS | SFXWB_PASSWORD;
302*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_FILTEROPTIONS;
303cdf0e10cSrcweir 	}
304*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE )
305cdf0e10cSrcweir 	{
306cdf0e10cSrcweir 		nBits = WB_SAVEAS;
307*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_TEMPLATES;
308cdf0e10cSrcweir 	}
309*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION )
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		nBits = WB_SAVEAS;
312*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_SELECTION;
313*97fa22caSmseidel 	}
314cdf0e10cSrcweir 
315*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE )
316cdf0e10cSrcweir 	{
317cdf0e10cSrcweir 		nBits = WB_OPEN;
318*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_INSERTASLINK | SFX_EXTRA_SHOWPREVIEW | SFX_EXTRA_IMAGE_TEMPLATE;
319cdf0e10cSrcweir 	}
320*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILEOPEN_PLAY )
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		nBits = WB_OPEN;
323*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_PLAYBUTTON;
324*97fa22caSmseidel 	}
325*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILEOPEN_READONLY_VERSION )
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		nBits = WB_OPEN | SFXWB_READONLY;
328*97fa22caSmseidel 		rExtraBits = SFX_EXTRA_SHOWVERSIONS;
329cdf0e10cSrcweir 	}
330*97fa22caSmseidel 	else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW )
331cdf0e10cSrcweir 	{
332cdf0e10cSrcweir 		nBits = WB_OPEN;
333*97fa22caSmseidel 		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 //------------------------------------------------------------------------------------
notify(sal_Int16 _nEventId,sal_Int16 _nControlId)342cdf0e10cSrcweir void SvtFilePicker::notify( sal_Int16 _nEventId, sal_Int16 _nControlId )
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	if ( !m_xListener.is() )
345cdf0e10cSrcweir 		return;
346cdf0e10cSrcweir 
347*97fa22caSmseidel 	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:
FilterTitleMatch__anon1b94e2700111::FilterTitleMatch381cdf0e10cSrcweir 		FilterTitleMatch( const ::rtl::OUString& _rTitle ) : rTitle( _rTitle ) { }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 		//............................................................................
operator ()__anon1b94e2700111::FilterTitleMatch384cdf0e10cSrcweir 		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 		}
operator ()__anon1b94e2700111::FilterTitleMatch401cdf0e10cSrcweir 		bool operator () ( const UnoFilterEntry& _rEntry )
402cdf0e10cSrcweir 		{
403cdf0e10cSrcweir 			return _rEntry.First == rTitle ? true : false;
404cdf0e10cSrcweir 		}
405cdf0e10cSrcweir 	};
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir //------------------------------------------------------------------------------------
FilterNameExists(const::rtl::OUString & rTitle)409cdf0e10cSrcweir sal_Bool SvtFilePicker::FilterNameExists( const ::rtl::OUString& rTitle )
410cdf0e10cSrcweir {
411*97fa22caSmseidel 	sal_Bool bRet = sal_False;
412cdf0e10cSrcweir 
413*97fa22caSmseidel 	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 
421*97fa22caSmseidel 	return bRet;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir //------------------------------------------------------------------------------------
FilterNameExists(const UnoFilterList & _rGroupedFilters)425cdf0e10cSrcweir sal_Bool SvtFilePicker::FilterNameExists( const UnoFilterList& _rGroupedFilters )
426cdf0e10cSrcweir {
427*97fa22caSmseidel 	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 //------------------------------------------------------------------------------------
ensureFilterList(const::rtl::OUString & _rInitialCurrentFilter)444cdf0e10cSrcweir void SvtFilePicker::ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir 	if ( !m_pFilterList )
447*97fa22caSmseidel 	{
448cdf0e10cSrcweir 		m_pFilterList = new FilterList;
449cdf0e10cSrcweir 
450*97fa22caSmseidel 		// set the first filter to the current filter
451*97fa22caSmseidel 		if ( ! m_aCurrentFilter.getLength() )
452*97fa22caSmseidel 			m_aCurrentFilter = _rInitialCurrentFilter;
453*97fa22caSmseidel 	}
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir //------------------------------------------------------------------------------------
457cdf0e10cSrcweir // class SvtFilePicker
458cdf0e10cSrcweir //------------------------------------------------------------------------------------
SvtFilePicker(const Reference<XMultiServiceFactory> & xFactory)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 
~SvtFilePicker()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 //------------------------------------------------------------------------------------
implExecutePicker()480cdf0e10cSrcweir sal_Int16 SvtFilePicker::implExecutePicker( )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir 	getDialog()->SetFileCallback( this );
483cdf0e10cSrcweir 
484*97fa22caSmseidel 	prepareExecute();
485cdf0e10cSrcweir 
486*97fa22caSmseidel 	getDialog()->EnableAutocompletion( sal_True );
487*97fa22caSmseidel 	// now we are ready to execute the dialog
488*97fa22caSmseidel 	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 //------------------------------------------------------------------------------------
implCreateDialog(Window * _pParent)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 //------------------------------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(SvtFilePicker,OCommonPicker,SvtFilePicker_Base)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 //------------------------------------------------------------------------------------
execute()537cdf0e10cSrcweir sal_Int16 SAL_CALL SvtFilePicker::execute(  ) throw (RuntimeException)
538cdf0e10cSrcweir {
539cdf0e10cSrcweir 	return OCommonPicker::execute();
540cdf0e10cSrcweir }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir //------------------------------------------------------------------------------------
543cdf0e10cSrcweir // XAsynchronousExecutableDialog functions
544cdf0e10cSrcweir //------------------------------------------------------------------------------------
545cdf0e10cSrcweir 
546cdf0e10cSrcweir //------------------------------------------------------------------------------------
setDialogTitle(const::rtl::OUString & _rTitle)547cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setDialogTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException)
548cdf0e10cSrcweir {
549*97fa22caSmseidel 	setTitle( _rTitle );
550cdf0e10cSrcweir }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir //------------------------------------------------------------------------------------
startExecuteModal(const Reference<::com::sun::star::ui::dialogs::XDialogClosedListener> & xListener)553cdf0e10cSrcweir void SAL_CALL SvtFilePicker::startExecuteModal( const Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (RuntimeException)
554cdf0e10cSrcweir {
555*97fa22caSmseidel 	m_xDlgClosedListener = xListener;
556*97fa22caSmseidel 	prepareDialog();
557*97fa22caSmseidel 	prepareExecute();
558*97fa22caSmseidel 	getDialog()->EnableAutocompletion( sal_True );
559*97fa22caSmseidel 	getDialog()->StartExecuteModal( LINK( this, SvtFilePicker, DialogClosedHdl ) );
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir //------------------------------------------------------------------------------------
563cdf0e10cSrcweir // XFilePicker functions
564cdf0e10cSrcweir //------------------------------------------------------------------------------------
565cdf0e10cSrcweir 
setMultiSelectionMode(sal_Bool bMode)566cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setMultiSelectionMode( sal_Bool bMode ) throw( RuntimeException )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir 	checkAlive();
569cdf0e10cSrcweir 
570*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
571cdf0e10cSrcweir 	m_bMultiSelection = bMode;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir 
setDefaultName(const rtl::OUString & aName)574cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setDefaultName( const rtl::OUString& aName ) throw( RuntimeException )
575cdf0e10cSrcweir {
576cdf0e10cSrcweir 	checkAlive();
577cdf0e10cSrcweir 
578*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
579cdf0e10cSrcweir 	m_aDefaultName = aName;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
setDisplayDirectory(const rtl::OUString & aDirectory)582cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setDisplayDirectory( const rtl::OUString& aDirectory )
583*97fa22caSmseidel 	throw( IllegalArgumentException, RuntimeException )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir 	checkAlive();
586cdf0e10cSrcweir 
587*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
588cdf0e10cSrcweir 	m_aDisplayDirectory = aDirectory;
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
getDisplayDirectory()591cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getDisplayDirectory() throw( RuntimeException )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir 	checkAlive();
594cdf0e10cSrcweir 
595*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
596cdf0e10cSrcweir 	if ( getDialog() )
597*97fa22caSmseidel 	{
598*97fa22caSmseidel 		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 ) )
607*97fa22caSmseidel 		{
608*97fa22caSmseidel 			INetURLObject aFolder( aPath );
609*97fa22caSmseidel 			aFolder.CutLastName();
610*97fa22caSmseidel 			aPath = aFolder.GetMainURL( INetURLObject::NO_DECODE );
611*97fa22caSmseidel 		}
612cdf0e10cSrcweir 		m_aOldDisplayDirectory = aPath;
613*97fa22caSmseidel 		return aPath;
614*97fa22caSmseidel 	}
615*97fa22caSmseidel 	else
616*97fa22caSmseidel 		return m_aDisplayDirectory;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
getFiles()619cdf0e10cSrcweir Sequence< rtl::OUString > SAL_CALL SvtFilePicker::getFiles() throw( RuntimeException )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir 	checkAlive();
622cdf0e10cSrcweir 
623*97fa22caSmseidel 	::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 
setValue(sal_Int16 nElementID,sal_Int16 nControlAction,const Any & rValue)662cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID,
663*97fa22caSmseidel 									   sal_Int16 nControlAction,
664*97fa22caSmseidel 									   const Any& rValue )
665*97fa22caSmseidel 	throw( RuntimeException )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir 	checkAlive();
668cdf0e10cSrcweir 
669*97fa22caSmseidel 	::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 
680*97fa22caSmseidel 		sal_Bool bFound = sal_False;
681cdf0e10cSrcweir 		ElementList::iterator aListIter;
682cdf0e10cSrcweir 
683*97fa22caSmseidel 		for ( aListIter = m_pElemList->begin();
684cdf0e10cSrcweir 			  aListIter != m_pElemList->end(); ++aListIter )
685cdf0e10cSrcweir 		{
686cdf0e10cSrcweir 			ElementEntry_Impl& rEntry = *aListIter;
687*97fa22caSmseidel 			if ( ( rEntry.m_nElementID == nElementID ) &&
688*97fa22caSmseidel 				( !rEntry.m_bHasValue || ( rEntry.m_nControlAction == nControlAction ) ) )
689*97fa22caSmseidel 			{
690*97fa22caSmseidel 				rEntry.setAction( nControlAction );
691*97fa22caSmseidel 				rEntry.setValue( rValue );
692*97fa22caSmseidel 				bFound = sal_True;
693*97fa22caSmseidel 			}
694cdf0e10cSrcweir 		}
695cdf0e10cSrcweir 
696*97fa22caSmseidel 		if ( !bFound )
697*97fa22caSmseidel 		{
698*97fa22caSmseidel 			ElementEntry_Impl aNew( nElementID );
699*97fa22caSmseidel 			aNew.setAction( nControlAction );
700*97fa22caSmseidel 			aNew.setValue( rValue );
701*97fa22caSmseidel 			m_pElemList->insert( m_pElemList->end(), aNew );
702*97fa22caSmseidel 		}
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir }
705cdf0e10cSrcweir 
706cdf0e10cSrcweir //------------------------------------------------------------------------------------
707cdf0e10cSrcweir 
getValue(sal_Int16 nElementID,sal_Int16 nControlAction)708cdf0e10cSrcweir Any SAL_CALL SvtFilePicker::getValue( sal_Int16 nElementID, sal_Int16 nControlAction )
709*97fa22caSmseidel 	throw( RuntimeException )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir 	checkAlive();
712cdf0e10cSrcweir 
713*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
714*97fa22caSmseidel 	Any aAny;
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 	// execute() called?
717cdf0e10cSrcweir 	if ( getDialog() )
718cdf0e10cSrcweir 	{
719cdf0e10cSrcweir 		::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
720cdf0e10cSrcweir 		aAny = aAccess.getValue( nElementID, nControlAction );
721cdf0e10cSrcweir 	}
722*97fa22caSmseidel 	else if ( m_pElemList && !m_pElemList->empty() )
723*97fa22caSmseidel 	{
724cdf0e10cSrcweir 		ElementList::iterator aListIter;
725cdf0e10cSrcweir 		for ( aListIter = m_pElemList->begin();
726cdf0e10cSrcweir 			  aListIter != m_pElemList->end(); ++aListIter )
727cdf0e10cSrcweir 		{
728cdf0e10cSrcweir 			ElementEntry_Impl& rEntry = *aListIter;
729*97fa22caSmseidel 			if ( ( rEntry.m_nElementID == nElementID ) &&
730*97fa22caSmseidel 				 ( rEntry.m_bHasValue ) &&
731*97fa22caSmseidel 				 ( rEntry.m_nControlAction == nControlAction ) )
732*97fa22caSmseidel 			{
733*97fa22caSmseidel 				aAny = rEntry.m_aValue;
734*97fa22caSmseidel 				break;
735*97fa22caSmseidel 			}
736cdf0e10cSrcweir 		}
737*97fa22caSmseidel 	}
738cdf0e10cSrcweir 
739*97fa22caSmseidel 	return aAny;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir 
742cdf0e10cSrcweir 
743cdf0e10cSrcweir //------------------------------------------------------------------------------------
setLabel(sal_Int16 nLabelID,const rtl::OUString & rValue)744cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const rtl::OUString& rValue )
745*97fa22caSmseidel 	throw ( RuntimeException )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir 	checkAlive();
748cdf0e10cSrcweir 
749*97fa22caSmseidel 	::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 
760*97fa22caSmseidel 		sal_Bool bFound = sal_False;
761cdf0e10cSrcweir 		ElementList::iterator aListIter;
762cdf0e10cSrcweir 
763*97fa22caSmseidel 		for ( aListIter = m_pElemList->begin();
764cdf0e10cSrcweir 			  aListIter != m_pElemList->end(); ++aListIter )
765cdf0e10cSrcweir 		{
766cdf0e10cSrcweir 			ElementEntry_Impl& rEntry = *aListIter;
767*97fa22caSmseidel 			if ( rEntry.m_nElementID == nLabelID )
768*97fa22caSmseidel 			{
769*97fa22caSmseidel 				rEntry.setLabel( rValue );
770*97fa22caSmseidel 				bFound = sal_True;
771*97fa22caSmseidel 			}
772cdf0e10cSrcweir 		}
773cdf0e10cSrcweir 
774*97fa22caSmseidel 		if ( !bFound )
775*97fa22caSmseidel 		{
776*97fa22caSmseidel 			ElementEntry_Impl aNew( nLabelID );
777*97fa22caSmseidel 			aNew.setLabel( rValue );
778*97fa22caSmseidel 			m_pElemList->insert( m_pElemList->end(), aNew );
779*97fa22caSmseidel 		}
780cdf0e10cSrcweir 	}
781cdf0e10cSrcweir }
782cdf0e10cSrcweir 
783cdf0e10cSrcweir //------------------------------------------------------------------------------------
getLabel(sal_Int16 nLabelID)784cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getLabel( sal_Int16 nLabelID )
785*97fa22caSmseidel 	throw ( RuntimeException )
786cdf0e10cSrcweir {
787cdf0e10cSrcweir 	checkAlive();
788cdf0e10cSrcweir 
789*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
790cdf0e10cSrcweir 	rtl::OUString aLabel;
791cdf0e10cSrcweir 
792*97fa22caSmseidel 	if ( getDialog() )
793cdf0e10cSrcweir 	{
794cdf0e10cSrcweir 		::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
795cdf0e10cSrcweir 		aLabel = aAccess.getLabel( nLabelID );
796cdf0e10cSrcweir 	}
797*97fa22caSmseidel 	else if ( m_pElemList && !m_pElemList->empty() )
798*97fa22caSmseidel 	{
799cdf0e10cSrcweir 		ElementList::iterator aListIter;
800cdf0e10cSrcweir 		for ( aListIter = m_pElemList->begin();
801cdf0e10cSrcweir 			  aListIter != m_pElemList->end(); ++aListIter )
802cdf0e10cSrcweir 		{
803cdf0e10cSrcweir 			ElementEntry_Impl& rEntry = *aListIter;
804*97fa22caSmseidel 			if ( rEntry.m_nElementID == nLabelID )
805*97fa22caSmseidel 			{
806*97fa22caSmseidel 				if ( rEntry.m_bHasLabel )
807*97fa22caSmseidel 					aLabel = rEntry.m_aLabel;
808*97fa22caSmseidel 				break;
809*97fa22caSmseidel 			}
810cdf0e10cSrcweir 		}
811*97fa22caSmseidel 	}
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 	return aLabel;
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir //------------------------------------------------------------------------------------
enableControl(sal_Int16 nElementID,sal_Bool bEnable)817cdf0e10cSrcweir void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnable )
818*97fa22caSmseidel 	throw( RuntimeException )
819cdf0e10cSrcweir {
820cdf0e10cSrcweir 	checkAlive();
821cdf0e10cSrcweir 
822*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
823*97fa22caSmseidel 	if ( getDialog() )
824cdf0e10cSrcweir 	{
825cdf0e10cSrcweir 		::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
826cdf0e10cSrcweir 		aAccess.enableControl( nElementID, bEnable );
827cdf0e10cSrcweir 	}
828*97fa22caSmseidel 	else
829*97fa22caSmseidel 	{
830cdf0e10cSrcweir 		if ( !m_pElemList )
831cdf0e10cSrcweir 			m_pElemList = new ElementList;
832cdf0e10cSrcweir 
833*97fa22caSmseidel 		sal_Bool bFound = sal_False;
834cdf0e10cSrcweir 		ElementList::iterator aListIter;
835cdf0e10cSrcweir 
836*97fa22caSmseidel 		for ( aListIter = m_pElemList->begin();
837cdf0e10cSrcweir 			  aListIter != m_pElemList->end(); ++aListIter )
838cdf0e10cSrcweir 		{
839cdf0e10cSrcweir 			ElementEntry_Impl& rEntry = *aListIter;
840*97fa22caSmseidel 			if ( rEntry.m_nElementID == nElementID )
841*97fa22caSmseidel 			{
842*97fa22caSmseidel 				rEntry.setEnabled( bEnable );
843*97fa22caSmseidel 				bFound = sal_True;
844*97fa22caSmseidel 			}
845cdf0e10cSrcweir 		}
846cdf0e10cSrcweir 
847*97fa22caSmseidel 		if ( !bFound )
848*97fa22caSmseidel 		{
849*97fa22caSmseidel 			ElementEntry_Impl aNew( nElementID );
850*97fa22caSmseidel 			aNew.setEnabled( bEnable );
851*97fa22caSmseidel 			m_pElemList->insert( m_pElemList->end(), aNew );
852*97fa22caSmseidel 		}
853*97fa22caSmseidel 	}
854cdf0e10cSrcweir }
855cdf0e10cSrcweir 
856cdf0e10cSrcweir //------------------------------------------------------------------------------------
857cdf0e10cSrcweir // XFilePickerNotifier functions
858cdf0e10cSrcweir //------------------------------------------------------------------------------------
859cdf0e10cSrcweir 
addFilePickerListener(const Reference<XFilePickerListener> & xListener)860cdf0e10cSrcweir void SAL_CALL SvtFilePicker::addFilePickerListener( const Reference< XFilePickerListener >& xListener ) throw ( RuntimeException )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir 	checkAlive();
863cdf0e10cSrcweir 
864*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
865cdf0e10cSrcweir 	m_xListener = xListener;
866cdf0e10cSrcweir }
867cdf0e10cSrcweir 
868cdf0e10cSrcweir //------------------------------------------------------------------------------------
removeFilePickerListener(const Reference<XFilePickerListener> &)869cdf0e10cSrcweir void SAL_CALL SvtFilePicker::removeFilePickerListener( const Reference< XFilePickerListener >& ) throw ( RuntimeException )
870cdf0e10cSrcweir {
871cdf0e10cSrcweir 	checkAlive();
872cdf0e10cSrcweir 
873*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
874cdf0e10cSrcweir 	m_xListener.clear();
875cdf0e10cSrcweir }
876cdf0e10cSrcweir 
877cdf0e10cSrcweir //------------------------------------------------------------------------------------
878cdf0e10cSrcweir // XFilePreview functions
879cdf0e10cSrcweir //------------------------------------------------------------------------------------
880cdf0e10cSrcweir 
getSupportedImageFormats()881cdf0e10cSrcweir Sequence< sal_Int16 > SAL_CALL SvtFilePicker::getSupportedImageFormats()
882*97fa22caSmseidel 	throw ( RuntimeException )
883cdf0e10cSrcweir {
884cdf0e10cSrcweir 	checkAlive();
885cdf0e10cSrcweir 
886*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
887*97fa22caSmseidel 	Sequence< sal_Int16 > aFormats( 1 );
888cdf0e10cSrcweir 
889*97fa22caSmseidel 	aFormats[0] = FilePreviewImageFormats::BITMAP;
890cdf0e10cSrcweir 
891*97fa22caSmseidel 	return aFormats;
892cdf0e10cSrcweir }
893cdf0e10cSrcweir 
894cdf0e10cSrcweir //------------------------------------------------------------------------------------
getTargetColorDepth()895cdf0e10cSrcweir sal_Int32 SAL_CALL SvtFilePicker::getTargetColorDepth() throw ( RuntimeException )
896cdf0e10cSrcweir {
897cdf0e10cSrcweir 	checkAlive();
898cdf0e10cSrcweir 
899*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
900*97fa22caSmseidel 	sal_Int32 nDepth = 0;
901cdf0e10cSrcweir 
902*97fa22caSmseidel 	if ( getDialog() )
903*97fa22caSmseidel 		nDepth = getDialog()->getTargetColorDepth();
904cdf0e10cSrcweir 
905*97fa22caSmseidel 	return nDepth;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir //------------------------------------------------------------------------------------
getAvailableWidth()909cdf0e10cSrcweir sal_Int32 SAL_CALL SvtFilePicker::getAvailableWidth() throw ( RuntimeException )
910cdf0e10cSrcweir {
911cdf0e10cSrcweir 	checkAlive();
912cdf0e10cSrcweir 
913*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
914*97fa22caSmseidel 	sal_Int32 nWidth = 0;
915cdf0e10cSrcweir 
916*97fa22caSmseidel 	if ( getDialog() )
917*97fa22caSmseidel 		nWidth = getDialog()->getAvailableWidth();
918cdf0e10cSrcweir 
919*97fa22caSmseidel 	return nWidth;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir 
922cdf0e10cSrcweir //------------------------------------------------------------------------------------
getAvailableHeight()923cdf0e10cSrcweir sal_Int32 SAL_CALL SvtFilePicker::getAvailableHeight() throw ( RuntimeException )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir 	checkAlive();
926cdf0e10cSrcweir 
927*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
928*97fa22caSmseidel 	sal_Int32 nHeigth = 0;
929cdf0e10cSrcweir 
930*97fa22caSmseidel 	if ( getDialog() )
931*97fa22caSmseidel 		nHeigth = getDialog()->getAvailableHeight();
932cdf0e10cSrcweir 
933*97fa22caSmseidel 	return nHeigth;
934cdf0e10cSrcweir }
935cdf0e10cSrcweir 
936cdf0e10cSrcweir //------------------------------------------------------------------------------------
setImage(sal_Int16 aImageFormat,const Any & rImage)937cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setImage( sal_Int16 aImageFormat, const Any& rImage )
938*97fa22caSmseidel 	throw ( IllegalArgumentException, RuntimeException )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir 	checkAlive();
941cdf0e10cSrcweir 
942*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
943*97fa22caSmseidel 	if ( getDialog() )
944*97fa22caSmseidel 		getDialog()->setImage( aImageFormat, rImage );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir 
947cdf0e10cSrcweir //------------------------------------------------------------------------------------
setShowState(sal_Bool bShowState)948cdf0e10cSrcweir sal_Bool SAL_CALL SvtFilePicker::setShowState( sal_Bool bShowState )
949*97fa22caSmseidel 	throw ( RuntimeException )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir 	checkAlive();
952cdf0e10cSrcweir 
953*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
954*97fa22caSmseidel 	sal_Bool bRet = sal_False;
955cdf0e10cSrcweir 
956*97fa22caSmseidel 	if ( getDialog() )
957*97fa22caSmseidel 		bRet = getDialog()->setShowState( bShowState );
958cdf0e10cSrcweir 
959*97fa22caSmseidel 	return bRet;
960cdf0e10cSrcweir }
961cdf0e10cSrcweir 
962cdf0e10cSrcweir //------------------------------------------------------------------------------------
getShowState()963cdf0e10cSrcweir sal_Bool SAL_CALL SvtFilePicker::getShowState() throw ( RuntimeException )
964cdf0e10cSrcweir {
965cdf0e10cSrcweir 	checkAlive();
966cdf0e10cSrcweir 
967*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
968*97fa22caSmseidel 	sal_Bool bRet = sal_False;
969cdf0e10cSrcweir 
970*97fa22caSmseidel 	if ( getDialog() )
971*97fa22caSmseidel 		bRet = getDialog()->getShowState();
972cdf0e10cSrcweir 
973*97fa22caSmseidel 	return bRet;
974cdf0e10cSrcweir }
975cdf0e10cSrcweir 
976cdf0e10cSrcweir //------------------------------------------------------------------------------------
977cdf0e10cSrcweir // XFilterGroupManager functions
978cdf0e10cSrcweir //------------------------------------------------------------------------------------
979cdf0e10cSrcweir 
appendFilterGroup(const::rtl::OUString & sGroupTitle,const Sequence<StringPair> & aFilters)980cdf0e10cSrcweir void SAL_CALL SvtFilePicker::appendFilterGroup(	const ::rtl::OUString& sGroupTitle,
981cdf0e10cSrcweir 												const Sequence< StringPair >& aFilters )
982cdf0e10cSrcweir 	throw ( IllegalArgumentException, RuntimeException )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir 	checkAlive();
985cdf0e10cSrcweir 
986*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 	// check the names
989cdf0e10cSrcweir 	if ( FilterNameExists( aFilters ) )
990*97fa22caSmseidel 		throw IllegalArgumentException(
991*97fa22caSmseidel 			rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("filter name exists")),
992*97fa22caSmseidel 			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 
appendFilter(const rtl::OUString & aTitle,const rtl::OUString & aFilter)1008cdf0e10cSrcweir void SAL_CALL SvtFilePicker::appendFilter( const rtl::OUString& aTitle,
1009*97fa22caSmseidel 										   const rtl::OUString& aFilter )
1010*97fa22caSmseidel 	throw( IllegalArgumentException, RuntimeException )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir 	checkAlive();
1013cdf0e10cSrcweir 
1014*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
1015cdf0e10cSrcweir 	// check the name
1016cdf0e10cSrcweir 	if ( FilterNameExists( aTitle ) )
1017cdf0e10cSrcweir 		// TODO: a more precise exception message
1018*97fa22caSmseidel 		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 //------------------------------------------------------------------------------------
setCurrentFilter(const rtl::OUString & aTitle)1028cdf0e10cSrcweir void SAL_CALL SvtFilePicker::setCurrentFilter( const rtl::OUString& aTitle )
1029*97fa22caSmseidel 	throw( IllegalArgumentException, RuntimeException )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir 	checkAlive();
1032cdf0e10cSrcweir 
1033*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
1034*97fa22caSmseidel 	if ( ! FilterNameExists( aTitle ) )
1035*97fa22caSmseidel 		throw IllegalArgumentException();
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 	m_aCurrentFilter = aTitle;
1038cdf0e10cSrcweir 
1039*97fa22caSmseidel 	if ( getDialog() )
1040*97fa22caSmseidel 		getDialog()->SetCurFilter( aTitle );
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir //------------------------------------------------------------------------------------
getCurrentFilter()1044cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getCurrentFilter()
1045*97fa22caSmseidel 	throw( RuntimeException )
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir 	checkAlive();
1048cdf0e10cSrcweir 
1049*97fa22caSmseidel 	::vos::OGuard aGuard( Application::GetSolarMutex() );
1050cdf0e10cSrcweir 	rtl::OUString aFilter = getDialog() ? rtl::OUString( getDialog()->GetCurFilter() ) :
1051*97fa22caSmseidel 										  rtl::OUString( m_aCurrentFilter );
1052cdf0e10cSrcweir 	return aFilter;
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir //------------------------------------------------------------------------------------
1057cdf0e10cSrcweir // XInitialization functions
1058cdf0e10cSrcweir //------------------------------------------------------------------------------------
1059cdf0e10cSrcweir 
initialize(const Sequence<Any> & _rArguments)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 //-------------------------------------------------------------------------
implHandleInitializationArgument(const::rtl::OUString & _rName,const Any & _rValue)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 */
getImplementationName()1145cdf0e10cSrcweir rtl::OUString SAL_CALL SvtFilePicker::getImplementationName() throw( RuntimeException )
1146cdf0e10cSrcweir {
1147cdf0e10cSrcweir 	return impl_getStaticImplementationName();
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir /* XServiceInfo */
supportsService(const rtl::OUString & sServiceName)1151cdf0e10cSrcweir sal_Bool SAL_CALL SvtFilePicker::supportsService( const rtl::OUString& sServiceName ) throw( RuntimeException )
1152cdf0e10cSrcweir {
1153*97fa22caSmseidel 	Sequence< rtl::OUString > seqServiceNames = getSupportedServiceNames();
1154*97fa22caSmseidel 	const rtl::OUString* pArray = seqServiceNames.getConstArray();
1155*97fa22caSmseidel 	for ( sal_Int32 i = 0; i < seqServiceNames.getLength(); i++ )
1156cdf0e10cSrcweir 	{
1157*97fa22caSmseidel 		if ( sServiceName == pArray[i] )
1158cdf0e10cSrcweir 		{
1159*97fa22caSmseidel 			return sal_True ;
1160cdf0e10cSrcweir 		}
1161cdf0e10cSrcweir 	}
1162*97fa22caSmseidel 	return sal_False ;
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir /* XServiceInfo */
getSupportedServiceNames()1166cdf0e10cSrcweir Sequence< rtl::OUString > SAL_CALL SvtFilePicker::getSupportedServiceNames() throw( RuntimeException )
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir 	return impl_getStaticSupportedServiceNames();
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir /* Helper for XServiceInfo */
impl_getStaticSupportedServiceNames()1172cdf0e10cSrcweir Sequence< rtl::OUString > SvtFilePicker::impl_getStaticSupportedServiceNames()
1173cdf0e10cSrcweir {
1174*97fa22caSmseidel 	Sequence< rtl::OUString > seqServiceNames( 1 );
1175*97fa22caSmseidel 	rtl::OUString* pArray = seqServiceNames.getArray();
1176*97fa22caSmseidel 	pArray[0] = rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.OfficeFilePicker" );
1177*97fa22caSmseidel 	return seqServiceNames ;
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir /* Helper for XServiceInfo */
impl_getStaticImplementationName()1181cdf0e10cSrcweir rtl::OUString SvtFilePicker::impl_getStaticImplementationName()
1182cdf0e10cSrcweir {
1183*97fa22caSmseidel 	return rtl::OUString::createFromAscii( "com.sun.star.svtools.OfficeFilePicker" );
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir /* Helper for registry */
impl_createInstance(const Reference<XComponentContext> & rxContext)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