Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_FPICKER_SOURCE_OFFICE_IODLGIMP_HXX
20 : #define INCLUDED_FPICKER_SOURCE_OFFICE_IODLGIMP_HXX
21 :
22 : #include <PlacesListBox.hxx>
23 :
24 : #include <vcl/fixed.hxx>
25 : #include <vcl/lstbox.hxx>
26 : #include <vcl/menubtn.hxx>
27 : #include <vcl/timer.hxx>
28 : #include <vcl/group.hxx>
29 :
30 : #include <vector>
31 : #include <boost/ptr_container/ptr_deque.hpp>
32 :
33 : class CheckBox;
34 : class SvtFileDialog;
35 :
36 : #define FILEDIALOG_DEF_EXTSEP ';'
37 : #define FILEDIALOG_DEF_WILDCARD '*'
38 :
39 :
40 : // SvtFileDialogFilter_Impl
41 :
42 :
43 : /* [Description]
44 :
45 : Instances of this class represent a filter.
46 : */
47 :
48 : class SvtFileDialogFilter_Impl
49 : {
50 : private:
51 : OUString m_aName; // name of the entry
52 : OUString m_aType; // filter wildcard - if empty, the entry marks a group
53 :
54 : public:
55 : SvtFileDialogFilter_Impl( const OUString& rName, const OUString& rType );
56 : ~SvtFileDialogFilter_Impl();
57 :
58 0 : const OUString& GetName() const { return m_aName; }
59 0 : const OUString& GetType() const { return m_aType; }
60 0 : const OUString GetExtension() const { return m_aType.getLength() > 2 ? m_aType.copy( 2 ) : OUString(); }
61 :
62 0 : bool isGroupSeparator() const { return m_aType.isEmpty(); }
63 : };
64 :
65 : typedef boost::ptr_deque<SvtFileDialogFilter_Impl> SvtFileDialogFilterList_Impl;
66 :
67 : enum SvtFileDlgMode
68 : {
69 : FILEDLG_MODE_OPEN = 0,
70 : FILEDLG_MODE_SAVE = 1
71 : };
72 :
73 : enum SvtFileDlgType
74 : {
75 : FILEDLG_TYPE_FILEDLG = 0,
76 : FILEDLG_TYPE_PATHDLG
77 : };
78 :
79 : class SvtFileDialogURLSelector : public MenuButton
80 : {
81 : public:
82 : virtual ~SvtFileDialogURLSelector();
83 : virtual void dispose() SAL_OVERRIDE;
84 : private:
85 : VclPtr<SvtFileDialog> m_pDlg;
86 : PopupMenu* m_pMenu;
87 :
88 : protected:
89 0 : inline SvtFileDialog* GetDialogParent() { return m_pDlg; }
90 :
91 : virtual void FillURLMenu( PopupMenu* _pMenu ) = 0;
92 :
93 : SvtFileDialogURLSelector( vcl::Window* _pParent, SvtFileDialog* _pDlg, WinBits nBits, sal_uInt16 _nButtonId );
94 :
95 : virtual void Activate() SAL_OVERRIDE;
96 : };
97 :
98 : class SvtUpButton_Impl : public SvtFileDialogURLSelector
99 : {
100 : private:
101 : std::vector<OUString> _aURLs;
102 :
103 : public:
104 : SvtUpButton_Impl( vcl::Window* pParent, SvtFileDialog* pDlg, WinBits nBits );
105 : virtual ~SvtUpButton_Impl();
106 :
107 : protected:
108 : virtual void FillURLMenu( PopupMenu* _pMenu ) SAL_OVERRIDE;
109 : virtual void Select() SAL_OVERRIDE;
110 : virtual void Click() SAL_OVERRIDE;
111 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
112 : };
113 :
114 : typedef sal_uInt8 SvtFileDlgState;
115 :
116 : #define FILEDLG_STATE_NONE ((SvtFileDlgState)0x00)
117 : #define FILEDLG_STATE_REMOTE ((SvtFileDlgState)0x01)
118 :
119 : class SvtURLBox;
120 : class SvtExpFileDlg_Impl
121 : {
122 : private:
123 : DECL_STATIC_LINK( SvtExpFileDlg_Impl, UnClickHdl, Button* );
124 :
125 : private:
126 : const SvtFileDialogFilter_Impl* _pCurFilter;
127 : OUString m_sCurrentFilterDisplayName; // may differ from _pCurFilter->GetName in case it is a cached entry
128 :
129 : ::com::sun::star::uno::Sequence< OUString > _aBlackList;
130 :
131 : public:
132 : SvtFileDialogFilterList_Impl* _pFilter;
133 : SvtFileDialogFilter_Impl* _pUserFilter;
134 :
135 : VclPtr<FixedText> _pFtFileName;
136 : VclPtr<SvtURLBox> _pEdFileName;
137 :
138 : VclPtr<FixedText> _pFtFileVersion;
139 : VclPtr<ListBox> _pLbFileVersion;
140 :
141 : VclPtr<FixedText> _pFtTemplates;
142 : VclPtr<ListBox> _pLbTemplates;
143 :
144 : VclPtr<FixedText> _pFtImageTemplates;
145 : VclPtr<ListBox> _pLbImageTemplates;
146 :
147 : VclPtr<FixedText> _pFtFileType;
148 : VclPtr<ListBox> _pLbFilter;
149 : VclPtr<PushButton> _pBtnFileOpen;
150 : VclPtr<PushButton> _pBtnCancel;
151 : VclPtr<HelpButton> _pBtnHelp;
152 : VclPtr<SvtUpButton_Impl> _pBtnUp;
153 : VclPtr<PushButton> _pBtnNewFolder;
154 : VclPtr<CheckBox> _pCbPassword;
155 : VclPtr<SvtURLBox> _pEdCurrentPath;
156 : VclPtr<CheckBox> _pCbAutoExtension;
157 : VclPtr<CheckBox> _pCbOptions;
158 :
159 : VclPtr<PlacesListBox> _pPlaces;
160 : VclPtr<PushButton> _pBtnConnectToServer;
161 :
162 : SvtFileDlgMode _eMode;
163 : SvtFileDlgType _eDlgType;
164 : SvtFileDlgState _nState;
165 : WinBits _nStyle;
166 :
167 : OUString _aStdDir;
168 :
169 : // delay filter when traveling the filterbox
170 : Timer _aFilterTimer;
171 :
172 : // shows OpenHdl_Imp() if the open was triggered by a double click
173 : bool _bDoubleClick;
174 : bool m_bNeedDelayedFilterExecute;
175 :
176 : // list of the 5 most recently used filters
177 : // Defaultfilter for <All> oder <All ...>
178 : const SvtFileDialogFilter_Impl* _pDefaultFilter;
179 :
180 : // MultiSelection?
181 : bool _bMultiSelection;
182 :
183 : // remember sizes
184 : OUString _aIniKey;
185 :
186 : bool _bFolderHasOpened;
187 :
188 : SvtExpFileDlg_Impl( WinBits nBits );
189 : ~SvtExpFileDlg_Impl();
190 :
191 :
192 0 : inline void SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList ) { _aBlackList = rBlackList; }
193 0 : inline const ::com::sun::star::uno::Sequence< OUString >& GetBlackList() const { return _aBlackList; }
194 : void SetStandardDir( const OUString& _rDir );
195 0 : inline const OUString& GetStandardDir() const { return _aStdDir; }
196 0 : inline void DisableFilterBoxAutoWidth() { _pLbFilter->EnableDDAutoWidth( false ); }
197 :
198 :
199 : // access to the filter listbox only as Control* - we want to maintain the entries/userdata ourself
200 0 : Control* GetFilterListControl() { return _pLbFilter; }
201 : const Control* GetFilterListControl() const { return _pLbFilter; }
202 : inline void SetFilterListSelectHdl( const Link<>& _rHandler );
203 :
204 : // inits the listbox for the filters from the filter list (_pFilter)
205 : void ClearFilterList( );
206 : void InitFilterList( );
207 : inline bool HasFilterListEntry( const OUString& _rFilterName );
208 : inline void SelectFilterListEntry( const OUString& _rFilterName );
209 : inline void SetNoFilterListSelection( );
210 : void InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc );
211 : // _pFilterDesc must already have been added to _pFilter
212 : inline SvtFileDialogFilter_Impl* GetSelectedFilterEntry( OUString& /* [out] */ _rDisplayName ) const;
213 : inline bool IsFilterListTravelSelect() const;
214 :
215 :
216 : // access to the current filter via methods only - need to care for consistency between _pCurFilter and m_sCurrentFilterDisplayName
217 : inline const SvtFileDialogFilter_Impl* GetCurFilter( ) const;
218 : inline const OUString& GetCurFilterDisplayName() const;
219 : void SetCurFilter( SvtFileDialogFilter_Impl* _pFilter, const OUString& _rDisplayName );
220 : inline void SetCurFilter( SvtFileDialogFilter_Impl* _pFilter );
221 : };
222 :
223 0 : inline void SvtExpFileDlg_Impl::SetFilterListSelectHdl( const Link<>& _rHandler )
224 : {
225 0 : _pLbFilter->SetSelectHdl( _rHandler );
226 0 : }
227 :
228 0 : inline bool SvtExpFileDlg_Impl::HasFilterListEntry( const OUString& _rFilterName )
229 : {
230 0 : return ( LISTBOX_ENTRY_NOTFOUND != _pLbFilter->GetEntryPos( _rFilterName ) );
231 : }
232 :
233 0 : inline void SvtExpFileDlg_Impl::SelectFilterListEntry( const OUString& _rFilterName )
234 : {
235 0 : _pLbFilter->SelectEntry( _rFilterName );
236 0 : }
237 :
238 0 : inline void SvtExpFileDlg_Impl::SetNoFilterListSelection( )
239 : {
240 0 : _pLbFilter->SetNoSelection( );
241 0 : }
242 :
243 0 : inline SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetSelectedFilterEntry( OUString& _rDisplayName ) const
244 : {
245 0 : _rDisplayName = _pLbFilter->GetSelectEntry();
246 0 : return static_cast< SvtFileDialogFilter_Impl* >( _pLbFilter->GetSelectEntryData () );
247 : }
248 :
249 0 : inline bool SvtExpFileDlg_Impl::IsFilterListTravelSelect() const
250 : {
251 0 : return _pLbFilter->IsTravelSelect();
252 : }
253 :
254 0 : inline const SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetCurFilter( ) const
255 : {
256 0 : return _pCurFilter;
257 : }
258 :
259 0 : inline const OUString& SvtExpFileDlg_Impl::GetCurFilterDisplayName() const
260 : {
261 0 : return m_sCurrentFilterDisplayName;
262 : }
263 :
264 : inline void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter )
265 : {
266 : SetCurFilter( pFilter, pFilter->GetName() );
267 : }
268 :
269 : #endif // INCLUDED_FPICKER_SOURCE_OFFICE_IODLGIMP_HXX
270 :
271 :
272 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|