merged tag ooo/DEV300_m102
[LibreOffice.git] / fpicker / source / office / iodlgimp.hxx
blob9826290858c2a058fd80557c293eb6894862fa25
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef _IODLGIMP_HXX
28 #define _IODLGIMP_HXX
30 #include <tools/string.hxx>
31 #include <vcl/fixed.hxx>
32 #include <vcl/lstbox.hxx>
33 #include <vcl/menubtn.hxx>
34 #include <vcl/timer.hxx>
35 #include <vcl/group.hxx>
37 #include "svl/svarray.hxx"
39 #include <vector>
41 //*****************************************************************************
43 class Accelerator;
44 class CheckBox;
45 class SvtFileDialog;
46 class SvStringsDtor;
47 class SvUShorts;
49 //*****************************************************************************
51 #define FILEDIALOG_DEF_EXTSEP ';'
52 #define FILEDIALOG_DEF_WILDCARD '*'
53 #define FILEDIALOG_DEF_IMAGEBORDER 10
54 #define FILEDIALOG_DEF_TIMEOUT 250
56 //*****************************************************************************
57 // SvtFileDialogFilter_Impl
58 //*****************************************************************************
60 /* [Beschreibung]
62 Instanzen dieser Klasse repr"asentieren einen Filter
65 class SvtFileDialogFilter_Impl
67 private:
68 String m_aName; // name of the entry
69 String m_aType; // filter wildcard - if empty, the entry marks a group
71 public:
72 SvtFileDialogFilter_Impl( const String& rName, const String& rType );
73 ~SvtFileDialogFilter_Impl();
75 const String& GetName() const { return m_aName; }
76 const String& GetType() const { return m_aType; }
77 const String GetExtension() const { return m_aType.Copy( 2 ); }
79 sal_Bool isGroupSeparator() const { return 0 == m_aType.Len(); }
82 //*****************************************************************************
83 // SvtFileDialogFilterList_Impl
84 //*****************************************************************************
86 SV_DECL_PTRARR_DEL( SvtFileDialogFilterList_Impl, SvtFileDialogFilter_Impl*, 3, 3 )
88 //*****************************************************************************
89 // SvtFileDlgMode
90 //*****************************************************************************
92 enum SvtFileDlgMode
94 FILEDLG_MODE_OPEN = 0,
95 FILEDLG_MODE_SAVE = 1
98 //*****************************************************************************
99 // SvtFileDlgType
100 //*****************************************************************************
102 enum SvtFileDlgType
104 FILEDLG_TYPE_FILEDLG = 0,
105 FILEDLG_TYPE_PATHDLG
108 //*****************************************************************************
109 // SvtFileDialogURLSelector
110 //*****************************************************************************
111 class SvtFileDialogURLSelector : public MenuButton
113 private:
114 SvtFileDialog* m_pParent;
115 PopupMenu* m_pMenu;
117 protected:
118 inline SvtFileDialog* GetDialogParent() { return m_pParent; }
120 protected:
121 void OpenURL( const String& rURL );
123 virtual void FillURLMenu( PopupMenu* _pMenu ) = 0;
125 protected:
126 SvtFileDialogURLSelector( SvtFileDialog* _pParent, const ResId& _rResId, sal_uInt16 _nButtonId );
127 ~SvtFileDialogURLSelector();
129 virtual void Activate();
132 //*****************************************************************************
133 // SvtUpButton_Impl
134 //*****************************************************************************
136 class SvtUpButton_Impl : public SvtFileDialogURLSelector
138 private:
139 SvStringsDtor* _pURLs;
141 public:
142 SvtUpButton_Impl( SvtFileDialog* pParent, const ResId& rResId );
143 ~SvtUpButton_Impl();
145 protected:
146 virtual void FillURLMenu( PopupMenu* _pMenu );
147 virtual void Select();
148 virtual void Click();
151 //*****************************************************************************
152 // SvtTravelButton_Impl
153 //*****************************************************************************
155 class SvtTravelButton_Impl : public SvtFileDialogURLSelector
157 private:
158 ::std::vector< String > m_aFavourites;
160 public:
161 SvtTravelButton_Impl( SvtFileDialog* pParent, const ResId& rResId );
162 ~SvtTravelButton_Impl();
164 void SetFavouriteLocations( const ::std::vector< String >& _rLocations );
166 protected:
167 virtual void FillURLMenu( PopupMenu* _pMenu );
168 virtual void Select();
169 virtual void Click();
172 //*****************************************************************************
173 // SvtFileDlgState
174 //*****************************************************************************
176 typedef sal_uInt8 SvtFileDlgState;
178 #define FILEDLG_STATE_NONE ((SvtFileDlgState)0x00)
179 #define FILEDLG_STATE_REMOTE ((SvtFileDlgState)0x01)
181 //*****************************************************************************
182 // SvtExpFileDlg_Impl
183 //*****************************************************************************
184 class SvtURLBox;
185 class SvtExpFileDlg_Impl
187 private:
188 DECL_STATIC_LINK( SvtExpFileDlg_Impl, UnClickHdl, Button* );
190 private:
191 ListBox* _pLbFilter;
193 const SvtFileDialogFilter_Impl* _pCurFilter;
194 String m_sCurrentFilterDisplayName; // may differ from _pCurFilter->GetName in case it is a cached entry
196 ::com::sun::star::uno::Sequence< ::rtl::OUString > _aBlackList;
198 public:
199 SvtFileDialogFilterList_Impl* _pFilter;
200 SvtFileDialogFilter_Impl* _pUserFilter;
202 FixedText* _pFtFileName;
203 SvtURLBox* _pEdFileName;
205 FixedText* _pFtFileVersion;
206 ListBox* _pLbFileVersion;
208 FixedText* _pFtTemplates;
209 ListBox* _pLbTemplates;
211 FixedText* _pFtImageTemplates;
212 ListBox* _pLbImageTemplates;
214 FixedText* _pFtFileType;
215 PushButton* _pBtnFileOpen;
216 PushButton* _pBtnCancel;
217 HelpButton* _pBtnHelp;
218 SvtUpButton_Impl* _pBtnUp;
219 ImageButton* _pBtnNewFolder;
220 SvtTravelButton_Impl* _pBtnStandard;
221 CheckBox* _pCbPassword;
222 FixedText* _pFtCurrentPath;
223 CheckBox* _pCbAutoExtension;
224 CheckBox* _pCbOptions;
226 SvtFileDlgMode _eMode;
227 SvtFileDlgType _eDlgType;
228 SvtFileDlgState _nState;
229 WinBits _nStyle;
231 String _aStdDir;
233 // beim traveln der Filterbox erst Zeitversetzt filtern
234 Timer _aFilterTimer;
236 // Zeigt der OpenHdl_Imp(), ob das Open durch einen Doppelclick ausgel"ost wurde
237 sal_Bool _bDoubleClick;
238 sal_Bool m_bNeedDelayedFilterExecute;
240 // Liste mit den 5 zuletzt genutzten Filtern
241 // Defaultfilter fuer <Alle> oder <Alle ...>
242 const SvtFileDialogFilter_Impl* _pDefaultFilter;
244 // Multiselektion?
245 sal_Bool _bMultiSelection;
247 // Fixgr"ossen f"ur Resize merken
248 long _nFixDeltaHeight;
249 Size _a6Size;
250 Size _aDlgSize;
251 String _aIniKey;
253 sal_Bool _bFolderHasOpened;
255 SvtExpFileDlg_Impl( WinBits nBits );
256 ~SvtExpFileDlg_Impl();
259 inline void SetBlackList( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) { _aBlackList = rBlackList; }
260 inline const ::com::sun::star::uno::Sequence< ::rtl::OUString >& GetBlackList() const { return _aBlackList; }
261 void SetStandardDir( const String& _rDir );
262 inline const String& GetStandardDir() const { return _aStdDir; }
263 inline void DisableFilterBoxAutoWidth() { _pLbFilter->EnableDDAutoWidth( sal_False ); }
265 // ------------------------------------------
266 // access to the filter listbox only as Control* - we want to maintain the entries/userdata ourself
267 Control* GetFilterListControl() { return _pLbFilter; }
268 const Control* GetFilterListControl() const { return _pLbFilter; }
269 void CreateFilterListControl( Window* _pParent, const ResId& _rId );
270 inline void SetFilterListSelectHdl( const Link& _rHandler );
272 // inits the listbox for the filters from the filter list (_pFilter)
273 void ClearFilterList( );
274 void InitFilterList( );
275 inline sal_Bool HasFilterListEntry( const String& _rFilterName );
276 inline void SelectFilterListEntry( const String& _rFilterName );
277 inline void SetNoFilterListSelection( );
278 void InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc );
279 // _pFilterDesc must already have been added to _pFilter
280 inline SvtFileDialogFilter_Impl* GetSelectedFilterEntry( String& /* [out] */ _rDisplayName ) const;
281 inline sal_Bool IsFilterListTravelSelect() const;
283 // ------------------------------------------
284 // access to the current filter via methods only - need to care for consistency between _pCurFilter and m_sCurrentFilterDisplayName
285 inline const SvtFileDialogFilter_Impl* GetCurFilter( ) const;
286 inline const String& GetCurFilterDisplayName() const;
287 void SetCurFilter( SvtFileDialogFilter_Impl* _pFilter, const String& _rDisplayName );
288 inline void SetCurFilter( SvtFileDialogFilter_Impl* _pFilter );
291 inline void SvtExpFileDlg_Impl::SetFilterListSelectHdl( const Link& _rHandler )
293 _pLbFilter->SetSelectHdl( _rHandler );
296 inline sal_Bool SvtExpFileDlg_Impl::HasFilterListEntry( const String& _rFilterName )
298 return ( LISTBOX_ENTRY_NOTFOUND != _pLbFilter->GetEntryPos( _rFilterName ) );
301 inline void SvtExpFileDlg_Impl::SelectFilterListEntry( const String& _rFilterName )
303 _pLbFilter->SelectEntry( _rFilterName );
306 inline void SvtExpFileDlg_Impl::SetNoFilterListSelection( )
308 _pLbFilter->SetNoSelection( );
311 inline SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetSelectedFilterEntry( String& _rDisplayName ) const
313 _rDisplayName = _pLbFilter->GetSelectEntry();
314 return static_cast< SvtFileDialogFilter_Impl* >( _pLbFilter->GetEntryData ( _pLbFilter->GetSelectEntryPos() ) );
317 inline sal_Bool SvtExpFileDlg_Impl::IsFilterListTravelSelect() const
319 return _pLbFilter->IsTravelSelect();
322 inline const SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetCurFilter( ) const
324 return _pCurFilter;
327 inline const String& SvtExpFileDlg_Impl::GetCurFilterDisplayName() const
329 return m_sCurrentFilterDisplayName;
332 inline void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter )
334 SetCurFilter( pFilter, pFilter->GetName() );
337 #endif // #ifndef _IODLGIMP_HXX