Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_CUI_SOURCE_INC_CUIGALDLG_HXX
21 : #define INCLUDED_CUI_SOURCE_INC_CUIGALDLG_HXX
22 :
23 : #include "sal/config.h"
24 :
25 : #include <salhelper/thread.hxx>
26 : #include <vcl/dialog.hxx>
27 : #include <vcl/graph.hxx>
28 : #include <vcl/fixed.hxx>
29 : #include <vcl/button.hxx>
30 : #include <vcl/lstbox.hxx>
31 : #include <vcl/menu.hxx>
32 : #include <vcl/edit.hxx>
33 : #include <vcl/combobox.hxx>
34 : #include <svl/slstitm.hxx>
35 : #include <svtools/transfer.hxx>
36 : #include <svtools/grfmgr.hxx>
37 : #include <sfx2/tabdlg.hxx>
38 : #include <svx/galctrl.hxx>
39 : #include <svx/galmisc.hxx>
40 : #include <com/sun/star/media/XPlayer.hpp>
41 : #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
42 : #include <svtools/dialogclosedlistener.hxx>
43 : #include <vector>
44 :
45 : class GalleryTheme;
46 : class SearchProgress;
47 : class TakeProgress;
48 : class TPGalleryThemeProperties;
49 :
50 : typedef ::std::vector< OUString > StringList;
51 : typedef ::std::vector< sal_uLong > TokenList_impl;
52 :
53 0 : struct FilterEntry
54 : {
55 : OUString aFilterName;
56 : };
57 :
58 : class SearchThread: public salhelper::Thread
59 : {
60 : private:
61 :
62 : SearchProgress* mpProgress;
63 : TPGalleryThemeProperties* mpBrowser;
64 : INetURLObject maStartURL;
65 :
66 : void ImplSearch( const INetURLObject& rStartURL,
67 : const ::std::vector< OUString >& rFormats,
68 : bool bRecursive );
69 :
70 : virtual ~SearchThread();
71 : virtual void execute() SAL_OVERRIDE;
72 :
73 : public:
74 :
75 : SearchThread( SearchProgress* pProgess,
76 : TPGalleryThemeProperties* pBrowser,
77 : const INetURLObject& rStartURL );
78 : };
79 :
80 : class SearchProgress : public ModalDialog
81 : {
82 : private:
83 : FixedText* m_pFtSearchDir;
84 : FixedText* m_pFtSearchType;
85 : CancelButton* m_pBtnCancel;
86 : vcl::Window * parent_;
87 : INetURLObject startUrl_;
88 : rtl::Reference< SearchThread > maSearchThread;
89 :
90 : DECL_LINK( ClickCancelBtn, void* );
91 : void Terminate();
92 :
93 : public:
94 : SearchProgress( vcl::Window* pParent, const INetURLObject& rStartURL );
95 0 : virtual ~SearchProgress() {};
96 :
97 : DECL_LINK( CleanUpHdl, void* );
98 :
99 : virtual short Execute() SAL_OVERRIDE;
100 : virtual void StartExecuteModal( const Link& rEndDialogHdl ) SAL_OVERRIDE;
101 0 : void SetFileType( const OUString& rType ) { m_pFtSearchType->SetText( rType ); }
102 0 : void SetDirectory( const INetURLObject& rURL ) { m_pFtSearchDir->SetText( GetReducedString( rURL, 30 ) ); }
103 : };
104 :
105 : class TakeThread: public salhelper::Thread
106 : {
107 : private:
108 :
109 : TakeProgress* mpProgress;
110 : TPGalleryThemeProperties* mpBrowser;
111 : TokenList_impl& mrTakenList;
112 :
113 : virtual ~TakeThread();
114 : virtual void execute() SAL_OVERRIDE;
115 :
116 : public:
117 :
118 : TakeThread(
119 : TakeProgress* pProgess,
120 : TPGalleryThemeProperties* pBrowser,
121 : TokenList_impl& rTakenList
122 : );
123 : };
124 :
125 0 : class TakeProgress : public ModalDialog
126 : {
127 : private:
128 : FixedText* m_pFtTakeFile;
129 : CancelButton* m_pBtnCancel;
130 : vcl::Window * window_;
131 : rtl::Reference< TakeThread > maTakeThread;
132 : TokenList_impl maTakenList;
133 :
134 : DECL_LINK( ClickCancelBtn, void* );
135 : void Terminate();
136 :
137 : public:
138 :
139 : TakeProgress( vcl::Window* pWindow );
140 :
141 : DECL_LINK( CleanUpHdl, void* );
142 :
143 0 : void SetFile( const INetURLObject& rURL ) { m_pFtTakeFile->SetText( GetReducedString( rURL, 30 ) ); }
144 : virtual short Execute() SAL_OVERRIDE;
145 : virtual void StartExecuteModal( const Link& rEndDialogHdl ) SAL_OVERRIDE;
146 : };
147 :
148 : class ActualizeProgress : public ModalDialog
149 : {
150 : private:
151 : FixedText* m_pFtActualizeFile;
152 : CancelButton* m_pBtnCancel;
153 : Timer* pTimer;
154 : GalleryTheme* pTheme;
155 : GalleryProgress aStatusProgress;
156 :
157 : DECL_LINK( ClickCancelBtn, void* );
158 : DECL_LINK( TimeoutHdl, Timer* );
159 : DECL_LINK( ActualizeHdl, INetURLObject* pURL );
160 :
161 : public:
162 : ActualizeProgress( vcl::Window* pWindow, GalleryTheme* pThm );
163 0 : virtual ~ActualizeProgress() {};
164 :
165 : virtual short Execute() SAL_OVERRIDE;
166 : };
167 :
168 0 : class TitleDialog : public ModalDialog
169 : {
170 : private:
171 : Edit* m_pEdit;
172 : public:
173 : TitleDialog(vcl::Window* pParent, const OUString& rOldText);
174 0 : OUString GetTitle() const { return m_pEdit->GetText(); }
175 : };
176 :
177 0 : class GalleryIdDialog : public ModalDialog
178 : {
179 : private:
180 : OKButton* m_pBtnOk;
181 : ListBox* m_pLbResName;
182 : GalleryTheme* pThm;
183 :
184 : DECL_LINK( ClickOkHdl, void* );
185 : DECL_LINK( ClickResNameHdl, void* );
186 : public:
187 : GalleryIdDialog( vcl::Window* pParent, GalleryTheme* pThm );
188 0 : sal_uLong GetId() const { return m_pLbResName->GetSelectEntryPos(); }
189 : };
190 :
191 0 : class GalleryThemeProperties : public SfxTabDialog
192 : {
193 : ExchangeData* pData;
194 :
195 : sal_uInt16 m_nGeneralPageId;
196 : sal_uInt16 m_nFilesPageId;
197 :
198 : virtual void PageCreated(sal_uInt16 nId, SfxTabPage &rPage) SAL_OVERRIDE;
199 :
200 : public:
201 : GalleryThemeProperties(vcl::Window* pParent, ExchangeData* pData, SfxItemSet* pItemSet);
202 : };
203 :
204 : class TPGalleryThemeGeneral : public SfxTabPage
205 : {
206 : private:
207 :
208 : FixedImage* m_pFiMSImage;
209 : Edit* m_pEdtMSName;
210 : FixedText* m_pFtMSShowType;
211 : FixedText* m_pFtMSShowPath;
212 : FixedText* m_pFtMSShowContent;
213 : FixedText* m_pFtMSShowChangeDate;
214 : ExchangeData* pData;
215 :
216 0 : virtual void Reset( const SfxItemSet* ) SAL_OVERRIDE {}
217 : virtual bool FillItemSet( SfxItemSet* rSet ) SAL_OVERRIDE;
218 :
219 :
220 : public:
221 :
222 : TPGalleryThemeGeneral( vcl::Window* pParent, const SfxItemSet& rSet );
223 0 : virtual ~TPGalleryThemeGeneral() {}
224 :
225 : void SetXChgData( ExchangeData* pData );
226 : const ExchangeData* GetXChgData() const { return pData; }
227 :
228 : static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rSet );
229 : };
230 :
231 : typedef ::std::vector< FilterEntry* > FilterEntryList_impl;
232 :
233 : class TPGalleryThemeProperties : public SfxTabPage
234 : {
235 : friend class SearchThread;
236 : friend class TakeProgress;
237 : friend class TakeThread;
238 :
239 : ComboBox* m_pCbbFileType;
240 : ListBox* m_pLbxFound;
241 : PushButton* m_pBtnSearch;
242 : PushButton* m_pBtnTake;
243 : PushButton* m_pBtnTakeAll;
244 : CheckBox* m_pCbxPreview;
245 : GalleryPreview* m_pWndPreview;
246 :
247 : ExchangeData* pData;
248 : StringList aFoundList;
249 : FilterEntryList_impl aFilterEntryList;
250 : Timer aPreviewTimer;
251 : OUString aLastFilterName;
252 : OUString aPreviewString;
253 : INetURLObject aURL;
254 : sal_uInt16 nCurFilterPos;
255 : sal_uInt16 nFirstExtFilterPos;
256 : bool bEntriesFound;
257 : bool bInputAllowed;
258 : bool bTakeAll;
259 : bool bSearchRecursive;
260 :
261 : ::com::sun::star::uno::Reference< ::svt::DialogClosedListener > xDialogListener;
262 : ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > xMediaPlayer;
263 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFolderPicker2 > xFolderPicker;
264 :
265 0 : virtual void Reset( const SfxItemSet* /*rSet*/ ) SAL_OVERRIDE {}
266 0 : virtual bool FillItemSet( SfxItemSet* /*rSet*/ ) SAL_OVERRIDE { return true; }
267 : OUString addExtension( const OUString&, const OUString& );
268 : void FillFilterList();
269 :
270 : void SearchFiles();
271 : void TakeFiles();
272 : void DoPreview();
273 :
274 : DECL_LINK( ClickPreviewHdl, void* );
275 : DECL_LINK( ClickSearchHdl, void* );
276 : DECL_LINK( ClickTakeHdl, void* );
277 : DECL_LINK( ClickTakeAllHdl, void* );
278 : DECL_LINK( SelectFoundHdl, void* );
279 : DECL_LINK( SelectThemeHdl, void* );
280 : DECL_LINK( SelectFileTypeHdl, void* );
281 : DECL_LINK( DClickFoundHdl, void* );
282 : DECL_LINK( PreviewTimerHdl, void* );
283 : DECL_LINK(EndSearchProgressHdl, void *);
284 : DECL_LINK( DialogClosedHdl, ::com::sun::star::ui::dialogs::DialogClosedEvent* );
285 :
286 : public:
287 : TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet );
288 : virtual ~TPGalleryThemeProperties();
289 :
290 : void SetXChgData( ExchangeData* pData );
291 0 : const ExchangeData* GetXChgData() const { return pData; }
292 :
293 : void StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult );
294 :
295 : static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rSet );
296 : };
297 :
298 : #endif // INCLUDED_CUI_SOURCE_INC_CUIGALDLG_HXX
299 :
300 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|