xref: /aoo42x/main/svtools/inc/svtools/fileview.hxx (revision 01aa44aa)
1*01aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*01aa44aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*01aa44aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*01aa44aaSAndrew Rist  * distributed with this work for additional information
6*01aa44aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*01aa44aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*01aa44aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*01aa44aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*01aa44aaSAndrew Rist  *
11*01aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*01aa44aaSAndrew Rist  *
13*01aa44aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*01aa44aaSAndrew Rist  * software distributed under the License is distributed on an
15*01aa44aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*01aa44aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*01aa44aaSAndrew Rist  * specific language governing permissions and limitations
18*01aa44aaSAndrew Rist  * under the License.
19*01aa44aaSAndrew Rist  *
20*01aa44aaSAndrew Rist  *************************************************************/
21*01aa44aaSAndrew Rist 
22*01aa44aaSAndrew Rist 
23cdf0e10cSrcweir #ifndef _SVT_FILEVIEW_HXX
24cdf0e10cSrcweir #define	_SVT_FILEVIEW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "svtools/svtdllapi.h"
27cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
28cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp>
29cdf0e10cSrcweir #include <vcl/ctrl.hxx>
30cdf0e10cSrcweir #include <vcl/image.hxx>
31cdf0e10cSrcweir #include <vcl/fixed.hxx>
32cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
33cdf0e10cSrcweir #include <vcl/button.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <vcl/dialog.hxx>
36cdf0e10cSrcweir #include <rtl/ustring.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // class SvtFileView -----------------------------------------------------
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define FILEVIEW_ONLYFOLDER			0x0001
41cdf0e10cSrcweir #define FILEVIEW_MULTISELECTION		0x0002
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define FILEVIEW_SHOW_TITLE			0x0010
44cdf0e10cSrcweir #define FILEVIEW_SHOW_SIZE			0x0020
45cdf0e10cSrcweir #define FILEVIEW_SHOW_DATE			0x0040
46cdf0e10cSrcweir #define FILEVIEW_SHOW_ALL			0x0070
47cdf0e10cSrcweir 
48cdf0e10cSrcweir class ViewTabListBox_Impl;
49cdf0e10cSrcweir class SvtFileView_Impl;
50cdf0e10cSrcweir class SvLBoxEntry;
51cdf0e10cSrcweir class HeaderBar;
52cdf0e10cSrcweir class IUrlFilter;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /// the result of an action in the FileView
55cdf0e10cSrcweir enum FileViewResult
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     eSuccess,
58cdf0e10cSrcweir     eFailure,
59cdf0e10cSrcweir     eTimeout,
60cdf0e10cSrcweir     eStillRunning
61cdf0e10cSrcweir };
62cdf0e10cSrcweir 
63cdf0e10cSrcweir /// describes parameters for doing an action on the FileView asynchronously
64cdf0e10cSrcweir struct FileViewAsyncAction
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     sal_uInt32  nMinTimeout;    /// minimum time to wait for a result, in milliseconds
67cdf0e10cSrcweir     sal_uInt32  nMaxTimeout;    /// maximum time to wait for a result, in milliseconds, until eTimeout is returned
68cdf0e10cSrcweir     Link        aFinishHandler; /// the handler to be called when the action is finished. Called in every case, no matter of the result
69cdf0e10cSrcweir 
FileViewAsyncActionFileViewAsyncAction70cdf0e10cSrcweir     FileViewAsyncAction()
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir         nMinTimeout = nMaxTimeout = 0;
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir class SVT_DLLPUBLIC SvtFileView : public Control
77cdf0e10cSrcweir {
78cdf0e10cSrcweir private:
79cdf0e10cSrcweir     SvtFileView_Impl*       mpImp;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::rtl::OUString > mpBlackList;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	SVT_DLLPRIVATE void					OpenFolder( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aContents );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	DECL_DLLPRIVATE_LINK( 				HeaderSelect_Impl, HeaderBar * );
86cdf0e10cSrcweir 	DECL_DLLPRIVATE_LINK( 				HeaderEndDrag_Impl, HeaderBar * );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir protected:
89cdf0e10cSrcweir 	virtual void GetFocus();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir public:
92cdf0e10cSrcweir 	SvtFileView( Window* pParent, const ResId& rResId, sal_Bool bOnlyFolder, sal_Bool bMultiSelection );
93cdf0e10cSrcweir 	SvtFileView( Window* pParent, const ResId& rResId, sal_Int8 nFlags );
94cdf0e10cSrcweir 	~SvtFileView();
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     const String&           GetViewURL() const;
97cdf0e10cSrcweir 	String					GetURL( SvLBoxEntry* pEntry ) const;
98cdf0e10cSrcweir 	String					GetCurrentURL() const;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     sal_Bool				GetParentURL( String& _rParentURL ) const;
101cdf0e10cSrcweir 	sal_Bool				CreateNewFolder( const String& rNewFolder );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	void					SetHelpId( const rtl::OString& rHelpId );
104cdf0e10cSrcweir 	const rtl::OString&		GetHelpId( ) const;
105cdf0e10cSrcweir 	void					SetSizePixel( const Size& rNewSize );
106cdf0e10cSrcweir     using Window::SetPosSizePixel;
107cdf0e10cSrcweir 	virtual void			SetPosSizePixel( const Point& rNewPos, const Size& rNewSize );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /** initialize the view with the content of a folder given by URL, and aply an immediate filter
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         @param rFolderURL
112cdf0e10cSrcweir             the URL of the folder whose content is to be read
113cdf0e10cSrcweir         @param rFilter
114cdf0e10cSrcweir             the initial filter to be applied
115cdf0e10cSrcweir         @param pAsyncDescriptor
116cdf0e10cSrcweir             If not <NULL/>, this struct describes the parameters for doing the
117cdf0e10cSrcweir             action asynchronously.
118cdf0e10cSrcweir     */
119cdf0e10cSrcweir 	FileViewResult          Initialize(
120cdf0e10cSrcweir                                 const String& rFolderURL,
121cdf0e10cSrcweir                                 const String& rFilter,
122cdf0e10cSrcweir                                 const FileViewAsyncAction* pAsyncDescriptor,
123cdf0e10cSrcweir 								const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList
124cdf0e10cSrcweir                             );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	FileViewResult          Initialize(
127cdf0e10cSrcweir                                 const String& rFolderURL,
128cdf0e10cSrcweir                                 const String& rFilter,
129cdf0e10cSrcweir                                 const FileViewAsyncAction* pAsyncDescriptor );
130cdf0e10cSrcweir     /** initialze the view with a sequence of contents, which have already been obtained elsewhere
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         This method will never return <member>eStillRunning</member>, since it will fill the
133cdf0e10cSrcweir         view synchronously
134cdf0e10cSrcweir     */
135cdf0e10cSrcweir     sal_Bool                Initialize( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aContents );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     /** initializes the view with the content of a folder given by an UCB content
138cdf0e10cSrcweir     */
139cdf0e10cSrcweir     sal_Bool				Initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent,
140cdf0e10cSrcweir 										const String& rFilter );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     /** reads the current content of the current folder again, and applies the given filter to it
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         Note 1: The folder is really read a second time. This implies that any new elements (which were
145cdf0e10cSrcweir         not present when you called Initialize the last time) are now displayed.
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         Note 2: This method must not be called when you previously initialized the view from a sequence
148cdf0e10cSrcweir         of strings, or a UNO content object.
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         @param rFilter
151cdf0e10cSrcweir             the filter to be applied
152cdf0e10cSrcweir         @param pAsyncDescriptor
153cdf0e10cSrcweir             If not <NULL/>, this struct describes the parameters for doing the
154cdf0e10cSrcweir             action asynchronously.
155cdf0e10cSrcweir     */
156cdf0e10cSrcweir 	FileViewResult          ExecuteFilter(
157cdf0e10cSrcweir                                 const String& rFilter,
158cdf0e10cSrcweir                                 const FileViewAsyncAction* pAsyncDescriptor
159cdf0e10cSrcweir                             );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     /** cancels a running async action (if any)
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         @seealso Initialize
164cdf0e10cSrcweir         @seealso ExecuteFilter
165cdf0e10cSrcweir         @seealso FileViewAsyncAction
166cdf0e10cSrcweir     */
167cdf0e10cSrcweir     void                    CancelRunningAsyncAction();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     /** initializes the view with the parent folder of the current folder
170cdf0e10cSrcweir 
171cdf0e10cSrcweir         @param rNewURL
172cdf0e10cSrcweir             the URL of the folder which we just navigated to
173cdf0e10cSrcweir         @param pAsyncDescriptor
174cdf0e10cSrcweir             If not <NULL/>, this struct describes the parameters for doing the
175cdf0e10cSrcweir             action asynchronously.
176cdf0e10cSrcweir     */
177cdf0e10cSrcweir 	FileViewResult          PreviousLevel(
178cdf0e10cSrcweir                                 const FileViewAsyncAction* pAsyncDescriptor
179cdf0e10cSrcweir                             );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     void					SetNoSelection();
182cdf0e10cSrcweir 	void					ResetCursor();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	void					SetSelectHdl( const Link& rHdl );
185cdf0e10cSrcweir 	void					SetDoubleClickHdl( const Link& rHdl );
186cdf0e10cSrcweir     void                    SetOpenDoneHdl( const Link& rHdl );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	sal_uLong           		GetSelectionCount() const;
189cdf0e10cSrcweir 	SvLBoxEntry*			FirstSelected() const;
190cdf0e10cSrcweir 	SvLBoxEntry*			NextSelected( SvLBoxEntry* pEntry ) const;
191cdf0e10cSrcweir 	void					EnableAutoResize();
192cdf0e10cSrcweir 	void					SetFocus();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     void                    EnableContextMenu( sal_Bool bEnable );
195cdf0e10cSrcweir     void                    EnableDelete( sal_Bool bEnable );
196cdf0e10cSrcweir 	void					EnableNameReplacing( sal_Bool bEnable = sal_True );
197cdf0e10cSrcweir 								// translate folder names or display doc-title instead of file name
198cdf0e10cSrcweir 								// EnableContextMenu( sal_True )/EnableDelete(sal_True) disable name replacing!
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 							// save and load column size and sort order
201cdf0e10cSrcweir 	String                  GetConfigString() const;
202cdf0e10cSrcweir 	void					SetConfigString( const String& rCfgStr );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     void                    SetUrlFilter( const IUrlFilter* _pFilter );
205cdf0e10cSrcweir     const IUrlFilter*       GetUrlFilter( ) const;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     void                    EndInplaceEditing( bool _bCancel );
208cdf0e10cSrcweir 
209cdf0e10cSrcweir protected:
210cdf0e10cSrcweir     virtual void            StateChanged( StateChangedType nStateChange );
211cdf0e10cSrcweir };
212cdf0e10cSrcweir 
213cdf0e10cSrcweir // struct SvtContentEntry ------------------------------------------------
214cdf0e10cSrcweir 
215cdf0e10cSrcweir struct SvtContentEntry
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	sal_Bool	mbIsFolder;
218cdf0e10cSrcweir 	UniString	maURL;
219cdf0e10cSrcweir 
SvtContentEntrySvtContentEntry220cdf0e10cSrcweir 	SvtContentEntry( const UniString& rURL, sal_Bool bIsFolder ) :
221cdf0e10cSrcweir 		mbIsFolder( bIsFolder ), maURL( rURL ) {}
222cdf0e10cSrcweir };
223cdf0e10cSrcweir 
224cdf0e10cSrcweir namespace svtools {
225cdf0e10cSrcweir 
226cdf0e10cSrcweir // -----------------------------------------------------------------------
227cdf0e10cSrcweir // QueryDeleteDlg_Impl
228cdf0e10cSrcweir // -----------------------------------------------------------------------
229cdf0e10cSrcweir 
230cdf0e10cSrcweir enum QueryDeleteResult_Impl
231cdf0e10cSrcweir {
232cdf0e10cSrcweir 	QUERYDELETE_YES = 0,
233cdf0e10cSrcweir 	QUERYDELETE_NO,
234cdf0e10cSrcweir 	QUERYDELETE_ALL,
235cdf0e10cSrcweir 	QUERYDELETE_CANCEL
236cdf0e10cSrcweir };
237cdf0e10cSrcweir 
238cdf0e10cSrcweir class SVT_DLLPUBLIC QueryDeleteDlg_Impl : public ModalDialog
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	FixedText               _aEntryLabel;
241cdf0e10cSrcweir 	FixedText               _aEntry;
242cdf0e10cSrcweir 	FixedText               _aQueryMsg;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	PushButton              _aYesButton;
245cdf0e10cSrcweir 	PushButton              _aAllButton;
246cdf0e10cSrcweir 	PushButton              _aNoButton;
247cdf0e10cSrcweir 	CancelButton            _aCancelButton;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     QueryDeleteResult_Impl  _eResult;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir private:
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	DECL_DLLPRIVATE_STATIC_LINK( QueryDeleteDlg_Impl, ClickLink, PushButton* );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir public:
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 							QueryDeleteDlg_Impl( Window* pParent,
258cdf0e10cSrcweir 												 const String& rName );
259cdf0e10cSrcweir 
EnableAllButton()260cdf0e10cSrcweir     void                    EnableAllButton() { _aAllButton.Enable( sal_True ); }
GetResult() const261cdf0e10cSrcweir     QueryDeleteResult_Impl  GetResult() const { return _eResult; }
262cdf0e10cSrcweir };
263cdf0e10cSrcweir 
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir #endif // _SVT_FILEVIEW_HXX
267cdf0e10cSrcweir 
268