11#include <rtl/character.hxx>
21constexpr OUStringLiteral HELPIMG_FAKE_THEME(u
"helpimg");
24filename_from_url(std::u16string_view url)
26 size_t slashPosition = url.rfind(
'/' );
27 if (slashPosition == std::u16string_view::npos) {
30 OUString filename( url.substr( slashPosition+1 ) );
47: mUrlToFile(urlToFile)
49 OUString filename = filename_from_url(urlToFile);
50 if (filename.isEmpty()) {
51 throw std::runtime_error(
"invalid URL passed to IconThemeInfo()");
62 if (themeName ==
u"galaxy") {
63 return Size( 26, 26 );
66 return Size( 24, 24 );
73 OUString fname = filename_from_url(url);
74 if (fname.isEmpty()) {
86 if (fname.indexOf(HELPIMG_FAKE_THEME) != -1 ) {
98 if (positionOfLastDot == std::u16string_view::npos) {
99 throw std::runtime_error(
"IconThemeInfo::FileNameToThemeId() called with invalid filename.");
102 if (positionOfFirstUnderscore == std::u16string_view::npos) {
103 throw std::runtime_error(
"IconThemeInfo::FileNameToThemeId() called with invalid filename.");
106 r = filename.substr(positionOfFirstUnderscore, positionOfLastDot - positionOfFirstUnderscore);
113 if (themeId.isEmpty()) {
114 throw std::runtime_error(
"IconThemeInfo::ThemeIdToDisplayName() called with invalid id.");
118 OUString aDisplayName = themeId;
120 bool bIsSvg = aDisplayName.endsWith(
"_svg", &aDisplayName);
121 bool bIsDark = aDisplayName.endsWith(
"_dark", &aDisplayName);
122 if (!bIsSvg && bIsDark)
123 bIsSvg = aDisplayName.endsWith(
"_svg", &aDisplayName);
127 if (rtl::isAsciiLowerCase(firstLetter))
129 aDisplayName = OUStringChar(
sal_Unicode(rtl::toAsciiUpperCase(firstLetter))) + aDisplayName.subView(1);
133 aDisplayName = aDisplayName.replace(
'_',
' ');
135 if (bIsSvg && bIsDark)
136 aDisplayName +=
" (SVG + dark)";
138 aDisplayName +=
" (SVG)";
140 aDisplayName +=
" (dark)";
152 explicit SameTheme(
const OUString &rThemeId) :
m_rThemeId(rThemeId) {}
163 std::vector<vcl::IconThemeInfo>::const_iterator it = std::find_if(themes.begin(), themes.end(),
165 if (it == themes.end())
167 throw std::runtime_error(
"Could not find theme id in theme vector.");
175 return std::any_of(themes.begin(), themes.end(), SameTheme(themeId));
const OUString & m_rThemeId
This class provides information about an icon theme.
static const vcl::IconThemeInfo & FindIconThemeById(const std::vector< vcl::IconThemeInfo > &themes, const OUString &themeId)
Find an icon theme by its id in a vector.
IconThemeInfo()
private constructor for testing purposes only
static bool UrlCanBeParsed(std::u16string_view url)
Check whether an IconThemeInfo can be constructed from a URL.
static OUString ThemeIdToDisplayName(const OUString &)
Creates the display name for the given id of a file.
const OUString & GetThemeId() const
OUString mDisplayName
The name which is presented to the user.
static OUString FileNameToThemeId(std::u16string_view)
Determine the icon theme name from the filename If the name has an underscore, the name is taken from...
static Size SizeByThemeName(std::u16string_view)
Obtain the icon size by theme name.
static bool IconThemeIsInVector(const std::vector< vcl::IconThemeInfo > &themes, const OUString &themeId)
Check whether a theme with a specified id is in a vector of IconThemeInfo.
OUString mThemeId
The theme id.
const sal_Unicode ICON_THEME_PACKAGE_PREFIX[]
const sal_Unicode EXTENSION_FOR_ICON_PACKAGES[]