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 #include "svtools/svtdllapi.h"
34 #include <com/sun/star/uno/Sequence.h>
35 #include <com/sun/star/ucb/XContent.hpp>
36 #include <vcl/ctrl.hxx>
37 #include <vcl/image.hxx>
38 #include <vcl/fixed.hxx>
39 #ifndef _SV_BUTTON_HXX
40 #include <vcl/button.hxx>
42 #include <vcl/dialog.hxx>
43 #include <rtl/ustring.hxx>
45 // class SvtFileView -----------------------------------------------------
47 #define FILEVIEW_ONLYFOLDER 0x0001
48 #define FILEVIEW_MULTISELECTION 0x0002
50 #define FILEVIEW_SHOW_TITLE 0x0010
51 #define FILEVIEW_SHOW_SIZE 0x0020
52 #define FILEVIEW_SHOW_DATE 0x0040
53 #define FILEVIEW_SHOW_ALL 0x0070
54 #define FILEVIEW_SHOW_NONE 0x00A0
56 class ViewTabListBox_Impl
;
57 class SvtFileView_Impl
;
62 /// the result of an action in the FileView
71 /// describes parameters for doing an action on the FileView asynchronously
72 struct FileViewAsyncAction
74 sal_uInt32 nMinTimeout
; /// minimum time to wait for a result, in milliseconds
75 sal_uInt32 nMaxTimeout
; /// maximum time to wait for a result, in milliseconds, until eTimeout is returned
76 Link aFinishHandler
; /// the handler to be called when the action is finished. Called in every case, no matter of the result
80 nMinTimeout
= nMaxTimeout
= 0;
84 class SVT_DLLPUBLIC SvtFileView
: public Control
87 SvtFileView_Impl
* mpImp
;
90 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> mpBlackList
;
92 SVT_DLLPRIVATE
void OpenFolder( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aContents
);
94 DECL_DLLPRIVATE_LINK( HeaderSelect_Impl
, HeaderBar
* );
95 DECL_DLLPRIVATE_LINK( HeaderEndDrag_Impl
, HeaderBar
* );
98 virtual void GetFocus();
101 SvtFileView( Window
* pParent
, const ResId
& rResId
, sal_Bool bOnlyFolder
, sal_Bool bMultiSelection
);
102 SvtFileView( Window
* pParent
, const ResId
& rResId
, sal_Int8 nFlags
);
105 const String
& GetViewURL() const;
106 String
GetURL( SvLBoxEntry
* pEntry
) const;
107 String
GetCurrentURL() const;
109 sal_Bool
GetParentURL( String
& _rParentURL
) const;
110 sal_Bool
CreateNewFolder( const String
& rNewFolder
);
112 void SetHelpId( sal_uInt32 nHelpId
);
113 sal_uInt32
GetHelpId( ) const;
114 void SetSizePixel( const Size
& rNewSize
);
115 using Window::SetPosSizePixel
;
116 virtual void SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
);
117 void SetSortColumn( sal_Bool bValue
) { bSortColumn
= bValue
; }
118 sal_Bool
GetSortColumn() { return bSortColumn
; }
120 /** initialize the view with the content of a folder given by URL, and aply an immediate filter
123 the URL of the folder whose content is to be read
125 the initial filter to be applied
126 @param pAsyncDescriptor
127 If not <NULL/>, this struct describes the parameters for doing the
128 action asynchronously.
130 FileViewResult
Initialize(
131 const String
& rFolderURL
,
132 const String
& rFilter
,
133 const FileViewAsyncAction
* pAsyncDescriptor
,
134 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& rBlackList
137 FileViewResult
Initialize(
138 const String
& rFolderURL
,
139 const String
& rFilter
,
140 const FileViewAsyncAction
* pAsyncDescriptor
);
141 /** initialze the view with a sequence of contents, which have already been obtained elsewhere
143 This method will never return <member>eStillRunning</member>, since it will fill the
146 sal_Bool
Initialize( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aContents
);
148 /** initializes the view with the content of a folder given by an UCB content
150 sal_Bool
Initialize( const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
,
151 const String
& rFilter
);
153 /** reads the current content of the current folder again, and applies the given filter to it
155 Note 1: The folder is really read a second time. This implies that any new elements (which were
156 not present when you called Initialize the last time) are now displayed.
158 Note 2: This method must not be called when you previously initialized the view from a sequence
159 of strings, or a UNO content object.
162 the filter to be applied
163 @param pAsyncDescriptor
164 If not <NULL/>, this struct describes the parameters for doing the
165 action asynchronously.
167 FileViewResult
ExecuteFilter(
168 const String
& rFilter
,
169 const FileViewAsyncAction
* pAsyncDescriptor
172 /** cancels a running async action (if any)
175 @seealso ExecuteFilter
176 @seealso FileViewAsyncAction
178 void CancelRunningAsyncAction();
180 /** initializes the view with the parent folder of the current folder
183 the URL of the folder which we just navigated to
184 @param pAsyncDescriptor
185 If not <NULL/>, this struct describes the parameters for doing the
186 action asynchronously.
188 FileViewResult
PreviousLevel(
189 const FileViewAsyncAction
* pAsyncDescriptor
192 void SetNoSelection();
195 void SetSelectHdl( const Link
& rHdl
);
196 void SetDoubleClickHdl( const Link
& rHdl
);
197 void SetOpenDoneHdl( const Link
& rHdl
);
199 ULONG
GetSelectionCount() const;
200 SvLBoxEntry
* FirstSelected() const;
201 SvLBoxEntry
* NextSelected( SvLBoxEntry
* pEntry
) const;
202 void EnableAutoResize();
205 void EnableContextMenu( sal_Bool bEnable
);
206 void EnableDelete( sal_Bool bEnable
);
207 void EnableNameReplacing( sal_Bool bEnable
= sal_True
);
208 // translate folder names or display doc-title instead of file name
209 // EnableContextMenu( TRUE )/EnableDelete(TRUE) disable name replacing!
211 // save and load column size and sort order
212 String
GetConfigString() const;
213 void SetConfigString( const String
& rCfgStr
);
215 void SetUrlFilter( const IUrlFilter
* _pFilter
);
216 const IUrlFilter
* GetUrlFilter( ) const;
218 void EndInplaceEditing( bool _bCancel
);
221 virtual void StateChanged( StateChangedType nStateChange
);
224 // struct SvtContentEntry ------------------------------------------------
226 struct SvtContentEntry
231 SvtContentEntry( const UniString
& rURL
, sal_Bool bIsFolder
) :
232 mbIsFolder( bIsFolder
), maURL( rURL
) {}
237 // -----------------------------------------------------------------------
238 // QueryDeleteDlg_Impl
239 // -----------------------------------------------------------------------
241 enum QueryDeleteResult_Impl
249 class SVT_DLLPUBLIC QueryDeleteDlg_Impl
: public ModalDialog
251 FixedText _aEntryLabel
;
253 FixedText _aQueryMsg
;
255 PushButton _aYesButton
;
256 PushButton _aAllButton
;
257 PushButton _aNoButton
;
258 CancelButton _aCancelButton
;
260 QueryDeleteResult_Impl _eResult
;
264 DECL_DLLPRIVATE_STATIC_LINK( QueryDeleteDlg_Impl
, ClickLink
, PushButton
* );
268 QueryDeleteDlg_Impl( Window
* pParent
,
269 const String
& rName
);
271 void EnableAllButton() { _aAllButton
.Enable( sal_True
); }
272 QueryDeleteResult_Impl
GetResult() const { return _eResult
; }
277 #endif // _SVT_FILEVIEW_HXX