LCOV - code coverage report
Current view: top level - include/vcl - IconThemeInfo.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 4 75.0 %
Date: 2015-06-13 12:38:46 Functions: 4 5 80.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_ICONTHEMEINFO_HXX
      11             : #define INCLUDED_VCL_ICONTHEMEINFO_HXX
      12             : 
      13             : #include <vcl/dllapi.h>
      14             : #include <tools/gen.hxx>
      15             : #include <rtl/ustring.hxx>
      16             : 
      17             : #include <vector>
      18             : 
      19             : // forward declaration of unit test classes. Required for friend relationship.
      20             : class IconThemeInfoTest;
      21             : class IconThemeSelectorTest;
      22             : class IconThemeScannerTest;
      23             : 
      24             : namespace vcl {
      25             : 
      26             : /** This class provides information about an icon theme.
      27             :  */
      28      692246 : class VCL_DLLPUBLIC IconThemeInfo {
      29             : 
      30             : public:
      31             : 
      32             :     /** The name of the icon theme to use for high contrast mode */
      33             :     static const OUString HIGH_CONTRAST_ID;
      34             : 
      35             :     /** Construct an IconThemeInfo from the URL to a file.
      36             :      * This method will throw a std::runtime_error if the URL cannot be properly parsed.
      37             :      * Check the URL with UrlCanBeParsed() first.
      38             :      */
      39             :     IconThemeInfo(const OUString& urlToFile);
      40             : 
      41           0 :     const OUString& GetDisplayName() const {return mDisplayName;}
      42             : 
      43      352071 :     const OUString& GetThemeId() const { return mThemeId; }
      44             : 
      45           1 :     const OUString& GetUrlToFile() const { return mUrlToFile; }
      46             : 
      47             :     /** Obtain the icon size by theme name.
      48             :      * @internal
      49             :      * It is not clear where this information belongs to. The sizes were hard-coded before they moved here.
      50             :      * Maybe there is a way to determine the sizes from the icon theme packages.
      51             :      */
      52             :     static Size SizeByThemeName(const OUString&);
      53             : 
      54             :     /** Check whether a IconThemeInfo can be constructed from an URL */
      55             :     static bool UrlCanBeParsed(const OUString& url);
      56             : 
      57             :     /** Find an icon theme by its id in a vector.
      58             :      * Throws a runtime_error if the theme is not contained in the vector
      59             :      */
      60             :     static const vcl::IconThemeInfo&
      61             :     FindIconThemeById(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId);
      62             : 
      63             :     /** Check whether a theme with a specified id is in a vector of IconThemeInfo */
      64             :     static bool
      65             :     IconThemeIsInVector(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId);
      66             : 
      67             : private:
      68             :     /** private constructor for testing purposes only */
      69             :     IconThemeInfo();
      70             : 
      71             :     /** Determine the icon theme name from the filename
      72             :      * If the name has an underscore, the name is taken from the first underscore to the last dot,
      73             :      * e.g., images_oxygen.zip becomes oxygen
      74             :      * If the name does not have an underscore in it, the whole name until the last dot is returned,
      75             :      * e.g. default.zip becomes default
      76             :      */
      77             :     static OUString FileNameToThemeId(const OUString&);
      78             : 
      79             :     /** Creates the display name for the given id of a file.
      80             :      * Currently, we only uppercase the id.
      81             :      */
      82             :     static OUString ThemeIdToDisplayName(const OUString&);
      83             : 
      84             :     /** The name which is presented to the user */
      85             :     OUString mDisplayName;
      86             :     /** The theme id. This id is used in ... to determine the file name */
      87             :     OUString mThemeId;
      88             :     /** The url to the icon theme package */
      89             :     OUString mUrlToFile;
      90             : 
      91             :     friend class ::IconThemeInfoTest;
      92             :     friend class ::IconThemeScannerTest;
      93             :     friend class ::IconThemeSelectorTest;
      94             : };
      95             : 
      96             : } // namespace vcl
      97             : 
      98             : 
      99             : #endif // INCLUDED_VCL_ICONTHEMEINFO_HXX

Generated by: LCOV version 1.11