From ce8536ad3cfd00242c4fa7642e59374c0c5812f3 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 1 Nov 2017 08:17:55 +0300 Subject: Winreg configuration layer: support oox:external values Change-Id: Ie03cd4e351de62bf298009e220ed25338dc42f62 Reviewed-on: https://gerrit.libreoffice.org/44148 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- configmgr/source/winreg.cxx | 53 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx index 773775dfde92..81fc4b43ea0d 100644 --- a/configmgr/source/winreg.cxx +++ b/configmgr/source/winreg.cxx @@ -39,7 +39,8 @@ namespace { // This is not a generic registry reader. We assume the following structure: // Last element of Key becomes prop, first part is the path and optionally nodes, // when the node has oor:op attribute. -// Values can be the following: Value (string) and Final (dword, optional) +// Values can be the following: Value (string), Type (string, optional), +// Final (dword, optional), External (dword, optional) // // For example the following registry setting: // [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\LibreOffice\org.openoffice.UserProfile\Data\o] @@ -81,6 +82,18 @@ namespace { // false // // +// +// External (component data) example: +// [HKEY_CURRENT_USER\Software\Policies\LibreOffice\org.openoffice.UserProfile\Data\o] +// "Value"="com.sun.star.configuration.backend.LdapUserProfileBe company" +// "Final"=dword:00000001 +// "External"=dword:00000001 +// becomes the following in configuration: +// +// +// +// +// void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFileHandle) { @@ -127,6 +140,7 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil new wchar_t[nLongestValueLen/sizeof(wchar_t) + 1]); bool bFinal = false; + bool bExternal = false; OUString aValue; OUString aType; @@ -136,17 +150,25 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil DWORD nValueLen = nLongestValueLen + 1; RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, reinterpret_cast(pValue.get()), &nValueLen); - const wchar_t wsValue[] = L"Value"; - const wchar_t wsFinal[] = L"Final"; - const wchar_t wsType[] = L"Type"; - if(!wcscmp(pValueName.get(), wsValue)) + if (!wcscmp(pValueName.get(), L"Value")) aValue = o3tl::toU(pValue.get()); - else if (!wcscmp(pValueName.get(), wsType)) + else if (!wcscmp(pValueName.get(), L"Type")) aType = o3tl::toU(pValue.get()); - else if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast(pValue.get()) == 1) - bFinal = true; + else if (!wcscmp(pValueName.get(), L"Final")) + { + if (*reinterpret_cast(pValue.get()) == 1) + bFinal = true; + } + else if (!wcscmp(pValueName.get(), L"External")) + { + if (*reinterpret_cast(pValue.get()) == 1) + bExternal = true; + } } + // type and external are mutually exclusive + assert(aType.isEmpty() || !bExternal); + sal_Int32 aLastSeparator = aKeyName.lastIndexOf('\\'); OUString aPathAndNodes = aKeyName.copy(0, aLastSeparator); OUString aProp = aKeyName.copy(aLastSeparator + 1); @@ -202,9 +224,20 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil } if(bFinal) aFileHandle.writeString(" oor:finalized=\"true\""); - aFileHandle.writeString(">"); + aFileHandle.writeString(">"); + writeValueContent(aFileHandle, aValue); - aFileHandle.writeString(""); + + if (bExternal) + aFileHandle.writeString("\"/"); + else + aFileHandle.writeString(""); for(; nCloseNode > 0; nCloseNode--) aFileHandle.writeString(""); aFileHandle.writeString("\n"); -- cgit