1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <PlacesListBox.hxx>
24 #include <tools/string.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/lstbox.hxx>
27 #include <vcl/menubtn.hxx>
28 #include <vcl/timer.hxx>
29 #include <vcl/group.hxx>
32 #include <boost/ptr_container/ptr_deque.hpp>
37 #define FILEDIALOG_DEF_EXTSEP ';'
38 #define FILEDIALOG_DEF_WILDCARD '*'
40 //*****************************************************************************
41 // SvtFileDialogFilter_Impl
42 //*****************************************************************************
46 Instances of this class represent a filter.
49 class SvtFileDialogFilter_Impl
52 String m_aName
; // name of the entry
53 String m_aType
; // filter wildcard - if empty, the entry marks a group
56 SvtFileDialogFilter_Impl( const String
& rName
, const String
& rType
);
57 ~SvtFileDialogFilter_Impl();
59 const String
& GetName() const { return m_aName
; }
60 const String
& GetType() const { return m_aType
; }
61 const String
GetExtension() const { return m_aType
.Copy( 2 ); }
63 sal_Bool
isGroupSeparator() const { return 0 == m_aType
.Len(); }
66 typedef boost::ptr_deque
<SvtFileDialogFilter_Impl
> SvtFileDialogFilterList_Impl
;
70 FILEDLG_MODE_OPEN
= 0,
76 FILEDLG_TYPE_FILEDLG
= 0,
80 class SvtFileDialogURLSelector
: public MenuButton
83 SvtFileDialog
* m_pParent
;
87 inline SvtFileDialog
* GetDialogParent() { return m_pParent
; }
91 virtual void FillURLMenu( PopupMenu
* _pMenu
) = 0;
94 SvtFileDialogURLSelector( SvtFileDialog
* _pParent
, const ResId
& _rResId
, sal_uInt16 _nButtonId
);
95 ~SvtFileDialogURLSelector();
97 virtual void Activate();
100 class SvtUpButton_Impl
: public SvtFileDialogURLSelector
103 std::vector
<OUString
> _aURLs
;
106 SvtUpButton_Impl( SvtFileDialog
* pParent
, const ResId
& rResId
);
110 virtual void FillURLMenu( PopupMenu
* _pMenu
);
111 virtual void Select();
112 virtual void Click();
115 typedef sal_uInt8 SvtFileDlgState
;
117 #define FILEDLG_STATE_NONE ((SvtFileDlgState)0x00)
118 #define FILEDLG_STATE_REMOTE ((SvtFileDlgState)0x01)
121 class SvtExpFileDlg_Impl
124 DECL_STATIC_LINK( SvtExpFileDlg_Impl
, UnClickHdl
, Button
* );
129 const SvtFileDialogFilter_Impl
* _pCurFilter
;
130 String m_sCurrentFilterDisplayName
; // may differ from _pCurFilter->GetName in case it is a cached entry
132 ::com::sun::star::uno::Sequence
< OUString
> _aBlackList
;
135 SvtFileDialogFilterList_Impl
* _pFilter
;
136 SvtFileDialogFilter_Impl
* _pUserFilter
;
138 FixedText
* _pFtFileName
;
139 SvtURLBox
* _pEdFileName
;
141 FixedText
* _pFtFileVersion
;
142 ListBox
* _pLbFileVersion
;
144 FixedText
* _pFtTemplates
;
145 ListBox
* _pLbTemplates
;
147 FixedText
* _pFtImageTemplates
;
148 ListBox
* _pLbImageTemplates
;
150 FixedText
* _pFtFileType
;
151 PushButton
* _pBtnFileOpen
;
152 PushButton
* _pBtnCancel
;
153 HelpButton
* _pBtnHelp
;
154 SvtUpButton_Impl
* _pBtnUp
;
155 ImageButton
* _pBtnNewFolder
;
156 CheckBox
* _pCbPassword
;
157 SvtURLBox
* _pEdCurrentPath
;
158 CheckBox
* _pCbAutoExtension
;
159 CheckBox
* _pCbOptions
;
161 PlacesListBox
* _pPlaces
;
162 PushButton
* _pBtnConnectToServer
;
164 SvtFileDlgMode _eMode
;
165 SvtFileDlgType _eDlgType
;
166 SvtFileDlgState _nState
;
171 // delay filter when traveling the filterbox
174 // shows OpenHdl_Imp() if the open was triggered by a double click
175 sal_Bool _bDoubleClick
;
176 sal_Bool m_bNeedDelayedFilterExecute
;
178 // list of the 5 most recently used filters
179 // Defaultfilter for <All> oder <All ...>
180 const SvtFileDialogFilter_Impl
* _pDefaultFilter
;
183 sal_Bool _bMultiSelection
;
185 // remember fixsizes for resize
186 long _nFixDeltaHeight
;
191 sal_Bool _bFolderHasOpened
;
193 SvtExpFileDlg_Impl( WinBits nBits
);
194 ~SvtExpFileDlg_Impl();
197 inline void SetBlackList( const ::com::sun::star::uno::Sequence
< OUString
>& rBlackList
) { _aBlackList
= rBlackList
; }
198 inline const ::com::sun::star::uno::Sequence
< OUString
>& GetBlackList() const { return _aBlackList
; }
199 void SetStandardDir( const String
& _rDir
);
200 inline const String
& GetStandardDir() const { return _aStdDir
; }
201 inline void DisableFilterBoxAutoWidth() { _pLbFilter
->EnableDDAutoWidth( sal_False
); }
203 // ------------------------------------------
204 // access to the filter listbox only as Control* - we want to maintain the entries/userdata ourself
205 Control
* GetFilterListControl() { return _pLbFilter
; }
206 const Control
* GetFilterListControl() const { return _pLbFilter
; }
207 void CreateFilterListControl( Window
* _pParent
, const ResId
& _rId
);
208 inline void SetFilterListSelectHdl( const Link
& _rHandler
);
210 // inits the listbox for the filters from the filter list (_pFilter)
211 void ClearFilterList( );
212 void InitFilterList( );
213 inline sal_Bool
HasFilterListEntry( const String
& _rFilterName
);
214 inline void SelectFilterListEntry( const String
& _rFilterName
);
215 inline void SetNoFilterListSelection( );
216 void InsertFilterListEntry( const SvtFileDialogFilter_Impl
* _pFilterDesc
);
217 // _pFilterDesc must already have been added to _pFilter
218 inline SvtFileDialogFilter_Impl
* GetSelectedFilterEntry( String
& /* [out] */ _rDisplayName
) const;
219 inline sal_Bool
IsFilterListTravelSelect() const;
221 // ------------------------------------------
222 // access to the current filter via methods only - need to care for consistency between _pCurFilter and m_sCurrentFilterDisplayName
223 inline const SvtFileDialogFilter_Impl
* GetCurFilter( ) const;
224 inline const String
& GetCurFilterDisplayName() const;
225 void SetCurFilter( SvtFileDialogFilter_Impl
* _pFilter
, const String
& _rDisplayName
);
226 inline void SetCurFilter( SvtFileDialogFilter_Impl
* _pFilter
);
229 inline void SvtExpFileDlg_Impl::SetFilterListSelectHdl( const Link
& _rHandler
)
231 _pLbFilter
->SetSelectHdl( _rHandler
);
234 inline sal_Bool
SvtExpFileDlg_Impl::HasFilterListEntry( const String
& _rFilterName
)
236 return ( LISTBOX_ENTRY_NOTFOUND
!= _pLbFilter
->GetEntryPos( _rFilterName
) );
239 inline void SvtExpFileDlg_Impl::SelectFilterListEntry( const String
& _rFilterName
)
241 _pLbFilter
->SelectEntry( _rFilterName
);
244 inline void SvtExpFileDlg_Impl::SetNoFilterListSelection( )
246 _pLbFilter
->SetNoSelection( );
249 inline SvtFileDialogFilter_Impl
* SvtExpFileDlg_Impl::GetSelectedFilterEntry( String
& _rDisplayName
) const
251 _rDisplayName
= _pLbFilter
->GetSelectEntry();
252 return static_cast< SvtFileDialogFilter_Impl
* >( _pLbFilter
->GetEntryData ( _pLbFilter
->GetSelectEntryPos() ) );
255 inline sal_Bool
SvtExpFileDlg_Impl::IsFilterListTravelSelect() const
257 return _pLbFilter
->IsTravelSelect();
260 inline const SvtFileDialogFilter_Impl
* SvtExpFileDlg_Impl::GetCurFilter( ) const
265 inline const String
& SvtExpFileDlg_Impl::GetCurFilterDisplayName() const
267 return m_sCurrentFilterDisplayName
;
270 inline void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl
* pFilter
)
272 SetCurFilter( pFilter
, pFilter
->GetName() );
275 #endif // #ifndef _IODLGIMP_HXX
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */