[Libreoffice-commits] core.git: shell/source

Stephan Bergmann sbergman at redhat.com
Mon Aug 22 15:38:40 UTC 2016


 shell/source/backends/desktopbe/desktopbackend.cxx |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 4278cac8935339dddfa5473490124d11061a0b38
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Aug 22 17:36:15 2016 +0200

    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

diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx
index 550e87a..fdbe4d4 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" ||


More information about the Libreoffice-commits mailing list