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_svtools.hxx" 30*cdf0e10cSrcweir #include "contentenumeration.hxx" 31*cdf0e10cSrcweir #include <svl/urlfilter.hxx> 32*cdf0e10cSrcweir #include <svtools/inettbc.hxx> 33*cdf0e10cSrcweir #include <svtools/imagemgr.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir /** === begin UNO includes === **/ 36*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 43*cdf0e10cSrcweir /** === end UNO includes === **/ 44*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 45*cdf0e10cSrcweir #include <tools/debug.hxx> 46*cdf0e10cSrcweir #include <vcl/svapp.hxx> 47*cdf0e10cSrcweir #include <vos/mutex.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <memory> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir //........................................................................ 52*cdf0e10cSrcweir namespace svt 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir //........................................................................ 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #define ROW_TITLE 1 57*cdf0e10cSrcweir #define ROW_SIZE 2 58*cdf0e10cSrcweir #define ROW_DATE_MOD 3 59*cdf0e10cSrcweir #define ROW_DATE_CREATE 4 60*cdf0e10cSrcweir #define ROW_IS_FOLDER 5 61*cdf0e10cSrcweir #define ROW_TARGET_URL 6 62*cdf0e10cSrcweir #define ROW_IS_HIDDEN 7 63*cdf0e10cSrcweir #define ROW_IS_VOLUME 8 64*cdf0e10cSrcweir #define ROW_IS_REMOTE 9 65*cdf0e10cSrcweir #define ROW_IS_REMOVEABLE 10 66*cdf0e10cSrcweir #define ROW_IS_FLOPPY 11 67*cdf0e10cSrcweir #define ROW_IS_COMPACTDISC 12 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir #define CONVERT_DATETIME( aUnoDT, aToolsDT ) \ 70*cdf0e10cSrcweir aToolsDT = ::DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \ 71*cdf0e10cSrcweir Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds ) ); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 74*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 75*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 76*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 77*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 78*cdf0e10cSrcweir using ::com::sun::star::util::DateTime; 79*cdf0e10cSrcweir using ::com::sun::star::sdbc::XResultSet; 80*cdf0e10cSrcweir using ::com::sun::star::sdbc::XRow; 81*cdf0e10cSrcweir using ::com::sun::star::ucb::XDynamicResultSet; 82*cdf0e10cSrcweir using ::com::sun::star::ucb::CommandAbortedException; 83*cdf0e10cSrcweir using ::com::sun::star::ucb::XContentAccess; 84*cdf0e10cSrcweir using ::com::sun::star::ucb::XCommandEnvironment; 85*cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 86*cdf0e10cSrcweir using ::rtl::OUString; 87*cdf0e10cSrcweir using ::ucbhelper::ResultSetInclude; 88*cdf0e10cSrcweir using ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir //==================================================================== 91*cdf0e10cSrcweir //= FileViewContentEnumerator 92*cdf0e10cSrcweir //==================================================================== 93*cdf0e10cSrcweir //-------------------------------------------------------------------- 94*cdf0e10cSrcweir FileViewContentEnumerator::FileViewContentEnumerator( 95*cdf0e10cSrcweir const Reference< XCommandEnvironment >& _rxCommandEnv, 96*cdf0e10cSrcweir ContentData& _rContentToFill, ::osl::Mutex& _rContentMutex, 97*cdf0e10cSrcweir const IContentTitleTranslation* _pTranslator ) 98*cdf0e10cSrcweir :m_rContent ( _rContentToFill ) 99*cdf0e10cSrcweir ,m_rContentMutex ( _rContentMutex ) 100*cdf0e10cSrcweir ,m_refCount ( 0 ) 101*cdf0e10cSrcweir ,m_xCommandEnv ( _rxCommandEnv ) 102*cdf0e10cSrcweir ,m_pFilter ( NULL ) 103*cdf0e10cSrcweir ,m_pTranslator ( _pTranslator ) 104*cdf0e10cSrcweir ,m_bCancelled ( false ) 105*cdf0e10cSrcweir ,m_rBlackList ( ::com::sun::star::uno::Sequence< ::rtl::OUString >() ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir //-------------------------------------------------------------------- 110*cdf0e10cSrcweir FileViewContentEnumerator::~FileViewContentEnumerator() 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir //-------------------------------------------------------------------- 115*cdf0e10cSrcweir void FileViewContentEnumerator::cancel() 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 118*cdf0e10cSrcweir m_bCancelled = true; 119*cdf0e10cSrcweir m_pResultHandler = NULL; 120*cdf0e10cSrcweir m_pTranslator = NULL; 121*cdf0e10cSrcweir m_pFilter = NULL; 122*cdf0e10cSrcweir m_aFolder.aContent = ::ucbhelper::Content(); 123*cdf0e10cSrcweir m_aFolder.sURL = String(); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //-------------------------------------------------------------------- 127*cdf0e10cSrcweir EnumerationResult FileViewContentEnumerator::enumerateFolderContentSync( 128*cdf0e10cSrcweir const FolderDescriptor& _rFolder, 129*cdf0e10cSrcweir const IUrlFilter* _pFilter, 130*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 134*cdf0e10cSrcweir m_aFolder = _rFolder; 135*cdf0e10cSrcweir m_pFilter = _pFilter; 136*cdf0e10cSrcweir m_pResultHandler = NULL; 137*cdf0e10cSrcweir m_rBlackList = rBlackList; 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir return enumerateFolderContent(); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir //-------------------------------------------------------------------- 143*cdf0e10cSrcweir void FileViewContentEnumerator::enumerateFolderContent( 144*cdf0e10cSrcweir const FolderDescriptor& _rFolder, const IUrlFilter* _pFilter, IEnumerationResultHandler* _pResultHandler ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir // ensure that we don't get deleted while herein 147*cdf0e10cSrcweir acquire(); 148*cdf0e10cSrcweir // the matching "release" will be called in onTerminated 149*cdf0e10cSrcweir // Note that onTerminated is only called if run was left normally. 150*cdf0e10cSrcweir // If somebody terminates the thread from the outside, then onTerminated 151*cdf0e10cSrcweir // will never be called. However, our terminate method is not accessible 152*cdf0e10cSrcweir // to our clients, so the only class which could misbehave is this class 153*cdf0e10cSrcweir // here itself ... 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 156*cdf0e10cSrcweir m_aFolder = _rFolder; 157*cdf0e10cSrcweir m_pFilter = _pFilter; 158*cdf0e10cSrcweir m_pResultHandler = _pResultHandler; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir OSL_ENSURE( m_aFolder.aContent.get().is() || m_aFolder.sURL.Len(), 161*cdf0e10cSrcweir "FileViewContentEnumerator::enumerateFolderContent: invalid folder descriptor!" ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // start the thread 164*cdf0e10cSrcweir create(); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir //-------------------------------------------------------------------- 168*cdf0e10cSrcweir oslInterlockedCount SAL_CALL FileViewContentEnumerator::acquire() 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir return osl_incrementInterlockedCount( &m_refCount ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //-------------------------------------------------------------------- 174*cdf0e10cSrcweir oslInterlockedCount SAL_CALL FileViewContentEnumerator::release() 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir if ( 0 == osl_decrementInterlockedCount( &m_refCount ) ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir delete this; 179*cdf0e10cSrcweir return 0; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir return m_refCount; 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir //-------------------------------------------------------------------- 185*cdf0e10cSrcweir EnumerationResult FileViewContentEnumerator::enumerateFolderContent() 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir EnumerationResult eResult = ERROR; 188*cdf0e10cSrcweir try 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir Reference< XResultSet > xResultSet; 192*cdf0e10cSrcweir Sequence< OUString > aProps(12); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir aProps[0] = OUString::createFromAscii( "Title" ); 195*cdf0e10cSrcweir aProps[1] = OUString::createFromAscii( "Size" ); 196*cdf0e10cSrcweir aProps[2] = OUString::createFromAscii( "DateModified" ); 197*cdf0e10cSrcweir aProps[3] = OUString::createFromAscii( "DateCreated" ); 198*cdf0e10cSrcweir aProps[4] = OUString::createFromAscii( "IsFolder" ); 199*cdf0e10cSrcweir aProps[5] = OUString::createFromAscii( "TargetURL" ); 200*cdf0e10cSrcweir aProps[6] = OUString::createFromAscii( "IsHidden" ); 201*cdf0e10cSrcweir aProps[7] = OUString::createFromAscii( "IsVolume" ); 202*cdf0e10cSrcweir aProps[8] = OUString::createFromAscii( "IsRemote" ); 203*cdf0e10cSrcweir aProps[9] = OUString::createFromAscii( "IsRemoveable" ); 204*cdf0e10cSrcweir aProps[10] = OUString::createFromAscii( "IsFloppy" ); 205*cdf0e10cSrcweir aProps[11] = OUString::createFromAscii( "IsCompactDisc" ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir Reference< XCommandEnvironment > xEnvironment; 208*cdf0e10cSrcweir try 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir FolderDescriptor aFolder; 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 213*cdf0e10cSrcweir aFolder = m_aFolder; 214*cdf0e10cSrcweir xEnvironment = m_xCommandEnv; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir if ( !aFolder.aContent.get().is() ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir aFolder.aContent = ::ucbhelper::Content( aFolder.sURL, xEnvironment ); 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 221*cdf0e10cSrcweir m_aFolder.aContent = aFolder.aContent; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir Reference< XDynamicResultSet > xDynResultSet; 226*cdf0e10cSrcweir ResultSetInclude eInclude = INCLUDE_FOLDERS_AND_DOCUMENTS; 227*cdf0e10cSrcweir xDynResultSet = aFolder.aContent.createDynamicCursor( aProps, eInclude ); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir if ( xDynResultSet.is() ) 230*cdf0e10cSrcweir xResultSet = xDynResultSet->getStaticResultSet(); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir catch( CommandAbortedException& ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir DBG_ERRORFILE( "createCursor: CommandAbortedException" ); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir catch( Exception& ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir bool bCancelled = false; 241*cdf0e10cSrcweir if ( xResultSet.is() ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir Reference< XRow > xRow( xResultSet, UNO_QUERY ); 244*cdf0e10cSrcweir Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir try 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir SortingData_Impl* pData; 249*cdf0e10cSrcweir DateTime aDT; 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir while ( !bCancelled && xResultSet->next() ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir sal_Bool bIsHidden = xRow->getBoolean( ROW_IS_HIDDEN ); 254*cdf0e10cSrcweir // don't show hidden files 255*cdf0e10cSrcweir if ( !bIsHidden || xRow->wasNull() ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir pData = NULL; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir aDT = xRow->getTimestamp( ROW_DATE_MOD ); 260*cdf0e10cSrcweir sal_Bool bContainsDate = !xRow->wasNull(); 261*cdf0e10cSrcweir if ( !bContainsDate ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir aDT = xRow->getTimestamp( ROW_DATE_CREATE ); 264*cdf0e10cSrcweir bContainsDate = !xRow->wasNull(); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir OUString aContentURL = xContentAccess->queryContentIdentifierString(); 268*cdf0e10cSrcweir OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); 269*cdf0e10cSrcweir sal_Bool bHasTargetURL = !xRow->wasNull() && aTargetURL.getLength() > 0; 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir OUString sRealURL = bHasTargetURL ? aTargetURL : aContentURL; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir // check for restrictions 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 276*cdf0e10cSrcweir if ( m_pFilter && !m_pFilter->isUrlAllowed( sRealURL ) ) 277*cdf0e10cSrcweir continue; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir if ( /* m_rBlackList.hasElements() && */ URLOnBlackList ( sRealURL ) ) 280*cdf0e10cSrcweir continue; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir pData = new SortingData_Impl; 284*cdf0e10cSrcweir pData->maTargetURL = sRealURL; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir pData->mbIsFolder = xRow->getBoolean( ROW_IS_FOLDER ) && !xRow->wasNull(); 287*cdf0e10cSrcweir pData->mbIsVolume = xRow->getBoolean( ROW_IS_VOLUME ) && !xRow->wasNull(); 288*cdf0e10cSrcweir pData->mbIsRemote = xRow->getBoolean( ROW_IS_REMOTE ) && !xRow->wasNull(); 289*cdf0e10cSrcweir pData->mbIsRemoveable = xRow->getBoolean( ROW_IS_REMOVEABLE ) && !xRow->wasNull(); 290*cdf0e10cSrcweir pData->mbIsFloppy = xRow->getBoolean( ROW_IS_FLOPPY ) && !xRow->wasNull(); 291*cdf0e10cSrcweir pData->mbIsCompactDisc = xRow->getBoolean( ROW_IS_COMPACTDISC ) && !xRow->wasNull(); 292*cdf0e10cSrcweir pData->SetNewTitle( xRow->getString( ROW_TITLE ) ); 293*cdf0e10cSrcweir pData->maSize = xRow->getLong( ROW_SIZE ); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir if ( bHasTargetURL && 296*cdf0e10cSrcweir INetURLObject( aContentURL ).GetProtocol() == INET_PROT_VND_SUN_STAR_HIER ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir ::ucbhelper::Content aCnt( aTargetURL, xEnvironment ); 299*cdf0e10cSrcweir try 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir aCnt.getPropertyValue( OUString::createFromAscii( "Size" ) ) >>= pData->maSize; 302*cdf0e10cSrcweir aCnt.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aDT; 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir catch (...) {} 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir if ( bContainsDate ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir CONVERT_DATETIME( aDT, pData->maModDate ); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir if ( pData->mbIsFolder ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 315*cdf0e10cSrcweir ::svtools::VolumeInfo aVolInfo( pData->mbIsVolume, pData->mbIsRemote, 316*cdf0e10cSrcweir pData->mbIsRemoveable, pData->mbIsFloppy, 317*cdf0e10cSrcweir pData->mbIsCompactDisc ); 318*cdf0e10cSrcweir pData->maType = SvFileInformationManager::GetFolderDescription( aVolInfo ); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir else 321*cdf0e10cSrcweir pData->maType = SvFileInformationManager::GetFileDescription( 322*cdf0e10cSrcweir INetURLObject( pData->maTargetURL ) ); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir // replace names on demand 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 327*cdf0e10cSrcweir if( m_pTranslator ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir OUString sNewTitle; 330*cdf0e10cSrcweir sal_Bool bTranslated = sal_False; 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir if ( pData->mbIsFolder ) 333*cdf0e10cSrcweir bTranslated = m_pTranslator->GetTranslation( pData->GetTitle(), sNewTitle ); 334*cdf0e10cSrcweir else 335*cdf0e10cSrcweir bTranslated = implGetDocTitle( pData->maTargetURL, sNewTitle ); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir if ( bTranslated ) 338*cdf0e10cSrcweir pData->ChangeTitle( sNewTitle ); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_rContentMutex ); 344*cdf0e10cSrcweir m_rContent.push_back( pData ); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 350*cdf0e10cSrcweir bCancelled = m_bCancelled; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir eResult = SUCCESS; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir catch( CommandAbortedException& ) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir DBG_ERRORFILE( "FileViewContentEnumerator::enumerateFolderContent: caught an CommandAbortedException while enumerating!" ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir catch( Exception& ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir DBG_ERRORFILE( "FileViewContentEnumerator::enumerateFolderContent: caught an exception other than CommandAbortedException while enumerating!" ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir catch( CommandAbortedException& ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir DBG_ERRORFILE( "FileViewContentEnumerator::enumerateFolderContent: caught an CommandAbortedException!" ); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir catch( Exception& ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir DBG_ERRORFILE( "FileViewContentEnumerator::enumerateFolderContent: caught an exception other than CommandAbortedException!" ); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir IEnumerationResultHandler* pHandler = NULL; 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 377*cdf0e10cSrcweir pHandler = m_pResultHandler; 378*cdf0e10cSrcweir if ( m_bCancelled ) 379*cdf0e10cSrcweir return ERROR; 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_rContentMutex ); 384*cdf0e10cSrcweir if ( eResult != SUCCESS ) 385*cdf0e10cSrcweir // clear any "intermediate" and unfinished result 386*cdf0e10cSrcweir m_rContent.clear(); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir if ( pHandler ) 390*cdf0e10cSrcweir pHandler->enumerationDone( eResult ); 391*cdf0e10cSrcweir return eResult; 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir //-------------------------------------------------------------------- 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir sal_Bool FileViewContentEnumerator::URLOnBlackList ( const ::rtl::OUString& sRealURL ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir ::rtl::OUString entryName = sRealURL.copy( sRealURL.lastIndexOf( rtl::OUString::createFromAscii("/")) +1 ); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir for (int i = 0; i < m_rBlackList.getLength() ; i++) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir if ( entryName.equals( m_rBlackList[i] ) ) 403*cdf0e10cSrcweir return true; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir return false; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir //-------------------------------------------------------------------- 410*cdf0e10cSrcweir sal_Bool FileViewContentEnumerator::implGetDocTitle( const OUString& _rTargetURL, OUString& _rRet ) const 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir sal_Bool bRet = sal_False; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir try 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 417*cdf0e10cSrcweir if( !m_xDocInfo.is() ) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir m_xDocInfo = m_xDocInfo.query( 420*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( 421*cdf0e10cSrcweir String( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.StandaloneDocumentInfo") ) 422*cdf0e10cSrcweir ) 423*cdf0e10cSrcweir ); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir DBG_ASSERT( m_xDocInfo.is(), "FileViewContentEnumerator::implGetDocTitle: no DocumentProperties service!" ); 427*cdf0e10cSrcweir if ( !m_xDocInfo.is() ) 428*cdf0e10cSrcweir return sal_False; 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir m_xDocInfo->loadFromURL( _rTargetURL ); 431*cdf0e10cSrcweir Reference< XPropertySet > xPropSet( m_xDocInfo, UNO_QUERY ); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir Any aAny = xPropSet->getPropertyValue( OUString::createFromAscii( "Title" ) ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir OUString sTitle; 436*cdf0e10cSrcweir if ( ( aAny >>= sTitle ) && sTitle.getLength() > 0 ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir _rRet = sTitle; 439*cdf0e10cSrcweir bRet = sal_True; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir catch ( const Exception& ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir return bRet; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir //-------------------------------------------------------------------- 450*cdf0e10cSrcweir void SAL_CALL FileViewContentEnumerator::run() 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir enumerateFolderContent(); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir //-------------------------------------------------------------------- 456*cdf0e10cSrcweir void SAL_CALL FileViewContentEnumerator::onTerminated() 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir release(); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir //........................................................................ 462*cdf0e10cSrcweir } // namespace svt 463*cdf0e10cSrcweir //........................................................................ 464*cdf0e10cSrcweir 465