kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-Resolves-rhbz-1065807-use-xdg-Templates-for-default-.patch

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