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