summaryrefslogtreecommitdiffstats
path: root/framework/source/services/pathsettings.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/services/pathsettings.cxx')
-rw-r--r--framework/source/services/pathsettings.cxx81
1 files changed, 41 insertions, 40 deletions
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index fc74b81d55f1..90cbb3281e10 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -50,11 +50,12 @@
#include <comphelper/sequence.hxx>
#include <comphelper/configurationhelper.hxx>
#include <unotools/configpaths.hxx>
+#include <o3tl/string_view.hxx>
using namespace framework;
-constexpr OUStringLiteral CFGPROP_USERPATHS = u"UserPaths";
-constexpr OUStringLiteral CFGPROP_WRITEPATH = u"WritePath";
+constexpr OUString CFGPROP_USERPATHS = u"UserPaths"_ustr;
+constexpr OUString CFGPROP_WRITEPATH = u"WritePath"_ustr;
/*
0 : old style "Template" string using ";" as separator
@@ -63,9 +64,9 @@ constexpr OUStringLiteral CFGPROP_WRITEPATH = u"WritePath";
3 : write path "Template_write" string
*/
-constexpr OUStringLiteral POSTFIX_INTERNAL_PATHS = u"_internal";
-constexpr OUStringLiteral POSTFIX_USER_PATHS = u"_user";
-constexpr OUStringLiteral POSTFIX_WRITE_PATH = u"_writable";
+constexpr OUString POSTFIX_INTERNAL_PATHS = u"_internal"_ustr;
+constexpr OUString POSTFIX_USER_PATHS = u"_user"_ustr;
+constexpr OUString POSTFIX_WRITE_PATH = u"_writable"_ustr;
namespace {
@@ -165,7 +166,7 @@ public:
Attention: It's necessary for right function of this class, that the order of base
classes is the right one. Because we transfer information from one base to another
during this ctor runs! */
- explicit PathSettings(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit PathSettings(css::uno::Reference< css::uno::XComponentContext > xContext);
/** free all used resources ... if it was not already done. */
virtual ~PathSettings() override;
@@ -347,8 +348,7 @@ private:
/** filter "real user defined paths" from the old configuration schema
and set it as UserPaths on the new schema.
Can be removed with new major release ... */
-
- void impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
+ static void impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
const std::vector<OUString>& lOld );
/** reload one path directly from the new configuration schema (because
@@ -360,7 +360,7 @@ private:
or check if the given path value uses paths, which can be replaced with predefined
placeholder variables ...
*/
- void impl_subst(std::vector<OUString>& lVals ,
+ static void impl_subst(std::vector<OUString>& lVals ,
const css::uno::Reference< css::util::XStringSubstitution >& xSubst ,
bool bReSubst);
@@ -368,14 +368,14 @@ private:
bool bReSubst);
/** converts our new string list schema to the old ";" separated schema ... */
- OUString impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath ) const;
- std::vector<OUString> impl_convertOldStyle2Path(const OUString& sOldStylePath) const;
+ static OUString impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath );
+ static std::vector<OUString> impl_convertOldStyle2Path(std::u16string_view sOldStylePath);
/** remove still known paths from the given lList argument.
So real user defined paths can be extracted from the list of
fix internal paths !
*/
- void impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
+ static void impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
std::vector<OUString>& lList);
/** rebuild the member m_lPropDesc using the path list m_lPaths. */
@@ -394,8 +394,8 @@ private:
const PathSettings::PathInfo* impl_getPathAccessConst(sal_Int32 nHandle) const;
/** it checks, if the given path value seems to be a valid URL or system path. */
- bool impl_isValidPath(const OUString& sPath) const;
- bool impl_isValidPath(const std::vector<OUString>& lPath) const;
+ static bool impl_isValidPath(std::u16string_view sPath);
+ static bool impl_isValidPath(const std::vector<OUString>& lPath);
void impl_storePath(const PathSettings::PathInfo& aPath);
@@ -427,10 +427,10 @@ private:
css::uno::Reference< css::container::XNameAccess > fa_getCfgNew();
};
-PathSettings::PathSettings( const css::uno::Reference< css::uno::XComponentContext >& xContext )
+PathSettings::PathSettings( css::uno::Reference< css::uno::XComponentContext > xContext )
: PathSettings_BASE(m_aMutex)
, ::cppu::OPropertySetHelper(cppu::WeakComponentImplHelperBase::rBHelper)
- , m_xContext (xContext)
+ , m_xContext (std::move(xContext))
{
}
@@ -637,13 +637,13 @@ void PathSettings::impl_storePath(const PathSettings::PathInfo& aPath)
::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew,
aResubstPath.sPathName,
CFGPROP_USERPATHS,
- css::uno::makeAny(comphelper::containerToSequence(aResubstPath.lUserPaths)));
+ css::uno::Any(comphelper::containerToSequence(aResubstPath.lUserPaths)));
}
::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew,
aResubstPath.sPathName,
CFGPROP_WRITEPATH,
- css::uno::makeAny(aResubstPath.sWritePath));
+ css::uno::Any(aResubstPath.sWritePath));
::comphelper::ConfigurationHelper::flush(xCfgNew);
@@ -661,6 +661,7 @@ void PathSettings::impl_storePath(const PathSettings::PathInfo& aPath)
}
}
+// static
void PathSettings::impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
const std::vector<OUString>& lOld )
{
@@ -910,6 +911,7 @@ void PathSettings::impl_notifyPropListener( std::u16string_view sPath,
}
}
+// static
void PathSettings::impl_subst(std::vector<OUString>& lVals ,
const css::uno::Reference< css::util::XStringSubstitution >& xSubst ,
bool bReSubst)
@@ -939,44 +941,41 @@ void PathSettings::impl_subst(PathSettings::PathInfo& aPath ,
aPath.sWritePath = xSubst->substituteVariables(aPath.sWritePath, false);
}
-OUString PathSettings::impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath) const
+// static
+OUString PathSettings::impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath)
{
- std::vector<OUString> lTemp;
- lTemp.reserve(rPath.lInternalPaths.size() + rPath.lUserPaths.size() + 1);
+ OUStringBuffer sPathVal(256);
for (auto const& internalPath : rPath.lInternalPaths)
{
- lTemp.push_back(internalPath);
+ if (sPathVal.getLength())
+ sPathVal.append(";");
+ sPathVal.append(internalPath);
}
for (auto const& userPath : rPath.lUserPaths)
{
- lTemp.push_back(userPath);
+ if (sPathVal.getLength())
+ sPathVal.append(";");
+ sPathVal.append(userPath);
}
-
if (!rPath.sWritePath.isEmpty())
- lTemp.push_back(rPath.sWritePath);
-
- OUStringBuffer sPathVal(256);
- for ( auto pIt = lTemp.begin();
- pIt != lTemp.end();
- )
{
- sPathVal.append(*pIt);
- ++pIt;
- if (pIt != lTemp.end())
+ if (sPathVal.getLength())
sPathVal.append(";");
+ sPathVal.append(rPath.sWritePath);
}
return sPathVal.makeStringAndClear();
}
-std::vector<OUString> PathSettings::impl_convertOldStyle2Path(const OUString& sOldStylePath) const
+// static
+std::vector<OUString> PathSettings::impl_convertOldStyle2Path(std::u16string_view sOldStylePath)
{
std::vector<OUString> lList;
sal_Int32 nToken = 0;
do
{
- OUString sToken = sOldStylePath.getToken(0, ';', nToken);
+ OUString sToken( o3tl::getToken(sOldStylePath, 0, ';', nToken) );
if (!sToken.isEmpty())
lList.push_back(sToken);
}
@@ -985,6 +984,7 @@ std::vector<OUString> PathSettings::impl_convertOldStyle2Path(const OUString& sO
return lList;
}
+// static
void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
std::vector<OUString>& lList)
{
@@ -1001,11 +1001,10 @@ void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
}
// Erase items not in lList from the user path list.
- rPath.lUserPaths.erase(std::remove_if(rPath.lUserPaths.begin(), rPath.lUserPaths.end(),
+ std::erase_if(rPath.lUserPaths,
[&lList](const OUString& rItem) {
return std::find(lList.begin(), lList.end(), rItem) == lList.end();
- }),
- rPath.lUserPaths.end());
+ });
// Erase items in the user path list from lList.
for (auto const& userPath : rPath.lUserPaths)
@@ -1216,7 +1215,8 @@ void PathSettings::impl_setPathValue( sal_Int32 nID ,
*pOrgPath = std::move(aChangePath);
}
-bool PathSettings::impl_isValidPath(const std::vector<OUString>& lPath) const
+// static
+bool PathSettings::impl_isValidPath(const std::vector<OUString>& lPath)
{
for (auto const& path : lPath)
{
@@ -1227,7 +1227,8 @@ bool PathSettings::impl_isValidPath(const std::vector<OUString>& lPath) const
return true;
}
-bool PathSettings::impl_isValidPath(const OUString& sPath) const
+// static
+bool PathSettings::impl_isValidPath(std::u16string_view sPath)
{
// allow empty path to reset a path.
// idea by LLA to support empty paths