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 .
21 #include "PlacesListBox.hxx"
23 #include <vcl/idle.hxx>
32 #define FILEDIALOG_DEF_EXTSEP ';'
33 #define FILEDIALOG_DEF_WILDCARD '*'
36 // SvtFileDialogFilter_Impl
41 Instances of this class represent a filter.
44 class SvtFileDialogFilter_Impl
47 OUString m_aName
; // name of the entry
48 OUString m_aType
; // filter wildcard - if empty, the entry marks a group
51 SvtFileDialogFilter_Impl( OUString aName
, OUString aType
);
52 ~SvtFileDialogFilter_Impl();
54 const OUString
& GetName() const { return m_aName
; }
55 const OUString
& GetType() const { return m_aType
; }
56 OUString
GetExtension() const { return m_aType
.getLength() > 2 ? m_aType
.copy( 2 ) : OUString(); }
58 bool isGroupSeparator() const { return m_aType
.isEmpty(); }
61 typedef std::deque
<std::unique_ptr
<SvtFileDialogFilter_Impl
>> SvtFileDialogFilterList_Impl
;
65 FILEDLG_MODE_OPEN
= 0,
71 FILEDLG_TYPE_FILEDLG
= 0,
75 class SvtUpButton_Impl
78 std::unique_ptr
<weld::Toolbar
> m_xToolbar
;
79 std::unique_ptr
<weld::Menu
> m_xMenu
;
80 SvtFileDialog
* m_pDlg
;
82 std::vector
<OUString
> aURLs
;
85 SvtUpButton_Impl(std::unique_ptr
<weld::Toolbar
> xToolbar
,
86 std::unique_ptr
<weld::Menu
> xMenu
,
89 void set_help_id(const OUString
& rHelpId
) { m_xToolbar
->set_help_id(rHelpId
); }
90 void show() { m_xToolbar
->show(); }
94 weld::Widget
* getWidget() { return m_xToolbar
.get(); }
98 DECL_LINK(SelectHdl
, const OUString
&, void);
99 DECL_LINK(ClickHdl
, const OUString
&, void);
103 class SvtExpFileDlg_Impl
106 const SvtFileDialogFilter_Impl
* m_pCurFilter
;
107 OUString m_sCurrentFilterDisplayName
; // may differ from m_pCurFilter->GetName in case it is a cached entry
109 css::uno::Sequence
< OUString
> m_aDenyList
;
112 SvtFileDialogFilterList_Impl m_aFilter
;
113 std::unique_ptr
<SvtFileDialogFilter_Impl
> m_xUserFilter
;
115 std::unique_ptr
<weld::Label
> m_xFtFileName
;
116 std::unique_ptr
<SvtURLBox
> m_xEdFileName
;
118 std::unique_ptr
<weld::Label
> m_xSharedLabel
;
119 std::unique_ptr
<weld::ComboBox
> m_xSharedListBox
;
121 std::unique_ptr
<weld::Label
> m_xFtFileType
;
122 std::unique_ptr
<weld::ComboBox
> m_xLbFilter
;
123 std::unique_ptr
<weld::Button
> m_xBtnFileOpen
;
124 std::unique_ptr
<weld::Button
> m_xBtnCancel
;
125 std::unique_ptr
<weld::Button
> m_xBtnHelp
;
126 std::unique_ptr
<SvtUpButton_Impl
> m_xBtnUp
;
127 std::unique_ptr
<weld::Button
> m_xBtnNewFolder
;
128 std::unique_ptr
<weld::CheckButton
> m_xCbPassword
;
129 std::unique_ptr
<weld::CheckButton
> m_xCbGPGEncrypt
;
130 std::unique_ptr
<SvtURLBox
> m_xEdCurrentPath
;
131 std::unique_ptr
<weld::CheckButton
> m_xCbAutoExtension
;
132 std::unique_ptr
<weld::CheckButton
> m_xCbOptions
;
134 std::unique_ptr
<PlacesListBox
> m_xPlaces
;
135 std::unique_ptr
<weld::Button
> m_xBtnConnectToServer
;
137 SvtFileDlgMode m_eMode
;
138 SvtFileDlgType m_eDlgType
;
139 PickerFlags m_nStyle
;
143 // delay filter when traveling the filterbox
146 // shows OpenHdl_Imp() if the open was triggered by a double click
150 bool m_bMultiSelection
;
155 explicit SvtExpFileDlg_Impl();
156 ~SvtExpFileDlg_Impl();
158 void SetDenyList( const css::uno::Sequence
< OUString
>& rDenyList
) { m_aDenyList
= rDenyList
; }
159 const css::uno::Sequence
< OUString
>& GetDenyList() const { return m_aDenyList
; }
160 void SetStandardDir( const OUString
& rDir
);
161 const OUString
& GetStandardDir() const { return m_aStdDir
; }
163 // access to the filter listbox only as weld::Widget* - we want to maintain the entries/userdata ourself
164 weld::Widget
* GetFilterListControl() { return m_xLbFilter
.get(); }
165 const weld::Widget
* GetFilterListControl() const { return m_xLbFilter
.get(); }
166 void SetFilterListSelectHdl(const Link
<weld::ComboBox
&, void>& rHandler
)
168 m_xLbFilter
->connect_changed(rHandler
);
171 // inits the listbox for the filters from the filter list (_pFilter)
172 void InitFilterList( );
173 bool HasFilterListEntry( const OUString
& rFilterName
)
175 return m_xLbFilter
->find_text(rFilterName
) != -1;
178 void SelectFilterListEntry( const OUString
& rFilterName
)
180 m_xLbFilter
->set_active_text(rFilterName
);
183 void InsertFilterListEntry( const SvtFileDialogFilter_Impl
* _pFilterDesc
);
184 // _pFilterDesc must already have been added to _pFilter
185 SvtFileDialogFilter_Impl
* GetSelectedFilterEntry( OUString
& rDisplayName
) const
187 rDisplayName
= m_xLbFilter
->get_active_text();
188 return weld::fromId
<SvtFileDialogFilter_Impl
*>(m_xLbFilter
->get_active_id());
191 // access to the current filter via methods only - need to care for consistency between m_pCurFilter and m_sCurrentFilterDisplayName
192 const SvtFileDialogFilter_Impl
* GetCurFilter( ) const
197 const OUString
& GetCurFilterDisplayName() const
199 return m_sCurrentFilterDisplayName
;
202 void SetCurFilter( SvtFileDialogFilter_Impl
const * _pFilter
, const OUString
& rDisplayName
);
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */