diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-08-22 17:36:15 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-08-22 17:36:15 +0200 |
commit | 4278cac8935339dddfa5473490124d11061a0b38 (patch) | |
tree | 8fd82e703551bbec3b734e357db099d34eda0079 /shell | |
parent | c0ee13464f239d84bb4afaf34e491413eb49961b (diff) |
tdf#101661: Report XDG_{DOCUMENTS,TEMPLATES}_DIR only when it exists
...as had been done in the GConf-based backend prior to
3cf557c12d27f1b2250e69a543136da098112d80 "drop gconf integration as per ESC
decision".
Change-Id: I56f256aaec542e0a62fc30a37d5c982e93e77812
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/backends/desktopbe/desktopbackend.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx index 550e87a49d34..fdbe4d4e9d61 100644 --- a/shell/source/backends/desktopbe/desktopbackend.cxx +++ b/shell/source/backends/desktopbe/desktopbackend.cxx @@ -252,6 +252,14 @@ OUString xdg_user_dir_lookup (const char *type) return aHomeDirURL + "/" + OUString::createFromAscii(type); } +css::uno::Any xdgDirectoryIfExists(char const * type) { + auto url = xdg_user_dir_lookup(type); + return css::uno::Any( + osl::Directory(url).open() == osl::FileBase::E_None + ? css::beans::Optional<css::uno::Any>(true, css::uno::Any(url)) + : css::beans::Optional<css::uno::Any>(false, css::uno::Any())); +} + } // namespace css::uno::Any Default::getPropertyValue(OUString const & PropertyName) @@ -261,16 +269,12 @@ css::uno::Any Default::getPropertyValue(OUString const & PropertyName) { if (PropertyName == "TemplatePathVariable") { - OUString aDirURL = xdg_user_dir_lookup("Templates"); - css::uno::Any aValue(aDirURL); - return css::uno::makeAny(css::beans::Optional<css::uno::Any>(true, aValue)); + return xdgDirectoryIfExists("Templates"); } if (PropertyName == "WorkPathVariable") { - OUString aDirURL = xdg_user_dir_lookup("Documents"); - css::uno::Any aValue(aDirURL); - return css::uno::makeAny(css::beans::Optional<css::uno::Any>(true, aValue)); + return xdgDirectoryIfExists("Documents"); } if ( PropertyName == "EnableATToolSupport" || |