6168b26
From cc9493e690c6dbe40a1da47a06acf7172a33ffa7 Mon Sep 17 00:00:00 2001
e12435c
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
e12435c
Date: Mon, 24 Feb 2014 11:38:13 +0000
6168b26
Subject: [PATCH 1/2] Resolves: rhbz#1065807 use xdg ~/Templates for default
e12435c
 Template location
e12435c
e12435c
(if it exists)
e12435c
e12435c
Change-Id: I98fc9fd54d1f56c8bed24ce4d2ebf53756ded2cc
e12435c
---
ed42b79
 framework/source/services/pathsettings.cxx         |  6 ++++
e12435c
 .../registry/data/org/openoffice/Office/Paths.xcu  | 13 +++++++
e12435c
 shell/source/backends/desktopbe/desktopbackend.cxx | 21 ++++++++---
ed42b79
 shell/source/backends/gconfbe/gconfaccess.cxx      | 41 ++++++++++++++++------
e12435c
 shell/source/backends/gconfbe/gconfaccess.hxx      |  1 +
ed42b79
 5 files changed, 66 insertions(+), 16 deletions(-)
e12435c
e12435c
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
ed42b79
index 15fb3c0..bdb2949 100644
e12435c
--- a/framework/source/services/pathsettings.cxx
e12435c
+++ b/framework/source/services/pathsettings.cxx
ed42b79
@@ -280,6 +280,12 @@ PathSettings::PathInfo PathSettings::impl_readNewFormat(const OUString& sPath)
e12435c
     // read the writeable path
e12435c
     xPath->getByName(CFGPROP_WRITEPATH) >>= aPathVal.sWritePath;
e12435c
 
e12435c
+    // avoid duplicates, by removing the writeable path from
e12435c
+    // the user defined path list if it happens to be there too
e12435c
+    OUStringList::iterator aI = aPathVal.lUserPaths.find(aPathVal.sWritePath);
e12435c
+    if (aI != aPathVal.lUserPaths.end())
e12435c
+        aPathVal.lUserPaths.erase(aI);
e12435c
+
e12435c
     // read state props
e12435c
     xPath->getByName(CFGPROP_ISSINGLEPATH) >>= aPathVal.bIsSinglePath;
e12435c
 
e12435c
diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu
6168b26
index 05f8e0b..2a9eb5c 100644
e12435c
--- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu
e12435c
+++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu
6168b26
@@ -161,8 +161,21 @@
6168b26
         <node oor:name="$(insturl)/@LIBO_SHARE_FOLDER@/template/common" oor:op="fuse"/>
e12435c
         <node oor:name="$(insturl)/@LIBO_SHARE_FOLDER@/template/$(vlang)" oor:op="fuse"/>
e12435c
       </node>
e12435c
+      
e12435c
+           On unix check of we have a ~/Templates and use that as the write path.
e12435c
+           On other platforms, or if ~/Templates doesn't exist, use the traditional
e12435c
+           $(userurl)/template path.
e12435c
+
e12435c
+           If we end up using the new ~/Templates as the write path, we then want
e12435c
+           to have $(userurl)/template in our userpath for any templates left behind
e12435c
+           in that dir.
e12435c
+      -->
e12435c
       <prop oor:name="WritePath">
e12435c
         <value>$(userurl)/template</value>
e12435c
+        <value install:module="unixdesktop" oor:external="com.sun.star.configuration.backend.DesktopBackend TemplatePathVariable"/>
e12435c
+      </prop>
e12435c
+      <prop oor:name="UserPaths">
e12435c
+        <value install:module="unixdesktop">$(userurl)/template</value>
e12435c
       </prop>
e12435c
     </node>
e12435c
     <node oor:name="UIConfig" oor:op="fuse" oor:mandatory="true">
e12435c
diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx
ed42b79
index 3e8e8c1..52d8358 100644
e12435c
--- a/shell/source/backends/desktopbe/desktopbackend.cxx
e12435c
+++ b/shell/source/backends/desktopbe/desktopbackend.cxx
ed42b79
@@ -154,11 +154,22 @@ css::uno::Any Default::getPropertyValue(OUString const & PropertyName)
e12435c
         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
e12435c
         css::uno::RuntimeException)
e12435c
 {
e12435c
-    if ( PropertyName == "EnableATToolSupport" || PropertyName == "ExternalMailer" || PropertyName == "SourceViewFontHeight"
e12435c
-      || PropertyName == "SourceViewFontName" || PropertyName == "WorkPathVariable" || PropertyName == "ooInetFTPProxyName"
e12435c
-      || PropertyName == "ooInetFTPProxyPort" || PropertyName == "ooInetHTTPProxyName" || PropertyName == "ooInetHTTPProxyPort"
e12435c
-      || PropertyName == "ooInetHTTPSProxyName" || PropertyName == "ooInetHTTPSProxyPort" || PropertyName == "ooInetNoProxy"
e12435c
-      || PropertyName == "ooInetProxyType" || PropertyName == "givenname" || PropertyName == "sn" )
e12435c
+    if ( PropertyName == "EnableATToolSupport" ||
e12435c
+         PropertyName == "ExternalMailer" ||
e12435c
+         PropertyName == "SourceViewFontHeight" ||
e12435c
+         PropertyName == "SourceViewFontName" ||
e12435c
+         PropertyName == "TemplatePathVariable" ||
e12435c
+         PropertyName == "WorkPathVariable" ||
e12435c
+         PropertyName == "ooInetFTPProxyName" ||
e12435c
+         PropertyName == "ooInetFTPProxyPort" ||
e12435c
+         PropertyName == "ooInetHTTPProxyName" ||
e12435c
+         PropertyName == "ooInetHTTPProxyPort" ||
e12435c
+         PropertyName == "ooInetHTTPSProxyName" ||
e12435c
+         PropertyName == "ooInetHTTPSProxyPort" ||
e12435c
+         PropertyName == "ooInetNoProxy" ||
e12435c
+         PropertyName == "ooInetProxyType" ||
e12435c
+         PropertyName == "givenname" ||
e12435c
+         PropertyName == "sn" )
e12435c
     {
e12435c
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
e12435c
     }
e12435c
diff --git a/shell/source/backends/gconfbe/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx
ed42b79
index de8eb29..0d407d6 100644
e12435c
--- a/shell/source/backends/gconfbe/gconfaccess.cxx
e12435c
+++ b/shell/source/backends/gconfbe/gconfaccess.cxx
e12435c
@@ -23,6 +23,7 @@
e12435c
 #include <string.h>
e12435c
 
e12435c
 #include "com/sun/star/uno/RuntimeException.hpp"
e12435c
+#include "com/sun/star/uno/Sequence.hxx"
e12435c
 #include "osl/file.hxx"
e12435c
 #include "osl/security.hxx"
e12435c
 #include "osl/thread.h"
ed42b79
@@ -189,15 +190,8 @@ static OUString xdg_user_dir_lookup (const char *type)
e12435c
         if( osl::FileBase::E_None == aDocumentsDir.open() )
e12435c
             return aDocumentsDirURL;
e12435c
     }
e12435c
-    /* Special case desktop for historical compatibility */
e12435c
-    if (strcmp (type, "DESKTOP") == 0)
e12435c
-    {
e12435c
-        return aHomeDirURL + "/Desktop";
e12435c
-    }
e12435c
-    else
e12435c
-    {
e12435c
-        return aHomeDirURL + "/Documents";
e12435c
-    }
e12435c
+    /* Use fallbacks historical compatibility if nothing else exists */
e12435c
+    return aHomeDirURL + "/" + OUString::createFromAscii(type);
e12435c
 }
e12435c
 
ed42b79
 //------------------------------------------------------------------------------
ed42b79
@@ -317,11 +311,18 @@ uno::Any translateToOOo( const ConfigurationValue &rValue, GConfValue *pGconfVal
e12435c
 
e12435c
         case SETTING_WORK_DIRECTORY:
e12435c
         {
e12435c
-            OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS");
e12435c
+            OUString aDocumentsDirURL = xdg_user_dir_lookup("Documents");
e12435c
 
e12435c
             return uno::makeAny( aDocumentsDirURL );
e12435c
         }
e12435c
 
e12435c
+        case SETTING_TEMPLATE_DIRECTORY:
e12435c
+        {
e12435c
+            OUString aTemplatesDirURL = xdg_user_dir_lookup("Templates");
e12435c
+
e12435c
+            return uno::makeAny( aTemplatesDirURL );
e12435c
+        }
e12435c
+
e12435c
         case SETTING_USER_GIVENNAME:
e12435c
         {
e12435c
             OUString aCompleteName( OStringToOUString(
ed42b79
@@ -392,7 +393,7 @@ sal_Bool SAL_CALL isDependencySatisfied( GConfClient* pClient, const Configurati
e12435c
 
e12435c
         case SETTING_WORK_DIRECTORY:
e12435c
         {
e12435c
-            OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS");
e12435c
+            OUString aDocumentsDirURL = xdg_user_dir_lookup("Documents");
e12435c
             osl::Directory aDocumentsDir( aDocumentsDirURL );
e12435c
 
e12435c
             if( osl::FileBase::E_None == aDocumentsDir.open() )
ed42b79
@@ -400,6 +401,16 @@ sal_Bool SAL_CALL isDependencySatisfied( GConfClient* pClient, const Configurati
e12435c
         }
e12435c
             break;
e12435c
 
e12435c
+        case SETTING_TEMPLATE_DIRECTORY:
e12435c
+        {
e12435c
+            OUString aTemplatesDirURL = xdg_user_dir_lookup("Templates");
e12435c
+            osl::Directory aTemplatesDir( aTemplatesDirURL );
e12435c
+
e12435c
+            if( osl::FileBase::E_None == aTemplatesDir.open() )
e12435c
+                return sal_True;
e12435c
+        }
e12435c
+            break;
e12435c
+
e12435c
         case SETTING_USER_GIVENNAME:
e12435c
         {
e12435c
             OUString aCompleteName( OStringToOUString(
ed42b79
@@ -563,6 +574,14 @@ ConfigurationValue const ConfigurationValues[] =
e12435c
     },
e12435c
 
e12435c
     {
e12435c
+        SETTING_TEMPLATE_DIRECTORY,
e12435c
+        "/desktop/gnome/url-handlers/mailto/command", // dummy
e12435c
+        RTL_CONSTASCII_STRINGPARAM("TemplatePathVariable"),
e12435c
+        sal_True,
e12435c
+        SETTING_TEMPLATE_DIRECTORY, // so that the existence of the dir can be checked
e12435c
+    },
e12435c
+
e12435c
+    {
e12435c
         SETTING_USER_GIVENNAME,
e12435c
         "/desktop/gnome/url-handlers/mailto/command", // dummy
e12435c
         RTL_CONSTASCII_STRINGPARAM("givenname"),
e12435c
diff --git a/shell/source/backends/gconfbe/gconfaccess.hxx b/shell/source/backends/gconfbe/gconfaccess.hxx
e12435c
index 7f0a52a..3fcd217 100644
e12435c
--- a/shell/source/backends/gconfbe/gconfaccess.hxx
e12435c
+++ b/shell/source/backends/gconfbe/gconfaccess.hxx
e12435c
@@ -47,6 +47,7 @@ enum ConfigurationSetting
e12435c
     SETTING_ENABLE_ACCESSIBILITY,
e12435c
     SETTING_MAILER_PROGRAM,
e12435c
     SETTING_WORK_DIRECTORY,
e12435c
+    SETTING_TEMPLATE_DIRECTORY,
e12435c
     SETTING_SOURCEVIEWFONT_NAME,
e12435c
     SETTING_SOURCEVIEWFONT_HEIGHT,
e12435c
     SETTING_USER_GIVENNAME,
e12435c
-- 
6168b26
1.9.0
e12435c