xref: /aoo41x/main/fpicker/source/office/iodlgimp.cxx (revision cdf0e10c)
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 // includes *******************************************************************
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "iodlgimp.hxx"
34*cdf0e10cSrcweir #include "svtools/headbar.hxx"
35*cdf0e10cSrcweir #include <tools/debug.hxx>
36*cdf0e10cSrcweir #include <tools/wldcrd.hxx>
37*cdf0e10cSrcweir #include <tools/urlobj.hxx>
38*cdf0e10cSrcweir #include <vcl/menu.hxx>
39*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
41*cdf0e10cSrcweir #include <vcl/svapp.hxx>
42*cdf0e10cSrcweir // #97148# ---------------
43*cdf0e10cSrcweir #include "svl/ctypeitm.hxx"
44*cdf0e10cSrcweir #include "svl/eitem.hxx"
45*cdf0e10cSrcweir #include "unotools/viewoptions.hxx"
46*cdf0e10cSrcweir #include "svtools/fileview.hxx"
47*cdf0e10cSrcweir #include "svtools/inettbc.hxx"
48*cdf0e10cSrcweir #include "iodlg.hxx"
49*cdf0e10cSrcweir #include "iodlg.hrc"
50*cdf0e10cSrcweir #include "svtools/imagemgr.hxx"
51*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
52*cdf0e10cSrcweir #include "unotools/useroptions.hxx"
53*cdf0e10cSrcweir #include "rtl/instance.hxx"
54*cdf0e10cSrcweir #include <svl/svl.hrc>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #define _SVSTDARR_STRINGSSORTDTOR
57*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
58*cdf0e10cSrcweir #define _SVSTDARR_USHORTS
59*cdf0e10cSrcweir #include "svl/svstdarr.hxx"
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
62*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
63*cdf0e10cSrcweir using namespace ::utl;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir // some stuff for easier changes for SvtViewOptions
66*cdf0e10cSrcweir static const sal_Char*		pViewOptDataName = "dialog data";
67*cdf0e10cSrcweir #define VIEWOPT_DATANAME	::rtl::OUString::createFromAscii( pViewOptDataName )
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 	rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( ::rtl::OUString( rData ) ) );
72*cdf0e10cSrcweir }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
77*cdf0e10cSrcweir 	::rtl::OUString aUserData;
78*cdf0e10cSrcweir 	aAny >>= aUserData;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	return String( aUserData );
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // defines f"ur den Style der BrowseBox
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir #define STYLE_MULTI_SELECTION	\
87*cdf0e10cSrcweir 	CNTVIEWSTYLE_NODE_BUTTONS | \
88*cdf0e10cSrcweir 	CNTVIEWSTYLE_NODE_BUTTONS_AT_ROOT | \
89*cdf0e10cSrcweir 	CNTVIEWSTYLE_SHOW_MESSAGES | \
90*cdf0e10cSrcweir 	CNTVIEWSTYLE_SHOW_FOLDERS | \
91*cdf0e10cSrcweir 	CNTVIEWSTYLE_NO_SMARTHIGHLIGHT | \
92*cdf0e10cSrcweir 	CNTVIEWSTYLE_HIDE_OPENMENU | \
93*cdf0e10cSrcweir 	CNTVIEWSTYLE_DEFAULT_APPEARANCE | \
94*cdf0e10cSrcweir 	CNTVIEWSTYLE_SORT_BY_FOLDER
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir #define STYLE_SINGLE_SELECTION	\
97*cdf0e10cSrcweir 	STYLE_MULTI_SELECTION | CNTVIEWSTYLE_SINGLE_SELECTION
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir #define BOOL_NOT_INITIALIZE		((sal_Bool)2)
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir //*****************************************************************************
102*cdf0e10cSrcweir // ResMgrHolder / SvtSimpleResId
103*cdf0e10cSrcweir //*****************************************************************************
104*cdf0e10cSrcweir namespace
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	struct ResMgrHolder
107*cdf0e10cSrcweir 	{
108*cdf0e10cSrcweir 		ResMgr * operator ()()
109*cdf0e10cSrcweir 		{
110*cdf0e10cSrcweir 			return ResMgr::CreateResMgr (CREATEVERSIONRESMGR_NAME(svs));
111*cdf0e10cSrcweir 		}
112*cdf0e10cSrcweir 		static ResMgr * getOrCreate()
113*cdf0e10cSrcweir 		{
114*cdf0e10cSrcweir 			return rtl_Instance<
115*cdf0e10cSrcweir 				ResMgr, ResMgrHolder,
116*cdf0e10cSrcweir 				osl::MutexGuard, osl::GetGlobalMutex >::create (
117*cdf0e10cSrcweir 					ResMgrHolder(), osl::GetGlobalMutex());
118*cdf0e10cSrcweir 		}
119*cdf0e10cSrcweir 	};
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	struct SvtSimpleResId : public ResId
122*cdf0e10cSrcweir 	{
123*cdf0e10cSrcweir 		SvtSimpleResId (sal_uInt16 nId) : ResId (nId, *ResMgrHolder::getOrCreate()) {}
124*cdf0e10cSrcweir 	};
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir //*****************************************************************************
128*cdf0e10cSrcweir // SvtFileDialogFilter_Impl
129*cdf0e10cSrcweir //*****************************************************************************
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir DBG_NAME( SvtFileDialogFilter_Impl )
132*cdf0e10cSrcweir SvtFileDialogFilter_Impl::SvtFileDialogFilter_Impl( const String& rName, const String& rType )
133*cdf0e10cSrcweir 	:m_aName( rName )
134*cdf0e10cSrcweir 	,m_aType( rType )
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir 	DBG_CTOR( SvtFileDialogFilter_Impl, NULL );
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 	m_aType.ToLowerAscii();
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir //*****************************************************************************
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir SvtFileDialogFilter_Impl::~SvtFileDialogFilter_Impl()
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	DBG_DTOR( SvtFileDialogFilter_Impl, NULL );
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir //*****************************************************************************
149*cdf0e10cSrcweir // SvtFileDialogFilterList_Impl
150*cdf0e10cSrcweir //*****************************************************************************
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir SV_IMPL_PTRARR( SvtFileDialogFilterList_Impl, SvtFileDialogFilter_Impl* );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir //=============================================================================
155*cdf0e10cSrcweir //= SvtFileDialogURLSelector
156*cdf0e10cSrcweir //=============================================================================
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir //-----------------------------------------------------------------------------
159*cdf0e10cSrcweir SvtFileDialogURLSelector::SvtFileDialogURLSelector( SvtFileDialog* _pParent, const ResId& _rResId, sal_uInt16 _nButtonId )
160*cdf0e10cSrcweir     :MenuButton ( _pParent, _rResId )
161*cdf0e10cSrcweir 	,m_pParent  ( _pParent )
162*cdf0e10cSrcweir     ,m_pMenu    ( new PopupMenu )
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir 	SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE );
165*cdf0e10cSrcweir 	SetModeImage( m_pParent->GetButtonImage( _nButtonId ) );
166*cdf0e10cSrcweir 	SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
167*cdf0e10cSrcweir 	SetDropDown( PUSHBUTTON_DROPDOWN_TOOLBOX );
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir //-----------------------------------------------------------------------------
171*cdf0e10cSrcweir SvtFileDialogURLSelector::~SvtFileDialogURLSelector()
172*cdf0e10cSrcweir {
173*cdf0e10cSrcweir 	delete m_pMenu;
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir //-----------------------------------------------------------------------------
177*cdf0e10cSrcweir void SvtFileDialogURLSelector::OpenURL( const String& rURL )
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir 	INetURLObject aObj( rURL );
180*cdf0e10cSrcweir     DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "SvtFileDialogURLSelector::OpenURL: Invalid URL!" );
181*cdf0e10cSrcweir 	m_pParent->OpenURL_Impl( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
182*cdf0e10cSrcweir }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir //-----------------------------------------------------------------------------
185*cdf0e10cSrcweir void SvtFileDialogURLSelector::Activate()
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir 	m_pMenu->Clear();
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     FillURLMenu( m_pMenu );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	SetPopupMenu( m_pMenu );
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir //=============================================================================
195*cdf0e10cSrcweir //= SvtUpButton_Impl
196*cdf0e10cSrcweir //=============================================================================
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir //-----------------------------------------------------------------------------
199*cdf0e10cSrcweir SvtUpButton_Impl::SvtUpButton_Impl( SvtFileDialog* pParent, const ResId& rResId )
200*cdf0e10cSrcweir     :SvtFileDialogURLSelector( pParent, rResId, IMG_FILEDLG_BTN_UP )
201*cdf0e10cSrcweir 	,_pURLs			         ( NULL )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir //-----------------------------------------------------------------------------
206*cdf0e10cSrcweir SvtUpButton_Impl::~SvtUpButton_Impl()
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	delete _pURLs;
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir //-----------------------------------------------------------------------------
212*cdf0e10cSrcweir void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu )
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir 	SvtFileView* pBox = GetDialogParent()->GetView();
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	sal_uInt16 nItemId = 1;
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	delete _pURLs;
219*cdf0e10cSrcweir 	_pURLs = new SvStringsDtor;
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	// "Ubergeordnete Ebenen bestimmen.
222*cdf0e10cSrcweir 	INetURLObject aObject( pBox->GetViewURL() );
223*cdf0e10cSrcweir 	sal_Int32 nCount = aObject.getSegmentCount();
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 	::svtools::VolumeInfo aVolInfo( sal_True /* volume */, sal_False /* remote */,
226*cdf0e10cSrcweir 									sal_False /* removable */, sal_False /* floppy */,
227*cdf0e10cSrcweir 									sal_False /* compact disk */ );
228*cdf0e10cSrcweir 	sal_Bool bIsHighContrast = pBox->GetSettings().GetStyleSettings().GetHighContrastMode();
229*cdf0e10cSrcweir 	Image aVolumeImage( SvFileInformationManager::GetFolderImage( aVolInfo, bIsHighContrast ) );
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	while ( nCount >= 1 )
232*cdf0e10cSrcweir 	{
233*cdf0e10cSrcweir 		aObject.removeSegment();
234*cdf0e10cSrcweir 		String* pParentURL = new String( aObject.GetMainURL( INetURLObject::NO_DECODE ) );
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir         if ( GetDialogParent()->isUrlAllowed( *pParentURL ) )
237*cdf0e10cSrcweir         {
238*cdf0e10cSrcweir 		    String aTitle;
239*cdf0e10cSrcweir 		    // 97148# --------------------------------
240*cdf0e10cSrcweir 		    if ( !GetDialogParent()->ContentGetTitle( *pParentURL, aTitle ) || aTitle.Len() == 0 )
241*cdf0e10cSrcweir 			    aTitle = aObject.getName();
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 		    Image aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image
244*cdf0e10cSrcweir 			    ? SvFileInformationManager::GetImage( aObject, bIsHighContrast )
245*cdf0e10cSrcweir 			    : aVolumeImage;
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir             _pMenu->InsertItem( nItemId++, aTitle, aImage );
248*cdf0e10cSrcweir             _pURLs->Insert( pParentURL, _pURLs->Count() );
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir             if ( nCount == 1 )
251*cdf0e10cSrcweir             {
252*cdf0e10cSrcweir                 // adjust the title of the top level entry (the workspace)
253*cdf0e10cSrcweir                 _pMenu->SetItemText( --nItemId, SvtSimpleResId( STR_SVT_MIMETYPE_CNT_FSYSBOX ) );
254*cdf0e10cSrcweir             }
255*cdf0e10cSrcweir         }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir         --nCount;
258*cdf0e10cSrcweir 	}
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir //-----------------------------------------------------------------------------
262*cdf0e10cSrcweir void SvtUpButton_Impl::Select()
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir 	sal_uInt16 nId = GetCurItemId();
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 	if ( nId )
267*cdf0e10cSrcweir 	{
268*cdf0e10cSrcweir 		--nId;
269*cdf0e10cSrcweir 		DBG_ASSERT( nId <= _pURLs->Count(), "SvtUpButton_Impl:falscher Index" );
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir         String aURL = *(_pURLs->GetObject( nId ));
272*cdf0e10cSrcweir 		GetDialogParent()->OpenURL_Impl( aURL );
273*cdf0e10cSrcweir 	}
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir //-----------------------------------------------------------------------------
277*cdf0e10cSrcweir void SvtUpButton_Impl::Click()
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir 	GetDialogParent()->PrevLevel_Impl();
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir //=============================================================================
283*cdf0e10cSrcweir //= SvtTravelButton_Impl
284*cdf0e10cSrcweir //=============================================================================
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir //-----------------------------------------------------------------------------
287*cdf0e10cSrcweir SvtTravelButton_Impl::SvtTravelButton_Impl( SvtFileDialog* pParent, const ResId& rResId )
288*cdf0e10cSrcweir     :SvtFileDialogURLSelector   ( pParent, rResId, IMG_FILEDLG_BTN_STD )
289*cdf0e10cSrcweir {
290*cdf0e10cSrcweir 	SetDropDown( 0 );   // by default, don't drop down, as we don't have favourites
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir //-----------------------------------------------------------------------------
294*cdf0e10cSrcweir void SvtTravelButton_Impl::SetFavouriteLocations( const ::std::vector< String >& _rLocations )
295*cdf0e10cSrcweir {
296*cdf0e10cSrcweir     m_aFavourites = _rLocations;
297*cdf0e10cSrcweir     // enable the drop down if and only if we have favourites
298*cdf0e10cSrcweir     SetDropDown( m_aFavourites.empty() ? 0 : PUSHBUTTON_DROPDOWN_TOOLBOX );
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir //-----------------------------------------------------------------------------
302*cdf0e10cSrcweir SvtTravelButton_Impl::~SvtTravelButton_Impl()
303*cdf0e10cSrcweir {
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir //-----------------------------------------------------------------------------
307*cdf0e10cSrcweir void SvtTravelButton_Impl::FillURLMenu( PopupMenu* _pMenu )
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     if ( m_aFavourites.empty() )
310*cdf0e10cSrcweir         // though we claimed that we do not want to have a drop down button
311*cdf0e10cSrcweir         // in this case, VCL nevertheless behaves as if we had one .... :(
312*cdf0e10cSrcweir         return;
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     _pMenu->Clear();
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	sal_Bool bIsHighContrast = GetDialogParent()->GetView()->GetSettings().GetStyleSettings().GetHighContrastMode();
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     sal_uInt16 nItemId = 1;
319*cdf0e10cSrcweir     String sDisplayName;
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir     ::std::vector< String >::const_iterator aLoop;
322*cdf0e10cSrcweir     for ( aLoop = m_aFavourites.begin(); aLoop != m_aFavourites.end(); ++aLoop, ++nItemId )
323*cdf0e10cSrcweir     {
324*cdf0e10cSrcweir         if ( GetDialogParent()->isUrlAllowed( *aLoop ) )
325*cdf0e10cSrcweir         {
326*cdf0e10cSrcweir 		    Image aImage = SvFileInformationManager::GetImage(
327*cdf0e10cSrcweir 				INetURLObject(*aLoop), bIsHighContrast );
328*cdf0e10cSrcweir             if ( LocalFileHelper::ConvertURLToSystemPath(*aLoop, sDisplayName) )
329*cdf0e10cSrcweir                 _pMenu->InsertItem( nItemId, sDisplayName, aImage );
330*cdf0e10cSrcweir             else
331*cdf0e10cSrcweir                 _pMenu->InsertItem( nItemId, *aLoop, aImage );
332*cdf0e10cSrcweir         }
333*cdf0e10cSrcweir     }
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir //-----------------------------------------------------------------------------
337*cdf0e10cSrcweir void SvtTravelButton_Impl::Select()
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir 	sal_uInt16 nId = GetCurItemId();
340*cdf0e10cSrcweir 	if ( nId )
341*cdf0e10cSrcweir 	{
342*cdf0e10cSrcweir 		--nId;
343*cdf0e10cSrcweir         DBG_ASSERT( nId < m_aFavourites.size(), "SvtTravelButton_Impl::Select: invalid index!" );
344*cdf0e10cSrcweir         if ( nId < m_aFavourites.size() )
345*cdf0e10cSrcweir             OpenURL( m_aFavourites[ nId ] );
346*cdf0e10cSrcweir 	}
347*cdf0e10cSrcweir }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir //-----------------------------------------------------------------------------
350*cdf0e10cSrcweir void SvtTravelButton_Impl::Click()
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir 	OpenURL( GetDialogParent()->GetStandardDir() );
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir //*****************************************************************************
356*cdf0e10cSrcweir // SvtExpFileDlg_Impl
357*cdf0e10cSrcweir //*****************************************************************************
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir SvtExpFileDlg_Impl::SvtExpFileDlg_Impl( WinBits )	:
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir     _pLbFilter          ( NULL ),
362*cdf0e10cSrcweir     _pCurFilter         ( NULL ),
363*cdf0e10cSrcweir     _pFilter            ( new SvtFileDialogFilterList_Impl() ),
364*cdf0e10cSrcweir     _pUserFilter        ( NULL ),
365*cdf0e10cSrcweir 	_pFtFileName        ( NULL ),
366*cdf0e10cSrcweir 	_pEdFileName        ( NULL ),
367*cdf0e10cSrcweir 	_pFtFileVersion     ( NULL ),
368*cdf0e10cSrcweir 	_pLbFileVersion     ( NULL ),
369*cdf0e10cSrcweir 	_pFtTemplates		( NULL ),
370*cdf0e10cSrcweir 	_pLbTemplates		( NULL ),
371*cdf0e10cSrcweir 	_pFtImageTemplates	( NULL ),
372*cdf0e10cSrcweir 	_pLbImageTemplates	( NULL ),
373*cdf0e10cSrcweir 	_pFtFileType        ( NULL ),
374*cdf0e10cSrcweir     _pBtnFileOpen       ( NULL ),
375*cdf0e10cSrcweir 	_pBtnCancel         ( NULL ),
376*cdf0e10cSrcweir 	_pBtnHelp			( NULL ),
377*cdf0e10cSrcweir 	_pBtnUp             ( NULL ),
378*cdf0e10cSrcweir 	_pBtnNewFolder      ( NULL ),
379*cdf0e10cSrcweir 	_pBtnStandard       ( NULL ),
380*cdf0e10cSrcweir 	_pCbPassword        ( NULL ),
381*cdf0e10cSrcweir 	_pFtCurrentPath     ( NULL ),
382*cdf0e10cSrcweir 	_pCbAutoExtension   ( NULL ),
383*cdf0e10cSrcweir 	_pCbOptions			( NULL ),
384*cdf0e10cSrcweir 	_nState             ( FILEDLG_STATE_REMOTE ),
385*cdf0e10cSrcweir 	_nStyle				( 0 ),
386*cdf0e10cSrcweir 	_bDoubleClick       ( sal_False ),
387*cdf0e10cSrcweir     m_bNeedDelayedFilterExecute ( sal_False ),
388*cdf0e10cSrcweir     _pDefaultFilter     ( NULL ),
389*cdf0e10cSrcweir     _bMultiSelection    ( sal_False ),
390*cdf0e10cSrcweir     _nFixDeltaHeight    ( 0 ),
391*cdf0e10cSrcweir     _bFolderHasOpened   ( sal_False )
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir //*****************************************************************************
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
398*cdf0e10cSrcweir {
399*cdf0e10cSrcweir 	delete _pFtCurrentPath;
400*cdf0e10cSrcweir 	delete _pCbPassword;
401*cdf0e10cSrcweir 	delete _pCbAutoExtension;
402*cdf0e10cSrcweir 	delete _pCbOptions;
403*cdf0e10cSrcweir 	delete _pBtnStandard;
404*cdf0e10cSrcweir 	delete _pBtnNewFolder;
405*cdf0e10cSrcweir 	delete _pBtnUp;
406*cdf0e10cSrcweir 	delete _pBtnHelp;
407*cdf0e10cSrcweir 	delete _pBtnCancel;
408*cdf0e10cSrcweir 	delete _pBtnFileOpen;
409*cdf0e10cSrcweir 	delete _pLbFilter;
410*cdf0e10cSrcweir 	delete _pFtFileType;
411*cdf0e10cSrcweir 	delete _pLbFileVersion;
412*cdf0e10cSrcweir 	delete _pFtFileVersion;
413*cdf0e10cSrcweir 	delete _pFtTemplates;
414*cdf0e10cSrcweir 	delete _pLbTemplates;
415*cdf0e10cSrcweir 	delete _pFtImageTemplates;
416*cdf0e10cSrcweir 	delete _pLbImageTemplates;
417*cdf0e10cSrcweir 	delete _pEdFileName;
418*cdf0e10cSrcweir 	delete _pFtFileName;
419*cdf0e10cSrcweir 	delete _pUserFilter;
420*cdf0e10cSrcweir 	delete _pFilter;
421*cdf0e10cSrcweir }
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir //*****************************************************************************
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir void SvtExpFileDlg_Impl::SetStandardDir( const String& _rDir )
426*cdf0e10cSrcweir {
427*cdf0e10cSrcweir 	_aStdDir = _rDir;
428*cdf0e10cSrcweir 	if ( 0 == _aStdDir.Len() )
429*cdf0e10cSrcweir 		_aStdDir.AssignAscii( "file:///" );
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir //*****************************************************************************
433*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
434*cdf0e10cSrcweir //-----------------------------------------------------------------------------
435*cdf0e10cSrcweir namespace {
436*cdf0e10cSrcweir 	String lcl_DecoratedFilter( const String& _rOriginalFilter )
437*cdf0e10cSrcweir 	{
438*cdf0e10cSrcweir 		String aDecoratedFilter = '<';
439*cdf0e10cSrcweir 		aDecoratedFilter += _rOriginalFilter;
440*cdf0e10cSrcweir 		aDecoratedFilter += '>';
441*cdf0e10cSrcweir 		return aDecoratedFilter;
442*cdf0e10cSrcweir 	}
443*cdf0e10cSrcweir }
444*cdf0e10cSrcweir #endif
445*cdf0e10cSrcweir //-----------------------------------------------------------------------------
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir void SvtExpFileDlg_Impl::ClearFilterList( )
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir 	_pLbFilter->Clear();
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir //-----------------------------------------------------------------------------
453*cdf0e10cSrcweir void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter, const String& rDisplayName )
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir 	DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
456*cdf0e10cSrcweir 	DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
457*cdf0e10cSrcweir 			||	( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
458*cdf0e10cSrcweir 			"SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 	_pCurFilter = pFilter;
461*cdf0e10cSrcweir 	m_sCurrentFilterDisplayName = rDisplayName;
462*cdf0e10cSrcweir }
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir //-----------------------------------------------------------------------------
465*cdf0e10cSrcweir void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc )
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir 	String sName = _pFilterDesc->GetName();
468*cdf0e10cSrcweir 	if ( _pFilterDesc->isGroupSeparator() )
469*cdf0e10cSrcweir 		sName = String::CreateFromAscii( "------------------------------------------" );
470*cdf0e10cSrcweir 	else
471*cdf0e10cSrcweir 		sName = _pFilterDesc->GetName();
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	// insert an set user data
474*cdf0e10cSrcweir 	sal_uInt16 nPos = _pLbFilter->InsertEntry( sName );
475*cdf0e10cSrcweir 	_pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) );
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir //-----------------------------------------------------------------------------
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir void SvtExpFileDlg_Impl::InitFilterList( )
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir 	// clear the current list
483*cdf0e10cSrcweir 	ClearFilterList( );
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 	// reinit it
486*cdf0e10cSrcweir 	sal_uInt16 nPos = _pFilter->Count();
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir 	// search for the first entry which is no group separator
489*cdf0e10cSrcweir 	while ( nPos-- && _pFilter->GetObject( nPos ) && _pFilter->GetObject( nPos )->isGroupSeparator() )
490*cdf0e10cSrcweir 		;
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 	// add all following entries
493*cdf0e10cSrcweir 	while ( (sal_Int16)nPos >= 0 )
494*cdf0e10cSrcweir 		InsertFilterListEntry( _pFilter->GetObject( nPos-- ) );
495*cdf0e10cSrcweir }
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir //-----------------------------------------------------------------------------
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir void SvtExpFileDlg_Impl::CreateFilterListControl( Window* _pParent, const ResId& _rId )
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir 	DBG_ASSERT( !_pLbFilter, "SvtExpFileDlg_Impl::CreateFilterListControl: already created the control!" );
502*cdf0e10cSrcweir 	if ( !_pLbFilter )
503*cdf0e10cSrcweir     {
504*cdf0e10cSrcweir 		_pLbFilter = new ListBox( _pParent, _rId );
505*cdf0e10cSrcweir         _pLbFilter->SetDropDownLineCount( 10 );
506*cdf0e10cSrcweir     }
507*cdf0e10cSrcweir }
508