LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/contnr - contentenumeration.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 33 0.0 %
Date: 2013-07-09 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef SVTOOLS_SOURCE_CONTNR_CONTENTENUMERATION_HXX
      21             : #define SVTOOLS_SOURCE_CONTNR_CONTENTENUMERATION_HXX
      22             : 
      23             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      24             : #include <com/sun/star/document/XDocumentProperties.hpp>
      25             : #include <salhelper/thread.hxx>
      26             : #include <ucbhelper/content.hxx>
      27             : #include <rtl/ustring.hxx>
      28             : #include <tools/datetime.hxx>
      29             : #include <tools/string.hxx>
      30             : #include <vcl/image.hxx>
      31             : 
      32             : //........................................................................
      33             : namespace svt
      34             : {
      35             : //........................................................................
      36             : 
      37             :     //====================================================================
      38             :     //= SortingData_Impl
      39             :     //====================================================================
      40           0 :     struct SortingData_Impl
      41             :     {
      42             :     private:
      43             :         OUString maFilename;     // only filename in upper case - for compare purposes
      44             :         OUString maTitle;        //  -> be carefull when changing maTitle to update maFilename only when new
      45             :         OUString maLowerTitle;
      46             : 
      47             : 
      48             :     public:
      49             :         OUString maType;
      50             :         OUString maTargetURL;
      51             :         OUString maImageURL;
      52             :         OUString maDisplayText;
      53             :         DateTime        maModDate;
      54             :         Image           maImage;
      55             :         sal_Int64       maSize;
      56             :         sal_Bool        mbIsFolder;
      57             :         sal_Bool        mbIsVolume;
      58             :         sal_Bool        mbIsRemote;
      59             :         sal_Bool        mbIsRemoveable;
      60             :         sal_Bool        mbIsFloppy;
      61             :         sal_Bool        mbIsCompactDisc;
      62             : 
      63             :         inline                          SortingData_Impl();
      64             :         inline const OUString&   GetTitle() const;
      65             :         inline const OUString&   GetLowerTitle() const;
      66             :         inline const OUString&   GetFileName() const;
      67             :         inline void                     SetNewTitle( const OUString& rNewTitle );        // new maTitle is set -> maFilename is set to same!
      68             :         inline void                     ChangeTitle( const OUString& rChangedTitle );    // maTitle is changed, maFilename is unchanged!
      69             : 
      70             :     private:
      71             :         inline void                     SetTitles( const OUString& rNewTitle );
      72             :     };
      73             : 
      74           0 :     inline SortingData_Impl::SortingData_Impl() :
      75             :         maModDate       ( DateTime::EMPTY ),
      76             :         maSize          ( 0 ),
      77             :         mbIsFolder      ( sal_False ),
      78             :         mbIsVolume      ( sal_False ),
      79             :         mbIsRemote      ( sal_False ),
      80             :         mbIsRemoveable  ( sal_False ),
      81             :         mbIsFloppy      ( sal_False ),
      82           0 :         mbIsCompactDisc ( sal_False )
      83             :     {
      84           0 :     }
      85             : 
      86           0 :     inline const OUString& SortingData_Impl::GetTitle() const
      87             :     {
      88           0 :         return maTitle;
      89             :     }
      90             : 
      91           0 :     inline const OUString& SortingData_Impl::GetLowerTitle() const
      92             :     {
      93           0 :         return maLowerTitle;
      94             :     }
      95             : 
      96           0 :     inline const OUString& SortingData_Impl::GetFileName() const
      97             :     {
      98           0 :         return maFilename;
      99             :     }
     100             : 
     101           0 :     inline void SortingData_Impl::SetNewTitle( const OUString& rNewTitle )
     102             :     {
     103           0 :         SetTitles( rNewTitle );
     104           0 :         maFilename = rNewTitle.toAsciiUpperCase();
     105           0 :     }
     106             : 
     107           0 :     inline void SortingData_Impl::ChangeTitle( const OUString& rChangedTitle )
     108             :     {
     109           0 :         SetTitles( rChangedTitle );
     110           0 :     }
     111             : 
     112           0 :     inline void SortingData_Impl::SetTitles( const OUString& rNewTitle )
     113             :     {
     114           0 :         maTitle = rNewTitle;
     115           0 :         maLowerTitle = rNewTitle.toAsciiLowerCase();
     116           0 :     }
     117             : 
     118             :     //====================================================================
     119             :     //= IContentTitleTranslation
     120             :     //====================================================================
     121           0 :     class IContentTitleTranslation
     122             :     {
     123             :     public:
     124             :         virtual sal_Bool    GetTranslation( const OUString& _rOriginalName, OUString& _rTranslatedName ) const = 0;
     125             : 
     126             :     protected:
     127           0 :         ~IContentTitleTranslation() {}
     128             :     };
     129             : 
     130             :     //====================================================================
     131             :     //= EnumerationResult
     132             :     //====================================================================
     133             :     enum EnumerationResult
     134             :     {
     135             :         SUCCESS,    /// the enumeration was successful
     136             :         ERROR,      /// the enumeration was unsuccessful
     137             :         RUNNING     /// the enumeration is still running, and the maximum wait time has passed
     138             :     };
     139             : 
     140             :     //====================================================================
     141             :     //= FolderDescriptor
     142             :     //====================================================================
     143           0 :     struct FolderDescriptor
     144             :     {
     145             :         /** a content object describing the folder. Can be <NULL/>, in this case <member>sURL</member>
     146             :             is relevant.
     147             :         */
     148             :         ::ucbhelper::Content  aContent;
     149             :         /** the URL of a folder. Will be ignored if <member>aContent</member> is not <NULL/>.
     150             :         */
     151             :         String          sURL;
     152             : 
     153           0 :         FolderDescriptor() { }
     154             : 
     155           0 :         FolderDescriptor( const ::ucbhelper::Content& _rContent )
     156           0 :             :aContent( _rContent )
     157             :         {
     158           0 :         }
     159             : 
     160           0 :         FolderDescriptor( const String& _rURL )
     161           0 :             :sURL( _rURL )
     162             :         {
     163           0 :         }
     164             :     };
     165             : 
     166             :     //====================================================================
     167             :     //= IEnumerationResultHandler
     168             :     //====================================================================
     169           0 :     class IEnumerationResultHandler
     170             :     {
     171             :     public:
     172             :         virtual void        enumerationDone( EnumerationResult _eResult ) = 0;
     173             : 
     174             :     protected:
     175           0 :         ~IEnumerationResultHandler() {}
     176             :     };
     177             : 
     178             :     //====================================================================
     179             :     //= FileViewContentEnumerator
     180             :     //====================================================================
     181             :     class FileViewContentEnumerator: public salhelper::Thread
     182             :     {
     183             :     public:
     184             :         typedef ::std::vector< SortingData_Impl* >  ContentData;
     185             : 
     186             :     private:
     187             :         ContentData&                    m_rContent;
     188             :         ::osl::Mutex&                   m_rContentMutex;
     189             : 
     190             :         mutable ::osl::Mutex            m_aMutex;
     191             : 
     192             :         FolderDescriptor                m_aFolder;
     193             :         ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >
     194             :                                         m_xCommandEnv;
     195             :         const IContentTitleTranslation* m_pTranslator;
     196             :         IEnumerationResultHandler*      m_pResultHandler;
     197             :         bool                            m_bCancelled;
     198             : 
     199             :         mutable ::com::sun::star::uno::Reference<
     200             :             ::com::sun::star::document::XDocumentProperties>
     201             :                                         m_xDocProps;
     202             : 
     203             :         ::com::sun::star::uno::Sequence< OUString > m_rBlackList;
     204             : 
     205             :         sal_Bool URLOnBlackList ( const OUString& sRealURL );
     206             : 
     207             :     public:
     208             :         /** constructs an enumerator instance
     209             : 
     210             :             @param _rContentToFill
     211             :                 the structure which is to be filled with the found content
     212             :             @param _rContentMutex
     213             :                 the mutex which protects the access to <arg>_rContentToFill</arg>
     214             :             @param _pTranslator
     215             :                 an instance which should be used to translate content titles. May be <NULL/>
     216             :         */
     217             :         FileViewContentEnumerator(
     218             :             const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxCommandEnv,
     219             :             ContentData& _rContentToFill,
     220             :             ::osl::Mutex& _rContentMutex,
     221             :             const IContentTitleTranslation* _pTranslator
     222             :         );
     223             : 
     224             :         /** enumerates the content of a given folder
     225             : 
     226             :             @param _rFolder
     227             :                 the folder whose content is to be enumerated
     228             :             @param _pFilter
     229             :                 a filter to apply to the found contents
     230             :             @param _pResultHandler
     231             :                 an instance which should handle the results of the enumeration
     232             :         */
     233             :         void    enumerateFolderContent(
     234             :                     const FolderDescriptor& _rFolder,
     235             :                     IEnumerationResultHandler* _pResultHandler
     236             :                 );
     237             : 
     238             :         /** enumerates the content of a given folder synchronously
     239             :         */
     240             :         EnumerationResult   enumerateFolderContentSync(
     241             :                     const FolderDescriptor& _rFolder,
     242             :                     const ::com::sun::star::uno::Sequence< OUString >& rBlackList = ::com::sun::star::uno::Sequence< OUString >()
     243             :                 );
     244             : 
     245             :         /** cancels the running operation.
     246             : 
     247             :             Note that "cancel" may mean that the operation is running, but its result
     248             :             is simply disregarded later on.
     249             :         */
     250             :         void    cancel();
     251             : 
     252             :     protected:
     253             :         ~FileViewContentEnumerator();
     254             : 
     255             :     private:
     256             :         EnumerationResult enumerateFolderContent();
     257             : 
     258             :         // Thread overridables
     259             :         virtual void execute();
     260             : 
     261             :     private:
     262             :         sal_Bool implGetDocTitle( const OUString& _rTargetURL, OUString& _rRet ) const;
     263             :     };
     264             : 
     265             : //........................................................................
     266             : } // namespace svt
     267             : //........................................................................
     268             : 
     269             : #endif // SVTOOLS_SOURCE_CONTNR_CONTENTENUMERATION_HXX
     270             : 
     271             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10