[Libreoffice-commits] core.git: include/unotools include/vcl officecfg/registry unotools/source vcl/source
Caolán McNamara
caolanm at redhat.com
Fri Oct 13 07:30:24 UTC 2017
include/unotools/pathoptions.hxx | 2
include/vcl/IconThemeScanner.hxx | 6 -
officecfg/registry/data/org/openoffice/Office/Paths.xcu | 5 +
unotools/source/config/pathoptions.cxx | 11 ++-
vcl/source/app/IconThemeScanner.cxx | 56 +++++++++-------
vcl/source/app/settings.cxx | 13 +++
vcl/source/image/ImplImageTree.cxx | 43 +++++++-----
7 files changed, 90 insertions(+), 46 deletions(-)
New commits:
commit d4e5e20a29402a305da533357fe538beb45afb96
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Oct 12 14:48:56 2017 +0100
tdf#110742 add support for icon themes via extension manager
Change-Id: Ic33c086ef67cdcb634d9f03f84799c234fe3beec
Reviewed-on: https://gerrit.libreoffice.org/43341
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/unotools/pathoptions.hxx b/include/unotools/pathoptions.hxx
index 37e172632298..2334e0b56852 100644
--- a/include/unotools/pathoptions.hxx
+++ b/include/unotools/pathoptions.hxx
@@ -52,6 +52,7 @@ public:
PATH_GALLERY,
PATH_GRAPHIC,
PATH_HELP,
+ PATH_ICONSET,
PATH_LINGUISTIC,
PATH_MODULE,
PATH_PALETTE,
@@ -86,6 +87,7 @@ public:
const OUString& GetHelpPath() const;
const OUString& GetLinguisticPath() const;
const OUString& GetModulePath() const;
+ const OUString& GetIconsetPath() const;
const OUString& GetPalettePath() const;
const OUString& GetPluginPath() const;
const OUString& GetStoragePath() const;
diff --git a/include/vcl/IconThemeScanner.hxx b/include/vcl/IconThemeScanner.hxx
index 028173e9de59..7bb6f46e6cda 100644
--- a/include/vcl/IconThemeScanner.hxx
+++ b/include/vcl/IconThemeScanner.hxx
@@ -14,6 +14,7 @@
#include <tools/solar.h>
#include <rtl/ustring.hxx>
+#include <vcl/IconThemeInfo.hxx>
#include <memory>
#include <vector>
@@ -27,7 +28,6 @@ class DirectoryItem;
}
namespace vcl {
-class IconThemeInfo;
/** This class scans a folder for icon themes and provides the results.
*/
@@ -67,13 +67,11 @@ private:
/** Scan a directory for icon themes.
*
* @return
- * This method will return true on success.
* There are several cases when this method will fail:
* - The directory does not exist
* - There are no files which which match the pattern images_xxx.zip
*/
- bool
- ScanDirectoryForIconThemes(const OUString &path);
+ void ScanDirectoryForIconThemes(const OUString &path);
/** Adds the provided icon theme by path.
*/
diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu
index 55db320e8b15..d52e619d0445 100644
--- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu
@@ -118,6 +118,11 @@
<value>$(userurl)/wordbook</value>
</prop>
</node>
+ <node oor:name="Iconset" oor:op="fuse" oor:mandatory="true">
+ <node oor:name="InternalPaths">
+ <node oor:name="$(insturl)/@LIBO_SHARE_FOLDER@/config" oor:op="fuse"/>
+ </node>
+ </node>
<node oor:name="Module" oor:op="fuse" oor:mandatory="true">
<node oor:name="InternalPaths">
<node oor:name="$(progpath)" oor:op="fuse"/>
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 998ff53d0072..634fa2639015 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -111,6 +111,7 @@ class SvtPathOptions_Impl
const OUString& GetLinguisticPath() { return GetPath( SvtPathOptions::PATH_LINGUISTIC ); }
const OUString& GetModulePath() { return GetPath( SvtPathOptions::PATH_MODULE ); }
const OUString& GetPalettePath() { return GetPath( SvtPathOptions::PATH_PALETTE ); }
+ const OUString& GetIconsetPath() { return GetPath( SvtPathOptions::PATH_ICONSET); }
const OUString& GetPluginPath() { return GetPath( SvtPathOptions::PATH_PLUGIN ); }
const OUString& GetStoragePath() { return GetPath( SvtPathOptions::PATH_STORAGE ); }
const OUString& GetTempPath() { return GetPath( SvtPathOptions::PATH_TEMP ); }
@@ -182,6 +183,7 @@ static const PropertyStruct aPropNames[] =
{ "Gallery", SvtPathOptions::PATH_GALLERY },
{ "Graphic", SvtPathOptions::PATH_GRAPHIC },
{ "Help", SvtPathOptions::PATH_HELP },
+ { "Iconset", SvtPathOptions::PATH_ICONSET },
{ "Linguistic", SvtPathOptions::PATH_LINGUISTIC },
{ "Module", SvtPathOptions::PATH_MODULE },
{ "Palette", SvtPathOptions::PATH_PALETTE },
@@ -234,7 +236,8 @@ const OUString& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath )
osl::FileBase::getSystemPathFromFileURL( aPathValue, aResult );
aPathValue = aResult;
}
- else if (ePath == SvtPathOptions::PATH_PALETTE)
+ else if (ePath == SvtPathOptions::PATH_PALETTE ||
+ ePath == SvtPathOptions::PATH_ICONSET)
{
auto ctx = comphelper::getProcessComponentContext();
OUStringBuffer buf;
@@ -545,6 +548,11 @@ const OUString& SvtPathOptions::GetPalettePath() const
return pImpl->GetPalettePath();
}
+const OUString& SvtPathOptions::GetIconsetPath() const
+{
+ return pImpl->GetIconsetPath();
+}
+
const OUString& SvtPathOptions::GetPluginPath() const
{
return pImpl->GetPluginPath();
@@ -767,6 +775,7 @@ bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath )
case PATH_LINGUISTIC: aPath = GetLinguisticPath(); break;
case PATH_MODULE: aPath = GetModulePath(); break;
case PATH_PALETTE: aPath = GetPalettePath(); break;
+ case PATH_ICONSET: aPath = GetIconsetPath(); break;
case PATH_PLUGIN: aPath = GetPluginPath(); break;
case PATH_STORAGE: aPath = GetStoragePath(); break;
case PATH_TEMP: aPath = GetTempPath(); break;
diff --git a/vcl/source/app/IconThemeScanner.cxx b/vcl/source/app/IconThemeScanner.cxx
index 4d45a915d012..d8a81218c5ec 100644
--- a/vcl/source/app/IconThemeScanner.cxx
+++ b/vcl/source/app/IconThemeScanner.cxx
@@ -13,7 +13,7 @@
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <salhelper/linkhelper.hxx>
-
+#include <unotools/pathoptions.hxx>
#include <vcl/svapp.hxx>
#include <vcl/IconThemeInfo.hxx>
@@ -57,31 +57,42 @@ OUString convert_to_absolute_path(const OUString& path)
IconThemeScanner::IconThemeScanner()
{}
-bool
-IconThemeScanner::ScanDirectoryForIconThemes(const OUString& path)
+void IconThemeScanner::ScanDirectoryForIconThemes(const OUString& paths)
{
- osl::FileStatus fileStatus(osl_FileStatus_Mask_Type);
- bool couldSetFileStatus = set_file_status(fileStatus, path);
- if (!couldSetFileStatus) {
- return false;
- }
+ mFoundIconThemes.clear();
- if (!fileStatus.isDirectory()) {
- SAL_INFO("vcl.app", "Cannot search for icon themes in '"<< path << "'. It is not a directory.");
- return false;
- }
+ std::deque<OUString> aPaths;
- std::vector<OUString> iconThemePaths = ReadIconThemesFromPath(path);
- if (iconThemePaths.empty()) {
- SAL_WARN("vcl.app", "Could not find any icon themes in the provided directory ('" <<path<<"'.");
- return false;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ aPaths.push_front(paths.getToken(0, ';', nIndex));
}
- mFoundIconThemes.clear();
- for (std::vector<OUString>::iterator aI = iconThemePaths.begin(); aI != iconThemePaths.end(); ++aI)
+ while (nIndex >= 0);
+
+ for (const auto& path : aPaths)
{
- AddIconThemeByPath(*aI);
+ osl::FileStatus fileStatus(osl_FileStatus_Mask_Type);
+ bool couldSetFileStatus = set_file_status(fileStatus, path);
+ if (!couldSetFileStatus) {
+ continue;
+ }
+
+ if (!fileStatus.isDirectory()) {
+ SAL_INFO("vcl.app", "Cannot search for icon themes in '"<< path << "'. It is not a directory.");
+ continue;
+ }
+
+ std::vector<OUString> iconThemePaths = ReadIconThemesFromPath(path);
+ if (iconThemePaths.empty()) {
+ SAL_WARN("vcl.app", "Could not find any icon themes in the provided directory ('" <<path<<"'.");
+ continue;
+ }
+ for (std::vector<OUString>::iterator aI = iconThemePaths.begin(); aI != iconThemePaths.end(); ++aI)
+ {
+ AddIconThemeByPath(*aI);
+ }
}
- return true;
}
bool
@@ -165,9 +176,8 @@ IconThemeScanner::Create(const OUString &path)
/*static*/ OUString
IconThemeScanner::GetStandardIconThemePath()
{
- OUString url( "$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/config/" );
- rtl::Bootstrap::expandMacros(url);
- return url;
+ SvtPathOptions aPathOptions;
+ return aPathOptions.GetIconsetPath();
}
IconThemeScanner::~IconThemeScanner()
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 54d03cc0ae6a..75987898f814 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -520,7 +520,6 @@ bool MouseSettings::operator ==( const MouseSettings& rSet ) const
}
ImplStyleData::ImplStyleData() :
- mIconThemeScanner(vcl::IconThemeScanner::Create(vcl::IconThemeScanner::GetStandardIconThemePath())),
mIconThemeSelector(new vcl::IconThemeSelector()),
maPersonaHeaderFooter(),
maPersonaHeaderBitmap(),
@@ -658,7 +657,8 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
meContextMenuShortcuts = rData.meContextMenuShortcuts;
mbPrimaryButtonWarpsSlider = rData.mbPrimaryButtonWarpsSlider;
mnToolbarIconSize = rData.mnToolbarIconSize;
- mIconThemeScanner.reset(new vcl::IconThemeScanner(*rData.mIconThemeScanner));
+ if (rData.mIconThemeScanner)
+ mIconThemeScanner.reset(new vcl::IconThemeScanner(*rData.mIconThemeScanner));
mIconThemeSelector.reset(new vcl::IconThemeSelector(*rData.mIconThemeSelector));
mnEdgeBlending = rData.mnEdgeBlending;
maEdgeBlendingTopLeftColor = rData.maEdgeBlendingTopLeftColor;
@@ -2971,6 +2971,9 @@ StyleSettings::GetOptions() const
std::vector<vcl::IconThemeInfo>
StyleSettings::GetInstalledIconThemes() const
{
+ if (!mxData->mIconThemeScanner) {
+ const_cast<StyleSettings*>(this)->mxData->mIconThemeScanner = vcl::IconThemeScanner::Create(vcl::IconThemeScanner::GetStandardIconThemePath());
+ }
return mxData->mIconThemeScanner->GetFoundIconThemes();
}
@@ -2978,6 +2981,9 @@ StyleSettings::GetInstalledIconThemes() const
StyleSettings::GetAutomaticallyChosenIconTheme() const
{
OUString desktopEnvironment = Application::GetDesktopEnvironment();
+ if (!mxData->mIconThemeScanner) {
+ const_cast<StyleSettings*>(this)->mxData->mIconThemeScanner = vcl::IconThemeScanner::Create(vcl::IconThemeScanner::GetStandardIconThemePath());
+ }
OUString themeName = mxData->mIconThemeSelector->SelectIconThemeForDesktopEnvironment(
mxData->mIconThemeScanner->GetFoundIconThemes(),
desktopEnvironment
@@ -3014,6 +3020,9 @@ StyleSettings::DetermineIconTheme() const
}
}
+ if (!mxData->mIconThemeScanner) {
+ const_cast<StyleSettings*>(this)->mxData->mIconThemeScanner = vcl::IconThemeScanner::Create(vcl::IconThemeScanner::GetStandardIconThemePath());
+ }
OUString r = mxData->mIconThemeSelector->SelectIconTheme(
mxData->mIconThemeScanner->GetFoundIconThemes(),
sTheme);
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index 8b874868a32e..64466c4d0e41 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -44,8 +44,8 @@
#include <vcl/pngread.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-
#include <vcl/BitmapTools.hxx>
+#include <vcl/IconThemeScanner.hxx>
#include <vcl/pngwrite.hxx>
#include "BitmapProcessor.hxx"
@@ -93,13 +93,6 @@ OUString createPath(OUString const & name, sal_Int32 pos, OUString const & local
return name.copy(0, pos + 1) + locale + name.copy(pos);
}
-OUString getIconThemeFolderUrl()
-{
- OUString sUrl("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/config/");
- rtl::Bootstrap::expandMacros(sUrl);
- return sUrl;
-}
-
OUString getIconCacheUrl(OUString const & sStyle, OUString const & sVariant, OUString const & sName)
{
OUString sUrl("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/cache/");
@@ -401,19 +394,37 @@ void ImplImageTree::createStyle()
if (maCurrentStyle != "default")
{
- INetURLObject aUrl(getIconThemeFolderUrl());
- OSL_ASSERT(!aUrl.HasError());
+ OUString paths = vcl::IconThemeScanner::GetStandardIconThemePath();
+ std::deque<OUString> aPaths;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ aPaths.push_front(paths.getToken(0, ';', nIndex));
+ }
+ while (nIndex >= 0);
- bool ok = aUrl.Append("images_" + maCurrentStyle, INetURLObject::EncodeMechanism::All);
- OSL_ASSERT(ok);
- sThemeUrl = aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE) + ".zip";
+ for (const auto& path : aPaths)
+ {
+ INetURLObject aUrl(path);
+ OSL_ASSERT(!aUrl.HasError());
+
+ bool ok = aUrl.Append("images_" + maCurrentStyle, INetURLObject::EncodeMechanism::All);
+ OSL_ASSERT(ok);
+ sThemeUrl = aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE) + ".zip";
+ if (urlExists(sThemeUrl))
+ break;
+ sThemeUrl.clear();
+ }
+ if (sThemeUrl.isEmpty())
+ return;
}
else
+ {
sThemeUrl += "images";
-
- if (!urlExists(sThemeUrl))
- return;
+ if (!urlExists(sThemeUrl))
+ return;
+ }
maIconSets[maCurrentStyle] = IconSet(sThemeUrl);
More information about the Libreoffice-commits
mailing list