[ooo-build-commit] patches/dev300
Tor Lillqvist
tml at kemper.freedesktop.org
Thu Sep 17 15:22:56 PDT 2009
patches/dev300/apply | 3
patches/dev300/win32-restore-associations.diff | 206 +++++++++++++++++++++++++
2 files changed, 209 insertions(+)
New commits:
commit d635f716a75d8c1648eab0c1d598b390be8c4f07
Author: Tor Lillqvist <tlillqvist at novell.com>
Date: Thu Sep 17 22:16:40 2009 +0300
Add new patch to restore MSO file associations on uninstall
* patches/dev300/apply: Add it to Win32Only
* patches/dev300/win32-restore-associations.diff: New file. Save
previous associations of the MS Office file formats on installation
of OOo. On uninstallation of OOo, restore them. Still a bit
experimental, but seems to work.
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 525d551..1cfac5a 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2756,6 +2756,9 @@ seamonkey-source-1.1.14.patch.diff, i#84961, tml
# by Windows when built with debug=true, I think
win32-no-seterror-when-debugging.diff, tml
+# Save old associations for MS doc types when installing OOo, and then
+# restore them if still relevant when uninstalling OOo
+win32-restore-associations.diff, n#530872, tml
[ Fixes ]
#sc-xclimpchangetrack-discard-bogus-formula-size.diff, n#355304, tml
diff --git a/patches/dev300/win32-restore-associations.diff b/patches/dev300/win32-restore-associations.diff
new file mode 100644
index 0000000..932a451
--- /dev/null
+++ b/patches/dev300/win32-restore-associations.diff
@@ -0,0 +1,206 @@
+--- scp2/source/ooo/windowscustomaction_ooo.scp
++++ scp2/source/ooo/windowscustomaction_ooo.scp
+@@ -56,6 +56,15 @@
+ Inbinarytable = 1;
+ Assignment1 = ("InstallExecuteSequence", "Not REMOVE=\"ALL\" And Not PATCH", "CostFinalize");
+ End
++
++WindowsCustomAction gid_Customaction_Restoreregallmsdocdll
++ Name = "Restoreregallmsdocdll";
++ Typ = "65";
++ Source = "reg4allmsdoc.dll";
++ Target = "RestoreRegAllMSDoc";
++ Inbinarytable = 1;
++ Assignment1 = ("InstallExecuteSequence", "REMOVE=\"ALL\" And Not PATCH", "end");
++End
+
+ WindowsCustomAction gid_Customaction_Regactivexdll1
+ Name = "Regactivexdll1";
+--- setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx
++++ setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx
+@@ -191,6 +191,9 @@
+ return rc;
+ }
+
++// Unused
++#if 0
++
+ //----------------------------------------------------------
+ static BOOL RemoveExtensionInRegistry( LPCSTR lpSubKey )
+ {
+@@ -241,6 +244,8 @@
+ return ( ERROR_SUCCESS == lResult );
+ }
+
++#endif
++
+ //----------------------------------------------------------
+ bool GetMsiProp( MSIHANDLE handle, LPCSTR name, /*out*/std::string& value )
+ {
+@@ -268,11 +273,59 @@
+ }
+
+ //----------------------------------------------------------
++static void saveOldRegistration( LPCSTR lpSubKey )
++{
++ BOOL bRet = false;
++ HKEY hKey = NULL;
++ LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0,
++ KEY_QUERY_VALUE|KEY_SET_VALUE, &hKey );
++
++ if ( ERROR_SUCCESS == lResult )
++ {
++ CHAR szBuffer[1024];
++ DWORD nSize = sizeof( szBuffer );
++
++ lResult = RegQueryValueExA( hKey, "", NULL, NULL, (LPBYTE)szBuffer, &nSize );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ szBuffer[nSize] = '\0';
++
++ // No need to save assocations for our own types
++ if ( strncmp( szBuffer, "OpenOffice.org.", 15 ) != 0 )
++ {
++ // Save the old association
++ RegSetValueExA( hKey, "OOoBackupAssociation", 0,
++ REG_SZ, (LPBYTE)szBuffer, nSize );
++ // Also save what the old association means, just so we can try to verify
++ // if/when restoring it that the old application still exists
++ HKEY hKey2 = NULL;
++ lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, szBuffer, 0,
++ KEY_QUERY_VALUE, &hKey2 );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ nSize = sizeof( szBuffer );
++ lResult = RegQueryValueExA( hKey2, "", NULL, NULL, (LPBYTE)szBuffer, &nSize );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ RegSetValueExA( hKey, "OOoBackupAssociationDeref", 0,
++ REG_SZ, (LPBYTE)szBuffer, nSize );
++ }
++ RegCloseKey( hKey2 );
++ }
++ }
++ }
++ RegCloseKey( hKey );
++ }
++}
++
++//----------------------------------------------------------
+ static void registerForExtensions( MSIHANDLE handle, BOOL bRegisterAll )
+ { // Check all file extensions
+ int nIndex = 0;
+ while ( g_Extensions[nIndex] != 0 )
+ {
++ saveOldRegistration( g_Extensions[nIndex] );
++
+ BOOL bRegister = bRegisterAll || CheckExtensionInRegistry( g_Extensions[nIndex] );
+ if ( bRegister )
+ {
+@@ -290,6 +346,10 @@
+ //----------------------------------------------------------
+ //----------------------------------------------------------
+ //----------------------------------------------------------
++//
++// This is the (slightly misleadinly named) entry point for the
++// custom action called Regallmsdocdll.
++//
+ extern "C" UINT __stdcall FindRegisteredExtensions( MSIHANDLE handle )
+ {
+ bool bRegisterAll = IsSetMsiProp( handle, "REGISTER_ALL_MSO_TYPES" );
+@@ -309,7 +369,12 @@
+ return ERROR_SUCCESS;
+ }
+
++#if 0
++
+ //----------------------------------------------------------
++//
++// This entry is not called for any custom action.
++//
+ extern "C" UINT __stdcall DeleteRegisteredExtensions( MSIHANDLE /*handle*/ )
+ {
+ OutputDebugStringFormat( "DeleteRegisteredExtensions\n" );
+@@ -324,3 +389,77 @@
+
+ return ERROR_SUCCESS;
+ }
++
++#endif
++
++//----------------------------------------------------------
++static void restoreOldRegistration( LPCSTR lpSubKey )
++{
++ BOOL bRet = false;
++ HKEY hKey = NULL;
++ LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0,
++ KEY_QUERY_VALUE|KEY_SET_VALUE, &hKey );
++
++ if ( ERROR_SUCCESS == lResult )
++ {
++ CHAR szBuffer[1024];
++ DWORD nSize = sizeof( szBuffer );
++
++ lResult = RegQueryValueExA( hKey, "OOoBackupAssociation", NULL, NULL,
++ (LPBYTE)szBuffer, &nSize );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ HKEY hKey2 = NULL;
++ lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, szBuffer, 0,
++ KEY_QUERY_VALUE, &hKey2 );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ CHAR szBuffer2[1024];
++ DWORD nSize2 = sizeof( szBuffer2 );
++
++ lResult = RegQueryValueExA( hKey2, "", NULL, NULL, (LPBYTE)szBuffer2, &nSize2 );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ CHAR szBuffer3[1024];
++ DWORD nSize3 = sizeof( szBuffer3 );
++
++ // Try to verify that the old association is OK to restore
++ lResult = RegQueryValueExA( hKey, "OOoBackupAssociationDeref", NULL, NULL,
++ (LPBYTE)szBuffer3, &nSize3 );
++ if ( ERROR_SUCCESS == lResult )
++ {
++ if ( nSize2 == nSize3 && strcmp (szBuffer2, szBuffer3) == 0)
++ {
++ // Yep. So restore it
++ RegSetValueExA( hKey, "", 0, REG_SZ, (LPBYTE)szBuffer, nSize );
++ }
++ }
++ }
++ RegCloseKey( hKey2 );
++ }
++ RegDeleteValueA( hKey, "OOoBackupAssociation" );
++ }
++ RegDeleteValueA( hKey, "OOoBackupAssociationDeref" );
++ RegCloseKey( hKey );
++ }
++}
++
++//----------------------------------------------------------
++//
++// This function is not in upstream. We call this from the
++// Restoreregallmsdocdll custom action.
++//
++extern "C" UINT __stdcall RestoreRegAllMSDoc( MSIHANDLE /*handle*/ )
++{
++ OutputDebugStringFormat( "RestoreRegAllMSDoc\n" );
++
++ int nIndex = 0;
++ while ( g_Extensions[nIndex] != 0 )
++ {
++ restoreOldRegistration( g_Extensions[nIndex] );
++ ++nIndex;
++ }
++
++
++ return ERROR_SUCCESS;
++}
+--- setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp
++++ setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp
+@@ -1 +1,2 @@
+ FindRegisteredExtensions
++RestoreRegAllMSDoc
More information about the ooo-build-commit
mailing list