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 31*cdf0e10cSrcweir #include <svtools/fileview.hxx> 32*cdf0e10cSrcweir #include <svtools/svtdata.hxx> 33*cdf0e10cSrcweir #include <svtools/imagemgr.hxx> 34*cdf0e10cSrcweir #include <svtools/headbar.hxx> 35*cdf0e10cSrcweir #include <svtools/svtabbx.hxx> 36*cdf0e10cSrcweir #include <svtools/svtools.hrc> 37*cdf0e10cSrcweir #include "fileview.hrc" 38*cdf0e10cSrcweir #include "contentenumeration.hxx" 39*cdf0e10cSrcweir #include <svtools/AccessibleBrowseBoxObjType.hxx> 40*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/ucb/XProgressHandler.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/ucb/XAnyCompareFactory.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/ucb/ContentCreationException.hpp> 53*cdf0e10cSrcweir #include <vcl/waitobj.hxx> 54*cdf0e10cSrcweir #include <com/sun/star/io/XPersist.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #include <algorithm> 61*cdf0e10cSrcweir #include <memory> 62*cdf0e10cSrcweir #include <tools/urlobj.hxx> 63*cdf0e10cSrcweir #include <tools/datetime.hxx> 64*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 65*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 66*cdf0e10cSrcweir #include <ucbhelper/content.hxx> 67*cdf0e10cSrcweir #include <ucbhelper/commandenvironment.hxx> 68*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 69*cdf0e10cSrcweir #ifndef INCLUDED_RTL_MATH_H 70*cdf0e10cSrcweir #include <rtl/math.hxx> 71*cdf0e10cSrcweir #endif 72*cdf0e10cSrcweir #include <tools/config.hxx> 73*cdf0e10cSrcweir #include <osl/mutex.hxx> 74*cdf0e10cSrcweir #include <osl/conditn.hxx> 75*cdf0e10cSrcweir #include <vos/timer.hxx> 76*cdf0e10cSrcweir #include <vcl/svapp.hxx> 77*cdf0e10cSrcweir #include <vcl/sound.hxx> 78*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 79*cdf0e10cSrcweir #include <unotools/intlwrapper.hxx> 80*cdf0e10cSrcweir #include <unotools/syslocale.hxx> 81*cdf0e10cSrcweir #include <svl/urlfilter.hxx> 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 84*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 85*cdf0e10cSrcweir using namespace ::com::sun::star::task; 86*cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 87*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 88*cdf0e10cSrcweir using namespace ::com::sun::star::io; 89*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 90*cdf0e10cSrcweir using namespace ::comphelper; 91*cdf0e10cSrcweir using ::svt::SortingData_Impl; 92*cdf0e10cSrcweir using ::svt::FolderDescriptor; 93*cdf0e10cSrcweir using ::vos::TTimeValue; 94*cdf0e10cSrcweir using ::rtl::OUString; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir #define ALL_FILES_FILTER "*.*" 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir #define COLUMN_TITLE 1 99*cdf0e10cSrcweir #define COLUMN_TYPE 2 100*cdf0e10cSrcweir #define COLUMN_SIZE 3 101*cdf0e10cSrcweir #define COLUMN_DATE 4 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir DECLARE_LIST( StringList_Impl, OUString* ) 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir #define ROW_HEIGHT 17 // the height of a row has to be a little higher than the bitmap 106*cdf0e10cSrcweir #define QUICK_SEARCH_TIMEOUT 1500 // time in mSec before the quicksearch string will be reseted 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir namespace 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir //==================================================================== 111*cdf0e10cSrcweir //= ReleaseSolarMutex 112*cdf0e10cSrcweir //==================================================================== 113*cdf0e10cSrcweir struct ReleaseSolarMutex 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir private: 116*cdf0e10cSrcweir sal_uLong m_nCount; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir public: 119*cdf0e10cSrcweir inline ReleaseSolarMutex() 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir m_nCount = Application::ReleaseSolarMutex(); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir inline ~ReleaseSolarMutex() 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir Application::AcquireSolarMutex( m_nCount ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir }; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir //==================================================================== 130*cdf0e10cSrcweir //= ITimeoutHandler 131*cdf0e10cSrcweir //==================================================================== 132*cdf0e10cSrcweir class CallbackTimer; 133*cdf0e10cSrcweir class ITimeoutHandler 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir public: 136*cdf0e10cSrcweir virtual void onTimeout( CallbackTimer* _pInstigator ) = 0; 137*cdf0e10cSrcweir }; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir //==================================================================== 140*cdf0e10cSrcweir //= CallbackTimer 141*cdf0e10cSrcweir //==================================================================== 142*cdf0e10cSrcweir class CallbackTimer : public ::vos::OTimer 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir protected: 145*cdf0e10cSrcweir ITimeoutHandler* m_pTimeoutHandler; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir public: 148*cdf0e10cSrcweir CallbackTimer( ITimeoutHandler* _pHandler ) : m_pTimeoutHandler( _pHandler ) { } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir protected: 151*cdf0e10cSrcweir virtual void SAL_CALL onShot(); 152*cdf0e10cSrcweir }; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir //-------------------------------------------------------------------- 155*cdf0e10cSrcweir void SAL_CALL CallbackTimer::onShot() 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir OSL_ENSURE( m_pTimeoutHandler, "CallbackTimer::onShot: nobody interested in?" ); 158*cdf0e10cSrcweir ITimeoutHandler* pHandler( m_pTimeoutHandler ); 159*cdf0e10cSrcweir if ( pHandler ) 160*cdf0e10cSrcweir pHandler->onTimeout( this ); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // ----------------------------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir static sal_Bool isHighContrast( const Window* _pView ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir return _pView->GetSettings().GetStyleSettings().GetHighContrastMode(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // ----------------------------------------------------------------------- 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir void FilterMatch::createWildCardFilterList(const String& _rFilterList,::std::vector< WildCard >& _rFilters) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir if( _rFilterList.Len() ) 177*cdf0e10cSrcweir {// filter is given 178*cdf0e10cSrcweir xub_StrLen nCount = _rFilterList.GetTokenCount(); 179*cdf0e10cSrcweir _rFilters.reserve( nCount ); 180*cdf0e10cSrcweir xub_StrLen nIndex = 0; 181*cdf0e10cSrcweir OUString sToken; 182*cdf0e10cSrcweir do 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir sToken = _rFilterList.GetToken( 0, ';', nIndex ); 185*cdf0e10cSrcweir if ( sToken.getLength() ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir _rFilters.push_back( WildCard( sToken.toAsciiUpperCase() ) ); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir while ( nIndex != STRING_NOTFOUND ); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir else 193*cdf0e10cSrcweir // no filter is given -> match all 194*cdf0e10cSrcweir _rFilters.push_back( WildCard( String::CreateFromAscii( "*" ) ) ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir // class ViewTabListBox_Impl --------------------------------------------- 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir class ViewTabListBox_Impl : public SvHeaderTabListBox 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir private: 201*cdf0e10cSrcweir Reference< XCommandEnvironment > mxCmdEnv; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir ::osl::Mutex maMutex; 204*cdf0e10cSrcweir HeaderBar* mpHeaderBar; 205*cdf0e10cSrcweir SvtFileView_Impl* mpParent; 206*cdf0e10cSrcweir Timer maResetQuickSearch; 207*cdf0e10cSrcweir OUString maQuickSearchText; 208*cdf0e10cSrcweir String msAccessibleDescText; 209*cdf0e10cSrcweir String msFolder; 210*cdf0e10cSrcweir String msFile; 211*cdf0e10cSrcweir sal_uInt32 mnSearchIndex; 212*cdf0e10cSrcweir sal_Bool mbResizeDisabled : 1; 213*cdf0e10cSrcweir sal_Bool mbAutoResize : 1; 214*cdf0e10cSrcweir sal_Bool mbEnableDelete : 1; 215*cdf0e10cSrcweir sal_Bool mbEnableRename : 1; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir void DeleteEntries(); 218*cdf0e10cSrcweir void DoQuickSearch( const xub_Unicode& rChar ); 219*cdf0e10cSrcweir sal_Bool Kill( const OUString& rURL ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir protected: 222*cdf0e10cSrcweir virtual sal_Bool DoubleClickHdl(); 223*cdf0e10cSrcweir virtual ::rtl::OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos ) const; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir public: 226*cdf0e10cSrcweir ViewTabListBox_Impl( Window* pParentWin, SvtFileView_Impl* pParent, sal_Int16 nFlags ); 227*cdf0e10cSrcweir ~ViewTabListBox_Impl(); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir virtual void Resize(); 230*cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 231*cdf0e10cSrcweir virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir void ClearAll(); 234*cdf0e10cSrcweir HeaderBar* GetHeaderBar() const { return mpHeaderBar; } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir void EnableAutoResize() { mbAutoResize = sal_True; } 237*cdf0e10cSrcweir void EnableDelete( sal_Bool bEnable ) { mbEnableDelete = bEnable; } 238*cdf0e10cSrcweir void EnableRename( sal_Bool bEnable ) { mbEnableRename = bEnable; } 239*cdf0e10cSrcweir sal_Bool IsDeleteOrContextMenuEnabled() { return mbEnableDelete || IsContextMenuHandlingEnabled(); } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir Reference< XCommandEnvironment > GetCommandEnvironment() const { return mxCmdEnv; } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir DECL_LINK( ResetQuickSearch_Impl, Timer * ); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir virtual PopupMenu* CreateContextMenu( void ); 246*cdf0e10cSrcweir virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopentry ); 247*cdf0e10cSrcweir }; 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // class HashedEntry -------------------------------------------------- 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir class HashedEntry 252*cdf0e10cSrcweir { // just a special String which can be compared on equality much faster 253*cdf0e10cSrcweir protected: 254*cdf0e10cSrcweir OUString maName; 255*cdf0e10cSrcweir sal_Int32 mnHashCode; 256*cdf0e10cSrcweir public: 257*cdf0e10cSrcweir inline HashedEntry( const OUString& rName ); 258*cdf0e10cSrcweir inline HashedEntry( const INetURLObject& rURL ); 259*cdf0e10cSrcweir inline HashedEntry( const HashedEntry& rCopy ); 260*cdf0e10cSrcweir virtual ~HashedEntry(); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir inline sal_Bool operator ==( const HashedEntry& rRef ) const; 263*cdf0e10cSrcweir inline sal_Bool operator !=( const HashedEntry& rRef ) const; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir inline const OUString& GetName() const; 266*cdf0e10cSrcweir }; 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir inline HashedEntry::HashedEntry( const OUString& rName ): maName( rName ), mnHashCode( rName.hashCode() ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir inline HashedEntry::HashedEntry( const INetURLObject& rURL ): 273*cdf0e10cSrcweir maName( rURL.GetMainURL( INetURLObject::NO_DECODE ) ), 274*cdf0e10cSrcweir mnHashCode( maName.hashCode() ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir inline HashedEntry::HashedEntry( const HashedEntry& r ): maName( r.maName ), mnHashCode( r.mnHashCode ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir HashedEntry::~HashedEntry() 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir inline sal_Bool HashedEntry::operator ==( const HashedEntry& rRef ) const 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir return mnHashCode == rRef.mnHashCode && maName.reverseCompareTo( rRef.maName ) == 0; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir inline sal_Bool HashedEntry::operator !=( const HashedEntry& rRef ) const 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir return mnHashCode != rRef.mnHashCode || maName.reverseCompareTo( rRef.maName ) != 0; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir inline const OUString& HashedEntry::GetName() const 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir return maName; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir // class HashedEntryList ---------------------------------------------- 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir class HashedEntryList : protected List 304*cdf0e10cSrcweir {// provides a list of _unique_ Entries 305*cdf0e10cSrcweir protected: 306*cdf0e10cSrcweir inline HashedEntry* First(); 307*cdf0e10cSrcweir inline HashedEntry* Next(); 308*cdf0e10cSrcweir inline void Append( HashedEntry* pNewEntry ); 309*cdf0e10cSrcweir public: 310*cdf0e10cSrcweir virtual ~HashedEntryList(); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir const HashedEntry* Find( const OUString& rNameToSearchFor ); 313*cdf0e10cSrcweir const HashedEntry* Find( const HashedEntry& rToSearchFor ); 314*cdf0e10cSrcweir // not const, because First()/Next() is used 315*cdf0e10cSrcweir using List::Insert; 316*cdf0e10cSrcweir const HashedEntry& Insert( HashedEntry* pInsertOrDelete ); 317*cdf0e10cSrcweir // don't care about pInsertOrDelete after this any more and handle it as invalid! 318*cdf0e10cSrcweir // returns the Entry, which is effectively inserted 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir void Clear(); 321*cdf0e10cSrcweir }; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir inline HashedEntry* HashedEntryList::First() 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir return ( HashedEntry* ) List::First(); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir inline HashedEntry* HashedEntryList::Next() 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir return ( HashedEntry* ) List::Next(); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir inline void HashedEntryList::Append( HashedEntry* pNew ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir List::Insert( pNew, LIST_APPEND ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir HashedEntryList::~HashedEntryList() 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir Clear(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir const HashedEntry* HashedEntryList::Find( const OUString& rRefName ) 344*cdf0e10cSrcweir { // simple linear search, which should be fast enough for this purpose 345*cdf0e10cSrcweir HashedEntry aRef( rRefName ); 346*cdf0e10cSrcweir HashedEntry* pIter = First(); 347*cdf0e10cSrcweir while( pIter && *pIter != aRef ) 348*cdf0e10cSrcweir pIter = Next(); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir return pIter; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir const HashedEntry* HashedEntryList::Find( const HashedEntry& rRef ) 354*cdf0e10cSrcweir { // simple linear search, which should be fast enough for this purpose 355*cdf0e10cSrcweir HashedEntry* pIter = First(); 356*cdf0e10cSrcweir while( pIter && *pIter != rRef ) 357*cdf0e10cSrcweir pIter = Next(); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir return pIter; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir const HashedEntry& HashedEntryList::Insert( HashedEntry* pNew ) 363*cdf0e10cSrcweir { // inserts (appends) only, if entry doesn't already exists 364*cdf0e10cSrcweir // if it already exists, pNew is deleted, because the caller must not worry about pNew any more 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir DBG_ASSERT( pNew, "HashedEntryList::Insert(): NULL-pointer can't be inserted" ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir const HashedEntry* pSearch = Find( *pNew ); 369*cdf0e10cSrcweir if( pSearch ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir delete pNew; 372*cdf0e10cSrcweir return *pSearch; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir Append( pNew ); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir return *pNew; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir void HashedEntryList::Clear() 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir HashedEntry* p = First(); 383*cdf0e10cSrcweir while( p ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir delete p; 386*cdf0e10cSrcweir p = Next(); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir // class NameTranslationEntry ----------------------------------------- 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir class NameTranslationEntry : public HashedEntry 393*cdf0e10cSrcweir {// a fast compareble String and another String, which is used to get a substitution for a given String 394*cdf0e10cSrcweir protected: 395*cdf0e10cSrcweir OUString maTranslatedName; 396*cdf0e10cSrcweir public: 397*cdf0e10cSrcweir inline NameTranslationEntry( const OUString& rOriginalName, const OUString& rTranslatedName ); 398*cdf0e10cSrcweir inline NameTranslationEntry( const ByteString& rOriginalName, const ByteString& rTranslatedName ); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir inline const OUString& GetTranslation() const; 401*cdf0e10cSrcweir }; 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir inline NameTranslationEntry::NameTranslationEntry( const OUString& rOrg, const OUString& rTrans ): 404*cdf0e10cSrcweir HashedEntry( rOrg ), 405*cdf0e10cSrcweir maTranslatedName( rTrans ) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir inline NameTranslationEntry::NameTranslationEntry( const ByteString& rOrg, const ByteString& rTrans ): 410*cdf0e10cSrcweir HashedEntry( OUString( rOrg.GetBuffer(), rOrg.Len(), RTL_TEXTENCODING_ASCII_US ) ), 411*cdf0e10cSrcweir maTranslatedName( OUString( rTrans.GetBuffer(), rTrans.Len(), RTL_TEXTENCODING_UTF8 ) ) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir inline const OUString& NameTranslationEntry::GetTranslation() const 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir return maTranslatedName; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // class NameTranslationList ----------------------------------------- 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir class NameTranslationList : protected HashedEntryList 423*cdf0e10cSrcweir { // contains a list of substitutes of strings for a given folder (as URL) 424*cdf0e10cSrcweir // explanation of the circumstances see in remarks for Init(); 425*cdf0e10cSrcweir protected: 426*cdf0e10cSrcweir INetURLObject maTransFile; // URL of file with translation entries 427*cdf0e10cSrcweir HashedEntry maHashedURL; // for future purposes when dealing with a set of cached 428*cdf0e10cSrcweir // NameTranslationLists 429*cdf0e10cSrcweir private: 430*cdf0e10cSrcweir const String maTransFileName; 431*cdf0e10cSrcweir void Init(); // reads the translation file and fills the (internal) list 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir public: 434*cdf0e10cSrcweir NameTranslationList( const INetURLObject& rBaseURL ); 435*cdf0e10cSrcweir // rBaseURL: path to folder for which the translation of the entries 436*cdf0e10cSrcweir // should be done 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir using List::operator==; 439*cdf0e10cSrcweir inline sal_Bool operator ==( const HashedEntry& rRef ) const; 440*cdf0e10cSrcweir using List::operator!=; 441*cdf0e10cSrcweir inline sal_Bool operator !=( const HashedEntry& rRef ) const; 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir const OUString* Translate( const OUString& rName ) const; 444*cdf0e10cSrcweir // returns NULL, if rName can't be found 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir inline void Update(); // clears list and init 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir inline const String& GetTransTableFileName() const; 449*cdf0e10cSrcweir // returns the name for the file, which contains the translation strings 450*cdf0e10cSrcweir }; 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir inline const String& NameTranslationList::GetTransTableFileName() const 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir return maTransFileName; 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void NameTranslationList::Init() 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir // Tries to read the file ".nametranslation.table" in the base folder. Complete path/name is in maTransFile. 460*cdf0e10cSrcweir // Further on, the found entries in the section "TRANSLATIONNAMES" are used to replace names in the 461*cdf0e10cSrcweir // base folder by translated ones. The translation must be given in UTF8 462*cdf0e10cSrcweir // See examples of such a files in the samples-folder of an Office installation 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir try 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir ::ucbhelper::Content aTestContent( maTransFile.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() ); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir if( aTestContent.isDocument() ) 469*cdf0e10cSrcweir {// ... also tests the existence of maTransFile by throwing an Exception 470*cdf0e10cSrcweir const sal_Char* pSection = "TRANSLATIONNAMES"; 471*cdf0e10cSrcweir String aFsysName( maTransFile.getFSysPath( INetURLObject::FSYS_DETECT ) ); 472*cdf0e10cSrcweir Config aConfig( aFsysName ); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir aConfig.SetGroup( ByteString( pSection ) ); 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir sal_uInt16 nKeyCnt = aConfig.GetKeyCount(); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir for( sal_uInt16 nCnt = 0 ; nCnt < nKeyCnt ; ++nCnt ) 479*cdf0e10cSrcweir Insert( new NameTranslationEntry( aConfig.GetKeyName( nCnt ), aConfig.ReadKey( nCnt ) ) ); 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir catch( Exception const & ) {} 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir NameTranslationList::NameTranslationList( const INetURLObject& rBaseURL ): 486*cdf0e10cSrcweir maTransFile( rBaseURL ), 487*cdf0e10cSrcweir maHashedURL( rBaseURL ), 488*cdf0e10cSrcweir maTransFileName( String::CreateFromAscii( ".nametranslation.table" ) ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir maTransFile.insertName( maTransFileName ); 491*cdf0e10cSrcweir Init(); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir inline sal_Bool NameTranslationList::operator ==( const HashedEntry& rRef ) const 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir return maHashedURL == rRef; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir inline sal_Bool NameTranslationList::operator !=( const HashedEntry& rRef ) const 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir return maHashedURL != rRef; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir const OUString* NameTranslationList::Translate( const OUString& rName ) const 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir const NameTranslationEntry* pSearch = static_cast< const NameTranslationEntry* >( 507*cdf0e10cSrcweir ( const_cast< NameTranslationList* >( this ) )->Find( rName ) ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir return pSearch? &pSearch->GetTranslation() : NULL; 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir inline void NameTranslationList::Update() 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir Clear(); 515*cdf0e10cSrcweir Init(); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir // class NameTranslator_Impl ------------------------------------------ 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir // enables the user to get string substitutions (translations for the content) for a given folder 521*cdf0e10cSrcweir // see more explanations above in the description for NameTranslationList 522*cdf0e10cSrcweir class NameTranslator_Impl : public ::svt::IContentTitleTranslation 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir private: 525*cdf0e10cSrcweir NameTranslationList* mpActFolder; 526*cdf0e10cSrcweir public: 527*cdf0e10cSrcweir NameTranslator_Impl( void ); 528*cdf0e10cSrcweir NameTranslator_Impl( const INetURLObject& rActualFolder ); 529*cdf0e10cSrcweir virtual ~NameTranslator_Impl(); 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // IContentTitleTranslation 532*cdf0e10cSrcweir virtual sal_Bool GetTranslation( const OUString& rOriginalName, OUString& rTranslatedName ) const; 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir void UpdateTranslationTable(); // reads the translation file again 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir void SetActualFolder( const INetURLObject& rActualFolder ); 537*cdf0e10cSrcweir const String* GetTransTableFileName() const; 538*cdf0e10cSrcweir // returns the name for the file, which contains the translation strings 539*cdf0e10cSrcweir }; 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir //==================================================================== 542*cdf0e10cSrcweir //= SvtFileView_Impl 543*cdf0e10cSrcweir //==================================================================== 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir class SvtFileView_Impl :public ::svt::IEnumerationResultHandler 546*cdf0e10cSrcweir ,public ITimeoutHandler 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir protected: 549*cdf0e10cSrcweir SvtFileView* mpAntiImpl; 550*cdf0e10cSrcweir Link m_aSelectHandler; 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir ::rtl::Reference< ::svt::FileViewContentEnumerator > 553*cdf0e10cSrcweir m_pContentEnumerator; 554*cdf0e10cSrcweir Link m_aCurrentAsyncActionHandler; 555*cdf0e10cSrcweir ::osl::Condition m_aAsyncActionFinished; 556*cdf0e10cSrcweir ::rtl::Reference< ::vos::OTimer > m_pCancelAsyncTimer; 557*cdf0e10cSrcweir ::svt::EnumerationResult m_eAsyncActionResult; 558*cdf0e10cSrcweir bool m_bRunningAsyncAction; 559*cdf0e10cSrcweir bool m_bAsyncActionCancelled; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir public: 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir ::std::vector< SortingData_Impl* > maContent; 565*cdf0e10cSrcweir ::osl::Mutex maMutex; 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir ViewTabListBox_Impl* mpView; 568*cdf0e10cSrcweir NameTranslator_Impl* mpNameTrans; 569*cdf0e10cSrcweir const IUrlFilter* mpUrlFilter; 570*cdf0e10cSrcweir sal_uInt16 mnSortColumn; 571*cdf0e10cSrcweir sal_Bool mbAscending : 1; 572*cdf0e10cSrcweir sal_Bool mbOnlyFolder : 1; 573*cdf0e10cSrcweir sal_Bool mbReplaceNames : 1; // translate folder names or display doc-title instead of file name 574*cdf0e10cSrcweir sal_Int16 mnSuspendSelectCallback : 1; 575*cdf0e10cSrcweir sal_Bool mbIsFirstResort : 1; 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir IntlWrapper aIntlWrapper; 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir String maViewURL; 580*cdf0e10cSrcweir String maAllFilter; 581*cdf0e10cSrcweir String maCurrentFilter; 582*cdf0e10cSrcweir Image maFolderImage; 583*cdf0e10cSrcweir Link maOpenDoneLink; 584*cdf0e10cSrcweir Reference< XCommandEnvironment > mxCmdEnv; 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir SvtFileView_Impl( SvtFileView* pAntiImpl, Reference < XCommandEnvironment > xEnv, 587*cdf0e10cSrcweir sal_Int16 nFlags, 588*cdf0e10cSrcweir sal_Bool bOnlyFolder ); 589*cdf0e10cSrcweir virtual ~SvtFileView_Impl(); 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir void Clear(); 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir FileViewResult GetFolderContent_Impl( 594*cdf0e10cSrcweir const String& rFolder, 595*cdf0e10cSrcweir const FileViewAsyncAction* pAsyncDescriptor, 596*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >() ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir FileViewResult GetFolderContent_Impl( 599*cdf0e10cSrcweir const FolderDescriptor& _rFolder, 600*cdf0e10cSrcweir const FileViewAsyncAction* pAsyncDescriptor, 601*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >()); 602*cdf0e10cSrcweir void FilterFolderContent_Impl( const OUString &rFilter ); 603*cdf0e10cSrcweir void CancelRunningAsyncAction(); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir void OpenFolder_Impl(); 606*cdf0e10cSrcweir // #83004# ------- 607*cdf0e10cSrcweir void ReplaceTabWithString( OUString& aValue ); 608*cdf0e10cSrcweir void CreateDisplayText_Impl(); 609*cdf0e10cSrcweir void CreateVector_Impl( const Sequence < OUString > &rList ); 610*cdf0e10cSrcweir void SortFolderContent_Impl(); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir void EntryRemoved( const OUString& rURL ); 613*cdf0e10cSrcweir void EntryRenamed( OUString& rURL, 614*cdf0e10cSrcweir const OUString& rName ); 615*cdf0e10cSrcweir String FolderInserted( const OUString& rURL, 616*cdf0e10cSrcweir const OUString& rTitle ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir sal_uLong GetEntryPos( const OUString& rURL ); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir inline void EnableContextMenu( sal_Bool bEnable ); 621*cdf0e10cSrcweir inline void EnableDelete( sal_Bool bEnable ); 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir void Resort_Impl( sal_Int16 nColumn, sal_Bool bAscending ); 624*cdf0e10cSrcweir sal_Bool SearchNextEntry( sal_uInt32 &nIndex, 625*cdf0e10cSrcweir const OUString& rTitle, 626*cdf0e10cSrcweir sal_Bool bWrapAround ); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir inline sal_Bool EnableNameReplacing( sal_Bool bEnable = sal_True ); // returns false, if action wasn't possible 629*cdf0e10cSrcweir void SetActualFolder( const INetURLObject& rActualFolder ); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir sal_Bool GetDocTitle( const OUString& rTargetURL, OUString& rDocTitle ) const; 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir void SetSelectHandler( const Link& _rHdl ); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir void InitSelection(); 636*cdf0e10cSrcweir void ResetCursor(); 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir inline void EndEditing( bool _bCancel ); 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir protected: 641*cdf0e10cSrcweir DECL_LINK( SelectionMultiplexer, void* ); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir protected: 644*cdf0e10cSrcweir // IEnumerationResultHandler overridables 645*cdf0e10cSrcweir virtual void enumerationDone( ::svt::EnumerationResult _eResult ); 646*cdf0e10cSrcweir void implEnumerationSuccess(); 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir // ITimeoutHandler 649*cdf0e10cSrcweir virtual void onTimeout( CallbackTimer* _pInstigator ); 650*cdf0e10cSrcweir }; 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir inline void SvtFileView_Impl::EnableContextMenu( sal_Bool bEnable ) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir mpView->EnableContextMenuHandling( bEnable ); 655*cdf0e10cSrcweir if( bEnable ) 656*cdf0e10cSrcweir mbReplaceNames = sal_False; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir inline void SvtFileView_Impl::EnableDelete( sal_Bool bEnable ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir mpView->EnableDelete( bEnable ); 662*cdf0e10cSrcweir if( bEnable ) 663*cdf0e10cSrcweir mbReplaceNames = sal_False; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir inline sal_Bool SvtFileView_Impl::EnableNameReplacing( sal_Bool bEnable ) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir mpView->EnableRename( bEnable ); 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir sal_Bool bRet; 671*cdf0e10cSrcweir if( mpView->IsDeleteOrContextMenuEnabled() ) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir DBG_ASSERT( !mbReplaceNames, "SvtFileView_Impl::EnableNameReplacing(): state should be not possible!" ); 674*cdf0e10cSrcweir bRet = !bEnable; // only for enabling this is an unsuccessful result 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir else 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir mbReplaceNames = bEnable; 679*cdf0e10cSrcweir bRet = sal_True; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir return bRet; 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir inline void SvtFileView_Impl::EndEditing( bool _bCancel ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir if ( mpView->IsEditingActive() ) 688*cdf0e10cSrcweir mpView->EndEditing( _bCancel != false ); 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir // functions ------------------------------------------------------------- 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir OUString CreateExactSizeText_Impl( sal_Int64 nSize ) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir double fSize( ( double ) nSize ); 696*cdf0e10cSrcweir int nDec; 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir long nMega = 1024 * 1024; 699*cdf0e10cSrcweir long nGiga = nMega * 1024; 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir String aUnitStr = ' '; 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir if ( nSize < 10000 ) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir aUnitStr += String( SvtResId( STR_SVT_BYTES ) ); 706*cdf0e10cSrcweir nDec = 0; 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir else if ( nSize < nMega ) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir fSize /= 1024; 711*cdf0e10cSrcweir aUnitStr += String( SvtResId( STR_SVT_KB ) ); 712*cdf0e10cSrcweir nDec = 1; 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir else if ( nSize < nGiga ) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir fSize /= nMega; 717*cdf0e10cSrcweir aUnitStr += String( SvtResId( STR_SVT_MB ) ); 718*cdf0e10cSrcweir nDec = 2; 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir else 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir fSize /= nGiga; 723*cdf0e10cSrcweir aUnitStr += String( SvtResId( STR_SVT_GB ) ); 724*cdf0e10cSrcweir nDec = 3; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir OUString aSizeStr( ::rtl::math::doubleToUString( fSize, 728*cdf0e10cSrcweir rtl_math_StringFormat_F, nDec, 729*cdf0e10cSrcweir SvtSysLocale().GetLocaleData().getNumDecimalSep().GetChar(0))); 730*cdf0e10cSrcweir aSizeStr += aUnitStr; 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir return aSizeStr; 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir // ----------------------------------------------------------------------- 736*cdf0e10cSrcweir // class ViewTabListBox_Impl --------------------------------------------- 737*cdf0e10cSrcweir // ----------------------------------------------------------------------- 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir ViewTabListBox_Impl::ViewTabListBox_Impl( Window* pParentWin, 740*cdf0e10cSrcweir SvtFileView_Impl* pParent, 741*cdf0e10cSrcweir sal_Int16 nFlags ) : 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir SvHeaderTabListBox( pParentWin, WB_TABSTOP ), 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir mpHeaderBar ( NULL ), 746*cdf0e10cSrcweir mpParent ( pParent ), 747*cdf0e10cSrcweir msAccessibleDescText( SvtResId( STR_SVT_ACC_DESC_FILEVIEW ) ), 748*cdf0e10cSrcweir msFolder ( SvtResId( STR_SVT_ACC_DESC_FOLDER ) ), 749*cdf0e10cSrcweir msFile ( SvtResId( STR_SVT_ACC_DESC_FILE ) ), 750*cdf0e10cSrcweir mnSearchIndex ( 0 ), 751*cdf0e10cSrcweir mbResizeDisabled ( sal_False ), 752*cdf0e10cSrcweir mbAutoResize ( sal_False ), 753*cdf0e10cSrcweir mbEnableDelete ( sal_True ), 754*cdf0e10cSrcweir mbEnableRename ( sal_True ) 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir Size aBoxSize = pParentWin->GetSizePixel(); 758*cdf0e10cSrcweir mpHeaderBar = new HeaderBar( pParentWin, WB_BUTTONSTYLE | WB_BOTTOMBORDER ); 759*cdf0e10cSrcweir mpHeaderBar->SetPosSizePixel( Point( 0, 0 ), mpHeaderBar->CalcWindowSizePixel() ); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir HeaderBarItemBits nBits = ( HIB_LEFT | HIB_VCENTER | HIB_CLICKABLE ); 762*cdf0e10cSrcweir if ( ( nFlags & FILEVIEW_SHOW_ALL ) == FILEVIEW_SHOW_ALL ) 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir mpHeaderBar->InsertItem( COLUMN_TITLE, String( SvtResId( STR_SVT_FILEVIEW_COLUMN_TITLE ) ), 180, nBits | HIB_UPARROW ); 765*cdf0e10cSrcweir mpHeaderBar->InsertItem( COLUMN_TYPE, String( SvtResId( STR_SVT_FILEVIEW_COLUMN_TYPE ) ), 140, nBits ); 766*cdf0e10cSrcweir mpHeaderBar->InsertItem( COLUMN_SIZE, String( SvtResId( STR_SVT_FILEVIEW_COLUMN_SIZE ) ), 80, nBits ); 767*cdf0e10cSrcweir mpHeaderBar->InsertItem( COLUMN_DATE, String( SvtResId( STR_SVT_FILEVIEW_COLUMN_DATE ) ), 500, nBits ); 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir else 770*cdf0e10cSrcweir mpHeaderBar->InsertItem( COLUMN_TITLE, String( SvtResId( STR_SVT_FILEVIEW_COLUMN_TITLE ) ), 600, nBits ); 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir Size aHeadSize = mpHeaderBar->GetSizePixel(); 773*cdf0e10cSrcweir SetPosSizePixel( Point( 0, aHeadSize.Height() ), 774*cdf0e10cSrcweir Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) ); 775*cdf0e10cSrcweir InitHeaderBar( mpHeaderBar ); 776*cdf0e10cSrcweir SetHighlightRange(); 777*cdf0e10cSrcweir SetEntryHeight( ROW_HEIGHT ); 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir Show(); 780*cdf0e10cSrcweir mpHeaderBar->Show(); 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir maResetQuickSearch.SetTimeout( QUICK_SEARCH_TIMEOUT ); 783*cdf0e10cSrcweir maResetQuickSearch.SetTimeoutHdl( LINK( this, ViewTabListBox_Impl, ResetQuickSearch_Impl ) ); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 786*cdf0e10cSrcweir Reference< XInteractionHandler > xInteractionHandler = Reference< XInteractionHandler > ( 787*cdf0e10cSrcweir xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), UNO_QUERY ); 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir mxCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir EnableContextMenuHandling(); 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir // ----------------------------------------------------------------------- 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir ViewTabListBox_Impl::~ViewTabListBox_Impl() 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir maResetQuickSearch.Stop(); 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir delete mpHeaderBar; 801*cdf0e10cSrcweir } 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir // ----------------------------------------------------------------------- 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir IMPL_LINK( ViewTabListBox_Impl, ResetQuickSearch_Impl, Timer*, EMPTYARG ) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 808*cdf0e10cSrcweir 809*cdf0e10cSrcweir maQuickSearchText = OUString(); 810*cdf0e10cSrcweir mnSearchIndex = 0; 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir return 0; 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir // ----------------------------------------------------------------------- 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir void ViewTabListBox_Impl::Resize() 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir SvTabListBox::Resize(); 820*cdf0e10cSrcweir Size aBoxSize = Control::GetParent()->GetOutputSizePixel(); 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir if ( mbResizeDisabled || !aBoxSize.Width() ) 823*cdf0e10cSrcweir return; 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir Size aBarSize = mpHeaderBar->GetSizePixel(); 826*cdf0e10cSrcweir aBarSize.Width() = mbAutoResize ? aBoxSize.Width() : GetSizePixel().Width(); 827*cdf0e10cSrcweir mpHeaderBar->SetSizePixel( aBarSize ); 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir if ( mbAutoResize ) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir mbResizeDisabled = sal_True; 832*cdf0e10cSrcweir Point aPos = GetPosPixel(); 833*cdf0e10cSrcweir SetPosSizePixel( Point( 0, aBarSize.Height() ), 834*cdf0e10cSrcweir Size( aBoxSize.Width(), aBoxSize.Height() - aBarSize.Height() ) ); 835*cdf0e10cSrcweir mbResizeDisabled = sal_False; 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir // ----------------------------------------------------------------------- 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir void ViewTabListBox_Impl::KeyInput( const KeyEvent& rKEvt ) 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir bool bHandled = false; 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir const KeyCode& rKeyCode = rKEvt.GetKeyCode(); 846*cdf0e10cSrcweir if ( 0 == rKeyCode.GetModifier() ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir if ( rKeyCode.GetCode() == KEY_RETURN ) 849*cdf0e10cSrcweir { 850*cdf0e10cSrcweir ResetQuickSearch_Impl( NULL ); 851*cdf0e10cSrcweir GetDoubleClickHdl().Call( this ); 852*cdf0e10cSrcweir bHandled = true; 853*cdf0e10cSrcweir } 854*cdf0e10cSrcweir else if ( ( rKeyCode.GetCode() == KEY_DELETE ) && 855*cdf0e10cSrcweir mbEnableDelete ) 856*cdf0e10cSrcweir { 857*cdf0e10cSrcweir ResetQuickSearch_Impl( NULL ); 858*cdf0e10cSrcweir DeleteEntries(); 859*cdf0e10cSrcweir bHandled = true; 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir else if ( ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_NUM ) || 862*cdf0e10cSrcweir ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_ALPHA ) ) 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir DoQuickSearch( rKEvt.GetCharCode() ); 865*cdf0e10cSrcweir bHandled = true; 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir if ( !bHandled ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir ResetQuickSearch_Impl( NULL ); 872*cdf0e10cSrcweir SvHeaderTabListBox::KeyInput( rKEvt ); 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir // ----------------------------------------------------------------------- 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir PopupMenu* ViewTabListBox_Impl::CreateContextMenu( void ) 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir bool bEnableDelete = mbEnableDelete; 881*cdf0e10cSrcweir bool bEnableRename = mbEnableRename; 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir if ( bEnableDelete || bEnableRename ) 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir sal_Int32 nSelectedEntries = GetSelectionCount(); 886*cdf0e10cSrcweir bEnableDelete &= nSelectedEntries > 0; 887*cdf0e10cSrcweir bEnableRename &= nSelectedEntries == 1; 888*cdf0e10cSrcweir } 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir if ( bEnableDelete || bEnableRename ) 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstSelected(); 893*cdf0e10cSrcweir while ( pEntry ) 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir ::ucbhelper::Content aCnt; 896*cdf0e10cSrcweir try 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir OUString aURL( static_cast< SvtContentEntry * >( 899*cdf0e10cSrcweir pEntry->GetUserData() )->maURL ); 900*cdf0e10cSrcweir aCnt = ::ucbhelper::Content( aURL, mxCmdEnv ); 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir catch( Exception const & ) 903*cdf0e10cSrcweir { 904*cdf0e10cSrcweir bEnableDelete = bEnableRename = false; 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir if ( bEnableDelete ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir try 910*cdf0e10cSrcweir { 911*cdf0e10cSrcweir Reference< XCommandInfo > aCommands = aCnt.getCommands(); 912*cdf0e10cSrcweir if ( aCommands.is() ) 913*cdf0e10cSrcweir bEnableDelete 914*cdf0e10cSrcweir = aCommands->hasCommandByName( 915*cdf0e10cSrcweir OUString::createFromAscii( "delete" ) ); 916*cdf0e10cSrcweir else 917*cdf0e10cSrcweir bEnableDelete = false; 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir catch( Exception const & ) 920*cdf0e10cSrcweir { 921*cdf0e10cSrcweir bEnableDelete = false; 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir if ( bEnableRename ) 926*cdf0e10cSrcweir { 927*cdf0e10cSrcweir try 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir Reference< XPropertySetInfo > aProps = aCnt.getProperties(); 930*cdf0e10cSrcweir if ( aProps.is() ) 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir Property aProp 933*cdf0e10cSrcweir = aProps->getPropertyByName( 934*cdf0e10cSrcweir OUString::createFromAscii( "Title" ) ); 935*cdf0e10cSrcweir bEnableRename 936*cdf0e10cSrcweir = !( aProp.Attributes & PropertyAttribute::READONLY ); 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir else 939*cdf0e10cSrcweir bEnableRename = false; 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir catch( Exception const & ) 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir bEnableRename = false; 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir } 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir pEntry = ( bEnableDelete || bEnableRename ) 948*cdf0e10cSrcweir ? NextSelected( pEntry ) 949*cdf0e10cSrcweir : 0; 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir if ( bEnableDelete || bEnableRename ) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir PopupMenu * pRet 956*cdf0e10cSrcweir = new PopupMenu( SvtResId( RID_FILEVIEW_CONTEXTMENU ) ); 957*cdf0e10cSrcweir pRet->EnableItem( MID_FILEVIEW_DELETE, bEnableDelete ); 958*cdf0e10cSrcweir pRet->EnableItem( MID_FILEVIEW_RENAME, bEnableRename ); 959*cdf0e10cSrcweir pRet->RemoveDisabledEntries( sal_True, sal_True ); 960*cdf0e10cSrcweir return pRet; 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir return NULL; 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir // ----------------------------------------------------------------------- 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir void ViewTabListBox_Impl::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) 969*cdf0e10cSrcweir { 970*cdf0e10cSrcweir switch ( nSelectedPopupEntry ) 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir case MID_FILEVIEW_DELETE : 973*cdf0e10cSrcweir DeleteEntries(); 974*cdf0e10cSrcweir break; 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir case MID_FILEVIEW_RENAME : 977*cdf0e10cSrcweir EditEntry( FirstSelected() ); 978*cdf0e10cSrcweir break; 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir // ----------------------------------------------------------------------- 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir void ViewTabListBox_Impl::ClearAll() 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < GetEntryCount(); ++i ) 987*cdf0e10cSrcweir delete (SvtContentEntry*)GetEntry(i)->GetUserData(); 988*cdf0e10cSrcweir Clear(); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir // ----------------------------------------------------------------------- 992*cdf0e10cSrcweir void ViewTabListBox_Impl::DeleteEntries() 993*cdf0e10cSrcweir { 994*cdf0e10cSrcweir svtools::QueryDeleteResult_Impl eResult = svtools::QUERYDELETE_YES; 995*cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstSelected(); 996*cdf0e10cSrcweir String aURL; 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir ByteString sDialogPosition; 999*cdf0e10cSrcweir while ( pEntry && ( eResult != svtools::QUERYDELETE_CANCEL ) ) 1000*cdf0e10cSrcweir { 1001*cdf0e10cSrcweir SvLBoxEntry *pCurEntry = pEntry; 1002*cdf0e10cSrcweir pEntry = NextSelected( pEntry ); 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir if ( pCurEntry->GetUserData() ) 1005*cdf0e10cSrcweir aURL = ( (SvtContentEntry*)pCurEntry->GetUserData() )->maURL; 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir if ( !aURL.Len() ) 1008*cdf0e10cSrcweir continue; 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir bool canDelete = true; 1011*cdf0e10cSrcweir try 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir ::ucbhelper::Content aCnt( aURL, mxCmdEnv ); 1014*cdf0e10cSrcweir Reference< XCommandInfo > aCommands = aCnt.getCommands(); 1015*cdf0e10cSrcweir if ( aCommands.is() ) 1016*cdf0e10cSrcweir canDelete 1017*cdf0e10cSrcweir = aCommands->hasCommandByName( 1018*cdf0e10cSrcweir OUString::createFromAscii( "delete" ) ); 1019*cdf0e10cSrcweir else 1020*cdf0e10cSrcweir canDelete = false; 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir catch( Exception const & ) 1023*cdf0e10cSrcweir { 1024*cdf0e10cSrcweir canDelete = false; 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir if (!canDelete) 1028*cdf0e10cSrcweir continue; // process next entry 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir if ( eResult != svtools::QUERYDELETE_ALL ) 1031*cdf0e10cSrcweir { 1032*cdf0e10cSrcweir INetURLObject aObj( aURL ); 1033*cdf0e10cSrcweir svtools::QueryDeleteDlg_Impl aDlg( NULL, aObj.GetName( INetURLObject::DECODE_WITH_CHARSET ) ); 1034*cdf0e10cSrcweir if ( sDialogPosition.Len() ) 1035*cdf0e10cSrcweir aDlg.SetWindowState( sDialogPosition ); 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir if ( GetSelectionCount() > 1 ) 1038*cdf0e10cSrcweir aDlg.EnableAllButton(); 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir if ( aDlg.Execute() == RET_OK ) 1041*cdf0e10cSrcweir eResult = aDlg.GetResult(); 1042*cdf0e10cSrcweir else 1043*cdf0e10cSrcweir eResult = svtools::QUERYDELETE_CANCEL; 1044*cdf0e10cSrcweir 1045*cdf0e10cSrcweir sDialogPosition = aDlg.GetWindowState( ); 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir if ( ( eResult == svtools::QUERYDELETE_ALL ) || 1049*cdf0e10cSrcweir ( eResult == svtools::QUERYDELETE_YES ) ) 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir if ( Kill( aURL ) ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir delete (SvtContentEntry*)pCurEntry->GetUserData(); 1054*cdf0e10cSrcweir GetModel()->Remove( pCurEntry ); 1055*cdf0e10cSrcweir mpParent->EntryRemoved( aURL ); 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1062*cdf0e10cSrcweir sal_Bool ViewTabListBox_Impl::EditedEntry( SvLBoxEntry* pEntry, 1063*cdf0e10cSrcweir const XubString& rNewText ) 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir OUString aURL; 1068*cdf0e10cSrcweir SvtContentEntry* pData = (SvtContentEntry*)pEntry->GetUserData(); 1069*cdf0e10cSrcweir 1070*cdf0e10cSrcweir if ( pData ) 1071*cdf0e10cSrcweir aURL = OUString( pData->maURL ); 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir if ( ! aURL.getLength() ) 1074*cdf0e10cSrcweir return bRet; 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir try 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir OUString aPropName = OUString::createFromAscii( "Title" ); 1079*cdf0e10cSrcweir bool canRename = true; 1080*cdf0e10cSrcweir ::ucbhelper::Content aContent( aURL, mxCmdEnv ); 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir try 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir Reference< XPropertySetInfo > aProps = aContent.getProperties(); 1085*cdf0e10cSrcweir if ( aProps.is() ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir Property aProp = aProps->getPropertyByName( aPropName ); 1088*cdf0e10cSrcweir canRename = !( aProp.Attributes & PropertyAttribute::READONLY ); 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir else 1091*cdf0e10cSrcweir { 1092*cdf0e10cSrcweir canRename = false; 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir catch ( Exception const & ) 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir canRename = false; 1098*cdf0e10cSrcweir } 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir if ( canRename ) 1101*cdf0e10cSrcweir { 1102*cdf0e10cSrcweir Any aValue; 1103*cdf0e10cSrcweir aValue <<= OUString( rNewText ); 1104*cdf0e10cSrcweir aContent.setPropertyValue( aPropName, aValue ); 1105*cdf0e10cSrcweir mpParent->EntryRenamed( aURL, rNewText ); 1106*cdf0e10cSrcweir 1107*cdf0e10cSrcweir pData->maURL = aURL; 1108*cdf0e10cSrcweir pEntry->SetUserData( pData ); 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir bRet = sal_True; 1111*cdf0e10cSrcweir } 1112*cdf0e10cSrcweir } 1113*cdf0e10cSrcweir catch( Exception const & ) 1114*cdf0e10cSrcweir { 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir return bRet; 1118*cdf0e10cSrcweir } 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1121*cdf0e10cSrcweir void ViewTabListBox_Impl::DoQuickSearch( const xub_Unicode& rChar ) 1122*cdf0e10cSrcweir { 1123*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir maResetQuickSearch.Stop(); 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir OUString aLastText = maQuickSearchText; 1128*cdf0e10cSrcweir sal_uInt32 aLastPos = mnSearchIndex; 1129*cdf0e10cSrcweir sal_Bool bFound = sal_False; 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir maQuickSearchText += OUString( String( rChar ) ).toAsciiLowerCase(); 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir bFound = mpParent->SearchNextEntry( mnSearchIndex, maQuickSearchText, sal_False ); 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir if ( !bFound && ( aLastText.getLength() == 1 ) && 1136*cdf0e10cSrcweir ( aLastText == OUString( String( rChar ) ) ) ) 1137*cdf0e10cSrcweir { 1138*cdf0e10cSrcweir mnSearchIndex = aLastPos + 1; 1139*cdf0e10cSrcweir maQuickSearchText = aLastText; 1140*cdf0e10cSrcweir bFound = mpParent->SearchNextEntry( mnSearchIndex, maQuickSearchText, sal_True ); 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir if ( bFound ) 1144*cdf0e10cSrcweir { 1145*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( mnSearchIndex ); 1146*cdf0e10cSrcweir if ( pEntry ) 1147*cdf0e10cSrcweir { 1148*cdf0e10cSrcweir SelectAll( sal_False ); 1149*cdf0e10cSrcweir Select( pEntry ); 1150*cdf0e10cSrcweir SetCurEntry( pEntry ); 1151*cdf0e10cSrcweir MakeVisible( pEntry ); 1152*cdf0e10cSrcweir } 1153*cdf0e10cSrcweir else 1154*cdf0e10cSrcweir bFound = sal_False; 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir if ( !bFound ) 1158*cdf0e10cSrcweir Sound::Beep(); 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir maResetQuickSearch.Start(); 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1164*cdf0e10cSrcweir sal_Bool ViewTabListBox_Impl::DoubleClickHdl() 1165*cdf0e10cSrcweir { 1166*cdf0e10cSrcweir SvHeaderTabListBox::DoubleClickHdl(); 1167*cdf0e10cSrcweir return sal_False; 1168*cdf0e10cSrcweir // this means "do no additional handling". Especially this means that the SvImpLBox does not 1169*cdf0e10cSrcweir // recognize that the entry at the double click position change after the handler call (which is 1170*cdf0e10cSrcweir // the case if in the handler, our content was replaced) 1171*cdf0e10cSrcweir // If it _would_ recognize this change, it would take this as a reason to select the entry, again 1172*cdf0e10cSrcweir // - which is not what in the case of content replace 1173*cdf0e10cSrcweir // (I really doubt that this behaviour of the SvImpLBox does make any sense at all, but 1174*cdf0e10cSrcweir // who knows ...) 1175*cdf0e10cSrcweir // 07.12.2001 - 95727 - fs@openoffice.org 1176*cdf0e10cSrcweir } 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir ::rtl::OUString ViewTabListBox_Impl::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos ) const 1179*cdf0e10cSrcweir { 1180*cdf0e10cSrcweir ::rtl::OUString sRet = SvHeaderTabListBox::GetAccessibleObjectDescription( _eType, _nPos ); 1181*cdf0e10cSrcweir if ( ::svt::BBTYPE_TABLECELL == _eType ) 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir sal_Int32 nRow = -1; 1184*cdf0e10cSrcweir const sal_uInt16 nColumnCount = GetColumnCount(); 1185*cdf0e10cSrcweir if (nColumnCount > 0) 1186*cdf0e10cSrcweir nRow = _nPos / nColumnCount; 1187*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( nRow ); 1188*cdf0e10cSrcweir if ( pEntry ) 1189*cdf0e10cSrcweir { 1190*cdf0e10cSrcweir SvtContentEntry* pData = (SvtContentEntry*)pEntry->GetUserData(); 1191*cdf0e10cSrcweir if ( pData ) 1192*cdf0e10cSrcweir { 1193*cdf0e10cSrcweir static const String sVar1( RTL_CONSTASCII_USTRINGPARAM( "%1" ) ); 1194*cdf0e10cSrcweir static const String sVar2( RTL_CONSTASCII_USTRINGPARAM( "%2" ) ); 1195*cdf0e10cSrcweir String aText( msAccessibleDescText ); 1196*cdf0e10cSrcweir aText.SearchAndReplace( sVar1, pData->mbIsFolder ? msFolder : msFile ); 1197*cdf0e10cSrcweir aText.SearchAndReplace( sVar2, pData->maURL ); 1198*cdf0e10cSrcweir sRet += ::rtl::OUString( aText ); 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir return sRet; 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1207*cdf0e10cSrcweir sal_Bool ViewTabListBox_Impl::Kill( const OUString& rContent ) 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir sal_Bool bRet = sal_True; 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir try 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir ::ucbhelper::Content aCnt( rContent, mxCmdEnv ); 1214*cdf0e10cSrcweir aCnt.executeCommand( OUString::createFromAscii( "delete" ), makeAny( sal_Bool( sal_True ) ) ); 1215*cdf0e10cSrcweir } 1216*cdf0e10cSrcweir catch( ::com::sun::star::ucb::CommandAbortedException const & ) 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir DBG_WARNING( "CommandAbortedException" ); 1219*cdf0e10cSrcweir bRet = sal_False; 1220*cdf0e10cSrcweir } 1221*cdf0e10cSrcweir catch( Exception const & ) 1222*cdf0e10cSrcweir { 1223*cdf0e10cSrcweir DBG_WARNING( "Any other exception" ); 1224*cdf0e10cSrcweir bRet = sal_False; 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir 1227*cdf0e10cSrcweir return bRet; 1228*cdf0e10cSrcweir } 1229*cdf0e10cSrcweir 1230*cdf0e10cSrcweir 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1234*cdf0e10cSrcweir // class SvtFileView ----------------------------------------------------- 1235*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir SvtFileView::SvtFileView( Window* pParent, const ResId& rResId, 1238*cdf0e10cSrcweir sal_Bool bOnlyFolder, sal_Bool bMultiSelection ) : 1239*cdf0e10cSrcweir 1240*cdf0e10cSrcweir Control( pParent, rResId ) 1241*cdf0e10cSrcweir { 1242*cdf0e10cSrcweir sal_Int8 nFlags = FILEVIEW_SHOW_ALL; 1243*cdf0e10cSrcweir if ( bOnlyFolder ) 1244*cdf0e10cSrcweir nFlags |= FILEVIEW_ONLYFOLDER; 1245*cdf0e10cSrcweir if ( bMultiSelection ) 1246*cdf0e10cSrcweir nFlags |= FILEVIEW_MULTISELECTION; 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir Reference< XInteractionHandler > xInteractionHandler = Reference< XInteractionHandler > ( 1249*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), UNO_QUERY ); 1250*cdf0e10cSrcweir Reference < XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); 1251*cdf0e10cSrcweir 1252*cdf0e10cSrcweir mpImp = new SvtFileView_Impl( this, xCmdEnv, nFlags, bOnlyFolder ); 1253*cdf0e10cSrcweir mpImp->mpView->ForbidEmptyText(); 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir long pTabs[] = { 5, 20, 180, 320, 400, 600 }; 1256*cdf0e10cSrcweir mpImp->mpView->SetTabs( &pTabs[0], MAP_PIXEL ); 1257*cdf0e10cSrcweir mpImp->mpView->SetTabJustify( 2, AdjustRight ); // column "Size" 1258*cdf0e10cSrcweir 1259*cdf0e10cSrcweir if ( bMultiSelection ) 1260*cdf0e10cSrcweir mpImp->mpView->SetSelectionMode( MULTIPLE_SELECTION ); 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir HeaderBar* pHeaderBar = mpImp->mpView->GetHeaderBar(); 1263*cdf0e10cSrcweir pHeaderBar->SetSelectHdl( LINK( this, SvtFileView, HeaderSelect_Impl ) ); 1264*cdf0e10cSrcweir pHeaderBar->SetEndDragHdl( LINK( this, SvtFileView, HeaderEndDrag_Impl ) ); 1265*cdf0e10cSrcweir } 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir SvtFileView::SvtFileView( Window* pParent, const ResId& rResId, sal_Int8 nFlags ) : 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir Control( pParent, rResId ) 1270*cdf0e10cSrcweir { 1271*cdf0e10cSrcweir Reference< XInteractionHandler > xInteractionHandler = Reference< XInteractionHandler > ( 1272*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), UNO_QUERY ); 1273*cdf0e10cSrcweir Reference < XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); 1274*cdf0e10cSrcweir mpImp = new SvtFileView_Impl( this, xCmdEnv, nFlags, 1275*cdf0e10cSrcweir ( nFlags & FILEVIEW_ONLYFOLDER ) == FILEVIEW_ONLYFOLDER ); 1276*cdf0e10cSrcweir 1277*cdf0e10cSrcweir if ( ( nFlags & FILEVIEW_SHOW_ALL ) == FILEVIEW_SHOW_ALL ) 1278*cdf0e10cSrcweir { 1279*cdf0e10cSrcweir long pTabs[] = { 5, 20, 180, 320, 400, 600 }; 1280*cdf0e10cSrcweir mpImp->mpView->SetTabs( &pTabs[0], MAP_PIXEL ); 1281*cdf0e10cSrcweir mpImp->mpView->SetTabJustify( 2, AdjustRight ); // column "Size" 1282*cdf0e10cSrcweir } 1283*cdf0e10cSrcweir else 1284*cdf0e10cSrcweir { 1285*cdf0e10cSrcweir // show only title 1286*cdf0e10cSrcweir long pTabs[] = { 2, 20, 600 }; 1287*cdf0e10cSrcweir mpImp->mpView->SetTabs( &pTabs[0], MAP_PIXEL ); 1288*cdf0e10cSrcweir } 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir if ( ( nFlags & FILEVIEW_MULTISELECTION ) == FILEVIEW_MULTISELECTION ) 1291*cdf0e10cSrcweir mpImp->mpView->SetSelectionMode( MULTIPLE_SELECTION ); 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir HeaderBar *pHeaderBar = mpImp->mpView->GetHeaderBar(); 1294*cdf0e10cSrcweir pHeaderBar->SetSelectHdl( LINK( this, SvtFileView, HeaderSelect_Impl ) ); 1295*cdf0e10cSrcweir pHeaderBar->SetEndDragHdl( LINK( this, SvtFileView, HeaderEndDrag_Impl ) ); 1296*cdf0e10cSrcweir } 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir SvtFileView::~SvtFileView() 1301*cdf0e10cSrcweir { 1302*cdf0e10cSrcweir // use temp pointer to prevent access of deleted member (GetFocus()) 1303*cdf0e10cSrcweir SvtFileView_Impl* pTemp = mpImp; 1304*cdf0e10cSrcweir mpImp = NULL; 1305*cdf0e10cSrcweir delete pTemp; 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir void SvtFileView::OpenFolder( const Sequence< OUString >& aContents ) 1311*cdf0e10cSrcweir { 1312*cdf0e10cSrcweir mpImp->mpView->ClearAll(); 1313*cdf0e10cSrcweir const OUString* pFileProperties = aContents.getConstArray(); 1314*cdf0e10cSrcweir sal_uInt32 i, nCount = aContents.getLength(); 1315*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir String aRow( pFileProperties[i] ); 1318*cdf0e10cSrcweir // extract columns 1319*cdf0e10cSrcweir // the columns are: title, type, size, date, target url, is folder, image url 1320*cdf0e10cSrcweir String aTitle, aType, aSize, aDate, aURL, aImageURL; 1321*cdf0e10cSrcweir xub_StrLen nIdx = 0; 1322*cdf0e10cSrcweir aTitle = aRow.GetToken( 0, '\t', nIdx ); 1323*cdf0e10cSrcweir aType = aRow.GetToken( 0, '\t', nIdx ); 1324*cdf0e10cSrcweir aSize = aRow.GetToken( 0, '\t', nIdx ); 1325*cdf0e10cSrcweir aDate = aRow.GetToken( 0, '\t', nIdx ); 1326*cdf0e10cSrcweir aURL = aRow.GetToken( 0, '\t', nIdx ); 1327*cdf0e10cSrcweir sal_Unicode cFolder = aRow.GetToken( 0, '\t', nIdx ).GetChar(0); 1328*cdf0e10cSrcweir sal_Bool bIsFolder = ( '1' == cFolder ); 1329*cdf0e10cSrcweir if ( nIdx != STRING_NOTFOUND ) 1330*cdf0e10cSrcweir aImageURL = aRow.GetToken( 0, '\t', nIdx ); 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir if ( mpImp->mbOnlyFolder && !bIsFolder ) 1333*cdf0e10cSrcweir continue; 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir // build new row 1336*cdf0e10cSrcweir String aNewRow = aTitle; 1337*cdf0e10cSrcweir aNewRow += '\t'; 1338*cdf0e10cSrcweir aNewRow += aType; 1339*cdf0e10cSrcweir aNewRow += '\t'; 1340*cdf0e10cSrcweir aNewRow += aSize; 1341*cdf0e10cSrcweir aNewRow += '\t'; 1342*cdf0e10cSrcweir aNewRow += aDate; 1343*cdf0e10cSrcweir // detect image 1344*cdf0e10cSrcweir sal_Bool bDoInsert = sal_True; 1345*cdf0e10cSrcweir INetURLObject aObj( aImageURL.Len() > 0 ? aImageURL : aURL ); 1346*cdf0e10cSrcweir Image aImage = SvFileInformationManager::GetImage( aObj, sal_False, isHighContrast( this ) ); 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir if ( bDoInsert ) 1349*cdf0e10cSrcweir { 1350*cdf0e10cSrcweir // insert entry and set user data 1351*cdf0e10cSrcweir SvLBoxEntry* pEntry = mpImp->mpView->InsertEntry( aNewRow, aImage, aImage, NULL ); 1352*cdf0e10cSrcweir SvtContentEntry* pUserData = new SvtContentEntry( aURL, bIsFolder ); 1353*cdf0e10cSrcweir pEntry->SetUserData( pUserData ); 1354*cdf0e10cSrcweir } 1355*cdf0e10cSrcweir } 1356*cdf0e10cSrcweir 1357*cdf0e10cSrcweir mpImp->InitSelection(); 1358*cdf0e10cSrcweir mpImp->ResetCursor(); 1359*cdf0e10cSrcweir } 1360*cdf0e10cSrcweir 1361*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir String SvtFileView::GetURL( SvLBoxEntry* pEntry ) const 1364*cdf0e10cSrcweir { 1365*cdf0e10cSrcweir String aURL; 1366*cdf0e10cSrcweir if ( pEntry && pEntry->GetUserData() ) 1367*cdf0e10cSrcweir aURL = ( (SvtContentEntry*)pEntry->GetUserData() )->maURL; 1368*cdf0e10cSrcweir return aURL; 1369*cdf0e10cSrcweir } 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1372*cdf0e10cSrcweir 1373*cdf0e10cSrcweir String SvtFileView::GetCurrentURL() const 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir String aURL; 1376*cdf0e10cSrcweir SvLBoxEntry* pEntry = mpImp->mpView->FirstSelected(); 1377*cdf0e10cSrcweir if ( pEntry && pEntry->GetUserData() ) 1378*cdf0e10cSrcweir aURL = ( (SvtContentEntry*)pEntry->GetUserData() )->maURL; 1379*cdf0e10cSrcweir return aURL; 1380*cdf0e10cSrcweir } 1381*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir sal_Bool SvtFileView::CreateNewFolder( const String& rNewFolder ) 1384*cdf0e10cSrcweir { 1385*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1386*cdf0e10cSrcweir INetURLObject aObj( mpImp->maViewURL ); 1387*cdf0e10cSrcweir aObj.insertName( rNewFolder, false, INetURLObject::LAST_SEGMENT, true, INetURLObject::ENCODE_ALL ); 1388*cdf0e10cSrcweir String sURL = aObj.GetMainURL( INetURLObject::NO_DECODE ); 1389*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::MakeFolder( sURL, sal_True ) ) 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir String sTitle = aObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); 1392*cdf0e10cSrcweir String sEntry = mpImp->FolderInserted( sURL, sTitle ); 1393*cdf0e10cSrcweir SvLBoxEntry* pEntry = mpImp->mpView->InsertEntry( sEntry, mpImp->maFolderImage, mpImp->maFolderImage ); 1394*cdf0e10cSrcweir SvtContentEntry* pUserData = new SvtContentEntry( sURL, sal_True ); 1395*cdf0e10cSrcweir pEntry->SetUserData( pUserData ); 1396*cdf0e10cSrcweir mpImp->mpView->MakeVisible( pEntry ); 1397*cdf0e10cSrcweir bRet = sal_True; 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir return bRet; 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1403*cdf0e10cSrcweir 1404*cdf0e10cSrcweir FileViewResult SvtFileView::PreviousLevel( const FileViewAsyncAction* pAsyncDescriptor ) 1405*cdf0e10cSrcweir { 1406*cdf0e10cSrcweir FileViewResult eResult = eFailure; 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir String sParentURL; 1409*cdf0e10cSrcweir if ( GetParentURL( sParentURL ) ) 1410*cdf0e10cSrcweir eResult = Initialize( sParentURL, mpImp->maCurrentFilter, pAsyncDescriptor, mpBlackList ); 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir return eResult; 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir 1415*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1416*cdf0e10cSrcweir 1417*cdf0e10cSrcweir sal_Bool SvtFileView::GetParentURL( String& rParentURL ) const 1418*cdf0e10cSrcweir { 1419*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1420*cdf0e10cSrcweir try 1421*cdf0e10cSrcweir { 1422*cdf0e10cSrcweir ::ucbhelper::Content aCnt( mpImp->maViewURL, mpImp->mxCmdEnv ); 1423*cdf0e10cSrcweir Reference< XContent > xContent( aCnt.get() ); 1424*cdf0e10cSrcweir Reference< com::sun::star::container::XChild > xChild( xContent, UNO_QUERY ); 1425*cdf0e10cSrcweir if ( xChild.is() ) 1426*cdf0e10cSrcweir { 1427*cdf0e10cSrcweir Reference< XContent > xParent( xChild->getParent(), UNO_QUERY ); 1428*cdf0e10cSrcweir if ( xParent.is() ) 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir rParentURL = String( xParent->getIdentifier()->getContentIdentifier() ); 1431*cdf0e10cSrcweir bRet = ( rParentURL.Len() > 0 && rParentURL != mpImp->maViewURL ); 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir } 1435*cdf0e10cSrcweir catch( Exception const & ) 1436*cdf0e10cSrcweir { 1437*cdf0e10cSrcweir // perhaps an unkown url protocol (e.g. "private:newdoc") 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir return bRet; 1441*cdf0e10cSrcweir } 1442*cdf0e10cSrcweir 1443*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1444*cdf0e10cSrcweir 1445*cdf0e10cSrcweir const rtl::OString& SvtFileView::GetHelpId( ) const 1446*cdf0e10cSrcweir { 1447*cdf0e10cSrcweir return mpImp->mpView->GetHelpId( ); 1448*cdf0e10cSrcweir } 1449*cdf0e10cSrcweir 1450*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir void SvtFileView::SetHelpId( const rtl::OString& rHelpId ) 1453*cdf0e10cSrcweir { 1454*cdf0e10cSrcweir mpImp->mpView->SetHelpId( rHelpId ); 1455*cdf0e10cSrcweir } 1456*cdf0e10cSrcweir 1457*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1458*cdf0e10cSrcweir 1459*cdf0e10cSrcweir void SvtFileView::SetSizePixel( const Size& rNewSize ) 1460*cdf0e10cSrcweir { 1461*cdf0e10cSrcweir Control::SetSizePixel( rNewSize ); 1462*cdf0e10cSrcweir mpImp->mpView->SetSizePixel( rNewSize ); 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir 1465*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir void SvtFileView::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) 1468*cdf0e10cSrcweir { 1469*cdf0e10cSrcweir SetPosPixel( rNewPos ); 1470*cdf0e10cSrcweir SetSizePixel( rNewSize ); 1471*cdf0e10cSrcweir } 1472*cdf0e10cSrcweir 1473*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1474*cdf0e10cSrcweir sal_Bool SvtFileView::Initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent, const String& rFilter ) 1475*cdf0e10cSrcweir { 1476*cdf0e10cSrcweir WaitObject aWaitCursor( this ); 1477*cdf0e10cSrcweir 1478*cdf0e10cSrcweir mpImp->Clear(); 1479*cdf0e10cSrcweir ::ucbhelper::Content aContent(_xContent, mpImp->mxCmdEnv ); 1480*cdf0e10cSrcweir FileViewResult eResult = mpImp->GetFolderContent_Impl( FolderDescriptor( aContent ), NULL ); 1481*cdf0e10cSrcweir OSL_ENSURE( eResult != eStillRunning, "SvtFileView::Initialize: this was expected to be synchronous!" ); 1482*cdf0e10cSrcweir if ( eResult != eSuccess ) 1483*cdf0e10cSrcweir return sal_False; 1484*cdf0e10cSrcweir 1485*cdf0e10cSrcweir mpImp->FilterFolderContent_Impl( rFilter ); 1486*cdf0e10cSrcweir 1487*cdf0e10cSrcweir mpImp->SortFolderContent_Impl(); // possibly not necessary!!!!!!!!!! 1488*cdf0e10cSrcweir mpImp->CreateDisplayText_Impl(); 1489*cdf0e10cSrcweir mpImp->OpenFolder_Impl(); 1490*cdf0e10cSrcweir 1491*cdf0e10cSrcweir mpImp->maOpenDoneLink.Call( this ); 1492*cdf0e10cSrcweir return sal_True; 1493*cdf0e10cSrcweir } 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1496*cdf0e10cSrcweir FileViewResult SvtFileView::Initialize( 1497*cdf0e10cSrcweir const String& rURL, 1498*cdf0e10cSrcweir const String& rFilter, 1499*cdf0e10cSrcweir const FileViewAsyncAction* pAsyncDescriptor, 1500*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) 1501*cdf0e10cSrcweir { 1502*cdf0e10cSrcweir WaitObject aWaitCursor( this ); 1503*cdf0e10cSrcweir mpBlackList = rBlackList; 1504*cdf0e10cSrcweir 1505*cdf0e10cSrcweir String sPushURL( mpImp->maViewURL ); 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir mpImp->maViewURL = rURL; 1508*cdf0e10cSrcweir FileViewResult eResult = ExecuteFilter( rFilter, pAsyncDescriptor ); 1509*cdf0e10cSrcweir switch ( eResult ) 1510*cdf0e10cSrcweir { 1511*cdf0e10cSrcweir case eFailure: 1512*cdf0e10cSrcweir case eTimeout: 1513*cdf0e10cSrcweir mpImp->maViewURL = sPushURL; 1514*cdf0e10cSrcweir return eResult; 1515*cdf0e10cSrcweir 1516*cdf0e10cSrcweir case eStillRunning: 1517*cdf0e10cSrcweir OSL_ENSURE( pAsyncDescriptor, "SvtFileView::Initialize: we told it to read synchronously!" ); 1518*cdf0e10cSrcweir case eSuccess: 1519*cdf0e10cSrcweir return eResult; 1520*cdf0e10cSrcweir } 1521*cdf0e10cSrcweir 1522*cdf0e10cSrcweir OSL_ENSURE( sal_False, "SvtFileView::Initialize: unreachable!" ); 1523*cdf0e10cSrcweir return eFailure; 1524*cdf0e10cSrcweir } 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1527*cdf0e10cSrcweir FileViewResult SvtFileView::Initialize( 1528*cdf0e10cSrcweir const String& rURL, 1529*cdf0e10cSrcweir const String& rFilter, 1530*cdf0e10cSrcweir const FileViewAsyncAction* pAsyncDescriptor ) 1531*cdf0e10cSrcweir { 1532*cdf0e10cSrcweir return Initialize( rURL, rFilter, pAsyncDescriptor, ::com::sun::star::uno::Sequence< ::rtl::OUString >()); 1533*cdf0e10cSrcweir } 1534*cdf0e10cSrcweir 1535*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1538*cdf0e10cSrcweir sal_Bool SvtFileView::Initialize( const Sequence< OUString >& aContents ) 1539*cdf0e10cSrcweir { 1540*cdf0e10cSrcweir WaitObject aWaitCursor( this ); 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir mpImp->maViewURL = String(); 1543*cdf0e10cSrcweir mpImp->maCurrentFilter = mpImp->maAllFilter; 1544*cdf0e10cSrcweir 1545*cdf0e10cSrcweir mpImp->Clear(); 1546*cdf0e10cSrcweir mpImp->CreateVector_Impl( aContents ); 1547*cdf0e10cSrcweir mpImp->SortFolderContent_Impl(); 1548*cdf0e10cSrcweir 1549*cdf0e10cSrcweir mpImp->OpenFolder_Impl(); 1550*cdf0e10cSrcweir 1551*cdf0e10cSrcweir mpImp->maOpenDoneLink.Call( this ); 1552*cdf0e10cSrcweir 1553*cdf0e10cSrcweir return sal_True; 1554*cdf0e10cSrcweir } 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1557*cdf0e10cSrcweir 1558*cdf0e10cSrcweir FileViewResult SvtFileView::ExecuteFilter( const String& rFilter, const FileViewAsyncAction* pAsyncDescriptor ) 1559*cdf0e10cSrcweir { 1560*cdf0e10cSrcweir mpImp->maCurrentFilter = rFilter; 1561*cdf0e10cSrcweir mpImp->maCurrentFilter.ToLowerAscii(); 1562*cdf0e10cSrcweir 1563*cdf0e10cSrcweir mpImp->Clear(); 1564*cdf0e10cSrcweir FileViewResult eResult = mpImp->GetFolderContent_Impl( mpImp->maViewURL, pAsyncDescriptor, mpBlackList ); 1565*cdf0e10cSrcweir OSL_ENSURE( ( eResult != eStillRunning ) || pAsyncDescriptor, "SvtFileView::ExecuteFilter: we told it to read synchronously!" ); 1566*cdf0e10cSrcweir return eResult; 1567*cdf0e10cSrcweir } 1568*cdf0e10cSrcweir 1569*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir void SvtFileView::CancelRunningAsyncAction() 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir mpImp->CancelRunningAsyncAction(); 1574*cdf0e10cSrcweir } 1575*cdf0e10cSrcweir 1576*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1577*cdf0e10cSrcweir 1578*cdf0e10cSrcweir void SvtFileView::SetNoSelection() 1579*cdf0e10cSrcweir { 1580*cdf0e10cSrcweir mpImp->mpView->SelectAll( sal_False ); 1581*cdf0e10cSrcweir } 1582*cdf0e10cSrcweir 1583*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweir void SvtFileView::GetFocus() 1586*cdf0e10cSrcweir { 1587*cdf0e10cSrcweir Control::GetFocus(); 1588*cdf0e10cSrcweir if ( mpImp && mpImp->mpView ) 1589*cdf0e10cSrcweir mpImp->mpView->GrabFocus(); 1590*cdf0e10cSrcweir } 1591*cdf0e10cSrcweir 1592*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1593*cdf0e10cSrcweir 1594*cdf0e10cSrcweir void SvtFileView::ResetCursor() 1595*cdf0e10cSrcweir { 1596*cdf0e10cSrcweir mpImp->ResetCursor(); 1597*cdf0e10cSrcweir } 1598*cdf0e10cSrcweir 1599*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1600*cdf0e10cSrcweir 1601*cdf0e10cSrcweir void SvtFileView::SetSelectHdl( const Link& rHdl ) 1602*cdf0e10cSrcweir { 1603*cdf0e10cSrcweir mpImp->SetSelectHandler( rHdl ); 1604*cdf0e10cSrcweir } 1605*cdf0e10cSrcweir 1606*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1607*cdf0e10cSrcweir 1608*cdf0e10cSrcweir void SvtFileView::SetDoubleClickHdl( const Link& rHdl ) 1609*cdf0e10cSrcweir { 1610*cdf0e10cSrcweir mpImp->mpView->SetDoubleClickHdl( rHdl ); 1611*cdf0e10cSrcweir } 1612*cdf0e10cSrcweir 1613*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1614*cdf0e10cSrcweir 1615*cdf0e10cSrcweir sal_uLong SvtFileView::GetSelectionCount() const 1616*cdf0e10cSrcweir { 1617*cdf0e10cSrcweir return mpImp->mpView->GetSelectionCount(); 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1621*cdf0e10cSrcweir 1622*cdf0e10cSrcweir SvLBoxEntry* SvtFileView::FirstSelected() const 1623*cdf0e10cSrcweir { 1624*cdf0e10cSrcweir return mpImp->mpView->FirstSelected(); 1625*cdf0e10cSrcweir } 1626*cdf0e10cSrcweir 1627*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1628*cdf0e10cSrcweir 1629*cdf0e10cSrcweir SvLBoxEntry* SvtFileView::NextSelected( SvLBoxEntry* pEntry ) const 1630*cdf0e10cSrcweir { 1631*cdf0e10cSrcweir return mpImp->mpView->NextSelected( pEntry ); 1632*cdf0e10cSrcweir } 1633*cdf0e10cSrcweir 1634*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1635*cdf0e10cSrcweir 1636*cdf0e10cSrcweir void SvtFileView::EnableAutoResize() 1637*cdf0e10cSrcweir { 1638*cdf0e10cSrcweir mpImp->mpView->EnableAutoResize(); 1639*cdf0e10cSrcweir } 1640*cdf0e10cSrcweir 1641*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir void SvtFileView::SetFocus() 1644*cdf0e10cSrcweir { 1645*cdf0e10cSrcweir mpImp->mpView->GrabFocus(); 1646*cdf0e10cSrcweir } 1647*cdf0e10cSrcweir 1648*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1649*cdf0e10cSrcweir const String& SvtFileView::GetViewURL() const 1650*cdf0e10cSrcweir { 1651*cdf0e10cSrcweir return mpImp->maViewURL; 1652*cdf0e10cSrcweir } 1653*cdf0e10cSrcweir 1654*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1655*cdf0e10cSrcweir void SvtFileView::SetOpenDoneHdl( const Link& rHdl ) 1656*cdf0e10cSrcweir { 1657*cdf0e10cSrcweir mpImp->maOpenDoneLink = rHdl; 1658*cdf0e10cSrcweir } 1659*cdf0e10cSrcweir 1660*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1661*cdf0e10cSrcweir void SvtFileView::EnableContextMenu( sal_Bool bEnable ) 1662*cdf0e10cSrcweir { 1663*cdf0e10cSrcweir mpImp->EnableContextMenu( bEnable ); 1664*cdf0e10cSrcweir } 1665*cdf0e10cSrcweir 1666*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1667*cdf0e10cSrcweir void SvtFileView::EnableDelete( sal_Bool bEnable ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir mpImp->EnableDelete( bEnable ); 1670*cdf0e10cSrcweir } 1671*cdf0e10cSrcweir 1672*cdf0e10cSrcweir void SvtFileView::EnableNameReplacing( sal_Bool bEnable ) 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir mpImp->EnableNameReplacing( bEnable ); 1675*cdf0e10cSrcweir } 1676*cdf0e10cSrcweir 1677*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1678*cdf0e10cSrcweir void SvtFileView::EndInplaceEditing( bool _bCancel ) 1679*cdf0e10cSrcweir { 1680*cdf0e10cSrcweir return mpImp->EndEditing( _bCancel ); 1681*cdf0e10cSrcweir } 1682*cdf0e10cSrcweir 1683*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1684*cdf0e10cSrcweir IMPL_LINK( SvtFileView, HeaderSelect_Impl, HeaderBar*, pBar ) 1685*cdf0e10cSrcweir { 1686*cdf0e10cSrcweir DBG_ASSERT( pBar, "no headerbar" ); 1687*cdf0e10cSrcweir sal_uInt16 nItemID = pBar->GetCurItemId(); 1688*cdf0e10cSrcweir 1689*cdf0e10cSrcweir HeaderBarItemBits nBits; 1690*cdf0e10cSrcweir 1691*cdf0e10cSrcweir // clear the arrow of the recently used column 1692*cdf0e10cSrcweir if ( nItemID != mpImp->mnSortColumn ) 1693*cdf0e10cSrcweir { 1694*cdf0e10cSrcweir if ( !nItemID ) 1695*cdf0e10cSrcweir { 1696*cdf0e10cSrcweir // first call -> remove arrow from title column, 1697*cdf0e10cSrcweir // because another column is the sort column 1698*cdf0e10cSrcweir nItemID = mpImp->mnSortColumn; 1699*cdf0e10cSrcweir mpImp->mnSortColumn = COLUMN_TITLE; 1700*cdf0e10cSrcweir } 1701*cdf0e10cSrcweir nBits = pBar->GetItemBits( mpImp->mnSortColumn ); 1702*cdf0e10cSrcweir nBits &= ~( HIB_UPARROW | HIB_DOWNARROW ); 1703*cdf0e10cSrcweir pBar->SetItemBits( mpImp->mnSortColumn, nBits ); 1704*cdf0e10cSrcweir } 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir nBits = pBar->GetItemBits( nItemID ); 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW ); 1709*cdf0e10cSrcweir 1710*cdf0e10cSrcweir if ( bUp ) 1711*cdf0e10cSrcweir { 1712*cdf0e10cSrcweir nBits &= ~HIB_UPARROW; 1713*cdf0e10cSrcweir nBits |= HIB_DOWNARROW; 1714*cdf0e10cSrcweir } 1715*cdf0e10cSrcweir else 1716*cdf0e10cSrcweir { 1717*cdf0e10cSrcweir nBits &= ~HIB_DOWNARROW; 1718*cdf0e10cSrcweir nBits |= HIB_UPARROW; 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir 1721*cdf0e10cSrcweir pBar->SetItemBits( nItemID, nBits ); 1722*cdf0e10cSrcweir mpImp->Resort_Impl( nItemID, !bUp ); 1723*cdf0e10cSrcweir return 1; 1724*cdf0e10cSrcweir } 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1727*cdf0e10cSrcweir IMPL_LINK( SvtFileView, HeaderEndDrag_Impl, HeaderBar*, pBar ) 1728*cdf0e10cSrcweir { 1729*cdf0e10cSrcweir if ( !pBar->IsItemMode() ) 1730*cdf0e10cSrcweir { 1731*cdf0e10cSrcweir Size aSize; 1732*cdf0e10cSrcweir sal_uInt16 nTabs = pBar->GetItemCount(); 1733*cdf0e10cSrcweir long nTmpSize = 0; 1734*cdf0e10cSrcweir 1735*cdf0e10cSrcweir for ( sal_uInt16 i = 1; i <= nTabs; ++i ) 1736*cdf0e10cSrcweir { 1737*cdf0e10cSrcweir long nWidth = pBar->GetItemSize(i); 1738*cdf0e10cSrcweir aSize.Width() = nWidth + nTmpSize; 1739*cdf0e10cSrcweir nTmpSize += nWidth; 1740*cdf0e10cSrcweir mpImp->mpView->SetTab( i, aSize.Width(), MAP_PIXEL ); 1741*cdf0e10cSrcweir } 1742*cdf0e10cSrcweir } 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir return 0; 1745*cdf0e10cSrcweir } 1746*cdf0e10cSrcweir 1747*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1748*cdf0e10cSrcweir String SvtFileView::GetConfigString() const 1749*cdf0e10cSrcweir { 1750*cdf0e10cSrcweir String sRet; 1751*cdf0e10cSrcweir HeaderBar* pBar = mpImp->mpView->GetHeaderBar(); 1752*cdf0e10cSrcweir DBG_ASSERT( pBar, "invalid headerbar" ); 1753*cdf0e10cSrcweir 1754*cdf0e10cSrcweir // sort order 1755*cdf0e10cSrcweir sRet += String::CreateFromInt32( mpImp->mnSortColumn ); 1756*cdf0e10cSrcweir sRet += ';'; 1757*cdf0e10cSrcweir HeaderBarItemBits nBits = pBar->GetItemBits( mpImp->mnSortColumn ); 1758*cdf0e10cSrcweir sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW ); 1759*cdf0e10cSrcweir sRet += bUp ? '1' : '0'; 1760*cdf0e10cSrcweir sRet += ';'; 1761*cdf0e10cSrcweir 1762*cdf0e10cSrcweir sal_uInt16 nCount = pBar->GetItemCount(); 1763*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i ) 1764*cdf0e10cSrcweir { 1765*cdf0e10cSrcweir sal_uInt16 nId = pBar->GetItemId(i); 1766*cdf0e10cSrcweir sRet += String::CreateFromInt32( nId ); 1767*cdf0e10cSrcweir sRet += ';'; 1768*cdf0e10cSrcweir sRet += String::CreateFromInt32( pBar->GetItemSize( nId ) ); 1769*cdf0e10cSrcweir sRet += ';'; 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir sRet.EraseTrailingChars( ';' ); 1773*cdf0e10cSrcweir return sRet; 1774*cdf0e10cSrcweir } 1775*cdf0e10cSrcweir 1776*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1777*cdf0e10cSrcweir void SvtFileView::SetConfigString( const String& rCfgStr ) 1778*cdf0e10cSrcweir { 1779*cdf0e10cSrcweir HeaderBar* pBar = mpImp->mpView->GetHeaderBar(); 1780*cdf0e10cSrcweir DBG_ASSERT( pBar, "invalid headerbar" ); 1781*cdf0e10cSrcweir 1782*cdf0e10cSrcweir sal_uInt16 nIdx = 0; 1783*cdf0e10cSrcweir mpImp->mnSortColumn = (sal_uInt16)rCfgStr.GetToken( 0, ';', nIdx ).ToInt32(); 1784*cdf0e10cSrcweir sal_Bool bUp = (sal_Bool)(sal_uInt16)rCfgStr.GetToken( 0, ';', nIdx ).ToInt32(); 1785*cdf0e10cSrcweir HeaderBarItemBits nBits = pBar->GetItemBits( mpImp->mnSortColumn ); 1786*cdf0e10cSrcweir 1787*cdf0e10cSrcweir if ( bUp ) 1788*cdf0e10cSrcweir { 1789*cdf0e10cSrcweir nBits &= ~HIB_UPARROW; 1790*cdf0e10cSrcweir nBits |= HIB_DOWNARROW; 1791*cdf0e10cSrcweir } 1792*cdf0e10cSrcweir else 1793*cdf0e10cSrcweir { 1794*cdf0e10cSrcweir nBits &= ~HIB_DOWNARROW; 1795*cdf0e10cSrcweir nBits |= HIB_UPARROW; 1796*cdf0e10cSrcweir } 1797*cdf0e10cSrcweir pBar->SetItemBits( mpImp->mnSortColumn, nBits ); 1798*cdf0e10cSrcweir 1799*cdf0e10cSrcweir while ( nIdx != STRING_NOTFOUND ) 1800*cdf0e10cSrcweir { 1801*cdf0e10cSrcweir sal_uInt16 nItemId = (sal_uInt16)rCfgStr.GetToken( 0, ';', nIdx ).ToInt32(); 1802*cdf0e10cSrcweir pBar->SetItemSize( nItemId, rCfgStr.GetToken( 0, ';', nIdx ).ToInt32() ); 1803*cdf0e10cSrcweir } 1804*cdf0e10cSrcweir 1805*cdf0e10cSrcweir HeaderSelect_Impl( pBar ); 1806*cdf0e10cSrcweir HeaderEndDrag_Impl( pBar ); 1807*cdf0e10cSrcweir } 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1810*cdf0e10cSrcweir void SvtFileView::SetUrlFilter( const IUrlFilter* _pFilter ) 1811*cdf0e10cSrcweir { 1812*cdf0e10cSrcweir mpImp->mpUrlFilter = _pFilter; 1813*cdf0e10cSrcweir } 1814*cdf0e10cSrcweir 1815*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1816*cdf0e10cSrcweir const IUrlFilter* SvtFileView::GetUrlFilter( ) const 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir return mpImp->mpUrlFilter; 1819*cdf0e10cSrcweir } 1820*cdf0e10cSrcweir 1821*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1822*cdf0e10cSrcweir void SvtFileView::StateChanged( StateChangedType nStateChange ) 1823*cdf0e10cSrcweir { 1824*cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_ENABLE ) 1825*cdf0e10cSrcweir Invalidate(); 1826*cdf0e10cSrcweir Control::StateChanged( nStateChange ); 1827*cdf0e10cSrcweir } 1828*cdf0e10cSrcweir 1829*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1830*cdf0e10cSrcweir // class NameTranslator_Impl 1831*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1832*cdf0e10cSrcweir 1833*cdf0e10cSrcweir NameTranslator_Impl::NameTranslator_Impl( void ) : 1834*cdf0e10cSrcweir mpActFolder( NULL ) 1835*cdf0e10cSrcweir { 1836*cdf0e10cSrcweir } 1837*cdf0e10cSrcweir 1838*cdf0e10cSrcweir NameTranslator_Impl::NameTranslator_Impl( const INetURLObject& rActualFolder ) 1839*cdf0e10cSrcweir { 1840*cdf0e10cSrcweir mpActFolder = new NameTranslationList( rActualFolder ); 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir NameTranslator_Impl::~NameTranslator_Impl() 1844*cdf0e10cSrcweir { 1845*cdf0e10cSrcweir if( mpActFolder ) 1846*cdf0e10cSrcweir delete mpActFolder; 1847*cdf0e10cSrcweir } 1848*cdf0e10cSrcweir 1849*cdf0e10cSrcweir void NameTranslator_Impl::UpdateTranslationTable() 1850*cdf0e10cSrcweir { 1851*cdf0e10cSrcweir if( mpActFolder ) 1852*cdf0e10cSrcweir mpActFolder->Update(); 1853*cdf0e10cSrcweir } 1854*cdf0e10cSrcweir 1855*cdf0e10cSrcweir void NameTranslator_Impl::SetActualFolder( const INetURLObject& rActualFolder ) 1856*cdf0e10cSrcweir { 1857*cdf0e10cSrcweir HashedEntry aActFolder( rActualFolder ); 1858*cdf0e10cSrcweir 1859*cdf0e10cSrcweir if( mpActFolder ) 1860*cdf0e10cSrcweir { 1861*cdf0e10cSrcweir if( *mpActFolder != aActFolder ) 1862*cdf0e10cSrcweir { 1863*cdf0e10cSrcweir delete mpActFolder; 1864*cdf0e10cSrcweir mpActFolder = new NameTranslationList( rActualFolder ); 1865*cdf0e10cSrcweir } 1866*cdf0e10cSrcweir } 1867*cdf0e10cSrcweir else 1868*cdf0e10cSrcweir mpActFolder = new NameTranslationList( rActualFolder ); 1869*cdf0e10cSrcweir } 1870*cdf0e10cSrcweir 1871*cdf0e10cSrcweir sal_Bool NameTranslator_Impl::GetTranslation( const OUString& rOrg, OUString& rTrans ) const 1872*cdf0e10cSrcweir { 1873*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1874*cdf0e10cSrcweir 1875*cdf0e10cSrcweir if( mpActFolder ) 1876*cdf0e10cSrcweir { 1877*cdf0e10cSrcweir const OUString* pTrans = mpActFolder->Translate( rOrg ); 1878*cdf0e10cSrcweir if( pTrans ) 1879*cdf0e10cSrcweir { 1880*cdf0e10cSrcweir rTrans = *pTrans; 1881*cdf0e10cSrcweir bRet = sal_True; 1882*cdf0e10cSrcweir } 1883*cdf0e10cSrcweir } 1884*cdf0e10cSrcweir 1885*cdf0e10cSrcweir return bRet; 1886*cdf0e10cSrcweir } 1887*cdf0e10cSrcweir 1888*cdf0e10cSrcweir const String* NameTranslator_Impl::GetTransTableFileName() const 1889*cdf0e10cSrcweir { 1890*cdf0e10cSrcweir return mpActFolder? &mpActFolder->GetTransTableFileName() : NULL; 1891*cdf0e10cSrcweir } 1892*cdf0e10cSrcweir 1893*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1894*cdf0e10cSrcweir // class SvtFileView_Impl 1895*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1896*cdf0e10cSrcweir 1897*cdf0e10cSrcweir SvtFileView_Impl::SvtFileView_Impl( SvtFileView* pAntiImpl, Reference < XCommandEnvironment > xEnv, sal_Int16 nFlags, sal_Bool bOnlyFolder ) 1898*cdf0e10cSrcweir 1899*cdf0e10cSrcweir :mpAntiImpl ( pAntiImpl ) 1900*cdf0e10cSrcweir ,m_eAsyncActionResult ( ::svt::ERROR ) 1901*cdf0e10cSrcweir ,m_bRunningAsyncAction ( false ) 1902*cdf0e10cSrcweir ,m_bAsyncActionCancelled ( false ) 1903*cdf0e10cSrcweir ,mpNameTrans ( NULL ) 1904*cdf0e10cSrcweir ,mpUrlFilter ( NULL ) 1905*cdf0e10cSrcweir ,mnSortColumn ( COLUMN_TITLE ) 1906*cdf0e10cSrcweir ,mbAscending ( sal_True ) 1907*cdf0e10cSrcweir ,mbOnlyFolder ( bOnlyFolder ) 1908*cdf0e10cSrcweir ,mbReplaceNames ( sal_False ) 1909*cdf0e10cSrcweir ,mnSuspendSelectCallback ( 0 ) 1910*cdf0e10cSrcweir ,mbIsFirstResort ( sal_True ) 1911*cdf0e10cSrcweir ,aIntlWrapper ( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ) 1912*cdf0e10cSrcweir ,maFolderImage ( SvtResId( IMG_SVT_FOLDER ) ) 1913*cdf0e10cSrcweir ,mxCmdEnv ( xEnv ) 1914*cdf0e10cSrcweir 1915*cdf0e10cSrcweir { 1916*cdf0e10cSrcweir maAllFilter = String::CreateFromAscii( "*.*" ); 1917*cdf0e10cSrcweir mpView = new ViewTabListBox_Impl( mpAntiImpl, this, nFlags ); 1918*cdf0e10cSrcweir mpView->EnableCellFocus(); 1919*cdf0e10cSrcweir } 1920*cdf0e10cSrcweir 1921*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1922*cdf0e10cSrcweir SvtFileView_Impl::~SvtFileView_Impl() 1923*cdf0e10cSrcweir { 1924*cdf0e10cSrcweir Clear(); 1925*cdf0e10cSrcweir 1926*cdf0e10cSrcweir // use temp pointer to prevent access of deleted member (GetFocus()) 1927*cdf0e10cSrcweir ViewTabListBox_Impl* pTemp = mpView; 1928*cdf0e10cSrcweir mpView = NULL; 1929*cdf0e10cSrcweir delete pTemp; 1930*cdf0e10cSrcweir } 1931*cdf0e10cSrcweir 1932*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1933*cdf0e10cSrcweir void SvtFileView_Impl::Clear() 1934*cdf0e10cSrcweir { 1935*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1936*cdf0e10cSrcweir 1937*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aIt; 1938*cdf0e10cSrcweir 1939*cdf0e10cSrcweir for ( aIt = maContent.begin(); aIt != maContent.end(); aIt++ ) 1940*cdf0e10cSrcweir delete (*aIt); 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir maContent.clear(); 1943*cdf0e10cSrcweir 1944*cdf0e10cSrcweir if( mpNameTrans ) 1945*cdf0e10cSrcweir DELETEZ( mpNameTrans ); 1946*cdf0e10cSrcweir } 1947*cdf0e10cSrcweir 1948*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1949*cdf0e10cSrcweir FileViewResult SvtFileView_Impl::GetFolderContent_Impl( 1950*cdf0e10cSrcweir const String& rFolder, 1951*cdf0e10cSrcweir const FileViewAsyncAction* pAsyncDescriptor, 1952*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) 1953*cdf0e10cSrcweir { 1954*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( maMutex ); 1955*cdf0e10cSrcweir INetURLObject aFolderObj( rFolder ); 1956*cdf0e10cSrcweir DBG_ASSERT( aFolderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); 1957*cdf0e10cSrcweir 1958*cdf0e10cSrcweir // prepare name translation 1959*cdf0e10cSrcweir SetActualFolder( aFolderObj ); 1960*cdf0e10cSrcweir 1961*cdf0e10cSrcweir FolderDescriptor aFolder( aFolderObj.GetMainURL( INetURLObject::NO_DECODE ) ); 1962*cdf0e10cSrcweir 1963*cdf0e10cSrcweir aGuard.clear(); 1964*cdf0e10cSrcweir return GetFolderContent_Impl( aFolder, pAsyncDescriptor, rBlackList ); 1965*cdf0e10cSrcweir } 1966*cdf0e10cSrcweir 1967*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1968*cdf0e10cSrcweir FileViewResult SvtFileView_Impl::GetFolderContent_Impl( 1969*cdf0e10cSrcweir const FolderDescriptor& _rFolder, 1970*cdf0e10cSrcweir const FileViewAsyncAction* pAsyncDescriptor, 1971*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) 1972*cdf0e10cSrcweir { 1973*cdf0e10cSrcweir DBG_TESTSOLARMUTEX(); 1974*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( maMutex ); 1975*cdf0e10cSrcweir 1976*cdf0e10cSrcweir OSL_ENSURE( !m_pContentEnumerator.is(), "SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" ); 1977*cdf0e10cSrcweir m_pContentEnumerator = new ::svt::FileViewContentEnumerator( 1978*cdf0e10cSrcweir mpView->GetCommandEnvironment(), maContent, maMutex, mbReplaceNames ? mpNameTrans : NULL ); 1979*cdf0e10cSrcweir // TODO: should we cache and re-use this thread? 1980*cdf0e10cSrcweir 1981*cdf0e10cSrcweir if ( !pAsyncDescriptor ) 1982*cdf0e10cSrcweir { 1983*cdf0e10cSrcweir ::svt::EnumerationResult eResult = m_pContentEnumerator->enumerateFolderContentSync( _rFolder, mpUrlFilter, rBlackList ); 1984*cdf0e10cSrcweir if ( ::svt::SUCCESS == eResult ) 1985*cdf0e10cSrcweir { 1986*cdf0e10cSrcweir implEnumerationSuccess(); 1987*cdf0e10cSrcweir m_pContentEnumerator = NULL; 1988*cdf0e10cSrcweir return eSuccess; 1989*cdf0e10cSrcweir } 1990*cdf0e10cSrcweir m_pContentEnumerator = NULL; 1991*cdf0e10cSrcweir return eFailure; 1992*cdf0e10cSrcweir } 1993*cdf0e10cSrcweir 1994*cdf0e10cSrcweir m_bRunningAsyncAction = true; 1995*cdf0e10cSrcweir m_bAsyncActionCancelled = false; 1996*cdf0e10cSrcweir m_eAsyncActionResult = ::svt::ERROR; 1997*cdf0e10cSrcweir m_aAsyncActionFinished.reset(); 1998*cdf0e10cSrcweir 1999*cdf0e10cSrcweir // don't (yet) set m_aCurrentAsyncActionHandler to pTimeout->aFinishHandler. 2000*cdf0e10cSrcweir // By definition, this handler *only* get's called when the result cannot be obtained 2001*cdf0e10cSrcweir // during the minimum wait time, so it is only set below, when needed. 2002*cdf0e10cSrcweir m_aCurrentAsyncActionHandler = Link(); 2003*cdf0e10cSrcweir 2004*cdf0e10cSrcweir // minimum time to wait 2005*cdf0e10cSrcweir ::std::auto_ptr< TimeValue > pTimeout( new TimeValue ); 2006*cdf0e10cSrcweir sal_Int32 nMinTimeout = pAsyncDescriptor->nMinTimeout; 2007*cdf0e10cSrcweir OSL_ENSURE( nMinTimeout > 0, "SvtFileView_Impl::GetFolderContent_Impl: invalid minimum timeout!" ); 2008*cdf0e10cSrcweir if ( nMinTimeout <= 0 ) 2009*cdf0e10cSrcweir nMinTimeout = sal_Int32( 1000L ); 2010*cdf0e10cSrcweir pTimeout->Seconds = nMinTimeout / 1000L; 2011*cdf0e10cSrcweir pTimeout->Nanosec = ( nMinTimeout % 1000L ) * 1000000L; 2012*cdf0e10cSrcweir 2013*cdf0e10cSrcweir m_pContentEnumerator->enumerateFolderContent( _rFolder, mpUrlFilter, this ); 2014*cdf0e10cSrcweir 2015*cdf0e10cSrcweir // wait until the enumeration is finished 2016*cdf0e10cSrcweir // for this, release our own mutex (which is used by the enumerator thread) 2017*cdf0e10cSrcweir aGuard.clear(); 2018*cdf0e10cSrcweir 2019*cdf0e10cSrcweir ::osl::Condition::Result eResult = ::osl::Condition::result_ok; 2020*cdf0e10cSrcweir { 2021*cdf0e10cSrcweir // also release the SolarMutex. Not all code which is needed during the enumeration 2022*cdf0e10cSrcweir // is Solar-Thread-Safe, in particular there is some code which needs to access 2023*cdf0e10cSrcweir // string resources (and our resource system relies on the SolarMutex :() 2024*cdf0e10cSrcweir ReleaseSolarMutex aSolarRelease; 2025*cdf0e10cSrcweir 2026*cdf0e10cSrcweir // now wait. Note that if we didn't get an pAsyncDescriptor, then this is an infinite wait. 2027*cdf0e10cSrcweir eResult = m_aAsyncActionFinished.wait( pTimeout.get() ); 2028*cdf0e10cSrcweir } 2029*cdf0e10cSrcweir 2030*cdf0e10cSrcweir ::osl::MutexGuard aGuard2( maMutex ); 2031*cdf0e10cSrcweir if ( ::osl::Condition::result_timeout == eResult ) 2032*cdf0e10cSrcweir { 2033*cdf0e10cSrcweir // maximum time to wait 2034*cdf0e10cSrcweir OSL_ENSURE( !m_pCancelAsyncTimer.get(), "SvtFileView_Impl::GetFolderContent_Impl: there's still a previous timer!" ); 2035*cdf0e10cSrcweir m_pCancelAsyncTimer = new CallbackTimer( this ); 2036*cdf0e10cSrcweir sal_Int32 nMaxTimeout = pAsyncDescriptor->nMaxTimeout; 2037*cdf0e10cSrcweir OSL_ENSURE( nMaxTimeout > nMinTimeout, 2038*cdf0e10cSrcweir "SvtFileView_Impl::GetFolderContent_Impl: invalid maximum timeout!" ); 2039*cdf0e10cSrcweir if ( nMaxTimeout <= nMinTimeout ) 2040*cdf0e10cSrcweir nMaxTimeout = nMinTimeout + 5000; 2041*cdf0e10cSrcweir m_pCancelAsyncTimer->setRemainingTime( TTimeValue( nMaxTimeout - nMinTimeout ) ); 2042*cdf0e10cSrcweir // we already waited for nMinTimeout milliseconds, so take this into account 2043*cdf0e10cSrcweir m_pCancelAsyncTimer->start(); 2044*cdf0e10cSrcweir 2045*cdf0e10cSrcweir m_aCurrentAsyncActionHandler = pAsyncDescriptor->aFinishHandler; 2046*cdf0e10cSrcweir DBG_ASSERT( m_aCurrentAsyncActionHandler.IsSet(), "SvtFileView_Impl::GetFolderContent_Impl: nobody interested when it's finished?" ); 2047*cdf0e10cSrcweir mpView->ClearAll(); 2048*cdf0e10cSrcweir return eStillRunning; 2049*cdf0e10cSrcweir } 2050*cdf0e10cSrcweir 2051*cdf0e10cSrcweir m_bRunningAsyncAction = false; 2052*cdf0e10cSrcweir switch ( m_eAsyncActionResult ) 2053*cdf0e10cSrcweir { 2054*cdf0e10cSrcweir case ::svt::SUCCESS: 2055*cdf0e10cSrcweir return eSuccess; 2056*cdf0e10cSrcweir 2057*cdf0e10cSrcweir case ::svt::ERROR: 2058*cdf0e10cSrcweir return eFailure; 2059*cdf0e10cSrcweir 2060*cdf0e10cSrcweir case ::svt::RUNNING: 2061*cdf0e10cSrcweir return eStillRunning; 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir 2064*cdf0e10cSrcweir DBG_ERRORFILE( "SvtFileView_Impl::GetFolderContent_Impl: unreachable!" ); 2065*cdf0e10cSrcweir return eFailure; 2066*cdf0e10cSrcweir } 2067*cdf0e10cSrcweir 2068*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2069*cdf0e10cSrcweir void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) 2070*cdf0e10cSrcweir { 2071*cdf0e10cSrcweir sal_Bool bHideTransFile = mbReplaceNames && mpNameTrans; 2072*cdf0e10cSrcweir 2073*cdf0e10cSrcweir String sHideEntry; 2074*cdf0e10cSrcweir if( bHideTransFile ) 2075*cdf0e10cSrcweir { 2076*cdf0e10cSrcweir const String* pTransTableFileName = mpNameTrans->GetTransTableFileName(); 2077*cdf0e10cSrcweir if( pTransTableFileName ) 2078*cdf0e10cSrcweir { 2079*cdf0e10cSrcweir sHideEntry = *pTransTableFileName; 2080*cdf0e10cSrcweir sHideEntry.ToUpperAscii(); 2081*cdf0e10cSrcweir } 2082*cdf0e10cSrcweir else 2083*cdf0e10cSrcweir bHideTransFile = sal_False; 2084*cdf0e10cSrcweir } 2085*cdf0e10cSrcweir 2086*cdf0e10cSrcweir if ( !bHideTransFile && 2087*cdf0e10cSrcweir ( !rFilter.getLength() || ( rFilter.compareToAscii( ALL_FILES_FILTER ) == COMPARE_EQUAL ) ) ) 2088*cdf0e10cSrcweir // when replacing names, there is always something to filter (no view of ".nametranslation.table") 2089*cdf0e10cSrcweir return; 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2092*cdf0e10cSrcweir 2093*cdf0e10cSrcweir if ( maContent.empty() ) 2094*cdf0e10cSrcweir return; 2095*cdf0e10cSrcweir 2096*cdf0e10cSrcweir // count (estimate) the number of filter tokens 2097*cdf0e10cSrcweir sal_Int32 nTokens=0; 2098*cdf0e10cSrcweir const sal_Unicode* pStart = rFilter.getStr(); 2099*cdf0e10cSrcweir const sal_Unicode* pEnd = pStart + rFilter.getLength(); 2100*cdf0e10cSrcweir while ( pStart != pEnd ) 2101*cdf0e10cSrcweir if ( *pStart++ == ';' ) 2102*cdf0e10cSrcweir ++nTokens; 2103*cdf0e10cSrcweir 2104*cdf0e10cSrcweir // collect the filter tokens 2105*cdf0e10cSrcweir ::std::vector< WildCard > aFilters; 2106*cdf0e10cSrcweir FilterMatch::createWildCardFilterList(rFilter,aFilters); 2107*cdf0e10cSrcweir 2108*cdf0e10cSrcweir 2109*cdf0e10cSrcweir // do the filtering 2110*cdf0e10cSrcweir ::std::vector< SortingData_Impl* >::iterator aContentLoop = maContent.begin(); 2111*cdf0e10cSrcweir String sCompareString; 2112*cdf0e10cSrcweir do 2113*cdf0e10cSrcweir { 2114*cdf0e10cSrcweir if ( (*aContentLoop)->mbIsFolder ) 2115*cdf0e10cSrcweir ++aContentLoop; 2116*cdf0e10cSrcweir else 2117*cdf0e10cSrcweir { 2118*cdf0e10cSrcweir // normalize the content title (we always match case-insensitive) 2119*cdf0e10cSrcweir // 91872 - 11.09.2001 - frank.schoenheit@sun.com 2120*cdf0e10cSrcweir sCompareString = (*aContentLoop)->GetFileName(); // filter works on file name, not on title! 2121*cdf0e10cSrcweir sal_Bool bDelete; 2122*cdf0e10cSrcweir 2123*cdf0e10cSrcweir if( bHideTransFile && sCompareString == sHideEntry ) 2124*cdf0e10cSrcweir bDelete = sal_True; 2125*cdf0e10cSrcweir else 2126*cdf0e10cSrcweir { 2127*cdf0e10cSrcweir // search for the first filter which matches 2128*cdf0e10cSrcweir ::std::vector< WildCard >::const_iterator pMatchingFilter = 2129*cdf0e10cSrcweir ::std::find_if( 2130*cdf0e10cSrcweir aFilters.begin(), 2131*cdf0e10cSrcweir aFilters.end(), 2132*cdf0e10cSrcweir FilterMatch( sCompareString ) 2133*cdf0e10cSrcweir ); 2134*cdf0e10cSrcweir 2135*cdf0e10cSrcweir bDelete = aFilters.end() == pMatchingFilter; 2136*cdf0e10cSrcweir } 2137*cdf0e10cSrcweir 2138*cdf0e10cSrcweir if( bDelete ) 2139*cdf0e10cSrcweir { 2140*cdf0e10cSrcweir // none of the filters did match 2141*cdf0e10cSrcweir delete (*aContentLoop); 2142*cdf0e10cSrcweir 2143*cdf0e10cSrcweir if ( maContent.begin() == aContentLoop ) 2144*cdf0e10cSrcweir { 2145*cdf0e10cSrcweir maContent.erase( aContentLoop ); 2146*cdf0e10cSrcweir aContentLoop = maContent.begin(); 2147*cdf0e10cSrcweir } 2148*cdf0e10cSrcweir else 2149*cdf0e10cSrcweir { 2150*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aDelete = aContentLoop; 2151*cdf0e10cSrcweir --aContentLoop; // move the iterator to a position which is not invalidated by the erase 2152*cdf0e10cSrcweir maContent.erase( aDelete ); 2153*cdf0e10cSrcweir ++aContentLoop; // this is now the next one .... 2154*cdf0e10cSrcweir } 2155*cdf0e10cSrcweir } 2156*cdf0e10cSrcweir else 2157*cdf0e10cSrcweir ++aContentLoop; 2158*cdf0e10cSrcweir } 2159*cdf0e10cSrcweir } 2160*cdf0e10cSrcweir while ( aContentLoop != maContent.end() ); 2161*cdf0e10cSrcweir } 2162*cdf0e10cSrcweir 2163*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2164*cdf0e10cSrcweir IMPL_LINK( SvtFileView_Impl, SelectionMultiplexer, void*, _pSource ) 2165*cdf0e10cSrcweir { 2166*cdf0e10cSrcweir return mnSuspendSelectCallback ? 0L : m_aSelectHandler.Call( _pSource ); 2167*cdf0e10cSrcweir } 2168*cdf0e10cSrcweir 2169*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2170*cdf0e10cSrcweir void SvtFileView_Impl::SetSelectHandler( const Link& _rHdl ) 2171*cdf0e10cSrcweir { 2172*cdf0e10cSrcweir m_aSelectHandler = _rHdl; 2173*cdf0e10cSrcweir 2174*cdf0e10cSrcweir Link aMasterHandler; 2175*cdf0e10cSrcweir if ( m_aSelectHandler.IsSet() ) 2176*cdf0e10cSrcweir aMasterHandler = LINK( this, SvtFileView_Impl, SelectionMultiplexer ); 2177*cdf0e10cSrcweir 2178*cdf0e10cSrcweir mpView->SetSelectHdl( aMasterHandler ); 2179*cdf0e10cSrcweir } 2180*cdf0e10cSrcweir 2181*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2182*cdf0e10cSrcweir void SvtFileView_Impl::InitSelection() 2183*cdf0e10cSrcweir { 2184*cdf0e10cSrcweir mpView->SelectAll( sal_False ); 2185*cdf0e10cSrcweir SvLBoxEntry* pFirst = mpView->First(); 2186*cdf0e10cSrcweir if ( pFirst ) 2187*cdf0e10cSrcweir mpView->SetCursor( pFirst, sal_True ); 2188*cdf0e10cSrcweir } 2189*cdf0e10cSrcweir 2190*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2191*cdf0e10cSrcweir void SvtFileView_Impl::OpenFolder_Impl() 2192*cdf0e10cSrcweir { 2193*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2194*cdf0e10cSrcweir 2195*cdf0e10cSrcweir mpView->SetUpdateMode( sal_False ); 2196*cdf0e10cSrcweir mpView->ClearAll(); 2197*cdf0e10cSrcweir 2198*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aIt; 2199*cdf0e10cSrcweir 2200*cdf0e10cSrcweir for ( aIt = maContent.begin(); aIt != maContent.end(); aIt++ ) 2201*cdf0e10cSrcweir { 2202*cdf0e10cSrcweir if ( mbOnlyFolder && ! (*aIt)->mbIsFolder ) 2203*cdf0e10cSrcweir continue; 2204*cdf0e10cSrcweir 2205*cdf0e10cSrcweir // insert entry and set user data 2206*cdf0e10cSrcweir SvLBoxEntry* pEntry = mpView->InsertEntry( (*aIt)->maDisplayText, 2207*cdf0e10cSrcweir (*aIt)->maImage, 2208*cdf0e10cSrcweir (*aIt)->maImage ); 2209*cdf0e10cSrcweir 2210*cdf0e10cSrcweir SvtContentEntry* pUserData = new SvtContentEntry( (*aIt)->maTargetURL, 2211*cdf0e10cSrcweir (*aIt)->mbIsFolder ); 2212*cdf0e10cSrcweir pEntry->SetUserData( pUserData ); 2213*cdf0e10cSrcweir } 2214*cdf0e10cSrcweir 2215*cdf0e10cSrcweir InitSelection(); 2216*cdf0e10cSrcweir 2217*cdf0e10cSrcweir ++mnSuspendSelectCallback; 2218*cdf0e10cSrcweir mpView->SetUpdateMode( sal_True ); 2219*cdf0e10cSrcweir --mnSuspendSelectCallback; 2220*cdf0e10cSrcweir 2221*cdf0e10cSrcweir ResetCursor(); 2222*cdf0e10cSrcweir } 2223*cdf0e10cSrcweir 2224*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2225*cdf0e10cSrcweir void SvtFileView_Impl::ResetCursor() 2226*cdf0e10cSrcweir { 2227*cdf0e10cSrcweir // deselect 2228*cdf0e10cSrcweir SvLBoxEntry* pEntry = mpView->FirstSelected(); 2229*cdf0e10cSrcweir if ( pEntry ) 2230*cdf0e10cSrcweir mpView->Select( pEntry, sal_False ); 2231*cdf0e10cSrcweir // set cursor to the first entry 2232*cdf0e10cSrcweir mpView->SetCursor( mpView->First(), sal_True ); 2233*cdf0e10cSrcweir mpView->Update(); 2234*cdf0e10cSrcweir } 2235*cdf0e10cSrcweir 2236*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2237*cdf0e10cSrcweir void SvtFileView_Impl::CancelRunningAsyncAction() 2238*cdf0e10cSrcweir { 2239*cdf0e10cSrcweir DBG_TESTSOLARMUTEX(); 2240*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2241*cdf0e10cSrcweir if ( !m_pContentEnumerator.is() ) 2242*cdf0e10cSrcweir return; 2243*cdf0e10cSrcweir 2244*cdf0e10cSrcweir m_bAsyncActionCancelled = true; 2245*cdf0e10cSrcweir m_pContentEnumerator->cancel(); 2246*cdf0e10cSrcweir m_bRunningAsyncAction = false; 2247*cdf0e10cSrcweir 2248*cdf0e10cSrcweir m_pContentEnumerator = NULL; 2249*cdf0e10cSrcweir if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() ) 2250*cdf0e10cSrcweir m_pCancelAsyncTimer->stop(); 2251*cdf0e10cSrcweir m_pCancelAsyncTimer = NULL; 2252*cdf0e10cSrcweir } 2253*cdf0e10cSrcweir 2254*cdf0e10cSrcweir //----------------------------------------------------------------------- 2255*cdf0e10cSrcweir void SvtFileView_Impl::onTimeout( CallbackTimer* ) 2256*cdf0e10cSrcweir { 2257*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 2258*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2259*cdf0e10cSrcweir if ( !m_bRunningAsyncAction ) 2260*cdf0e10cSrcweir // there might have been a race condition while we waited for the mutex 2261*cdf0e10cSrcweir return; 2262*cdf0e10cSrcweir 2263*cdf0e10cSrcweir CancelRunningAsyncAction(); 2264*cdf0e10cSrcweir 2265*cdf0e10cSrcweir if ( m_aCurrentAsyncActionHandler.IsSet() ) 2266*cdf0e10cSrcweir { 2267*cdf0e10cSrcweir Application::PostUserEvent( m_aCurrentAsyncActionHandler, reinterpret_cast< void* >( eTimeout ) ); 2268*cdf0e10cSrcweir m_aCurrentAsyncActionHandler = Link(); 2269*cdf0e10cSrcweir } 2270*cdf0e10cSrcweir } 2271*cdf0e10cSrcweir 2272*cdf0e10cSrcweir //----------------------------------------------------------------------- 2273*cdf0e10cSrcweir void SvtFileView_Impl::enumerationDone( ::svt::EnumerationResult _eResult ) 2274*cdf0e10cSrcweir { 2275*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 2276*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2277*cdf0e10cSrcweir 2278*cdf0e10cSrcweir m_pContentEnumerator = NULL; 2279*cdf0e10cSrcweir if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() ) 2280*cdf0e10cSrcweir m_pCancelAsyncTimer->stop(); 2281*cdf0e10cSrcweir m_pCancelAsyncTimer = NULL; 2282*cdf0e10cSrcweir 2283*cdf0e10cSrcweir if ( m_bAsyncActionCancelled ) 2284*cdf0e10cSrcweir // this is to prevent race conditions 2285*cdf0e10cSrcweir return; 2286*cdf0e10cSrcweir 2287*cdf0e10cSrcweir m_eAsyncActionResult = _eResult; 2288*cdf0e10cSrcweir m_bRunningAsyncAction = false; 2289*cdf0e10cSrcweir 2290*cdf0e10cSrcweir m_aAsyncActionFinished.set(); 2291*cdf0e10cSrcweir 2292*cdf0e10cSrcweir if ( svt::SUCCESS == _eResult ) 2293*cdf0e10cSrcweir implEnumerationSuccess(); 2294*cdf0e10cSrcweir 2295*cdf0e10cSrcweir if ( m_aCurrentAsyncActionHandler.IsSet() ) 2296*cdf0e10cSrcweir { 2297*cdf0e10cSrcweir Application::PostUserEvent( m_aCurrentAsyncActionHandler, reinterpret_cast< void* >( m_eAsyncActionResult ) ); 2298*cdf0e10cSrcweir m_aCurrentAsyncActionHandler = Link(); 2299*cdf0e10cSrcweir } 2300*cdf0e10cSrcweir } 2301*cdf0e10cSrcweir 2302*cdf0e10cSrcweir //----------------------------------------------------------------------- 2303*cdf0e10cSrcweir void SvtFileView_Impl::implEnumerationSuccess() 2304*cdf0e10cSrcweir { 2305*cdf0e10cSrcweir FilterFolderContent_Impl( maCurrentFilter ); 2306*cdf0e10cSrcweir SortFolderContent_Impl(); 2307*cdf0e10cSrcweir CreateDisplayText_Impl(); 2308*cdf0e10cSrcweir OpenFolder_Impl(); 2309*cdf0e10cSrcweir maOpenDoneLink.Call( mpAntiImpl ); 2310*cdf0e10cSrcweir } 2311*cdf0e10cSrcweir 2312*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2313*cdf0e10cSrcweir void SvtFileView_Impl::ReplaceTabWithString( OUString& aValue ) 2314*cdf0e10cSrcweir { 2315*cdf0e10cSrcweir OUString aTab = OUString::createFromAscii( "\t" ); 2316*cdf0e10cSrcweir OUString aTabString = OUString::createFromAscii( "%09" ); 2317*cdf0e10cSrcweir sal_Int32 iPos; 2318*cdf0e10cSrcweir 2319*cdf0e10cSrcweir while ( ( iPos = aValue.indexOf( aTab ) ) >= 0 ) 2320*cdf0e10cSrcweir aValue = aValue.replaceAt( iPos, 1, aTabString ); 2321*cdf0e10cSrcweir } 2322*cdf0e10cSrcweir 2323*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2324*cdf0e10cSrcweir void SvtFileView_Impl::CreateDisplayText_Impl() 2325*cdf0e10cSrcweir { 2326*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2327*cdf0e10cSrcweir 2328*cdf0e10cSrcweir OUString aValue; 2329*cdf0e10cSrcweir OUString aTab = OUString::createFromAscii( "\t" ); 2330*cdf0e10cSrcweir OUString aDateSep = OUString::createFromAscii( ", " ); 2331*cdf0e10cSrcweir 2332*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aIt; 2333*cdf0e10cSrcweir 2334*cdf0e10cSrcweir for ( aIt = maContent.begin(); aIt != maContent.end(); aIt++ ) 2335*cdf0e10cSrcweir { 2336*cdf0e10cSrcweir // title, type, size, date 2337*cdf0e10cSrcweir aValue = (*aIt)->GetTitle(); 2338*cdf0e10cSrcweir // #83004# -------------------- 2339*cdf0e10cSrcweir ReplaceTabWithString( aValue ); 2340*cdf0e10cSrcweir aValue += aTab; 2341*cdf0e10cSrcweir aValue += (*aIt)->maType; 2342*cdf0e10cSrcweir aValue += aTab; 2343*cdf0e10cSrcweir // folders don't have a size 2344*cdf0e10cSrcweir if ( ! (*aIt)->mbIsFolder ) 2345*cdf0e10cSrcweir aValue += CreateExactSizeText_Impl( (*aIt)->maSize ); 2346*cdf0e10cSrcweir aValue += aTab; 2347*cdf0e10cSrcweir // set the date, but volumes have no date 2348*cdf0e10cSrcweir if ( ! (*aIt)->mbIsFolder || ! (*aIt)->mbIsVolume ) 2349*cdf0e10cSrcweir { 2350*cdf0e10cSrcweir SvtSysLocale aSysLocale; 2351*cdf0e10cSrcweir const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); 2352*cdf0e10cSrcweir aValue += rLocaleData.getDate( (*aIt)->maModDate ); 2353*cdf0e10cSrcweir aValue += aDateSep; 2354*cdf0e10cSrcweir aValue += rLocaleData.getTime( (*aIt)->maModDate ); 2355*cdf0e10cSrcweir } 2356*cdf0e10cSrcweir (*aIt)->maDisplayText = aValue; 2357*cdf0e10cSrcweir 2358*cdf0e10cSrcweir // detect image 2359*cdf0e10cSrcweir if ( (*aIt)->mbIsFolder ) 2360*cdf0e10cSrcweir { 2361*cdf0e10cSrcweir ::svtools::VolumeInfo aVolInfo( (*aIt)->mbIsVolume, (*aIt)->mbIsRemote, 2362*cdf0e10cSrcweir (*aIt)->mbIsRemoveable, (*aIt)->mbIsFloppy, 2363*cdf0e10cSrcweir (*aIt)->mbIsCompactDisc ); 2364*cdf0e10cSrcweir (*aIt)->maImage = SvFileInformationManager::GetFolderImage( aVolInfo, sal_False, isHighContrast( mpView ) ); 2365*cdf0e10cSrcweir } 2366*cdf0e10cSrcweir else 2367*cdf0e10cSrcweir (*aIt)->maImage = SvFileInformationManager::GetFileImage( INetURLObject( (*aIt)->maTargetURL ), sal_False, isHighContrast( mpView )); 2368*cdf0e10cSrcweir } 2369*cdf0e10cSrcweir } 2370*cdf0e10cSrcweir 2371*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2372*cdf0e10cSrcweir // this function converts the sequence of strings into a vector of SortingData 2373*cdf0e10cSrcweir // the string should have the form : 2374*cdf0e10cSrcweir // title \t type \t size \t date \t target url \t is folder \t image url 2375*cdf0e10cSrcweir 2376*cdf0e10cSrcweir void SvtFileView_Impl::CreateVector_Impl( const Sequence < OUString > &rList ) 2377*cdf0e10cSrcweir { 2378*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2379*cdf0e10cSrcweir 2380*cdf0e10cSrcweir OUString aTab = OUString::createFromAscii( "\t" ); 2381*cdf0e10cSrcweir 2382*cdf0e10cSrcweir sal_uInt32 nCount = (sal_uInt32) rList.getLength(); 2383*cdf0e10cSrcweir 2384*cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nCount; i++ ) 2385*cdf0e10cSrcweir { 2386*cdf0e10cSrcweir SortingData_Impl* pEntry = new SortingData_Impl; 2387*cdf0e10cSrcweir OUString aValue = rList[i]; 2388*cdf0e10cSrcweir OUString aDisplayText; 2389*cdf0e10cSrcweir sal_Int32 nIndex = 0; 2390*cdf0e10cSrcweir 2391*cdf0e10cSrcweir // get the title 2392*cdf0e10cSrcweir pEntry->SetNewTitle( aValue.getToken( 0, '\t', nIndex ) ); 2393*cdf0e10cSrcweir aDisplayText = pEntry->GetTitle(); 2394*cdf0e10cSrcweir // #83004# -------------------- 2395*cdf0e10cSrcweir ReplaceTabWithString( aDisplayText ); 2396*cdf0e10cSrcweir aDisplayText += aTab; 2397*cdf0e10cSrcweir 2398*cdf0e10cSrcweir // get the type 2399*cdf0e10cSrcweir if ( nIndex >= 0 ) 2400*cdf0e10cSrcweir { 2401*cdf0e10cSrcweir pEntry->maType = aValue.getToken( 0, '\t', nIndex ); 2402*cdf0e10cSrcweir aDisplayText += pEntry->maType; 2403*cdf0e10cSrcweir } 2404*cdf0e10cSrcweir aDisplayText += aTab; 2405*cdf0e10cSrcweir 2406*cdf0e10cSrcweir // get the size 2407*cdf0e10cSrcweir if ( nIndex >= 0 ) 2408*cdf0e10cSrcweir { 2409*cdf0e10cSrcweir OUString aSize = aValue.getToken( 0, '\t', nIndex ); 2410*cdf0e10cSrcweir aDisplayText += aSize; 2411*cdf0e10cSrcweir 2412*cdf0e10cSrcweir if ( aSize.getLength() ) 2413*cdf0e10cSrcweir pEntry->maSize = aSize.toInt64(); 2414*cdf0e10cSrcweir } 2415*cdf0e10cSrcweir aDisplayText += aTab; 2416*cdf0e10cSrcweir 2417*cdf0e10cSrcweir // get the date 2418*cdf0e10cSrcweir if ( nIndex >= 0 ) 2419*cdf0e10cSrcweir { 2420*cdf0e10cSrcweir OUString aDate = aValue.getToken( 0, '\t', nIndex ); 2421*cdf0e10cSrcweir aDisplayText += aDate; 2422*cdf0e10cSrcweir 2423*cdf0e10cSrcweir if ( aDate.getLength() ) 2424*cdf0e10cSrcweir { 2425*cdf0e10cSrcweir DBG_ERRORFILE( "Don't know, how to convert date" ); 2426*cdf0e10cSrcweir ;// convert date string to date 2427*cdf0e10cSrcweir } 2428*cdf0e10cSrcweir } 2429*cdf0e10cSrcweir // get the target url 2430*cdf0e10cSrcweir if ( nIndex >= 0 ) 2431*cdf0e10cSrcweir { 2432*cdf0e10cSrcweir pEntry->maTargetURL = aValue.getToken( 0, '\t', nIndex ); 2433*cdf0e10cSrcweir } 2434*cdf0e10cSrcweir // get the size 2435*cdf0e10cSrcweir if ( nIndex >= 0 ) 2436*cdf0e10cSrcweir { 2437*cdf0e10cSrcweir OUString aBool = aValue.getToken( 0, '\t', nIndex ); 2438*cdf0e10cSrcweir if ( aBool.getLength() ) 2439*cdf0e10cSrcweir pEntry->mbIsFolder = aBool.toBoolean(); 2440*cdf0e10cSrcweir } 2441*cdf0e10cSrcweir // get the image url 2442*cdf0e10cSrcweir if ( nIndex >= 0 ) 2443*cdf0e10cSrcweir { 2444*cdf0e10cSrcweir pEntry->maImageURL = aValue.getToken( 0, '\t', nIndex ); 2445*cdf0e10cSrcweir } 2446*cdf0e10cSrcweir 2447*cdf0e10cSrcweir // set the display text 2448*cdf0e10cSrcweir pEntry->maDisplayText = aDisplayText; 2449*cdf0e10cSrcweir 2450*cdf0e10cSrcweir // detect the image 2451*cdf0e10cSrcweir INetURLObject aObj( pEntry->maImageURL.getLength() ? pEntry->maImageURL : pEntry->maTargetURL ); 2452*cdf0e10cSrcweir pEntry->maImage = SvFileInformationManager::GetImage( aObj, sal_False, isHighContrast( mpView ) ); 2453*cdf0e10cSrcweir 2454*cdf0e10cSrcweir maContent.push_back( pEntry ); 2455*cdf0e10cSrcweir } 2456*cdf0e10cSrcweir } 2457*cdf0e10cSrcweir 2458*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2459*cdf0e10cSrcweir void SvtFileView_Impl::Resort_Impl( sal_Int16 nColumn, sal_Bool bAscending ) 2460*cdf0e10cSrcweir { 2461*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2462*cdf0e10cSrcweir 2463*cdf0e10cSrcweir if ( ( nColumn == mnSortColumn ) && 2464*cdf0e10cSrcweir ( bAscending == mbAscending ) ) 2465*cdf0e10cSrcweir return; 2466*cdf0e10cSrcweir 2467*cdf0e10cSrcweir // reset the quick search index 2468*cdf0e10cSrcweir mpView->ResetQuickSearch_Impl( NULL ); 2469*cdf0e10cSrcweir 2470*cdf0e10cSrcweir String aEntryURL; 2471*cdf0e10cSrcweir SvLBoxEntry* pEntry = mpView->GetCurEntry(); 2472*cdf0e10cSrcweir if ( pEntry && pEntry->GetUserData() ) 2473*cdf0e10cSrcweir aEntryURL = ( (SvtContentEntry*)pEntry->GetUserData() )->maURL; 2474*cdf0e10cSrcweir 2475*cdf0e10cSrcweir mnSortColumn = nColumn; 2476*cdf0e10cSrcweir mbAscending = bAscending; 2477*cdf0e10cSrcweir 2478*cdf0e10cSrcweir SortFolderContent_Impl(); 2479*cdf0e10cSrcweir OpenFolder_Impl(); 2480*cdf0e10cSrcweir 2481*cdf0e10cSrcweir if ( !mbIsFirstResort ) 2482*cdf0e10cSrcweir { 2483*cdf0e10cSrcweir sal_uLong nPos = GetEntryPos( aEntryURL ); 2484*cdf0e10cSrcweir if ( nPos < mpView->GetEntryCount() ) 2485*cdf0e10cSrcweir { 2486*cdf0e10cSrcweir pEntry = mpView->GetEntry( nPos ); 2487*cdf0e10cSrcweir 2488*cdf0e10cSrcweir ++mnSuspendSelectCallback; // #i15668# - 2004-04-25 - fs@openoffice.org 2489*cdf0e10cSrcweir mpView->SetCurEntry( pEntry ); 2490*cdf0e10cSrcweir --mnSuspendSelectCallback; 2491*cdf0e10cSrcweir } 2492*cdf0e10cSrcweir } 2493*cdf0e10cSrcweir else 2494*cdf0e10cSrcweir mbIsFirstResort = sal_False; 2495*cdf0e10cSrcweir } 2496*cdf0e10cSrcweir 2497*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2498*cdf0e10cSrcweir static sal_Bool gbAscending = sal_True; 2499*cdf0e10cSrcweir static sal_Int16 gnColumn = COLUMN_TITLE; 2500*cdf0e10cSrcweir static const CollatorWrapper* pCollatorWrapper = NULL; 2501*cdf0e10cSrcweir 2502*cdf0e10cSrcweir /* this functions returns true, if aOne is less then aTwo 2503*cdf0e10cSrcweir */ 2504*cdf0e10cSrcweir sal_Bool CompareSortingData_Impl( SortingData_Impl* const aOne, SortingData_Impl* const aTwo ) 2505*cdf0e10cSrcweir { 2506*cdf0e10cSrcweir DBG_ASSERT( pCollatorWrapper, "*CompareSortingData_Impl(): Can't work this way!" ); 2507*cdf0e10cSrcweir 2508*cdf0e10cSrcweir sal_Int32 nComp; 2509*cdf0e10cSrcweir sal_Bool bRet = sal_False; 2510*cdf0e10cSrcweir sal_Bool bEqual = sal_False; 2511*cdf0e10cSrcweir 2512*cdf0e10cSrcweir if ( aOne->mbIsFolder != aTwo->mbIsFolder ) 2513*cdf0e10cSrcweir { 2514*cdf0e10cSrcweir if ( aOne->mbIsFolder ) 2515*cdf0e10cSrcweir bRet = sal_True; 2516*cdf0e10cSrcweir else 2517*cdf0e10cSrcweir bRet = sal_False; 2518*cdf0e10cSrcweir 2519*cdf0e10cSrcweir // !!! pb: #100376# folder always on top 2520*cdf0e10cSrcweir if ( !gbAscending ) 2521*cdf0e10cSrcweir bRet = !bRet; 2522*cdf0e10cSrcweir } 2523*cdf0e10cSrcweir else 2524*cdf0e10cSrcweir { 2525*cdf0e10cSrcweir switch ( gnColumn ) 2526*cdf0e10cSrcweir { 2527*cdf0e10cSrcweir case COLUMN_TITLE: 2528*cdf0e10cSrcweir // compare case insensitiv first 2529*cdf0e10cSrcweir nComp = pCollatorWrapper->compareString( aOne->GetLowerTitle(), aTwo->GetLowerTitle() ); 2530*cdf0e10cSrcweir 2531*cdf0e10cSrcweir if ( nComp == 0 ) 2532*cdf0e10cSrcweir nComp = pCollatorWrapper->compareString( aOne->GetTitle(), aTwo->GetTitle() ); 2533*cdf0e10cSrcweir 2534*cdf0e10cSrcweir if ( nComp < 0 ) 2535*cdf0e10cSrcweir bRet = sal_True; 2536*cdf0e10cSrcweir else if ( nComp > 0 ) 2537*cdf0e10cSrcweir bRet = sal_False; 2538*cdf0e10cSrcweir else 2539*cdf0e10cSrcweir bEqual = sal_True; 2540*cdf0e10cSrcweir break; 2541*cdf0e10cSrcweir case COLUMN_TYPE: 2542*cdf0e10cSrcweir nComp = pCollatorWrapper->compareString( aOne->maType, aTwo->maType ); 2543*cdf0e10cSrcweir if ( nComp < 0 ) 2544*cdf0e10cSrcweir bRet = sal_True; 2545*cdf0e10cSrcweir else if ( nComp > 0 ) 2546*cdf0e10cSrcweir bRet = sal_False; 2547*cdf0e10cSrcweir else 2548*cdf0e10cSrcweir bEqual = sal_True; 2549*cdf0e10cSrcweir break; 2550*cdf0e10cSrcweir case COLUMN_SIZE: 2551*cdf0e10cSrcweir if ( aOne->maSize < aTwo->maSize ) 2552*cdf0e10cSrcweir bRet = sal_True; 2553*cdf0e10cSrcweir else if ( aOne->maSize > aTwo->maSize ) 2554*cdf0e10cSrcweir bRet = sal_False; 2555*cdf0e10cSrcweir else 2556*cdf0e10cSrcweir bEqual = sal_True; 2557*cdf0e10cSrcweir break; 2558*cdf0e10cSrcweir case COLUMN_DATE: 2559*cdf0e10cSrcweir if ( aOne->maModDate < aTwo->maModDate ) 2560*cdf0e10cSrcweir bRet = sal_True; 2561*cdf0e10cSrcweir else if ( aOne->maModDate > aTwo->maModDate ) 2562*cdf0e10cSrcweir bRet = sal_False; 2563*cdf0e10cSrcweir else 2564*cdf0e10cSrcweir bEqual = sal_True; 2565*cdf0e10cSrcweir break; 2566*cdf0e10cSrcweir default: 2567*cdf0e10cSrcweir DBG_WARNING( "CompareSortingData_Impl: Compare unknown type!" ); 2568*cdf0e10cSrcweir bRet = sal_False; 2569*cdf0e10cSrcweir } 2570*cdf0e10cSrcweir } 2571*cdf0e10cSrcweir 2572*cdf0e10cSrcweir // when the two elements are equal, we must not return sal_True (which would 2573*cdf0e10cSrcweir // happen if we just return ! ( a < b ) when not sorting ascending ) 2574*cdf0e10cSrcweir if ( bEqual ) 2575*cdf0e10cSrcweir return sal_False; 2576*cdf0e10cSrcweir 2577*cdf0e10cSrcweir return gbAscending ? bRet : !bRet; 2578*cdf0e10cSrcweir } 2579*cdf0e10cSrcweir 2580*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2581*cdf0e10cSrcweir void SvtFileView_Impl::SortFolderContent_Impl() 2582*cdf0e10cSrcweir { 2583*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2584*cdf0e10cSrcweir 2585*cdf0e10cSrcweir sal_uInt32 nSize = maContent.size(); 2586*cdf0e10cSrcweir 2587*cdf0e10cSrcweir if ( nSize > 1 ) 2588*cdf0e10cSrcweir { 2589*cdf0e10cSrcweir gbAscending = mbAscending; 2590*cdf0e10cSrcweir gnColumn = mnSortColumn; 2591*cdf0e10cSrcweir pCollatorWrapper = aIntlWrapper.getCaseCollator(); 2592*cdf0e10cSrcweir 2593*cdf0e10cSrcweir std::stable_sort( maContent.begin(), maContent.end(), CompareSortingData_Impl ); 2594*cdf0e10cSrcweir 2595*cdf0e10cSrcweir pCollatorWrapper = NULL; 2596*cdf0e10cSrcweir } 2597*cdf0e10cSrcweir } 2598*cdf0e10cSrcweir 2599*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2600*cdf0e10cSrcweir void SvtFileView_Impl::EntryRemoved( const OUString& rURL ) 2601*cdf0e10cSrcweir { 2602*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2603*cdf0e10cSrcweir 2604*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aIt; 2605*cdf0e10cSrcweir 2606*cdf0e10cSrcweir for ( aIt = maContent.begin(); aIt != maContent.end(); aIt++ ) 2607*cdf0e10cSrcweir { 2608*cdf0e10cSrcweir if ( (*aIt)->maTargetURL == rURL ) 2609*cdf0e10cSrcweir { 2610*cdf0e10cSrcweir maContent.erase( aIt ); 2611*cdf0e10cSrcweir break; 2612*cdf0e10cSrcweir } 2613*cdf0e10cSrcweir } 2614*cdf0e10cSrcweir } 2615*cdf0e10cSrcweir 2616*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2617*cdf0e10cSrcweir void SvtFileView_Impl::EntryRenamed( OUString& rURL, 2618*cdf0e10cSrcweir const OUString& rTitle ) 2619*cdf0e10cSrcweir { 2620*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2621*cdf0e10cSrcweir 2622*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aIt; 2623*cdf0e10cSrcweir 2624*cdf0e10cSrcweir for ( aIt = maContent.begin(); aIt != maContent.end(); aIt++ ) 2625*cdf0e10cSrcweir { 2626*cdf0e10cSrcweir if ( (*aIt)->maTargetURL == rURL ) 2627*cdf0e10cSrcweir { 2628*cdf0e10cSrcweir (*aIt)->SetNewTitle( rTitle ); 2629*cdf0e10cSrcweir OUString aDisplayText = (*aIt)->maDisplayText; 2630*cdf0e10cSrcweir sal_Int32 nIndex = aDisplayText.indexOf( '\t' ); 2631*cdf0e10cSrcweir 2632*cdf0e10cSrcweir if ( nIndex > 0 ) 2633*cdf0e10cSrcweir (*aIt)->maDisplayText = aDisplayText.replaceAt( 0, nIndex, rTitle ); 2634*cdf0e10cSrcweir 2635*cdf0e10cSrcweir INetURLObject aURLObj( rURL ); 2636*cdf0e10cSrcweir aURLObj.SetName( rTitle, INetURLObject::ENCODE_ALL ); 2637*cdf0e10cSrcweir 2638*cdf0e10cSrcweir rURL = aURLObj.GetMainURL( INetURLObject::NO_DECODE ); 2639*cdf0e10cSrcweir 2640*cdf0e10cSrcweir (*aIt)->maTargetURL = rURL; 2641*cdf0e10cSrcweir break; 2642*cdf0e10cSrcweir } 2643*cdf0e10cSrcweir } 2644*cdf0e10cSrcweir } 2645*cdf0e10cSrcweir 2646*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2647*cdf0e10cSrcweir String SvtFileView_Impl::FolderInserted( const OUString& rURL, const OUString& rTitle ) 2648*cdf0e10cSrcweir { 2649*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2650*cdf0e10cSrcweir 2651*cdf0e10cSrcweir SortingData_Impl* pData = new SortingData_Impl; 2652*cdf0e10cSrcweir 2653*cdf0e10cSrcweir pData->SetNewTitle( rTitle ); 2654*cdf0e10cSrcweir pData->maSize = 0; 2655*cdf0e10cSrcweir pData->mbIsFolder = sal_True; 2656*cdf0e10cSrcweir pData->maTargetURL = rURL; 2657*cdf0e10cSrcweir 2658*cdf0e10cSrcweir INetURLObject aURLObj( rURL ); 2659*cdf0e10cSrcweir 2660*cdf0e10cSrcweir ::svtools::VolumeInfo aVolInfo; 2661*cdf0e10cSrcweir pData->maType = SvFileInformationManager::GetFolderDescription( aVolInfo ); 2662*cdf0e10cSrcweir pData->maImage = SvFileInformationManager::GetFolderImage( aVolInfo, sal_False, isHighContrast( mpView ) ); 2663*cdf0e10cSrcweir 2664*cdf0e10cSrcweir OUString aValue; 2665*cdf0e10cSrcweir OUString aTab = OUString::createFromAscii( "\t" ); 2666*cdf0e10cSrcweir OUString aDateSep = OUString::createFromAscii( ", " ); 2667*cdf0e10cSrcweir 2668*cdf0e10cSrcweir // title, type, size, date 2669*cdf0e10cSrcweir aValue = pData->GetTitle(); 2670*cdf0e10cSrcweir // #83004# -------------------- 2671*cdf0e10cSrcweir ReplaceTabWithString( aValue ); 2672*cdf0e10cSrcweir aValue += aTab; 2673*cdf0e10cSrcweir aValue += pData->maType; 2674*cdf0e10cSrcweir aValue += aTab; 2675*cdf0e10cSrcweir // folders don't have a size 2676*cdf0e10cSrcweir aValue += aTab; 2677*cdf0e10cSrcweir // set the date 2678*cdf0e10cSrcweir SvtSysLocale aSysLocale; 2679*cdf0e10cSrcweir const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); 2680*cdf0e10cSrcweir aValue += rLocaleData.getDate( pData->maModDate ); 2681*cdf0e10cSrcweir aValue += aDateSep; 2682*cdf0e10cSrcweir aValue += rLocaleData.getTime( pData->maModDate ); 2683*cdf0e10cSrcweir 2684*cdf0e10cSrcweir pData->maDisplayText = aValue; 2685*cdf0e10cSrcweir maContent.push_back( pData ); 2686*cdf0e10cSrcweir 2687*cdf0e10cSrcweir return String( aValue ); 2688*cdf0e10cSrcweir } 2689*cdf0e10cSrcweir 2690*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2691*cdf0e10cSrcweir sal_uLong SvtFileView_Impl::GetEntryPos( const OUString& rURL ) 2692*cdf0e10cSrcweir { 2693*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2694*cdf0e10cSrcweir 2695*cdf0e10cSrcweir std::vector< SortingData_Impl* >::iterator aIt; 2696*cdf0e10cSrcweir sal_uLong nPos = 0; 2697*cdf0e10cSrcweir 2698*cdf0e10cSrcweir for ( aIt = maContent.begin(); aIt != maContent.end(); aIt++ ) 2699*cdf0e10cSrcweir { 2700*cdf0e10cSrcweir if ( (*aIt)->maTargetURL == rURL ) 2701*cdf0e10cSrcweir return nPos; 2702*cdf0e10cSrcweir nPos += 1; 2703*cdf0e10cSrcweir } 2704*cdf0e10cSrcweir 2705*cdf0e10cSrcweir return nPos; 2706*cdf0e10cSrcweir } 2707*cdf0e10cSrcweir 2708*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2709*cdf0e10cSrcweir sal_Bool SvtFileView_Impl::SearchNextEntry( sal_uInt32& nIndex, const OUString& rTitle, sal_Bool bWrapAround ) 2710*cdf0e10cSrcweir { 2711*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 2712*cdf0e10cSrcweir 2713*cdf0e10cSrcweir sal_uInt32 nEnd = maContent.size(); 2714*cdf0e10cSrcweir sal_uInt32 nStart = nIndex; 2715*cdf0e10cSrcweir while ( nIndex < nEnd ) 2716*cdf0e10cSrcweir { 2717*cdf0e10cSrcweir SortingData_Impl* pData = maContent[ nIndex ]; 2718*cdf0e10cSrcweir if ( rTitle.compareTo( pData->GetLowerTitle(), rTitle.getLength() ) == 0 ) 2719*cdf0e10cSrcweir return sal_True; 2720*cdf0e10cSrcweir nIndex += 1; 2721*cdf0e10cSrcweir } 2722*cdf0e10cSrcweir 2723*cdf0e10cSrcweir if ( bWrapAround ) 2724*cdf0e10cSrcweir { 2725*cdf0e10cSrcweir nIndex = 0; 2726*cdf0e10cSrcweir while ( nIndex < nEnd && nIndex <= nStart ) 2727*cdf0e10cSrcweir { 2728*cdf0e10cSrcweir SortingData_Impl* pData = maContent[ nIndex ]; 2729*cdf0e10cSrcweir if ( rTitle.compareTo( pData->GetLowerTitle(), rTitle.getLength() ) == 0 ) 2730*cdf0e10cSrcweir return sal_True; 2731*cdf0e10cSrcweir nIndex += 1; 2732*cdf0e10cSrcweir } 2733*cdf0e10cSrcweir } 2734*cdf0e10cSrcweir 2735*cdf0e10cSrcweir return sal_False; 2736*cdf0e10cSrcweir } 2737*cdf0e10cSrcweir 2738*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2739*cdf0e10cSrcweir void SvtFileView_Impl::SetActualFolder( const INetURLObject& rActualFolder ) 2740*cdf0e10cSrcweir { 2741*cdf0e10cSrcweir if( mbReplaceNames ) 2742*cdf0e10cSrcweir { 2743*cdf0e10cSrcweir if( mpNameTrans ) 2744*cdf0e10cSrcweir mpNameTrans->SetActualFolder( rActualFolder ); 2745*cdf0e10cSrcweir else 2746*cdf0e10cSrcweir mpNameTrans = new NameTranslator_Impl( rActualFolder ); 2747*cdf0e10cSrcweir } 2748*cdf0e10cSrcweir } 2749*cdf0e10cSrcweir 2750*cdf0e10cSrcweir namespace svtools { 2751*cdf0e10cSrcweir 2752*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2753*cdf0e10cSrcweir // QueryDeleteDlg_Impl 2754*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2755*cdf0e10cSrcweir 2756*cdf0e10cSrcweir QueryDeleteDlg_Impl::QueryDeleteDlg_Impl 2757*cdf0e10cSrcweir ( 2758*cdf0e10cSrcweir Window* pParent, 2759*cdf0e10cSrcweir const String& rName // Eintragsname 2760*cdf0e10cSrcweir ) : 2761*cdf0e10cSrcweir 2762*cdf0e10cSrcweir ModalDialog( pParent, SvtResId( DLG_SVT_QUERYDELETE ) ), 2763*cdf0e10cSrcweir 2764*cdf0e10cSrcweir _aEntryLabel ( this, SvtResId( TXT_ENTRY ) ), 2765*cdf0e10cSrcweir _aEntry ( this, SvtResId( TXT_ENTRYNAME ) ), 2766*cdf0e10cSrcweir _aQueryMsg ( this, SvtResId( TXT_QUERYMSG ) ), 2767*cdf0e10cSrcweir _aYesButton ( this, SvtResId( BTN_YES ) ), 2768*cdf0e10cSrcweir _aAllButton ( this, SvtResId( BTN_ALL ) ), 2769*cdf0e10cSrcweir _aNoButton ( this, SvtResId( BTN_NO ) ), 2770*cdf0e10cSrcweir _aCancelButton( this, SvtResId( BTN_CANCEL ) ) 2771*cdf0e10cSrcweir 2772*cdf0e10cSrcweir { 2773*cdf0e10cSrcweir FreeResource(); 2774*cdf0e10cSrcweir 2775*cdf0e10cSrcweir // Handler 2776*cdf0e10cSrcweir Link aLink( STATIC_LINK( this, QueryDeleteDlg_Impl, ClickLink ) ); 2777*cdf0e10cSrcweir _aYesButton.SetClickHdl( aLink ); 2778*cdf0e10cSrcweir _aAllButton.SetClickHdl( aLink ); 2779*cdf0e10cSrcweir _aNoButton.SetClickHdl( aLink ); 2780*cdf0e10cSrcweir 2781*cdf0e10cSrcweir // Anzeige der spezifizierten Texte 2782*cdf0e10cSrcweir 2783*cdf0e10cSrcweir WinBits nTmpStyle = _aEntry.GetStyle(); 2784*cdf0e10cSrcweir nTmpStyle |= WB_PATHELLIPSIS; 2785*cdf0e10cSrcweir _aEntry.SetStyle( nTmpStyle ); 2786*cdf0e10cSrcweir _aEntry.SetText( rName ); 2787*cdf0e10cSrcweir } 2788*cdf0e10cSrcweir 2789*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2790*cdf0e10cSrcweir 2791*cdf0e10cSrcweir IMPL_STATIC_LINK( QueryDeleteDlg_Impl, ClickLink, PushButton*, pBtn ) 2792*cdf0e10cSrcweir { 2793*cdf0e10cSrcweir if ( pBtn == &pThis->_aYesButton ) 2794*cdf0e10cSrcweir pThis->_eResult = QUERYDELETE_YES; 2795*cdf0e10cSrcweir else if ( pBtn == &pThis->_aNoButton ) 2796*cdf0e10cSrcweir pThis->_eResult = QUERYDELETE_NO; 2797*cdf0e10cSrcweir else if ( pBtn == &pThis->_aAllButton ) 2798*cdf0e10cSrcweir pThis->_eResult = QUERYDELETE_ALL; 2799*cdf0e10cSrcweir else if ( pBtn == &pThis->_aCancelButton ) 2800*cdf0e10cSrcweir pThis->_eResult = QUERYDELETE_CANCEL; 2801*cdf0e10cSrcweir 2802*cdf0e10cSrcweir pThis->EndDialog( RET_OK ); 2803*cdf0e10cSrcweir 2804*cdf0e10cSrcweir return 0; 2805*cdf0e10cSrcweir } 2806*cdf0e10cSrcweir 2807*cdf0e10cSrcweir } 2808*cdf0e10cSrcweir 2809