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