1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fileview.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVT_FILEVIEW_HXX
31 #define _SVT_FILEVIEW_HXX
33 #ifndef INCLUDED_SVTDLLAPI_H
34 #include "bf_svtools/svtdllapi.h"
37 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
38 #include <com/sun/star/uno/Sequence.h>
40 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
41 #include <com/sun/star/ucb/XContent.hpp>
45 #include <vcl/ctrl.hxx>
48 #include <vcl/image.hxx>
51 #include <vcl/fixed.hxx>
53 #ifndef _SV_BUTTON_HXX
54 #include <vcl/button.hxx>
56 #ifndef _SV_DIALOG_HXX
57 #include <vcl/dialog.hxx>
63 // class SvtFileView -----------------------------------------------------
65 #define FILEVIEW_ONLYFOLDER 0x0001
66 #define FILEVIEW_MULTISELECTION 0x0002
68 #define FILEVIEW_SHOW_TITLE 0x0010
69 #define FILEVIEW_SHOW_SIZE 0x0020
70 #define FILEVIEW_SHOW_DATE 0x0040
71 #define FILEVIEW_SHOW_ALL 0x0070
73 class ViewTabListBox_Impl
;
74 class SvtFileView_Impl
;
79 /// the result of an action in the FileView
88 /// describes parameters for doing an action on the FileView asynchronously
89 struct FileViewAsyncAction
91 sal_uInt32 nMinTimeout
; /// minimum time to wait for a result, in milliseconds
92 sal_uInt32 nMaxTimeout
; /// maximum time to wait for a result, in milliseconds, until eTimeout is returned
93 Link aFinishHandler
; /// the handler to be called when the action is finished. Called in every case, no matter of the result
97 nMinTimeout
= nMaxTimeout
= 0;
101 class SvtFileView
: public Control
104 SvtFileView_Impl
* mpImp
;
106 void OpenFolder( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aContents
);
108 DECL_LINK( HeaderSelect_Impl
, HeaderBar
* );
109 DECL_LINK( HeaderEndDrag_Impl
, HeaderBar
* );
112 virtual void GetFocus();
115 SvtFileView( Window
* pParent
, const ResId
& rResId
, sal_Bool bOnlyFolder
, sal_Bool bMultiSelection
);
116 SvtFileView( Window
* pParent
, const ResId
& rResId
, sal_Int8 nFlags
);
119 const String
& GetViewURL() const;
120 String
GetURL( SvLBoxEntry
* pEntry
) const;
121 String
GetCurrentURL() const;
123 sal_Bool
GetParentURL( String
& _rParentURL
) const;
124 sal_Bool
CreateNewFolder( const String
& rNewFolder
);
126 void SetHelpId( sal_uInt32 nHelpId
);
127 sal_uInt32
GetHelpId( ) const;
128 void SetSizePixel( const Size
& rNewSize
);
129 using Window::SetPosSizePixel
;
130 virtual void SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
);
132 /** initialize the view with the content of a folder given by URL, and aply an immediate filter
135 the URL of the folder whose content is to be read
137 the initial filter to be applied
138 @param pAsyncDescriptor
139 If not <NULL/>, this struct describes the parameters for doing the
140 action asynchronously.
142 FileViewResult
Initialize(
143 const String
& rFolderURL
,
144 const String
& rFilter
,
145 const FileViewAsyncAction
* pAsyncDescriptor
148 /** initialze the view with a sequence of contents, which have already been obtained elsewhere
150 This method will never return <member>eStillRunning</member>, since it will fill the
153 sal_Bool
Initialize( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aContents
);
155 /** initializes the view with the content of a folder given by an UCB content
157 sal_Bool
Initialize( const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
, const String
& rFilter
);
159 /** reads the current content of the current folder again, and applies the given filter to it
161 Note 1: The folder is really read a second time. This implies that any new elements (which were
162 not present when you called Initialize the last time) are now displayed.
164 Note 2: This method must not be called when you previously initialized the view from a sequence
165 of strings, or a UNO content object.
168 the filter to be applied
169 @param pAsyncDescriptor
170 If not <NULL/>, this struct describes the parameters for doing the
171 action asynchronously.
173 FileViewResult
ExecuteFilter(
174 const String
& rFilter
,
175 const FileViewAsyncAction
* pAsyncDescriptor
178 /** cancels a running async action (if any)
181 @seealso ExecuteFilter
182 @seealso FileViewAsyncAction
184 void CancelRunningAsyncAction();
186 /** initializes the view with the parent folder of the current folder
189 the URL of the folder which we just navigated to
190 @param pAsyncDescriptor
191 If not <NULL/>, this struct describes the parameters for doing the
192 action asynchronously.
194 FileViewResult
PreviousLevel(
195 const FileViewAsyncAction
* pAsyncDescriptor
198 void SetNoSelection();
201 void SetSelectHdl( const Link
& rHdl
);
202 void SetDoubleClickHdl( const Link
& rHdl
);
203 void SetOpenDoneHdl( const Link
& rHdl
);
205 ULONG
GetSelectionCount() const;
206 SvLBoxEntry
* FirstSelected() const;
207 SvLBoxEntry
* NextSelected( SvLBoxEntry
* pEntry
) const;
208 void EnableAutoResize();
211 void EnableContextMenu( sal_Bool bEnable
);
212 void EnableDelete( sal_Bool bEnable
);
213 void EnableNameReplacing( sal_Bool bEnable
= sal_True
);
214 // translate folder names or display doc-title instead of file name
215 // EnableContextMenu( TRUE )/EnableDelete(TRUE) disable name replacing!
217 // save and load column size and sort order
218 String
GetConfigString() const;
219 void SetConfigString( const String
& rCfgStr
);
221 void SetUrlFilter( const IUrlFilter
* _pFilter
);
222 const IUrlFilter
* GetUrlFilter( ) const;
224 void EndInplaceEditing( bool _bCancel
);
227 virtual void StateChanged( StateChangedType nStateChange
);
230 // struct SvtContentEntry ------------------------------------------------
232 struct SvtContentEntry
237 SvtContentEntry( const UniString
& rURL
, sal_Bool bIsFolder
) :
238 mbIsFolder( bIsFolder
), maURL( rURL
) {}
241 // -----------------------------------------------------------------------
242 // QueryDeleteDlg_Impl
243 // -----------------------------------------------------------------------
245 enum QueryDeleteResult_Impl
253 class QueryDeleteDlg_Impl
: public ModalDialog
255 FixedText _aEntryLabel
;
257 FixedText _aQueryMsg
;
259 PushButton _aYesButton
;
260 PushButton _aAllButton
;
261 PushButton _aNoButton
;
262 CancelButton _aCancelButton
;
264 QueryDeleteResult_Impl _eResult
;
268 DECL_DLLPRIVATE_STATIC_LINK( QueryDeleteDlg_Impl
, ClickLink
, PushButton
* );
272 QueryDeleteDlg_Impl( Window
* pParent
,
273 const String
& rName
);
275 void EnableAllButton() { _aAllButton
.Enable( sal_True
); }
276 QueryDeleteResult_Impl
GetResult() const { return _eResult
; }
281 #endif // _SVT_FILEVIEW_HXX