OpenOffice AutoRecovery cancellation script

Issues installing under the Mac OSX - X11 - Aqua
Locked
User avatar
MrProgrammer
Moderator
Posts: 5261
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

OpenOffice AutoRecovery cancellation script

Post by MrProgrammer »

If OpenOffice dies, the files which were open are usually available for recovery in the OpenOffice Document Recovery dialog. This feature is controlled with option Load/Save → General → Save AutoRecovery information every … minutes. Options are set with OpenOffice → Preferences on a Mac. The Start Recovery button attempts to recover the data as last saved with the AutoRecovery feature. The Cancel button tells OpenOffice to discard all AutoRecovery information and start without recovering files.
Autorecovery.gif
Autorecovery.gif (29.13 KiB) Viewed 9004 times

Occasionally I have had difficulty with the OpenOffice recovery process on MacOS, specifically, both Start Recovery and Cancel immediately fail with no error message. When OpenOffice is started again the same set of files is presented for recovery, thus it is not possible to start OpenOffice without creating a new user profile. I presume the difficulty does not occur with LibreOffice, and the problem may be specific to MacOS.

But creating a new user profile means all customization must be reapplied, which is a nuisance, especially since I have quite a lot of that. I've discovered that a quick workaround is to just remove a few items in the recoverymodifications.xcu file of the user profile. This is much faster for me. I do it with the TextEdit application on MacOS. The edit does require a good understanding of the structure of this file, so that approach may not be practical for most people.

Recently, I created a set of Bash commands to remove the AutoRecovery items. These commands are entered in the Terminal application which, like Bash, is pre-installed on every MacOS system. Commands are case-sensitive; they should be entered exactly as shown. It will probably be easier to use copy/paste than to type them. Be sure that OpenOffice is not running when you enter the commands.

I tested the procecdure on MacOS 13.7 and it allowed me to remove the Recovery items so I could start OpenOffice. If you have trouble with this the quickest solution is to create a new user profile. If you don't want to do that, here are the commands that I used.

/bin/sh                                                                          # Start the Bash shell
r=~/"Library/Application Support/OpenOffice/4/user/registrymodifications.xcu"    # user/registrymodifications.xcu
b="${r%xcu}$(date +%Y%m%d%H%M%S)"                                                # user/registrymodifications.YYYYMMDDHHMMSS
o='--xpath'                                                                      # Option name for xmllint command
s='1,2s|(<[^>]+>).+|\1|;2q'                                                      # Select only <?xml …> and <oor:items …> tags
i='//item[@*[1]!="/org.openoffice.Office.Recovery/RecoveryList"]'                # Get all except recovery list items
e='</oor:items>'                                                                 # Closing tag for item list

mv "$r" "$b"; [[ -e "$b" ]] || echo "Backup failed"                              # Rename file to backup YYYYMMDDHHMMSS name
set -C                                                                           # Disallow overwrite of existing file
( xmllint $o / "$b" | sed -E "$s"; xmllint $o "$i" "$b"; echo "$e"; ) >"$r"      # Create new registrymodifications.xcu

Use Terminal → Quit after you have created the new registrymodifications.xcu file, then launch OpenOffice. Similar commands should work on Linux systems. People who run Windows could use the Linux subsystem there. I don't have Linux or Windows systems available to help on those platforms.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.5, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Locked