Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

we moved the used configuration from ~/.libreoffice to
~/.config/libreoffice between LO-3.4 and 3.5 on Linux. Unfortunately,
the old configuration is not migrated. I have finally got time to dig
into it again. The result is the attached patch. It works well here.

Another solution would be to try to migrate both paths (single
registrymodifications.xcu, and the split bla.xcu). IMHO, it does not
make sense and it is better to check the registrymodifications.xcu
existence.

The patch is against libreoffice-3-5 branch. Small changes are necessary
to apply on master (caused by code clean up).

It would be great to get this into 3-5 and 3-5-0 branches. I will put it
into master then as well.


Best Regards,
Petr
From b6528fe5864fd161c7efac93933fba4bcf985901 Mon Sep 17 00:00:00 2001
From: Petr Mladek <pmladek@suse.cz>
Date: Fri, 27 Jan 2012 18:07:03 +0100
Subject: [PATCH] allow to migrate the shared registrymodifications.xcu

LO-3.3 and older wrote configuration into many files under
user/registry/data. LO-3.4 spped up startup by moving these
files into a single /user/registrymodifications.xcu.

officecfg/registry/data/org/openoffice/Setup.xcu defines what registry
nodes are migrated and what are excluded.

Finally, the old migration code detected the name of the .xcu file
by the first entry in IncludedNodes. This fix allows to search
the data in the single registrymodifications.xcu when available.
---
 desktop/source/migration/migration.cxx |   62 ++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index 7520eb8..d7f9765 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -773,33 +773,51 @@ void MigrationImpl::copyConfig() {
             }
         }
     }
+
+    // check if the shared registrymodifications.xcu file exists
+    bool bRegistryModificationsXcuExists = false;
+    rtl::OUString regFilePath(m_aInfo.userdata);
+    regFilePath += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/user/registrymodifications.xcu"));
+    File regFile(regFilePath);
+    ::osl::FileBase::RC nError = regFile.open(osl_File_OpenFlag_Read);
+    if ( nError == ::osl::FileBase::E_None ) {
+        bRegistryModificationsXcuExists = true;
+        regFile.close();
+    }
+
     for (Components::const_iterator i(comps.begin()); i != comps.end(); ++i) {
         if (!i->second.includedPaths.empty()) {
-            rtl::OUStringBuffer buf(m_aInfo.userdata);
-            buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("/user/registry/data"));
-            sal_Int32 n = 0;
-            do {
-                rtl::OUString seg(i->first.getToken(0, '.', n));
-                rtl::OUString enc(
-                    rtl::Uri::encode(
-                        seg, rtl_UriCharClassPchar, rtl_UriEncodeStrict,
-                        RTL_TEXTENCODING_UTF8));
-                if (enc.getLength() == 0 && seg.getLength() != 0) {
-                    OSL_TRACE(
-                        ("configuration migration component %s ignored (cannot"
-                         " be encoded as file path)"),
-                        rtl::OUStringToOString(
-                            i->first, RTL_TEXTENCODING_UTF8).getStr());
-                    goto next;
-                }
-                buf.append(sal_Unicode('/'));
-                buf.append(enc);
-            } while (n >= 0);
-            buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(".xcu"));
+            if (!bRegistryModificationsXcuExists) {
+                // shared registrymodifications.xcu does not exists
+                // the configuration is split in many registry files
+                // determine the file names from the first element in included paths
+                rtl::OUStringBuffer buf(m_aInfo.userdata);
+                buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("/user/registry/data"));
+                sal_Int32 n = 0;
+                do {
+                    rtl::OUString seg(i->first.getToken(0, '.', n));
+                    rtl::OUString enc(
+                        rtl::Uri::encode(
+                            seg, rtl_UriCharClassPchar, rtl_UriEncodeStrict,
+                            RTL_TEXTENCODING_UTF8));
+                    if (enc.getLength() == 0 && seg.getLength() != 0) {
+                        OSL_TRACE(
+                            ("configuration migration component %s ignored (cannot"
+                            " be encoded as file path)"),
+                            rtl::OUStringToOString(
+                                i->first, RTL_TEXTENCODING_UTF8).getStr());
+                        goto next;
+                    }
+                    buf.append(sal_Unicode('/'));
+                    buf.append(enc);
+                } while (n >= 0);
+                buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(".xcu"));
+                regFilePath = buf.toString();
+            }
             configuration::Update::get(
                 comphelper::getProcessComponentContext())->
                 insertModificationXcuFile(
-                    buf.makeStringAndClear(), setToSeq(i->second.includedPaths),
+                    regFilePath, setToSeq(i->second.includedPaths),
                     setToSeq(i->second.excludedPaths));
         } else {
             OSL_TRACE(
-- 
1.7.5.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.