summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorJanos Farago <farago.janos@andrews.hu>2013-09-29 15:03:53 +0200
committerAndras Timar <andras.timar@collabora.com>2013-10-02 20:15:03 +0000
commita434091ba31c9e7c7725b6e25c2c534b798058a4 (patch)
treea68abf8e327a52c8265669561da1abc181678183 /configmgr
parent1f82c0a46529ee056e99fd7031b5d569de522359 (diff)
winreg backend: add support for oor:op in config nodes
Change-Id: I9cc4472b37d24e426a67661806805c11b521dfb1 Reviewed-on: https://gerrit.libreoffice.org/6074 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/winreg.cxx73
1 files changed, 67 insertions, 6 deletions
diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx
index b68b9d2e9464..29695987d6f8 100644
--- a/configmgr/source/winreg.cxx
+++ b/configmgr/source/winreg.cxx
@@ -36,18 +36,39 @@ namespace configmgr {
namespace {
// This is not a generic registry reader. We assume the following structure:
-// Last element of Key becomes prop, first part is the path.
+// 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)
+//
// For example the following registry setting:
// [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\LibreOffice\org.openoffice.UserProfile\Data\o]
// "Value"="Example Corp."
// "Final"=dword:00000001
// becomes the following in configuration:
+// <!-- set the Company name -->
// <item oor:path="/org.openoffice.UserProfile/Data">
// <prop oor:name="o" oor:finalized="true">
// <value>Example Corp.</value>
// </prop>
// </item>
+//
+// Another example:
+// [HKEY_LOCAL_MACHINE\Policies\LibreOffice\org.openoffice.Office.OptionsDialog\OptionsDialogGroups\ProductName/#fuse\Pages\AboutConfig/#fuse\Hide]
+// "Value"="true"
+// becomes the following in configuration:
+// <!-- Hide Tools - Options - LibreOffice - Expert Config panel -->
+// <item oor:path="/org.openoffice.Office.OptionsDialog/OptionsDialogGroups">
+// <node oor:name="ProductName" oor:op="fuse">
+// <node oor:name="Pages">
+// <node oor:name="AboutConfig" oor:op="fuse">
+// <prop oor:name="Hide">
+// <value>true</value>
+// </prop>
+// </node>
+// </node>
+// </node>
+// </item>
+
void dumpWindowsRegistryKey(HKEY hKey, OUString aKeyName, oslFileHandle aFileHandle)
{
HKEY hCurKey;
@@ -107,19 +128,59 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString aKeyName, oslFileHandle aFileHan
bFinal = true;
}
sal_Int32 aLastSeparator = aKeyName.lastIndexOf('\\');
- OUString aPath = aKeyName.replaceAll("\\","/").copy(0, aLastSeparator);
+ OUString aPathAndNodes = aKeyName.copy(0, aLastSeparator);
OUString aProp = aKeyName.copy(aLastSeparator + 1);
+ bool bHasNode = false;
+ sal_Int32 nCloseNode = 0;
+
+ writeData(aFileHandle, "<item oor:path=\"");
+ for(sal_Int32 nIndex = 0;; ++nIndex)
+ {
+ OUString aNextPathPart = aPathAndNodes.getToken(nIndex, '\\');
+
+ if(!aNextPathPart.isEmpty())
+ {
+ if((aNextPathPart.lastIndexOf("/#") != -1) || bHasNode)
+ {
+ bHasNode = true;
+ nCloseNode++;
+ writeData(aFileHandle, "\"><node oor:name=\"");
+ sal_Int32 nCommandSeparator = aNextPathPart.lastIndexOf('#');
+ if(nCommandSeparator != -1)
+ {
+ OUString aNodeOp = aNextPathPart.copy(nCommandSeparator + 1);
+ writeAttributeValue(aFileHandle, aNextPathPart.copy(0, nCommandSeparator - 1));
+ writeData(aFileHandle, "\" oor:op=\"");
+ writeAttributeValue(aFileHandle, aNodeOp);
+ }
+ else
+ {
+ writeAttributeValue(aFileHandle, aNextPathPart);
+ }
+ }
+ else
+ {
+ writeAttributeValue(aFileHandle, "/" + aNextPathPart);
+ }
+ }
+ else
+ {
+ writeData(aFileHandle, "\">");
+ break;
+ }
+ }
- writeData(aFileHandle, "<item oor:path=\"/");
- writeAttributeValue(aFileHandle, aPath);
- writeData(aFileHandle, "\"><prop oor:name=\"");
+ writeData(aFileHandle, "<prop oor:name=\"");
writeAttributeValue(aFileHandle, aProp);
writeData(aFileHandle, "\"");
if(bFinal)
writeData(aFileHandle, " oor:finalized=\"true\"");
writeData(aFileHandle, "><value>");
writeValueContent(aFileHandle, aValue);
- writeData(aFileHandle, "</value></prop></item>\n");
+ writeData(aFileHandle, "</value></prop>");
+ for(; nCloseNode > 0; nCloseNode--)
+ writeData(aFileHandle, "</node>");
+ writeData(aFileHandle, "</item>\n");
delete[] pValueName;
delete[] pValue;
}