Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / IconThemeScanner.hxx
blob028173e9de59b74302024dcf3adbd491dd37bae6
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 <memory>
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 std::shared_ptr<IconThemeScanner> Create(const OUString &path);
44 /** This method will return the standard path where icon themes are located.
46 static OUString
47 GetStandardIconThemePath();
49 const std::vector<IconThemeInfo>&
50 GetFoundIconThemes() const {return mFoundIconThemes;}
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.
56 const IconThemeInfo& GetIconThemeInfo(const OUString& themeId);
58 /** Checks whether the theme with the provided name has been found in the
59 * scanned directory.
61 bool
62 IconThemeIsInstalled(const OUString& themeId) const;
64 private:
65 IconThemeScanner();
67 /** Scan a directory for icon themes.
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
75 bool
76 ScanDirectoryForIconThemes(const OUString &path);
78 /** Adds the provided icon theme by path.
80 bool
81 AddIconThemeByPath(const OUString &path);
83 /** Scans the provided directory for icon themes.
84 * The returned strings will contain the URLs to the icon themes.
86 static std::vector<OUString>
87 ReadIconThemesFromPath(const OUString& dir);
89 /** Check whether a single file is valid */
90 static bool
91 FileIsValidIconTheme(const OUString&);
93 std::vector<IconThemeInfo> mFoundIconThemes;
95 friend class ::IconThemeScannerTest;
98 } // end namespace vcl
100 #endif // INCLUDED_VCL_ICONTHEMESCANNER_HXX
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */