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

Generated by: LCOV version 1.10