1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*2ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*2ee96f1cSAndrew Rist * distributed with this work for additional information
6*2ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*2ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
10*2ee96f1cSAndrew Rist *
11*2ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*2ee96f1cSAndrew Rist *
13*2ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
17*2ee96f1cSAndrew Rist * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist * under the License.
19*2ee96f1cSAndrew Rist *
20*2ee96f1cSAndrew Rist *************************************************************/
21*2ee96f1cSAndrew Rist
22*2ee96f1cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <algorithm>
28cdf0e10cSrcweir #include <ucbhelper/content.hxx>
29cdf0e10cSrcweir #include <vos/mutex.hxx>
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
33cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
34cdf0e10cSrcweir #include <sfx2/opengrf.hxx>
35cdf0e10cSrcweir #include <svtools/filter.hxx>
36cdf0e10cSrcweir #include <svx/gallery1.hxx>
37cdf0e10cSrcweir #include <svx/galtheme.hxx>
38cdf0e10cSrcweir #include "cuigaldlg.hxx"
39cdf0e10cSrcweir #include "helpid.hrc"
40cdf0e10cSrcweir #include <unotools/syslocale.hxx>
41cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
42cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
43cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
44cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
45cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
46cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
47cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp>
49cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
50cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
51cdf0e10cSrcweir #include "dialmgr.hxx"
52cdf0e10cSrcweir #include "gallery.hrc"
53cdf0e10cSrcweir #include <svx/dialogs.hrc>
54cdf0e10cSrcweir #include <svx/dialmgr.hxx>
55cdf0e10cSrcweir
56cdf0e10cSrcweir
57cdf0e10cSrcweir // --------------
58cdf0e10cSrcweir // - Namespaces -
59cdf0e10cSrcweir // --------------
60cdf0e10cSrcweir
61cdf0e10cSrcweir using namespace ::ucbhelper;
62cdf0e10cSrcweir using namespace ::rtl;
63cdf0e10cSrcweir using namespace ::cppu;
64cdf0e10cSrcweir using namespace ::com::sun::star::lang;
65cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
66cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
67cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
68cdf0e10cSrcweir using namespace ::com::sun::star::uno;
69cdf0e10cSrcweir
70cdf0e10cSrcweir
71cdf0e10cSrcweir // -----------
72cdf0e10cSrcweir // - Defines -
73cdf0e10cSrcweir // -----------
74cdf0e10cSrcweir
75cdf0e10cSrcweir #define MAXPATH 1024
76cdf0e10cSrcweir
77cdf0e10cSrcweir // ----------------
78cdf0e10cSrcweir // - SearchThread -
79cdf0e10cSrcweir // ----------------
80cdf0e10cSrcweir
SearchThread(SearchProgress * pProgess,TPGalleryThemeProperties * pBrowser,const INetURLObject & rStartURL)81cdf0e10cSrcweir SearchThread::SearchThread( SearchProgress* pProgess,
82cdf0e10cSrcweir TPGalleryThemeProperties* pBrowser,
83cdf0e10cSrcweir const INetURLObject& rStartURL ) :
84cdf0e10cSrcweir mpProgress ( pProgess ),
85cdf0e10cSrcweir mpBrowser ( pBrowser ),
86cdf0e10cSrcweir maStartURL ( rStartURL )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir // ------------------------------------------------------------------------
91cdf0e10cSrcweir
~SearchThread()92cdf0e10cSrcweir SearchThread::~SearchThread()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir // ------------------------------------------------------------------------
97cdf0e10cSrcweir
run()98cdf0e10cSrcweir void SAL_CALL SearchThread::run()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir const String aFileType( mpBrowser->aCbbFileType.GetText() );
101cdf0e10cSrcweir
102cdf0e10cSrcweir if( aFileType.Len() )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir const sal_uInt16 nFileNumber = mpBrowser->aCbbFileType.GetEntryPos( aFileType );
105cdf0e10cSrcweir sal_uInt16 nBeginFormat, nEndFormat;
106cdf0e10cSrcweir ::std::vector< String > aFormats;
107cdf0e10cSrcweir
108cdf0e10cSrcweir if( !nFileNumber || ( nFileNumber >= mpBrowser->aCbbFileType.GetEntryCount() ) )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir nBeginFormat = 1;
111cdf0e10cSrcweir nEndFormat = mpBrowser->aCbbFileType.GetEntryCount() - 1;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir else
114cdf0e10cSrcweir nBeginFormat = nEndFormat = nFileNumber;
115cdf0e10cSrcweir
116cdf0e10cSrcweir for( sal_uInt16 i = nBeginFormat; i <= nEndFormat; ++i )
117cdf0e10cSrcweir aFormats.push_back( ( (FilterEntry*) mpBrowser->aFilterEntryList.GetObject( i ) )->aFilterName.ToLowerAscii() );
118cdf0e10cSrcweir
119cdf0e10cSrcweir ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir // ------------------------------------------------------------------------
124cdf0e10cSrcweir
onTerminated()125cdf0e10cSrcweir void SAL_CALL SearchThread::onTerminated()
126cdf0e10cSrcweir {
127cdf0e10cSrcweir Application::PostUserEvent( LINK( mpProgress, SearchProgress, CleanUpHdl ) );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir // ------------------------------------------------------------------------
131cdf0e10cSrcweir
ImplSearch(const INetURLObject & rStartURL,const::std::vector<String> & rFormats,sal_Bool bRecursive)132cdf0e10cSrcweir void SearchThread::ImplSearch( const INetURLObject& rStartURL,
133cdf0e10cSrcweir const ::std::vector< String >& rFormats,
134cdf0e10cSrcweir sal_Bool bRecursive )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir {
137cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
138cdf0e10cSrcweir
139cdf0e10cSrcweir mpProgress->SetDirectory( rStartURL );
140cdf0e10cSrcweir mpProgress->Sync();
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir try
144cdf0e10cSrcweir {
145cdf0e10cSrcweir ::com::sun::star::uno::Reference< XCommandEnvironment > xEnv;
146cdf0e10cSrcweir Content aCnt( rStartURL.GetMainURL( INetURLObject::NO_DECODE ), xEnv );
147cdf0e10cSrcweir Sequence< OUString > aProps( 2 );
148cdf0e10cSrcweir
149cdf0e10cSrcweir aProps.getArray()[ 0 ] = OUString::createFromAscii( "IsFolder" );
150cdf0e10cSrcweir aProps.getArray()[ 1 ] = OUString::createFromAscii( "IsDocument" );
151cdf0e10cSrcweir ::com::sun::star::uno::Reference< XResultSet > xResultSet(
152cdf0e10cSrcweir aCnt.createCursor( aProps, INCLUDE_FOLDERS_AND_DOCUMENTS ) );
153cdf0e10cSrcweir
154cdf0e10cSrcweir if( xResultSet.is() )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir ::com::sun::star::uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY_THROW );
157cdf0e10cSrcweir ::com::sun::star::uno::Reference< XRow > xRow( xResultSet, UNO_QUERY_THROW );
158cdf0e10cSrcweir
159cdf0e10cSrcweir while( xResultSet->next() && schedule() )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir INetURLObject aFoundURL( xContentAccess->queryContentIdentifierString() );
162cdf0e10cSrcweir DBG_ASSERT( aFoundURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
163cdf0e10cSrcweir
164cdf0e10cSrcweir sal_Bool bFolder = xRow->getBoolean( 1 ); // property "IsFolder"
165cdf0e10cSrcweir if ( xRow->wasNull() )
166cdf0e10cSrcweir bFolder = sal_False;
167cdf0e10cSrcweir
168cdf0e10cSrcweir if( bRecursive && bFolder )
169cdf0e10cSrcweir ImplSearch( aFoundURL, rFormats, sal_True );
170cdf0e10cSrcweir else
171cdf0e10cSrcweir {
172cdf0e10cSrcweir sal_Bool bDocument = xRow->getBoolean( 2 ); // property "IsDocument"
173cdf0e10cSrcweir if ( xRow->wasNull() )
174cdf0e10cSrcweir bDocument = sal_False;
175cdf0e10cSrcweir
176cdf0e10cSrcweir if( bDocument )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir GraphicDescriptor aDesc( aFoundURL );
179cdf0e10cSrcweir String aFileName;
180cdf0e10cSrcweir
181cdf0e10cSrcweir if( ( aDesc.Detect() &&
182cdf0e10cSrcweir ::std::find( rFormats.begin(),
183cdf0e10cSrcweir rFormats.end(),
184cdf0e10cSrcweir aDesc.GetImportFormatShortName(
185cdf0e10cSrcweir aDesc.GetFileFormat() ).ToLowerAscii() )
186cdf0e10cSrcweir != rFormats.end() ) ||
187cdf0e10cSrcweir ::std::find( rFormats.begin(),
188cdf0e10cSrcweir rFormats.end(),
189cdf0e10cSrcweir String(aFoundURL.GetExtension().toAsciiLowerCase()) )
190cdf0e10cSrcweir != rFormats.end() )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
193cdf0e10cSrcweir
194cdf0e10cSrcweir mpBrowser->aFoundList.Insert(
195cdf0e10cSrcweir new String( aFoundURL.GetMainURL( INetURLObject::NO_DECODE ) ),
196cdf0e10cSrcweir LIST_APPEND );
197cdf0e10cSrcweir mpBrowser->aLbxFound.InsertEntry(
198cdf0e10cSrcweir GetReducedString( aFoundURL, 50 ),
199cdf0e10cSrcweir (sal_uInt16) mpBrowser->aFoundList.Count() - 1 );
200cdf0e10cSrcweir }
201cdf0e10cSrcweir }
202cdf0e10cSrcweir }
203cdf0e10cSrcweir }
204cdf0e10cSrcweir }
205cdf0e10cSrcweir }
206cdf0e10cSrcweir catch( const ContentCreationException& )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir }
209cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir }
212cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir }
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
217cdf0e10cSrcweir // ------------------
218cdf0e10cSrcweir // - SearchProgress -
219cdf0e10cSrcweir // ------------------
220cdf0e10cSrcweir
SearchProgress(Window * pParent,const INetURLObject & rStartURL)221cdf0e10cSrcweir SearchProgress::SearchProgress( Window* pParent, const INetURLObject& rStartURL ) :
222cdf0e10cSrcweir ModalDialog ( pParent, CUI_RES(RID_SVXDLG_GALLERY_SEARCH_PROGRESS ) ),
223cdf0e10cSrcweir aFtSearchDir ( this, CUI_RES( FT_SEARCH_DIR ) ),
224cdf0e10cSrcweir aFLSearchDir ( this, CUI_RES( FL_SEARCH_DIR ) ),
225cdf0e10cSrcweir aFtSearchType ( this, CUI_RES( FT_SEARCH_TYPE ) ),
226cdf0e10cSrcweir aFLSearchType ( this, CUI_RES( FL_SEARCH_TYPE ) ),
227cdf0e10cSrcweir aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
228cdf0e10cSrcweir maSearchThread ( this, (TPGalleryThemeProperties*) pParent, rStartURL )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir FreeResource();
231cdf0e10cSrcweir aBtnCancel.SetClickHdl( LINK( this, SearchProgress, ClickCancelBtn ) );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir // ------------------------------------------------------------------------
235cdf0e10cSrcweir
Terminate()236cdf0e10cSrcweir void SearchProgress::Terminate()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir maSearchThread.terminate();
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
241cdf0e10cSrcweir // ------------------------------------------------------------------------
242cdf0e10cSrcweir
IMPL_LINK(SearchProgress,ClickCancelBtn,void *,EMPTYARG)243cdf0e10cSrcweir IMPL_LINK( SearchProgress, ClickCancelBtn, void*, EMPTYARG )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir Terminate();
246cdf0e10cSrcweir return 0L;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir // ------------------------------------------------------------------------
250cdf0e10cSrcweir
IMPL_LINK(SearchProgress,CleanUpHdl,void *,EMPTYARG)251cdf0e10cSrcweir IMPL_LINK( SearchProgress, CleanUpHdl, void*, EMPTYARG )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir EndDialog( RET_OK );
254cdf0e10cSrcweir delete this;
255cdf0e10cSrcweir return 0L;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir // ------------------------------------------------------------------------
259cdf0e10cSrcweir
Execute()260cdf0e10cSrcweir short SearchProgress::Execute()
261cdf0e10cSrcweir {
262cdf0e10cSrcweir DBG_ERROR( "SearchProgress cannot be executed via Dialog::Execute!\n"
263cdf0e10cSrcweir "It creates a thread that will call back to VCL apartment => deadlock!\n"
264cdf0e10cSrcweir "Use Dialog::StartExecuteModal to execute the dialog!" );
265cdf0e10cSrcweir return RET_CANCEL;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir // ------------------------------------------------------------------------
269cdf0e10cSrcweir
StartExecuteModal(const Link & rEndDialogHdl)270cdf0e10cSrcweir void SearchProgress::StartExecuteModal( const Link& rEndDialogHdl )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir maSearchThread.create();
273cdf0e10cSrcweir ModalDialog::StartExecuteModal( rEndDialogHdl );
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir // --------------
277cdf0e10cSrcweir // - TakeThread -
278cdf0e10cSrcweir // --------------
279cdf0e10cSrcweir
TakeThread(TakeProgress * pProgess,TPGalleryThemeProperties * pBrowser,List & rTakenList)280cdf0e10cSrcweir TakeThread::TakeThread( TakeProgress* pProgess, TPGalleryThemeProperties* pBrowser, List& rTakenList ) :
281cdf0e10cSrcweir mpProgress ( pProgess ),
282cdf0e10cSrcweir mpBrowser ( pBrowser ),
283cdf0e10cSrcweir mrTakenList ( rTakenList )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir // ------------------------------------------------------------------------
288cdf0e10cSrcweir
~TakeThread()289cdf0e10cSrcweir TakeThread::~TakeThread()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir }
292cdf0e10cSrcweir
293cdf0e10cSrcweir // ------------------------------------------------------------------------
294cdf0e10cSrcweir
run()295cdf0e10cSrcweir void SAL_CALL TakeThread::run()
296cdf0e10cSrcweir {
297cdf0e10cSrcweir String aName;
298cdf0e10cSrcweir INetURLObject aURL;
299cdf0e10cSrcweir sal_uInt16 nEntries;
300cdf0e10cSrcweir GalleryTheme* pThm = mpBrowser->GetXChgData()->pTheme;
301cdf0e10cSrcweir sal_uInt16 nPos;
302cdf0e10cSrcweir GalleryProgress* pStatusProgress;
303cdf0e10cSrcweir
304cdf0e10cSrcweir {
305cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
306cdf0e10cSrcweir pStatusProgress = new GalleryProgress;
307cdf0e10cSrcweir nEntries = mpBrowser->bTakeAll ? mpBrowser->aLbxFound.GetEntryCount() : mpBrowser->aLbxFound.GetSelectEntryCount();
308cdf0e10cSrcweir pThm->LockBroadcaster();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
311cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nEntries && schedule(); i++ )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir // kompletten Filenamen aus FoundList holen
314cdf0e10cSrcweir if( mpBrowser->bTakeAll )
315cdf0e10cSrcweir aURL = INetURLObject(*mpBrowser->aFoundList.GetObject( nPos = i ));
316cdf0e10cSrcweir else
317cdf0e10cSrcweir aURL = INetURLObject(*mpBrowser->aFoundList.GetObject( nPos = mpBrowser->aLbxFound.GetSelectEntryPos( i ) ));
318cdf0e10cSrcweir
319cdf0e10cSrcweir // Position in Taken-Liste uebernehmen
320cdf0e10cSrcweir mrTakenList.Insert( (void*) (sal_uLong)nPos, LIST_APPEND );
321cdf0e10cSrcweir
322cdf0e10cSrcweir {
323cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
324cdf0e10cSrcweir
325cdf0e10cSrcweir mpProgress->SetFile( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) );
326cdf0e10cSrcweir pStatusProgress->Update( i, nEntries - 1 );
327cdf0e10cSrcweir mpProgress->Sync();
328cdf0e10cSrcweir pThm->InsertURL( aURL );
329cdf0e10cSrcweir }
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
332cdf0e10cSrcweir {
333cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
334cdf0e10cSrcweir
335cdf0e10cSrcweir pThm->UnlockBroadcaster();
336cdf0e10cSrcweir delete pStatusProgress;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir // ------------------------------------------------------------------------
341cdf0e10cSrcweir
onTerminated()342cdf0e10cSrcweir void SAL_CALL TakeThread::onTerminated()
343cdf0e10cSrcweir {
344cdf0e10cSrcweir Application::PostUserEvent( LINK( mpProgress, TakeProgress, CleanUpHdl ) );
345cdf0e10cSrcweir }
346cdf0e10cSrcweir
347cdf0e10cSrcweir // ----------------
348cdf0e10cSrcweir // - TakeProgress -
349cdf0e10cSrcweir // ----------------
350cdf0e10cSrcweir
TakeProgress(Window * pWindow)351cdf0e10cSrcweir TakeProgress::TakeProgress( Window* pWindow ) :
352cdf0e10cSrcweir ModalDialog ( pWindow, CUI_RES( RID_SVXDLG_GALLERY_TAKE_PROGRESS ) ),
353cdf0e10cSrcweir aFtTakeFile ( this, CUI_RES( FT_TAKE_FILE ) ),
354cdf0e10cSrcweir aFLTakeProgress( this, CUI_RES( FL_TAKE_PROGRESS ) ),
355cdf0e10cSrcweir aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
356cdf0e10cSrcweir maTakeThread ( this, (TPGalleryThemeProperties*) pWindow, maTakenList )
357cdf0e10cSrcweir
358cdf0e10cSrcweir {
359cdf0e10cSrcweir FreeResource();
360cdf0e10cSrcweir aBtnCancel.SetClickHdl( LINK( this, TakeProgress, ClickCancelBtn ) );
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir // ------------------------------------------------------------------------
364cdf0e10cSrcweir
365cdf0e10cSrcweir
Terminate()366cdf0e10cSrcweir void TakeProgress::Terminate()
367cdf0e10cSrcweir {
368cdf0e10cSrcweir maTakeThread.terminate();
369cdf0e10cSrcweir }
370cdf0e10cSrcweir
371cdf0e10cSrcweir // ------------------------------------------------------------------------
372cdf0e10cSrcweir
IMPL_LINK(TakeProgress,ClickCancelBtn,void *,EMPTYARG)373cdf0e10cSrcweir IMPL_LINK( TakeProgress, ClickCancelBtn, void*, EMPTYARG )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir Terminate();
376cdf0e10cSrcweir return 0L;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
379cdf0e10cSrcweir // ------------------------------------------------------------------------
380cdf0e10cSrcweir
IMPL_LINK(TakeProgress,CleanUpHdl,void *,EMPTYARG)381cdf0e10cSrcweir IMPL_LINK( TakeProgress, CleanUpHdl, void*, EMPTYARG )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir TPGalleryThemeProperties* mpBrowser = (TPGalleryThemeProperties*) GetParent();
384cdf0e10cSrcweir ::std::bit_vector aRemoveEntries( mpBrowser->aFoundList.Count(), false );
385cdf0e10cSrcweir ::std::vector< String > aRemainingVector;
386cdf0e10cSrcweir sal_uInt32 i, nCount;
387cdf0e10cSrcweir
388cdf0e10cSrcweir GetParent()->EnterWait();
389cdf0e10cSrcweir mpBrowser->aLbxFound.SetUpdateMode( sal_False );
390cdf0e10cSrcweir mpBrowser->aLbxFound.SetNoSelection();
391cdf0e10cSrcweir
392cdf0e10cSrcweir // mark all taken positions in aRemoveEntries
393cdf0e10cSrcweir for( i = 0UL, nCount = maTakenList.Count(); i < nCount; ++i )
394cdf0e10cSrcweir aRemoveEntries[ (sal_uLong) maTakenList.GetObject( i ) ] = true;
395cdf0e10cSrcweir
396cdf0e10cSrcweir maTakenList.Clear();
397cdf0e10cSrcweir
398cdf0e10cSrcweir // refill found list
399cdf0e10cSrcweir for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
400cdf0e10cSrcweir if( !aRemoveEntries[ i ] )
401cdf0e10cSrcweir aRemainingVector.push_back( *mpBrowser->aFoundList.GetObject( i ) );
402cdf0e10cSrcweir
403cdf0e10cSrcweir for( String* pStr = mpBrowser->aFoundList.First(); pStr; pStr = mpBrowser->aFoundList.Next() )
404cdf0e10cSrcweir delete pStr;
405cdf0e10cSrcweir
406cdf0e10cSrcweir mpBrowser->aFoundList.Clear();
407cdf0e10cSrcweir
408cdf0e10cSrcweir for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
409cdf0e10cSrcweir mpBrowser->aFoundList.Insert( new String( aRemainingVector[ i ] ), LIST_APPEND );
410cdf0e10cSrcweir
411cdf0e10cSrcweir aRemainingVector.clear();
412cdf0e10cSrcweir
413cdf0e10cSrcweir // refill list box
414cdf0e10cSrcweir for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
415cdf0e10cSrcweir if( !aRemoveEntries[ i ] )
416cdf0e10cSrcweir aRemainingVector.push_back( mpBrowser->aLbxFound.GetEntry( (sal_uInt16) i ) );
417cdf0e10cSrcweir
418cdf0e10cSrcweir mpBrowser->aLbxFound.Clear();
419cdf0e10cSrcweir
420cdf0e10cSrcweir for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
421cdf0e10cSrcweir mpBrowser->aLbxFound.InsertEntry( aRemainingVector[ i ] );
422cdf0e10cSrcweir
423cdf0e10cSrcweir aRemainingVector.clear();
424cdf0e10cSrcweir
425cdf0e10cSrcweir mpBrowser->aLbxFound.SetUpdateMode( sal_True );
426cdf0e10cSrcweir mpBrowser->SelectFoundHdl( NULL );
427cdf0e10cSrcweir GetParent()->LeaveWait();
428cdf0e10cSrcweir
429cdf0e10cSrcweir EndDialog( RET_OK );
430cdf0e10cSrcweir delete this;
431cdf0e10cSrcweir return 0L;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir // ------------------------------------------------------------------------
435cdf0e10cSrcweir
Execute()436cdf0e10cSrcweir short TakeProgress::Execute()
437cdf0e10cSrcweir {
438cdf0e10cSrcweir DBG_ERROR( "TakeProgress cannot be executed via Dialog::Execute!\n"
439cdf0e10cSrcweir "It creates a thread that will call back to VCL apartment => deadlock!\n"
440cdf0e10cSrcweir "Use Dialog::StartExecuteModal to execute the dialog!" );
441cdf0e10cSrcweir return RET_CANCEL;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir // ------------------------------------------------------------------------
445cdf0e10cSrcweir
StartExecuteModal(const Link & rEndDialogHdl)446cdf0e10cSrcweir void TakeProgress::StartExecuteModal( const Link& rEndDialogHdl )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir maTakeThread.create();
449cdf0e10cSrcweir ModalDialog::StartExecuteModal( rEndDialogHdl );
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452cdf0e10cSrcweir // ---------------------
453cdf0e10cSrcweir // - ActualizeProgress -
454cdf0e10cSrcweir // ---------------------
455cdf0e10cSrcweir
ActualizeProgress(Window * pWindow,GalleryTheme * pThm)456cdf0e10cSrcweir ActualizeProgress::ActualizeProgress( Window* pWindow, GalleryTheme* pThm ) :
457cdf0e10cSrcweir ModalDialog ( pWindow, CUI_RES( RID_SVXDLG_GALLERY_ACTUALIZE_PROGRESS ) ),
458cdf0e10cSrcweir aFtActualizeFile ( this, CUI_RES( FT_ACTUALIZE_FILE ) ),
459cdf0e10cSrcweir aFLActualizeProgress ( this, CUI_RES( FL_ACTUALIZE_PROGRESS ) ),
460cdf0e10cSrcweir aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
461cdf0e10cSrcweir pTheme ( pThm )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir FreeResource();
464cdf0e10cSrcweir aBtnCancel.SetClickHdl( LINK( this, ActualizeProgress, ClickCancelBtn ) );
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir // ------------------------------------------------------------------------
468cdf0e10cSrcweir
Execute()469cdf0e10cSrcweir short ActualizeProgress::Execute()
470cdf0e10cSrcweir {
471cdf0e10cSrcweir short nRet;
472cdf0e10cSrcweir
473cdf0e10cSrcweir pTimer = new Timer;
474cdf0e10cSrcweir
475cdf0e10cSrcweir if ( pTimer )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir pTimer->SetTimeoutHdl( LINK( this, ActualizeProgress, TimeoutHdl ) );
478cdf0e10cSrcweir pTimer->SetTimeout( 500 );
479cdf0e10cSrcweir pTimer->Start();
480cdf0e10cSrcweir }
481cdf0e10cSrcweir
482cdf0e10cSrcweir nRet = ModalDialog::Execute();
483cdf0e10cSrcweir
484cdf0e10cSrcweir return nRet;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
487cdf0e10cSrcweir // ------------------------------------------------------------------------
488cdf0e10cSrcweir
IMPL_LINK(ActualizeProgress,ClickCancelBtn,void *,EMPTYARG)489cdf0e10cSrcweir IMPL_LINK( ActualizeProgress, ClickCancelBtn, void*, EMPTYARG )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir pTheme->AbortActualize();
492cdf0e10cSrcweir EndDialog( RET_OK );
493cdf0e10cSrcweir
494cdf0e10cSrcweir return 0L;
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
497cdf0e10cSrcweir // ------------------------------------------------------------------------
498cdf0e10cSrcweir
IMPL_LINK(ActualizeProgress,TimeoutHdl,Timer *,_pTimer)499cdf0e10cSrcweir IMPL_LINK( ActualizeProgress, TimeoutHdl, Timer*, _pTimer )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir if ( _pTimer )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir _pTimer->Stop();
504cdf0e10cSrcweir delete _pTimer;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir
507cdf0e10cSrcweir pTheme->Actualize( LINK( this, ActualizeProgress, ActualizeHdl ), &aStatusProgress );
508cdf0e10cSrcweir ClickCancelBtn( NULL );
509cdf0e10cSrcweir
510cdf0e10cSrcweir return 0;
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
513cdf0e10cSrcweir // ------------------------------------------------------------------------
514cdf0e10cSrcweir
IMPL_LINK(ActualizeProgress,ActualizeHdl,INetURLObject *,pURL)515cdf0e10cSrcweir IMPL_LINK( ActualizeProgress, ActualizeHdl, INetURLObject*, pURL )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir for( long i = 0; i < 128; i++ )
518cdf0e10cSrcweir Application::Reschedule();
519cdf0e10cSrcweir
520cdf0e10cSrcweir Flush();
521cdf0e10cSrcweir Sync();
522cdf0e10cSrcweir
523cdf0e10cSrcweir if( pURL )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir aFtActualizeFile.SetText( GetReducedString( *pURL, 30 ) );
526cdf0e10cSrcweir aFtActualizeFile.Flush();
527cdf0e10cSrcweir aFtActualizeFile.Sync();
528cdf0e10cSrcweir }
529cdf0e10cSrcweir
530cdf0e10cSrcweir return 0;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir
533cdf0e10cSrcweir // ---------------
534cdf0e10cSrcweir // - TitleDialog -
535cdf0e10cSrcweir // ---------------
536cdf0e10cSrcweir
TitleDialog(Window * pParent,const String & rOldTitle)537cdf0e10cSrcweir TitleDialog::TitleDialog( Window* pParent, const String& rOldTitle ) :
538cdf0e10cSrcweir ModalDialog ( pParent, CUI_RES( RID_SVXDLG_GALLERY_TITLE ) ),
539cdf0e10cSrcweir maOk ( this, CUI_RES( BTN_OK ) ),
540cdf0e10cSrcweir maCancel ( this, CUI_RES( BTN_CANCEL ) ),
541cdf0e10cSrcweir maHelp ( this, CUI_RES( BTN_HELP ) ),
542cdf0e10cSrcweir maFL ( this, CUI_RES( FL_TITLE ) ),
543cdf0e10cSrcweir maEdit ( this, CUI_RES( EDT_TITLE ) )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir FreeResource();
546cdf0e10cSrcweir maEdit.SetText( rOldTitle );
547cdf0e10cSrcweir maEdit.GrabFocus();
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
550cdf0e10cSrcweir // -------------------
551cdf0e10cSrcweir // - GalleryIdDialog -
552cdf0e10cSrcweir // -------------------
553cdf0e10cSrcweir
GalleryIdDialog(Window * pParent,GalleryTheme * _pThm)554cdf0e10cSrcweir GalleryIdDialog::GalleryIdDialog( Window* pParent, GalleryTheme* _pThm ) :
555cdf0e10cSrcweir ModalDialog ( pParent, CUI_RES( RID_SVXDLG_GALLERY_THEMEID ) ),
556cdf0e10cSrcweir aBtnOk ( this, CUI_RES( BTN_OK ) ),
557cdf0e10cSrcweir aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
558cdf0e10cSrcweir aFLId ( this, CUI_RES( FL_ID ) ),
559cdf0e10cSrcweir aLbResName ( this, CUI_RES( LB_RESNAME ) ),
560cdf0e10cSrcweir pThm ( _pThm )
561cdf0e10cSrcweir {
562cdf0e10cSrcweir FreeResource();
563cdf0e10cSrcweir
564cdf0e10cSrcweir aLbResName.InsertEntry( String( RTL_CONSTASCII_USTRINGPARAM( "!!! No Id !!!" ) ) );
565cdf0e10cSrcweir
566cdf0e10cSrcweir GalleryTheme::InsertAllThemes( aLbResName );
567cdf0e10cSrcweir
568cdf0e10cSrcweir aLbResName.SelectEntryPos( (sal_uInt16) pThm->GetId() );
569cdf0e10cSrcweir aLbResName.GrabFocus();
570cdf0e10cSrcweir
571cdf0e10cSrcweir aBtnOk.SetClickHdl( LINK( this, GalleryIdDialog, ClickOkHdl ) );
572cdf0e10cSrcweir }
573cdf0e10cSrcweir
574cdf0e10cSrcweir // -----------------------------------------------------------------------------
575cdf0e10cSrcweir
IMPL_LINK(GalleryIdDialog,ClickOkHdl,void *,EMPTYARG)576cdf0e10cSrcweir IMPL_LINK( GalleryIdDialog, ClickOkHdl, void*, EMPTYARG )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir Gallery* pGal = pThm->GetParent();
579cdf0e10cSrcweir const sal_uLong nId = GetId();
580cdf0e10cSrcweir sal_Bool bDifferentThemeExists = sal_False;
581cdf0e10cSrcweir
582cdf0e10cSrcweir for( sal_uLong i = 0, nCount = pGal->GetThemeCount(); i < nCount && !bDifferentThemeExists; i++ )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir const GalleryThemeEntry* pInfo = pGal->GetThemeInfo( i );
585cdf0e10cSrcweir
586cdf0e10cSrcweir if( ( pInfo->GetId() == nId ) && ( pInfo->GetThemeName() != pThm->GetName() ) )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir String aStr( CUI_RES( RID_SVXSTR_GALLERY_ID_EXISTS ) );
589cdf0e10cSrcweir
590cdf0e10cSrcweir aStr += String( RTL_CONSTASCII_USTRINGPARAM( " (" ) );
591cdf0e10cSrcweir aStr += pInfo->GetThemeName();
592cdf0e10cSrcweir aStr += ')';
593cdf0e10cSrcweir
594cdf0e10cSrcweir InfoBox aBox( this, aStr );
595cdf0e10cSrcweir aBox.Execute();
596cdf0e10cSrcweir aLbResName.GrabFocus();
597cdf0e10cSrcweir bDifferentThemeExists = sal_True;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir }
600cdf0e10cSrcweir
601cdf0e10cSrcweir if( !bDifferentThemeExists )
602cdf0e10cSrcweir EndDialog( RET_OK );
603cdf0e10cSrcweir
604cdf0e10cSrcweir return 0L;
605cdf0e10cSrcweir }
606cdf0e10cSrcweir
607cdf0e10cSrcweir
608cdf0e10cSrcweir // --------------------------
609cdf0e10cSrcweir // - GalleryThemeProperties -
610cdf0e10cSrcweir // --------------------------
611cdf0e10cSrcweir
GalleryThemeProperties(Window * pParent,ExchangeData * _pData,SfxItemSet * pItemSet)612cdf0e10cSrcweir GalleryThemeProperties::GalleryThemeProperties( Window* pParent, ExchangeData* _pData, SfxItemSet* pItemSet ) :
613cdf0e10cSrcweir SfxTabDialog ( pParent, CUI_RES( RID_SVXTABDLG_GALLERYTHEME ), pItemSet ),
614cdf0e10cSrcweir pData ( _pData )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir FreeResource();
617cdf0e10cSrcweir
618cdf0e10cSrcweir AddTabPage( RID_SVXTABPAGE_GALLERY_GENERAL, TPGalleryThemeGeneral::Create, 0 );
619cdf0e10cSrcweir AddTabPage( RID_SVXTABPAGE_GALLERYTHEME_FILES, TPGalleryThemeProperties::Create, 0 );
620cdf0e10cSrcweir
621cdf0e10cSrcweir if( pData->pTheme->IsReadOnly() )
622cdf0e10cSrcweir RemoveTabPage( RID_SVXTABPAGE_GALLERYTHEME_FILES );
623cdf0e10cSrcweir
624cdf0e10cSrcweir String aText( GetText() );
625cdf0e10cSrcweir
626cdf0e10cSrcweir aText += pData->pTheme->GetName();
627cdf0e10cSrcweir
628cdf0e10cSrcweir if( pData->pTheme->IsReadOnly() )
629cdf0e10cSrcweir aText += String( CUI_RES( RID_SVXSTR_GALLERY_READONLY ) );
630cdf0e10cSrcweir
631cdf0e10cSrcweir SetText( aText );
632cdf0e10cSrcweir }
633cdf0e10cSrcweir
634cdf0e10cSrcweir // ------------------------------------------------------------------------
635cdf0e10cSrcweir
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)636cdf0e10cSrcweir void GalleryThemeProperties::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir if( RID_SVXTABPAGE_GALLERY_GENERAL == nId )
639cdf0e10cSrcweir ( (TPGalleryThemeGeneral&) rPage ).SetXChgData( pData );
640cdf0e10cSrcweir else
641cdf0e10cSrcweir ( (TPGalleryThemeProperties&) rPage ).SetXChgData( pData );
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir // -------------------------
645cdf0e10cSrcweir // - TPGalleryThemeGeneral -
646cdf0e10cSrcweir // -------------------------
647cdf0e10cSrcweir
TPGalleryThemeGeneral(Window * pParent,const SfxItemSet & rSet)648cdf0e10cSrcweir TPGalleryThemeGeneral::TPGalleryThemeGeneral( Window* pParent, const SfxItemSet& rSet ) :
649cdf0e10cSrcweir SfxTabPage ( pParent, CUI_RES( RID_SVXTABPAGE_GALLERY_GENERAL ), rSet ),
650cdf0e10cSrcweir aFiMSImage ( this, CUI_RES( FI_MS_IMAGE ) ),
651cdf0e10cSrcweir aEdtMSName ( this, CUI_RES( EDT_MS_NAME ) ),
652cdf0e10cSrcweir aFlMSGeneralFirst ( this, CUI_RES( FL_MS_GENERAL_FIRST ) ),
653cdf0e10cSrcweir aFtMSType ( this, CUI_RES( FT_MS_TYPE ) ),
654cdf0e10cSrcweir aFtMSShowType ( this, CUI_RES( FT_MS_SHOW_TYPE ) ),
655cdf0e10cSrcweir aFtMSPath ( this, CUI_RES( FT_MS_PATH ) ),
656cdf0e10cSrcweir aFtMSShowPath ( this, CUI_RES( FT_MS_SHOW_PATH ) ),
657cdf0e10cSrcweir aFtMSContent ( this, CUI_RES( FT_MS_CONTENT ) ),
658cdf0e10cSrcweir aFtMSShowContent ( this, CUI_RES( FT_MS_SHOW_CONTENT ) ),
659cdf0e10cSrcweir aFlMSGeneralSecond ( this, CUI_RES( FL_MS_GENERAL_SECOND ) ),
660cdf0e10cSrcweir aFtMSChangeDate ( this, CUI_RES( FT_MS_CHANGEDATE ) ),
661cdf0e10cSrcweir aFtMSShowChangeDate ( this, CUI_RES( FT_MS_SHOW_CHANGEDATE ) )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir FreeResource();
664cdf0e10cSrcweir
665cdf0e10cSrcweir String aAccName(SVX_RES(RID_SVXSTR_GALLERY_THEMENAME));
666cdf0e10cSrcweir aEdtMSName.SetAccessibleName(aAccName);
667cdf0e10cSrcweir aFiMSImage.SetAccessibleName(aAccName);
668cdf0e10cSrcweir aEdtMSName.SetAccessibleRelationLabeledBy( &aFiMSImage );
669cdf0e10cSrcweir }
670cdf0e10cSrcweir
671cdf0e10cSrcweir // ------------------------------------------------------------------------
672cdf0e10cSrcweir
SetXChgData(ExchangeData * _pData)673cdf0e10cSrcweir void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir pData = _pData;
676cdf0e10cSrcweir
677cdf0e10cSrcweir GalleryTheme* pThm = pData->pTheme;
678cdf0e10cSrcweir String aOutStr( String::CreateFromInt32( pThm->GetObjectCount() ) );
679cdf0e10cSrcweir String aObjStr( CUI_RES( RID_SVXSTR_GALLERYPROPS_OBJECT ) );
680cdf0e10cSrcweir String aAccess;
681cdf0e10cSrcweir String aType( SVX_RES( RID_SVXSTR_GALLERYPROPS_GALTHEME ) );
682cdf0e10cSrcweir sal_Bool bReadOnly = pThm->IsReadOnly() && !pThm->IsImported();
683cdf0e10cSrcweir
684cdf0e10cSrcweir aEdtMSName.SetHelpId( HID_GALLERY_EDIT_MSNAME );
685cdf0e10cSrcweir aEdtMSName.SetText( pThm->GetName() );
686cdf0e10cSrcweir aEdtMSName.SetReadOnly( bReadOnly );
687cdf0e10cSrcweir
688cdf0e10cSrcweir if( bReadOnly )
689cdf0e10cSrcweir aEdtMSName.Disable();
690cdf0e10cSrcweir else
691cdf0e10cSrcweir aEdtMSName.Enable();
692cdf0e10cSrcweir
693cdf0e10cSrcweir if( pThm->IsReadOnly() )
694cdf0e10cSrcweir aType += String( CUI_RES( RID_SVXSTR_GALLERY_READONLY ) );
695cdf0e10cSrcweir
696cdf0e10cSrcweir aFtMSShowType.SetText( aType );
697cdf0e10cSrcweir aFtMSShowPath.SetText( pThm->GetSdgURL().GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) );
698cdf0e10cSrcweir
699cdf0e10cSrcweir // Ein- oder Mehrzahl?
700cdf0e10cSrcweir if ( 1 == pThm->GetObjectCount() )
701cdf0e10cSrcweir aObjStr = aObjStr.GetToken( 0 );
702cdf0e10cSrcweir else
703cdf0e10cSrcweir aObjStr = aObjStr.GetToken( 1 );
704cdf0e10cSrcweir
705cdf0e10cSrcweir aOutStr += ' ';
706cdf0e10cSrcweir aOutStr += aObjStr;
707cdf0e10cSrcweir
708cdf0e10cSrcweir aFtMSShowContent.SetText( aOutStr );
709cdf0e10cSrcweir
710cdf0e10cSrcweir // get locale wrapper (singleton)
711cdf0e10cSrcweir const LocaleDataWrapper& aLocaleData = SvtSysLocale().GetLocaleData();
712cdf0e10cSrcweir
713cdf0e10cSrcweir // ChangeDate/Time
714cdf0e10cSrcweir aAccess = aLocaleData.getDate( pData->aThemeChangeDate );
715cdf0e10cSrcweir aAccess += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
716cdf0e10cSrcweir aAccess += aLocaleData.getTime( pData->aThemeChangeTime );
717cdf0e10cSrcweir aFtMSShowChangeDate.SetText( aAccess );
718cdf0e10cSrcweir
719cdf0e10cSrcweir // Image setzen
720cdf0e10cSrcweir sal_uInt16 nId;
721cdf0e10cSrcweir
722cdf0e10cSrcweir if( pThm->IsImported() )
723cdf0e10cSrcweir nId = RID_SVXBMP_THEME_IMPORTED_BIG;
724cdf0e10cSrcweir else if( pThm->IsReadOnly() )
725cdf0e10cSrcweir nId = RID_SVXBMP_THEME_READONLY_BIG;
726cdf0e10cSrcweir else if( pThm->IsDefault() )
727cdf0e10cSrcweir nId = RID_SVXBMP_THEME_DEFAULT_BIG;
728cdf0e10cSrcweir else
729cdf0e10cSrcweir nId = RID_SVXBMP_THEME_NORMAL_BIG;
730cdf0e10cSrcweir
731cdf0e10cSrcweir aFiMSImage.SetImage( Image( Bitmap( CUI_RES( nId ) ), COL_LIGHTMAGENTA ) );
732cdf0e10cSrcweir }
733cdf0e10cSrcweir
734cdf0e10cSrcweir // ------------------------------------------------------------------------
735cdf0e10cSrcweir
FillItemSet(SfxItemSet &)736cdf0e10cSrcweir sal_Bool TPGalleryThemeGeneral::FillItemSet( SfxItemSet& /*rSet*/ )
737cdf0e10cSrcweir {
738cdf0e10cSrcweir pData->aEditedTitle = aEdtMSName.GetText();
739cdf0e10cSrcweir return sal_True;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir
742cdf0e10cSrcweir // ------------------------------------------------------------------------
743cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rSet)744cdf0e10cSrcweir SfxTabPage* TPGalleryThemeGeneral::Create( Window* pParent, const SfxItemSet& rSet )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir return new TPGalleryThemeGeneral( pParent, rSet );
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
749cdf0e10cSrcweir // ----------------------------
750cdf0e10cSrcweir // - TPGalleryThemeProperties -
751cdf0e10cSrcweir // ----------------------------
752cdf0e10cSrcweir
TPGalleryThemeProperties(Window * pWindow,const SfxItemSet & rSet)753cdf0e10cSrcweir TPGalleryThemeProperties::TPGalleryThemeProperties( Window* pWindow, const SfxItemSet& rSet ) :
754cdf0e10cSrcweir SfxTabPage ( pWindow, CUI_RES( RID_SVXTABPAGE_GALLERYTHEME_FILES ), rSet ),
755cdf0e10cSrcweir aFtFileType ( this, CUI_RES(FT_FILETYPE ) ),
756cdf0e10cSrcweir aCbbFileType ( this, CUI_RES(CBB_FILETYPE ) ),
757cdf0e10cSrcweir aLbxFound ( this, CUI_RES(LBX_FOUND ) ),
758cdf0e10cSrcweir aBtnSearch ( this, CUI_RES(BTN_SEARCH ) ),
759cdf0e10cSrcweir aBtnTake ( this, CUI_RES(BTN_TAKE ) ),
760cdf0e10cSrcweir aBtnTakeAll ( this, CUI_RES(BTN_TAKEALL ) ),
761cdf0e10cSrcweir aCbxPreview ( this, CUI_RES(CBX_PREVIEW ) ),
762cdf0e10cSrcweir aWndPreview ( this, CUI_RES( WND_BRSPRV ) ),
763cdf0e10cSrcweir nCurFilterPos (0),
764cdf0e10cSrcweir nFirstExtFilterPos (0),
765cdf0e10cSrcweir bEntriesFound (sal_False),
766cdf0e10cSrcweir bInputAllowed (sal_True),
767cdf0e10cSrcweir bSearchRecursive (sal_False),
768cdf0e10cSrcweir xDialogListener ( new ::svt::DialogClosedListener() )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir FreeResource();
771cdf0e10cSrcweir
772cdf0e10cSrcweir xDialogListener->SetDialogClosedLink( LINK( this, TPGalleryThemeProperties, DialogClosedHdl ) );
773cdf0e10cSrcweir aLbxFound.SetAccessibleName(String(SVX_RES(RID_SVXSTR_GALLERY_FILESFOUND)));
774cdf0e10cSrcweir aWndPreview.SetAccessibleName(aCbxPreview.GetText());
775cdf0e10cSrcweir aLbxFound.SetAccessibleRelationLabeledBy(&aLbxFound);
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir // ------------------------------------------------------------------------
779cdf0e10cSrcweir
SetXChgData(ExchangeData * _pData)780cdf0e10cSrcweir void TPGalleryThemeProperties::SetXChgData( ExchangeData* _pData )
781cdf0e10cSrcweir {
782cdf0e10cSrcweir pData = _pData;
783cdf0e10cSrcweir
784cdf0e10cSrcweir aPreviewTimer.SetTimeoutHdl( LINK( this, TPGalleryThemeProperties, PreviewTimerHdl ) );
785cdf0e10cSrcweir aPreviewTimer.SetTimeout( 500 );
786cdf0e10cSrcweir aBtnSearch.SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickSearchHdl));
787cdf0e10cSrcweir aBtnTake.SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickTakeHdl));
788cdf0e10cSrcweir aBtnTakeAll.SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickTakeAllHdl));
789cdf0e10cSrcweir aCbxPreview.SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickPreviewHdl));
790cdf0e10cSrcweir aCbbFileType.SetSelectHdl(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl));
791cdf0e10cSrcweir aCbbFileType.EnableDDAutoWidth( sal_False );
792cdf0e10cSrcweir aLbxFound.SetDoubleClickHdl(LINK(this, TPGalleryThemeProperties, DClickFoundHdl));
793cdf0e10cSrcweir aLbxFound.SetSelectHdl(LINK(this, TPGalleryThemeProperties, SelectFoundHdl));
794cdf0e10cSrcweir aLbxFound.InsertEntry(String(CUI_RES(RID_SVXSTR_GALLERY_NOFILES)));
795cdf0e10cSrcweir aLbxFound.Show();
796cdf0e10cSrcweir
797cdf0e10cSrcweir FillFilterList();
798cdf0e10cSrcweir
799cdf0e10cSrcweir aBtnTake.Enable();
800cdf0e10cSrcweir aBtnTakeAll.Disable();
801cdf0e10cSrcweir aCbxPreview.Disable();
802cdf0e10cSrcweir }
803cdf0e10cSrcweir
804cdf0e10cSrcweir // ------------------------------------------------------------------------
805cdf0e10cSrcweir
StartSearchFiles(const String & _rFolderURL,short _nDlgResult)806cdf0e10cSrcweir void TPGalleryThemeProperties::StartSearchFiles( const String& _rFolderURL, short _nDlgResult )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir if ( RET_OK == _nDlgResult )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir aURL = INetURLObject( _rFolderURL );
811cdf0e10cSrcweir bSearchRecursive = sal_True; // UI choice no longer possible, windows file picker allows no user controls
812cdf0e10cSrcweir SearchFiles();
813cdf0e10cSrcweir }
814cdf0e10cSrcweir
815cdf0e10cSrcweir nCurFilterPos = aCbbFileType.GetEntryPos( aCbbFileType.GetText() );
816cdf0e10cSrcweir }
817cdf0e10cSrcweir
818cdf0e10cSrcweir // ------------------------------------------------------------------------
819cdf0e10cSrcweir
~TPGalleryThemeProperties()820cdf0e10cSrcweir TPGalleryThemeProperties::~TPGalleryThemeProperties()
821cdf0e10cSrcweir {
822cdf0e10cSrcweir xMediaPlayer.clear();
823cdf0e10cSrcweir xDialogListener.clear();
824cdf0e10cSrcweir
825cdf0e10cSrcweir for( String* pStr = aFoundList.First(); pStr; pStr = aFoundList.Next() )
826cdf0e10cSrcweir delete pStr;
827cdf0e10cSrcweir
828cdf0e10cSrcweir for( void* pEntry = aFilterEntryList.First(); pEntry; pEntry = aFilterEntryList.Next() )
829cdf0e10cSrcweir delete (FilterEntry*) pEntry;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
832cdf0e10cSrcweir // ------------------------------------------------------------------------
833cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rSet)834cdf0e10cSrcweir SfxTabPage* TPGalleryThemeProperties::Create( Window* pParent, const SfxItemSet& rSet )
835cdf0e10cSrcweir {
836cdf0e10cSrcweir return new TPGalleryThemeProperties( pParent, rSet );
837cdf0e10cSrcweir }
838cdf0e10cSrcweir
839cdf0e10cSrcweir // ------------------------------------------------------------------------
840cdf0e10cSrcweir
addExtension(const::rtl::OUString & _rDisplayText,const::rtl::OUString & _rExtension)841cdf0e10cSrcweir ::rtl::OUString TPGalleryThemeProperties::addExtension( const ::rtl::OUString& _rDisplayText, const ::rtl::OUString& _rExtension )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir ::rtl::OUString sAllFilter( RTL_CONSTASCII_USTRINGPARAM( "(*.*)" ) );
844cdf0e10cSrcweir ::rtl::OUString sOpenBracket( RTL_CONSTASCII_USTRINGPARAM( " (" ) );
845cdf0e10cSrcweir ::rtl::OUString sCloseBracket( RTL_CONSTASCII_USTRINGPARAM( ")" ) );
846cdf0e10cSrcweir ::rtl::OUString sRet = _rDisplayText;
847cdf0e10cSrcweir
848cdf0e10cSrcweir if ( sRet.indexOf( sAllFilter ) == -1 )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir String sExt = _rExtension;
851cdf0e10cSrcweir sRet += sOpenBracket;
852cdf0e10cSrcweir sRet += sExt;
853cdf0e10cSrcweir sRet += sCloseBracket;
854cdf0e10cSrcweir }
855cdf0e10cSrcweir return sRet;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir // ------------------------------------------------------------------------
859cdf0e10cSrcweir
FillFilterList()860cdf0e10cSrcweir void TPGalleryThemeProperties::FillFilterList()
861cdf0e10cSrcweir {
862cdf0e10cSrcweir GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
863cdf0e10cSrcweir String aExt;
864cdf0e10cSrcweir String aName;
865cdf0e10cSrcweir FilterEntry* pFilterEntry;
866cdf0e10cSrcweir FilterEntry* pTestEntry;
867cdf0e10cSrcweir sal_uInt16 i, nKeyCount;
868cdf0e10cSrcweir sal_Bool bInList;
869cdf0e10cSrcweir
870cdf0e10cSrcweir // graphic filters
871cdf0e10cSrcweir for( i = 0, nKeyCount = pFilter->GetImportFormatCount(); i < nKeyCount; i++ )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir aExt = pFilter->GetImportFormatShortName( i );
874cdf0e10cSrcweir aName = pFilter->GetImportFormatName( i );
875cdf0e10cSrcweir pTestEntry = (FilterEntry*) aFilterEntryList.First();
876cdf0e10cSrcweir bInList = sal_False;
877cdf0e10cSrcweir
878cdf0e10cSrcweir String aExtensions;
879cdf0e10cSrcweir int j = 0;
880cdf0e10cSrcweir String sWildcard;
881cdf0e10cSrcweir while( sal_True )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir sWildcard = pFilter->GetImportWildcard( i, j++ );
884cdf0e10cSrcweir if ( !sWildcard.Len() )
885cdf0e10cSrcweir break;
886cdf0e10cSrcweir if ( aExtensions.Search( sWildcard ) == STRING_NOTFOUND )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir if ( aExtensions.Len() )
889cdf0e10cSrcweir aExtensions += sal_Unicode(';');
890cdf0e10cSrcweir aExtensions += sWildcard;
891cdf0e10cSrcweir }
892cdf0e10cSrcweir }
893cdf0e10cSrcweir aName = addExtension( aName, aExtensions );
894cdf0e10cSrcweir
895cdf0e10cSrcweir while( pTestEntry )
896cdf0e10cSrcweir {
897cdf0e10cSrcweir if ( pTestEntry->aFilterName == aExt )
898cdf0e10cSrcweir {
899cdf0e10cSrcweir bInList = sal_True;
900cdf0e10cSrcweir break;
901cdf0e10cSrcweir }
902cdf0e10cSrcweir pTestEntry = (FilterEntry*) aFilterEntryList.Next();
903cdf0e10cSrcweir }
904cdf0e10cSrcweir if ( !bInList )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir pFilterEntry = new FilterEntry;
907cdf0e10cSrcweir pFilterEntry->aFilterName = aExt;
908cdf0e10cSrcweir aFilterEntryList.Insert( pFilterEntry, aCbbFileType.InsertEntry( aName ) );
909cdf0e10cSrcweir }
910cdf0e10cSrcweir }
911cdf0e10cSrcweir
912cdf0e10cSrcweir // media filters
913cdf0e10cSrcweir static const ::rtl::OUString aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) );
914cdf0e10cSrcweir ::avmedia::FilterNameVector aFilters;
915cdf0e10cSrcweir const ::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) );
916cdf0e10cSrcweir ::rtl::OUString aAllTypes;
917cdf0e10cSrcweir
918cdf0e10cSrcweir ::avmedia::MediaWindow::getMediaFilters( aFilters );
919cdf0e10cSrcweir
920cdf0e10cSrcweir for( unsigned long l = 0; l < aFilters.size(); ++l )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir for( sal_Int32 nIndex = 0; nIndex >= 0; )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir ::rtl::OUString aFilterWildcard( aWildcard );
925cdf0e10cSrcweir
926cdf0e10cSrcweir pFilterEntry = new FilterEntry;
927cdf0e10cSrcweir pFilterEntry->aFilterName = aFilters[ l ].second.getToken( 0, ';', nIndex );
928cdf0e10cSrcweir nFirstExtFilterPos = aCbbFileType.InsertEntry( addExtension( aFilters[ l ].first,
929cdf0e10cSrcweir aFilterWildcard += pFilterEntry->aFilterName ) );
930cdf0e10cSrcweir aFilterEntryList.Insert( pFilterEntry, nFirstExtFilterPos );
931cdf0e10cSrcweir }
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
934cdf0e10cSrcweir // 'All' filters
935cdf0e10cSrcweir String aExtensions;
936cdf0e10cSrcweir
937cdf0e10cSrcweir // graphic filters
938cdf0e10cSrcweir for ( i = 0; i < nKeyCount; ++i )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir int j = 0;
941cdf0e10cSrcweir String sWildcard;
942cdf0e10cSrcweir while( sal_True )
943cdf0e10cSrcweir {
944cdf0e10cSrcweir sWildcard = pFilter->GetImportWildcard( i, j++ );
945cdf0e10cSrcweir if ( !sWildcard.Len() )
946cdf0e10cSrcweir break;
947cdf0e10cSrcweir if ( aExtensions.Search( sWildcard ) == STRING_NOTFOUND )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir if ( aExtensions.Len() )
950cdf0e10cSrcweir aExtensions += sal_Unicode( ';' );
951cdf0e10cSrcweir
952cdf0e10cSrcweir aExtensions += sWildcard;
953cdf0e10cSrcweir }
954cdf0e10cSrcweir }
955cdf0e10cSrcweir }
956cdf0e10cSrcweir
957cdf0e10cSrcweir // media filters
958cdf0e10cSrcweir for( unsigned long k = 0; k < aFilters.size(); ++k )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir for( sal_Int32 nIndex = 0; nIndex >= 0; )
961cdf0e10cSrcweir {
962cdf0e10cSrcweir if ( aExtensions.Len() )
963cdf0e10cSrcweir aExtensions += sal_Unicode( ';' );
964cdf0e10cSrcweir ( aExtensions += String( aWildcard ) ) += String( aFilters[ k ].second.getToken( 0, ';', nIndex ) );
965cdf0e10cSrcweir }
966cdf0e10cSrcweir }
967cdf0e10cSrcweir
968cdf0e10cSrcweir #if defined(WNT)
969cdf0e10cSrcweir if ( aExtensions.Len() > 240 )
970cdf0e10cSrcweir aExtensions = DEFINE_CONST_UNICODE( "*.*" );
971cdf0e10cSrcweir #endif
972cdf0e10cSrcweir
973cdf0e10cSrcweir pFilterEntry = new FilterEntry;
974cdf0e10cSrcweir pFilterEntry->aFilterName = String( CUI_RES( RID_SVXSTR_GALLERY_ALLFILES ) );
975cdf0e10cSrcweir pFilterEntry->aFilterName = addExtension( pFilterEntry->aFilterName, aExtensions );
976cdf0e10cSrcweir aFilterEntryList.Insert(pFilterEntry, aCbbFileType. InsertEntry( pFilterEntry->aFilterName, 0 ) );
977cdf0e10cSrcweir
978cdf0e10cSrcweir aCbbFileType.SetText( pFilterEntry->aFilterName );
979cdf0e10cSrcweir }
980cdf0e10cSrcweir
981cdf0e10cSrcweir // ------------------------------------------------------------------------
982cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,SelectFileTypeHdl,void *,EMPTYARG)983cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, SelectFileTypeHdl, void *, EMPTYARG )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir String aText( aCbbFileType.GetText() );
986cdf0e10cSrcweir
987cdf0e10cSrcweir if( bInputAllowed && ( aLastFilterName != aText ) )
988cdf0e10cSrcweir {
989cdf0e10cSrcweir aLastFilterName = aText;
990cdf0e10cSrcweir
991cdf0e10cSrcweir if( QueryBox( this, WB_YES_NO, String( CUI_RES( RID_SVXSTR_GALLERY_SEARCH ) ) ).Execute() == RET_YES )
992cdf0e10cSrcweir SearchFiles();
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
995cdf0e10cSrcweir return 0L;
996cdf0e10cSrcweir }
997cdf0e10cSrcweir
998cdf0e10cSrcweir // ------------------------------------------------------------------------
999cdf0e10cSrcweir
SearchFiles()1000cdf0e10cSrcweir void TPGalleryThemeProperties::SearchFiles()
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir SearchProgress* pProgress = new SearchProgress( this, aURL );
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir for( String* pStr = aFoundList.First(); pStr; pStr = aFoundList.Next() )
1005cdf0e10cSrcweir delete pStr;
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir aFoundList.Clear();
1008cdf0e10cSrcweir aLbxFound.Clear();
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir pProgress->SetFileType( aCbbFileType.GetText() );
1011cdf0e10cSrcweir pProgress->SetDirectory( rtl::OUString() );
1012cdf0e10cSrcweir pProgress->Update();
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir pProgress->StartExecuteModal( LINK( this, TPGalleryThemeProperties, EndSearchProgressHdl ) );
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir // ------------------------------------------------------------------------
1018cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,ClickCloseBrowserHdl,void *,EMPTYARG)1019cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, ClickCloseBrowserHdl, void *, EMPTYARG )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir if( bInputAllowed )
1022cdf0e10cSrcweir aPreviewTimer.Stop();
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir return 0L;
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir // ------------------------------------------------------------------------
1028cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,ClickSearchHdl,void *,EMPTYARG)1029cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, ClickSearchHdl, void *, EMPTYARG )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir if( bInputAllowed )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir try
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir // setup folder picker
1036cdf0e10cSrcweir ::com::sun::star::uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
1037cdf0e10cSrcweir if( xMgr.is() )
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir xFolderPicker = ::com::sun::star::uno::Reference< XFolderPicker >(
1040cdf0e10cSrcweir xMgr->createInstance( OUString::createFromAscii( "com.sun.star.ui.dialogs.FolderPicker" )), UNO_QUERY );
1041cdf0e10cSrcweir
1042cdf0e10cSrcweir if ( xFolderPicker.is() )
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir String aDlgPathName( SvtPathOptions().GetGraphicPath() );
1045cdf0e10cSrcweir xFolderPicker->setDisplayDirectory(aDlgPathName);
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir aPreviewTimer.Stop();
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
1050cdf0e10cSrcweir if ( xAsyncDlg.is() )
1051cdf0e10cSrcweir xAsyncDlg->startExecuteModal( xDialogListener.get() );
1052cdf0e10cSrcweir else
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir if( xFolderPicker->execute() == RET_OK )
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir aURL = INetURLObject( xFolderPicker->getDirectory() );
1057cdf0e10cSrcweir bSearchRecursive = sal_True; // UI choice no longer possible, windows file picker allows no user controls
1058cdf0e10cSrcweir SearchFiles();
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir nCurFilterPos = aCbbFileType.GetEntryPos( aCbbFileType.GetText() );
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir catch(IllegalArgumentException)
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir #ifdef DBG_UTIL
1069cdf0e10cSrcweir DBG_ERROR( "Folder picker failed with illegal arguments" );
1070cdf0e10cSrcweir #endif
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir return 0L;
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir // ------------------------------------------------------------------------
1078cdf0e10cSrcweir
TakeFiles()1079cdf0e10cSrcweir void TPGalleryThemeProperties::TakeFiles()
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir if( aLbxFound.GetSelectEntryCount() || ( bTakeAll && bEntriesFound ) )
1082cdf0e10cSrcweir {
1083cdf0e10cSrcweir TakeProgress* pTakeProgress = new TakeProgress( this );
1084cdf0e10cSrcweir pTakeProgress->Update();
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir pTakeProgress->StartExecuteModal(
1087cdf0e10cSrcweir Link() /* no postprocessing needed, pTakeProgress
1088cdf0e10cSrcweir will be deleted in TakeProgress::CleanupHdl */ );
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir // ------------------------------------------------------------------------
1093cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,ClickPreviewHdl,void *,EMPTYARG)1094cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, ClickPreviewHdl, void *, EMPTYARG )
1095cdf0e10cSrcweir {
1096cdf0e10cSrcweir if ( bInputAllowed )
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir aPreviewTimer.Stop();
1099cdf0e10cSrcweir aPreviewString.Erase();
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir if( !aCbxPreview.IsChecked() )
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir xMediaPlayer.clear();
1104cdf0e10cSrcweir aWndPreview.SetGraphic( Graphic() );
1105cdf0e10cSrcweir aWndPreview.Invalidate();
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir else
1108cdf0e10cSrcweir DoPreview();
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir return 0;
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir // ------------------------------------------------------------------------
1115cdf0e10cSrcweir
DoPreview()1116cdf0e10cSrcweir void TPGalleryThemeProperties::DoPreview()
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir String aString( aLbxFound.GetSelectEntry() );
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir if( aString != aPreviewString )
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir INetURLObject _aURL( *aFoundList.GetObject( aLbxFound.GetEntryPos( aString ) ) );
1123cdf0e10cSrcweir bInputAllowed = sal_False;
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir if ( !aWndPreview.SetGraphic( _aURL ) )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir GetParent()->LeaveWait();
1128cdf0e10cSrcweir ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTSPATH );
1129cdf0e10cSrcweir GetParent()->EnterWait();
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir else if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir xMediaPlayer = ::avmedia::MediaWindow::createPlayer( _aURL.GetMainURL( INetURLObject::NO_DECODE ) );
1134cdf0e10cSrcweir if( xMediaPlayer.is() )
1135cdf0e10cSrcweir xMediaPlayer->start();
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir
1138cdf0e10cSrcweir bInputAllowed = sal_True;
1139cdf0e10cSrcweir aPreviewString = aString;
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir // ------------------------------------------------------------------------
1144cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,ClickTakeHdl,void *,EMPTYARG)1145cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, ClickTakeHdl, void*, EMPTYARG )
1146cdf0e10cSrcweir {
1147cdf0e10cSrcweir if( bInputAllowed )
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir aPreviewTimer.Stop();
1150cdf0e10cSrcweir
1151cdf0e10cSrcweir if( !aLbxFound.GetSelectEntryCount() || !bEntriesFound )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir SvxOpenGraphicDialog aDlg(String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) ) );
1154cdf0e10cSrcweir aDlg.EnableLink(sal_False);
1155cdf0e10cSrcweir aDlg.AsLink(sal_False);
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir if( !aDlg.Execute() )
1158cdf0e10cSrcweir pData->pTheme->InsertURL( INetURLObject( aDlg.GetPath() ) );
1159cdf0e10cSrcweir }
1160cdf0e10cSrcweir else
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir bTakeAll = sal_False;
1163cdf0e10cSrcweir TakeFiles();
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir }
1166cdf0e10cSrcweir
1167cdf0e10cSrcweir return 0L;
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir // ------------------------------------------------------------------------
1171cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,ClickTakeAllHdl,void *,EMPTYARG)1172cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, ClickTakeAllHdl, void *, EMPTYARG )
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir if( bInputAllowed )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir aPreviewTimer.Stop();
1177cdf0e10cSrcweir bTakeAll = sal_True;
1178cdf0e10cSrcweir TakeFiles();
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir return 0L;
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir
1184cdf0e10cSrcweir // ------------------------------------------------------------------------
1185cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,SelectFoundHdl,void *,EMPTYARG)1186cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, SelectFoundHdl, void *, EMPTYARG )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir if( bInputAllowed )
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir sal_Bool bPreviewPossible = sal_False;
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir aPreviewTimer.Stop();
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir if( bEntriesFound )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir if( aLbxFound.GetSelectEntryCount() == 1 )
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir aCbxPreview.Enable();
1199cdf0e10cSrcweir bPreviewPossible = sal_True;
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir else
1202cdf0e10cSrcweir aCbxPreview.Disable();
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir if( aFoundList.Count() )
1205cdf0e10cSrcweir aBtnTakeAll.Enable();
1206cdf0e10cSrcweir else
1207cdf0e10cSrcweir aBtnTakeAll.Disable();
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir if( bPreviewPossible && aCbxPreview.IsChecked() )
1211cdf0e10cSrcweir aPreviewTimer.Start();
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir return 0;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir // ------------------------------------------------------------------------
1218cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,DClickFoundHdl,void *,EMPTYARG)1219cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, DClickFoundHdl, void *, EMPTYARG )
1220cdf0e10cSrcweir {
1221cdf0e10cSrcweir if( bInputAllowed )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir aPreviewTimer.Stop();
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir return (aLbxFound.GetSelectEntryCount() == 1 && bEntriesFound) ?
1226cdf0e10cSrcweir ClickTakeHdl(NULL) : 0;
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir else
1229cdf0e10cSrcweir return 0;
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir // ------------------------------------------------------------------------
1233cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,PreviewTimerHdl,void *,EMPTYARG)1234cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, PreviewTimerHdl, void *, EMPTYARG )
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir aPreviewTimer.Stop();
1237cdf0e10cSrcweir DoPreview();
1238cdf0e10cSrcweir return 0L;
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir // ------------------------------------------------------------------------
1242cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,EndSearchProgressHdl,SearchProgress *,EMPTYARG)1243cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, EndSearchProgressHdl, SearchProgress *, EMPTYARG )
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir if( aFoundList.Count() )
1246cdf0e10cSrcweir {
1247cdf0e10cSrcweir aLbxFound.SelectEntryPos( 0 );
1248cdf0e10cSrcweir aBtnTakeAll.Enable();
1249cdf0e10cSrcweir aCbxPreview.Enable();
1250cdf0e10cSrcweir bEntriesFound = sal_True;
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir else
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir aLbxFound.InsertEntry( String( CUI_RES( RID_SVXSTR_GALLERY_NOFILES ) ) );
1255cdf0e10cSrcweir aBtnTakeAll.Disable();
1256cdf0e10cSrcweir aCbxPreview.Disable();
1257cdf0e10cSrcweir bEntriesFound = sal_False;
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir return 0L;
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir // ------------------------------------------------------------------------
1263cdf0e10cSrcweir
IMPL_LINK(TPGalleryThemeProperties,DialogClosedHdl,::com::sun::star::ui::dialogs::DialogClosedEvent *,pEvt)1264cdf0e10cSrcweir IMPL_LINK( TPGalleryThemeProperties, DialogClosedHdl, ::com::sun::star::ui::dialogs::DialogClosedEvent*, pEvt )
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir DBG_ASSERT( xFolderPicker.is() == sal_True, "TPGalleryThemeProperties::DialogClosedHdl(): no folder picker" );
1267cdf0e10cSrcweir
1268cdf0e10cSrcweir String sURL = String( xFolderPicker->getDirectory() );
1269cdf0e10cSrcweir StartSearchFiles( sURL, pEvt->DialogResult );
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir return 0L;
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir
1274