Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / include / vcl / IconThemeScanner.hxx
blobf8654903d1ab57963f4b5aa992b90183bcaa83b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_VCL_ICONTHEMESCANNER_HXX
11 #define INCLUDED_VCL_ICONTHEMESCANNER_HXX
13 #include <vcl/dllapi.h>
14 #include <tools/solar.h>
16 #include <rtl/ustring.hxx>
18 #include <boost/shared_ptr.hpp>
19 #include <vector>
21 // forward declaration of unit test class. Required for friend relationship.
22 class IconThemeScannerTest;
24 namespace osl {
25 class Directory;
26 class DirectoryItem;
29 namespace vcl {
30 class IconThemeInfo;
32 /** This class scans a folder for icon themes and provides the results.
34 class VCL_DLLPUBLIC IconThemeScanner
36 public:
37 ~IconThemeScanner();
39 /** Factory method to create the object.
40 * Provide a path to search for IconThemes.
42 static boost::shared_ptr<IconThemeScanner>
43 Create(const OUString &path);
45 /** This method will return the standard path where icon themes are located.
47 static OUString
48 GetStandardIconThemePath();
50 const std::vector<IconThemeInfo>&
51 GetFoundIconThemes() const {return mFoundIconThemes;}
53 /** Get the IconThemeInfo for a theme.
54 * If the theme id is not among the found themes, a std::runtime_error will be thrown.
55 * Use IconThemeIsInstalled() to check whether it is available.
57 const IconThemeInfo& GetIconThemeInfo(const OUString& themeId);
59 /** Checks whether the theme with the provided name has been found in the
60 * scanned directory.
62 bool
63 IconThemeIsInstalled(const OUString& themeId) const;
65 private:
66 IconThemeScanner();
68 /** Scan a directory for icon themes.
70 * @return
71 * This method will return true on success.
72 * There are several cases when this method will fail:
73 * - The directory does not exist
74 * - There are no files which which match the pattern images_xxx.zip
76 bool
77 ScanDirectoryForIconThemes(const OUString &path);
79 /** Adds the provided icon theme by path.
81 bool
82 AddIconThemeByPath(const OUString &path);
84 /** Scans the provided directory for icon themes.
85 * The returned strings will contain the URLs to the icon themes.
87 static std::vector<OUString>
88 ReadIconThemesFromPath(const OUString& dir);
90 /** Check whether a single file is valid */
91 static bool
92 FileIsValidIconTheme(const OUString&);
94 std::vector<IconThemeInfo> mFoundIconThemes;
96 friend class ::IconThemeScannerTest;
99 } // end namespace vcl
101 #endif // INCLUDED_VCL_ICONTHEMESCANNER_HXX
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */