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