28#include <com/sun/star/uno/Sequence.hxx>
29#include <com/sun/star/uno/Reference.h>
30#include <com/sun/star/util/thePathSettings.hpp>
41enum class DictionaryPathFlags
54#define PATH_FLAG_ALL (DictionaryPathFlags::INTERNAL | DictionaryPathFlags::USER)
63 if (!rMainURL.isEmpty())
68 uno::Reference< css::ucb::XCommandEnvironment >(),
72 catch (uno::Exception &)
80 std::u16string_view rPathPrefix,
81 DictionaryPathFlags nPathFlags )
83 std::vector< OUString > aRes;
84 uno::Sequence< OUString > aInternalPaths;
85 uno::Sequence< OUString > aUserPaths;
86 OUString aWritablePath;
92 OUString aInternal( OUString::Concat(rPathPrefix) +
"_internal" );
93 OUString aUser( OUString::Concat(rPathPrefix) +
"_user" );
94 OUString aWriteable( OUString::Concat(rPathPrefix) +
"_writable" );
96 uno::Reference< util::XPathSettings > xPathSettings =
97 util::thePathSettings::get( xContext );
98 xPathSettings->getPropertyValue( aInternal ) >>= aInternalPaths;
99 xPathSettings->getPropertyValue( aUser ) >>= aUserPaths;
100 xPathSettings->getPropertyValue( aWriteable ) >>= aWritablePath;
102 catch (uno::Exception &)
112 sal_Int32 nMaxEntries = aInternalPaths.getLength() + aUserPaths.getLength();
113 if (!aWritablePath.isEmpty())
115 aRes.reserve( nMaxEntries );
116 if (!aWritablePath.isEmpty())
117 aRes.push_back(aWritablePath);
119 auto lPathIsNotEmpty = [](
const OUString& rPath) {
return !rPath.isEmpty(); };
121 if (nPathFlags & DictionaryPathFlags::USER)
122 std::copy_if(std::cbegin(aUserPaths), std::cend(aUserPaths), std::back_inserter(aRes), lPathIsNotEmpty);
124 if (nPathFlags & DictionaryPathFlags::INTERNAL)
125 std::copy_if(std::cbegin(aInternalPaths), std::cend(aInternalPaths), std::back_inserter(aRes), lPathIsNotEmpty);
133 std::vector< OUString > aPaths(
135 DBG_ASSERT( aPaths.size() == 1,
"Dictionary_writable path corrupted?" );
void SetSmartProtocol(INetProtocol eTheSmartScheme)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
#define DBG_ASSERT(sCon, aError)
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral USER
OUString GetWritableDictionaryURL(std::u16string_view rDicName)
bool FileExists(const OUString &rMainURL)
static std::vector< OUString > GetMultiPaths_Impl(std::u16string_view rPathPrefix, DictionaryPathFlags nPathFlags)
OUString GetDictionaryWriteablePath()
std::vector< OUString > GetDictionaryPaths()