xref: /aoo41x/main/cui/source/inc/cuigaldlg.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CUI_GALDLG_HXX_
29 #define _CUI_GALDLG_HXX_
30 
31 #include <vos/thread.hxx>
32 #include <vcl/dialog.hxx>
33 #include <vcl/graph.hxx>
34 #include <vcl/fixed.hxx>
35 #include <vcl/button.hxx>
36 #include <vcl/lstbox.hxx>
37 #include <vcl/menu.hxx>
38 #include <vcl/edit.hxx>
39 #include <vcl/combobox.hxx>
40 #include <svl/slstitm.hxx>
41 #include <svtools/transfer.hxx>
42 #include <svtools/grfmgr.hxx>
43 #include <sfx2/tabdlg.hxx>
44 #include <svx/galctrl.hxx>
45 #include <svx/galmisc.hxx>
46 #include <com/sun/star/media/XPlayer.hpp>
47 #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
48 #include <svtools/dialogclosedlistener.hxx>
49 
50 DECLARE_LIST( StringList, String* )
51 
52 // ------------
53 // - Forwards -
54 // ------------
55 
56 class Gallery;
57 class GalleryTheme;
58 class SearchProgress;
59 class TakeProgress;
60 class TPGalleryThemeProperties;
61 
62 // ---------------
63 // - FilterEntry -
64 // ---------------
65 
66 struct FilterEntry
67 {
68 	String	aFilterName;
69 };
70 
71 // ----------------
72 // - SearchThread -
73 // ----------------
74 
75 class SearchThread : public ::vos::OThread
76 {
77 private:
78 
79 	SearchProgress*				mpProgress;
80 	TPGalleryThemeProperties*	mpBrowser;
81 	INetURLObject				maStartURL;
82 
83 	void						ImplSearch( const INetURLObject& rStartURL,
84                                             const ::std::vector< String >& rFormats,
85                                             sal_Bool bRecursive );
86 
87 	virtual void SAL_CALL		run();
88     virtual void SAL_CALL       onTerminated();
89 
90 public:
91 
92 								SearchThread( SearchProgress* pProgess,
93 											  TPGalleryThemeProperties* pBrowser,
94 											  const INetURLObject& rStartURL );
95     virtual						~SearchThread();
96 };
97 
98 // ------------------
99 // - SearchProgress -
100 // ------------------
101 
102 class SearchProgress : public ModalDialog
103 {
104 private:
105 
106 	FixedText			aFtSearchDir;
107     FixedLine           aFLSearchDir;
108 	FixedText			aFtSearchType;
109     FixedLine           aFLSearchType;
110 	CancelButton		aBtnCancel;
111 	SearchThread		maSearchThread;
112 
113 						DECL_LINK( ClickCancelBtn, void* );
114 	void				Terminate();
115 
116 public:
117 						SearchProgress( Window* pParent, const INetURLObject& rStartURL );
118 						~SearchProgress() {};
119 
120 						DECL_LINK( CleanUpHdl, void* );
121 
122 	virtual short		Execute();
123     virtual void        StartExecuteModal( const Link& rEndDialogHdl );
124 	void 				SetFileType( const String& rType ) { aFtSearchType.SetText( rType ); }
125 	void 				SetDirectory( const INetURLObject& rURL ) { aFtSearchDir.SetText( GetReducedString( rURL, 30 ) ); }
126 };
127 
128 // --------------
129 // - TakeThread -
130 // --------------
131 
132 class TakeThread : public ::vos::OThread
133 {
134 private:
135 
136 	TakeProgress*				mpProgress;
137 	TPGalleryThemeProperties*	mpBrowser;
138 	List&						mrTakenList;
139 
140 	virtual void SAL_CALL		run();
141     virtual void SAL_CALL       onTerminated();
142 
143 public:
144 
145 								TakeThread( TakeProgress* pProgess, TPGalleryThemeProperties* pBrowser, List& rTakenList );
146 	virtual                     ~TakeThread();
147 };
148 
149 // ----------------
150 // - TakeProgress -
151 // ----------------
152 
153 class TakeProgress : public ModalDialog
154 {
155 private:
156 
157 	FixedText			aFtTakeFile;
158     FixedLine           aFLTakeProgress;
159 	CancelButton		aBtnCancel;
160 	TakeThread			maTakeThread;
161 	List				maTakenList;
162 
163 						DECL_LINK( ClickCancelBtn, void* );
164 	void				Terminate();
165 
166 public:
167 
168 						TakeProgress( Window* pWindow );
169 						~TakeProgress() {};
170 
171 						DECL_LINK( CleanUpHdl, void* );
172 
173 	void 				SetFile( const INetURLObject& rURL ) { aFtTakeFile.SetText( GetReducedString( rURL, 30 ) ); }
174 	virtual short		Execute();
175     virtual void        StartExecuteModal( const Link& rEndDialogHdl );
176 };
177 
178 // ---------------------
179 // - ActualizeProgress -
180 // ---------------------
181 
182 class ActualizeProgress : public ModalDialog
183 {
184 private:
185 
186 	FixedText			aFtActualizeFile;
187     FixedLine           aFLActualizeProgress;
188 	CancelButton		aBtnCancel;
189 	Timer*				pTimer;
190 	GalleryTheme*		pTheme;
191 	GalleryProgress		aStatusProgress;
192 
193 						DECL_LINK( ClickCancelBtn, void* );
194 						DECL_LINK( TimeoutHdl, Timer* );
195 						DECL_LINK( ActualizeHdl, INetURLObject* pURL );
196 
197 public:
198 						ActualizeProgress( Window* pWindow, GalleryTheme* pThm );
199 						~ActualizeProgress() {};
200 
201 	virtual short		Execute();
202 };
203 
204 // ---------------
205 // - TitleDialog -
206 // ---------------
207 
208 class TitleDialog : public ModalDialog
209 {
210 private:
211 
212 	OKButton			maOk;
213 	CancelButton		maCancel;
214 	HelpButton			maHelp;
215     FixedLine           maFL;
216 	Edit				maEdit;
217 
218 public:
219 
220 						TitleDialog( Window* pParent, const String& rOldText );
221 	String				GetTitle() const { return maEdit.GetText(); }
222 };
223 
224 // -------------------
225 // - GalleryIdDialog -
226 // -------------------
227 
228 class GalleryIdDialog : public ModalDialog
229 {
230 private:
231 
232 	OKButton		aBtnOk;
233 	CancelButton	aBtnCancel;
234     FixedLine       aFLId;
235 	ListBox			aLbResName;
236 	GalleryTheme*	pThm;
237 
238 					DECL_LINK( ClickOkHdl, void* );
239 					DECL_LINK( ClickResNameHdl, void* );
240 
241 public:
242 
243 					GalleryIdDialog( Window* pParent, GalleryTheme* pThm );
244 					~GalleryIdDialog() {}
245 
246 	sal_uLong			GetId() const { return aLbResName.GetSelectEntryPos(); }
247 };
248 
249 // --------------------------
250 // - GalleryThemeProperties -
251 // --------------------------
252 
253 class GalleryThemeProperties : public SfxTabDialog
254 {
255 	ExchangeData*	pData;
256 
257 	virtual void	PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
258 
259 public:
260 
261 					GalleryThemeProperties( Window* pParent, ExchangeData* pData, SfxItemSet* pItemSet  );
262 					~GalleryThemeProperties() {}
263 };
264 
265 // -------------------------
266 // - TPGalleryThemeGeneral -
267 // -------------------------
268 
269 class TPGalleryThemeGeneral : public SfxTabPage
270 {
271 private:
272 
273 	FixedImage			aFiMSImage;
274 	Edit				aEdtMSName;
275 	FixedLine			aFlMSGeneralFirst;
276 	FixedText			aFtMSType;
277 	FixedText			aFtMSShowType;
278 	FixedText			aFtMSPath;
279 	FixedText			aFtMSShowPath;
280 	FixedText			aFtMSContent;
281 	FixedText			aFtMSShowContent;
282 	FixedLine			aFlMSGeneralSecond;
283 	FixedText			aFtMSChangeDate;
284 	FixedText			aFtMSShowChangeDate;
285 	ExchangeData*		pData;
286 
287 	virtual void		Reset( const SfxItemSet& ) {}
288 	virtual sal_Bool        FillItemSet( SfxItemSet& rSet );
289 
290 
291 public:
292 
293 						TPGalleryThemeGeneral( Window* pParent, const SfxItemSet& rSet );
294 						~TPGalleryThemeGeneral() {}
295 
296 	void				SetXChgData( ExchangeData* pData );
297 	const ExchangeData*	GetXChgData() const { return pData; }
298 
299 	static SfxTabPage*	Create( Window* pParent, const SfxItemSet& rSet );
300 };
301 
302 // ----------------------------
303 // - TPGalleryThemeProperties -
304 // ----------------------------
305 
306 class TPGalleryThemeProperties : public SfxTabPage
307 {
308 	friend class SearchThread;
309 	friend class TakeProgress;
310 	friend class TakeThread;
311 
312 	FixedText			aFtFileType;
313 	ComboBox			aCbbFileType;
314     MultiListBox		aLbxFound;
315 	PushButton			aBtnSearch;
316 	PushButton			aBtnTake;
317 	PushButton			aBtnTakeAll;
318 	CheckBox			aCbxPreview;
319 	GalleryPreview		aWndPreview;
320 
321 	ExchangeData*		pData;
322 	StringList			aFoundList;
323 	List				aFilterEntryList;
324 	Timer				aPreviewTimer;
325 	String				aLastFilterName;
326 	String				aPreviewString;
327 	INetURLObject		aURL;
328 	sal_uInt16				nCurFilterPos;
329 	sal_uInt16				nFirstExtFilterPos;
330 	sal_Bool				bEntriesFound;
331 	sal_Bool				bInputAllowed;
332 	sal_Bool				bTakeAll;
333 	sal_Bool				bSearchRecursive;
334 
335     ::com::sun::star::uno::Reference< ::svt::DialogClosedListener >                  xDialogListener;
336     ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer >             xMediaPlayer;
337     ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFolderPicker > xFolderPicker;
338 
339     virtual void        Reset( const SfxItemSet& /*rSet*/ ) {}
340     virtual sal_Bool        FillItemSet( SfxItemSet& /*rSet*/ ) { return sal_True; }
341 	::rtl::OUString 	addExtension( const ::rtl::OUString&, const ::rtl::OUString& );
342 	void				FillFilterList();
343 
344 	void				SearchFiles();
345 	void 				TakeFiles();
346 	void				DoPreview();
347 
348 						DECL_LINK( ClickPreviewHdl, void* );
349 						DECL_LINK( ClickCloseBrowserHdl, void* );
350 						DECL_LINK( ClickSearchHdl, void* );
351 						DECL_LINK( ClickTakeHdl, void* );
352 						DECL_LINK( ClickTakeAllHdl, void* );
353 						DECL_LINK( SelectFoundHdl, void* );
354 						DECL_LINK( SelectThemeHdl, void* );
355 						DECL_LINK( SelectFileTypeHdl, void* );
356 						DECL_LINK( DClickFoundHdl, void* );
357 						DECL_LINK( PreviewTimerHdl, void* );
358                         DECL_LINK( EndSearchProgressHdl, SearchProgress* );
359                         DECL_LINK( DialogClosedHdl, ::com::sun::star::ui::dialogs::DialogClosedEvent* );
360 
361 public:
362 						TPGalleryThemeProperties( Window* pWindow, const SfxItemSet& rSet );
363 						~TPGalleryThemeProperties();
364 
365 	void				SetXChgData( ExchangeData* pData );
366 	const ExchangeData*	GetXChgData() const { return pData; }
367 
368     void                StartSearchFiles( const String& _rFolderURL, short _nDlgResult );
369 
370 	static SfxTabPage*	Create( Window* pParent, const SfxItemSet& rSet );
371 };
372 
373 #endif // _CUI_GALDLG_HXX_
374