20#include <config_folders.h>
30#include <osl/file.hxx>
31#include <com/sun/star/util/theMacroExpander.hpp>
43 OUString aNormalizedURL;
44 if ( osl::FileBase::getAbsoluteFileURL( OUString(),
47 != osl::DirectoryItem::E_None )
50 osl::DirectoryItem aDirItem;
51 if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem )
52 != osl::DirectoryItem::E_None )
55 osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
57 if ( aDirItem.getFileStatus( aFileStatus )
58 == osl::DirectoryItem::E_None )
60 aNormalizedURL = aFileStatus.getFileURL();
62 if ( !aNormalizedURL.isEmpty() )
64 if ( !aNormalizedURL.endsWith(
"/") )
65 rURL = aNormalizedURL;
68 .copy( 0, aNormalizedURL.getLength() - 1 );
82 uno::Reference< uno::XComponentContext > xCtx )
120 if ( !
URL.isEmpty() )
124 OUString aCanonicalURL(
URL );
131 aCanonicalURL.replaceAt(
nIndex,
141 aCanonicalURL.replaceAt(
nIndex,
155 if ( !
URL.isEmpty() )
192 return "com.sun.star.comp.util.OfficeInstallationDirectories";
203uno::Sequence< OUString > SAL_CALL
206 return {
"com.sun.star.util.OfficeInstallationDirectories" };
214 std::unique_lock aGuard(
m_aMutex );
218 uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(
m_xCtx);
223 "Unable to obtain office brand installation directory!" );
228 xExpander->expandMacros(
229 "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE(
"bootstrap" )
":UserInstallation}" );
232 "Unable to obtain office user data directory!" );
240extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
242 css::uno::XComponentContext *context,
243 css::uno::Sequence<css::uno::Any>
const &)
245 return cppu::acquire(
Reference< XComponentContext > m_xCtx
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL makeRelocatableURL(const OUString &URL) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL makeAbsoluteURL(const OUString &URL) override
std::optional< OUString > m_xOfficeBrandDir
css::uno::Reference< css::uno::XComponentContext > m_xCtx
virtual OUString SAL_CALL getOfficeInstallationDirectoryURL() override
virtual ~OfficeInstallationDirectories() override
std::optional< OUString > m_xUserDir
OfficeInstallationDirectories(css::uno::Reference< css::uno::XComponentContext > xCtx)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getOfficeUserDataDirectoryURL() override
#define SAL_CONFIGFILE(name)
constexpr OUStringLiteral g_aUserDirMacro(u"$(userdataurl)")
COMPHELPER_DLLPUBLIC bool isFileUrl(std::u16string_view url)
constexpr OUStringLiteral g_aOfficeBrandDirMacro(u"$(brandbaseurl)")
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static bool makeCanonicalFileURL(OUString &rURL)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_util_OfficeInstallationDirectories(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)