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