LCOV - code coverage report
Current view: top level - include/vcl - IconThemeScanner.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.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             : 
      10             : #ifndef INCLUDED_VCL_ICONTHEMESCANNER_HXX
      11             : #define INCLUDED_VCL_ICONTHEMESCANNER_HXX
      12             : 
      13             : #include <vcl/dllapi.h>
      14             : #include <tools/solar.h>
      15             : 
      16             : #include <rtl/ustring.hxx>
      17             : 
      18             : #include <memory>
      19             : #include <vector>
      20             : 
      21             : // forward declaration of unit test class. Required for friend relationship.
      22             : class IconThemeScannerTest;
      23             : 
      24             : namespace osl {
      25             : class Directory;
      26             : class DirectoryItem;
      27             : }
      28             : 
      29             : namespace vcl {
      30             : class IconThemeInfo;
      31             : 
      32             : /** This class scans a folder for icon themes and provides the results.
      33             :  */
      34       49894 : class VCL_DLLPUBLIC IconThemeScanner
      35             : {
      36             : public:
      37             :     ~IconThemeScanner();
      38             : 
      39             :     /** Factory method to create the object.
      40             :      * Provide a path to search for IconThemes.
      41             :      */
      42             :     static std::shared_ptr<IconThemeScanner> Create(const OUString &path);
      43             : 
      44             :     /** This method will return the standard path where icon themes are located.
      45             :      */
      46             :     static OUString
      47             :     GetStandardIconThemePath();
      48             : 
      49             :     const std::vector<IconThemeInfo>&
      50      175969 :     GetFoundIconThemes() const {return mFoundIconThemes;}
      51             : 
      52             :     /** Get the IconThemeInfo for a theme.
      53             :      * If the theme id is not among the found themes, a std::runtime_error will be thrown.
      54             :      * Use IconThemeIsInstalled() to check whether it is available.
      55             :      */
      56             :     const IconThemeInfo& GetIconThemeInfo(const OUString& themeId);
      57             : 
      58             :     /** Checks whether the theme with the provided name has been found in the
      59             :      * scanned directory.
      60             :      */
      61             :     bool
      62             :     IconThemeIsInstalled(const OUString& themeId) const;
      63             : 
      64             : private:
      65             :     IconThemeScanner();
      66             : 
      67             :     /** Scan a directory for icon themes.
      68             :      *
      69             :      * @return
      70             :      * This method will return true on success.
      71             :      * There are several cases when this method will fail:
      72             :      * - The directory does not exist
      73             :      * - There are no files which which match the pattern images_xxx.zip
      74             :      */
      75             :     bool
      76             :     ScanDirectoryForIconThemes(const OUString &path);
      77             : 
      78             :     /** Adds the provided icon theme by path.
      79             :      */
      80             :     bool
      81             :     AddIconThemeByPath(const OUString &path);
      82             : 
      83             :     /** Scans the provided directory for icon themes.
      84             :      * The returned strings will contain the URLs to the icon themes.
      85             :      */
      86             :     static std::vector<OUString>
      87             :     ReadIconThemesFromPath(const OUString& dir);
      88             : 
      89             :     /** Check whether a single file is valid */
      90             :     static bool
      91             :     FileIsValidIconTheme(const OUString&);
      92             : 
      93             :     std::vector<IconThemeInfo> mFoundIconThemes;
      94             : 
      95             :     friend class ::IconThemeScannerTest;
      96             : };
      97             : 
      98             : } // end namespace vcl
      99             : 
     100             : #endif // INCLUDED_VCL_ICONTHEMESCANNER_HXX
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11