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