summaryrefslogtreecommitdiff
path: root/setup_native
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2004-05-26 16:06:21 +0000
committerTino Rachui <tra@openoffice.org>2004-05-26 16:06:21 +0000
commit72200a0ff7676d64dc127bfb281b73b2dcd77433 (patch)
tree65157004b9e720049adf2a62e7e3edb1d5f215e6 /setup_native
parentd028b0cdfc1e4a5a65597eefee1b7076b0e3b647 (diff)
#i28276#
Diffstat (limited to 'setup_native')
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/constants.hxx73
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/exports.dxp3
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/makefile.mk127
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx97
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/msihelper.hxx167
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/reg4msdocmsi.cxx227
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/register.cxx423
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/register.hxx119
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registrar.cxx704
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registrar.hxx107
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.cxx322
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.hxx140
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registry.cxx256
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registry.hxx365
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registryexception.cxx107
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registryexception.hxx104
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.cxx184
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.hxx108
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registryw9x.cxx593
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registryw9x.hxx236
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registrywnt.cxx653
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/registrywnt.hxx238
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/stringconverter.cxx99
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/stringconverter.hxx75
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx143
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/userregistrar.hxx45
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/windowsregistry.cxx75
-rw-r--r--setup_native/source/win32/customactions/reg4msdoc/windowsregistry.hxx33
28 files changed, 5823 insertions, 0 deletions
diff --git a/setup_native/source/win32/customactions/reg4msdoc/constants.hxx b/setup_native/source/win32/customactions/reg4msdoc/constants.hxx
new file mode 100644
index 000000000000..3510ab618254
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/constants.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: constants.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+ #ifndef _CONSTANTS_HXX_
+ #define _CONSTANTS_HXX_
+
+extern const int MSWORD;
+extern const int MSEXCEL;
+extern const int MSPOWERPOINT;
+extern const int DEFAULT_HTML_EDITOR_FOR_IE;
+extern const int HTML_EDITOR;
+extern const int DEFAULT_SHELL_HTML_EDITOR;
+
+ #endif
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/exports.dxp b/setup_native/source/win32/customactions/reg4msdoc/exports.dxp
new file mode 100644
index 000000000000..0f3d16886098
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/exports.dxp
@@ -0,0 +1,3 @@
+InstallUiSequenceEntry
+InstallExecSequenceEntry
+DeinstallExecSequenceEntry
diff --git a/setup_native/source/win32/customactions/reg4msdoc/makefile.mk b/setup_native/source/win32/customactions/reg4msdoc/makefile.mk
new file mode 100644
index 000000000000..6f314d5d4658
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/makefile.mk
@@ -0,0 +1,127 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: tra $ $Date: 2004-05-26 17:06:09 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=setup_native
+TARGET=reg4msdocmsi
+
+.IF "$(GUI)"=="WNT"
+
+# --- Settings -----------------------------------------------------
+
+ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=TRUE
+DYNAMIC_CRT=
+USE_DEFFILE=TRUE
+
+.INCLUDE : settings.mk
+
+#STDSHL=
+# SOLARINC!:=$(SOLARINC:s/stl//)
+
+CFLAGS+=-DUNICODE -D_UNICODE -D_STLP_USE_STATIC_LIB
+
+# --- Files --------------------------------------------------------
+
+UWINAPILIB=
+
+SLOFILES = $(SLO)$/msihelper.obj\
+ $(SLO)$/windowsregistry.obj\
+ $(SLO)$/userregistrar.obj\
+ $(SLO)$/stringconverter.obj\
+ $(SLO)$/registrywnt.obj\
+ $(SLO)$/registryw9x.obj\
+ $(SLO)$/registryvalueimpl.obj\
+ $(SLO)$/registryexception.obj\
+ $(SLO)$/registry.obj\
+ $(SLO)$/registrationcontextinformation.obj\
+ $(SLO)$/registrar.obj\
+ $(SLO)$/register.obj\
+ $(SLO)$/reg4msdocmsi.obj
+
+SHL1STDLIBS= kernel32.lib\
+ user32.lib\
+ advapi32.lib\
+ shell32.lib\
+ msi.lib\
+ $(LIBSTLPORTST)
+
+SHL1LIBS = $(SLB)$/$(TARGET).lib
+
+SHL1TARGET = $(TARGET)
+SHL1IMPLIB = i$(TARGET)
+
+SHL1DEF = $(MISC)$/$(SHL1TARGET).def
+SHL1DEPN = $(SLB)$/$(TARGET).lib
+SHL1BASE = 0x1c000000
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
+
+# -------------------------------------------------------------------------
+
+
+.ENDIF
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx b/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx
new file mode 100644
index 000000000000..8ea769a84b8b
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx
@@ -0,0 +1,97 @@
+#ifndef INCLUDED_MSIHELPER_HXX
+#include "msihelper.hxx"
+#endif
+
+#include <malloc.h>
+#include <assert.h>
+
+bool GetMsiProp(MSIHANDLE handle, LPCTSTR name, /*out*/std::wstring& value)
+{
+ DWORD sz = 0;
+ LPTSTR dummy = TEXT("");
+ if (MsiGetProperty(handle, name, dummy, &sz) == ERROR_MORE_DATA)
+ {
+ sz++;
+ DWORD nbytes = sz * sizeof(TCHAR);
+ LPTSTR buff = reinterpret_cast<LPTSTR>(_alloca(nbytes));
+ ZeroMemory(buff, nbytes);
+ MsiGetProperty(handle, name, buff, &sz);
+ value = buff;
+ return true;
+ }
+ return false;
+}
+
+void SetMsiProp(MSIHANDLE handle, LPCTSTR name)
+{
+ MsiSetProperty(handle, name, TEXT("1"));
+}
+
+void UnsetMsiProp(MSIHANDLE handle, LPCTSTR name)
+{
+ MsiSetProperty(handle, name, TEXT(""));
+}
+
+bool IsSetMsiProp(MSIHANDLE handle, LPCTSTR name)
+{
+ std::wstring val;
+ GetMsiProp(handle, name, val);
+ return (val == TEXT("1"));
+}
+
+bool IsAllUserInstallation(MSIHANDLE handle)
+{
+ return IsSetMsiProp(handle, TEXT("ALLUSERS"));
+}
+
+std::wstring GetOfficeInstallationPath(MSIHANDLE handle)
+{
+ std::wstring progpath;
+ GetMsiProp(handle, TEXT("OfficeFolder"), progpath);
+ return progpath;
+}
+
+std::wstring GetOfficeExecutablePath(MSIHANDLE handle)
+{
+ std::wstring exepath = GetOfficeInstallationPath(handle);
+ exepath += TEXT("program\\soffice.exe");
+ return exepath;
+}
+
+std::wstring GetProductName(MSIHANDLE handle)
+{
+ std::wstring prodname;
+ GetMsiProp(handle, TEXT("ProductName"), prodname);
+ return prodname;
+}
+
+bool IsModuleInstalled(MSIHANDLE handle, LPCTSTR name)
+{
+ INSTALLSTATE current_state;
+ INSTALLSTATE future_state;
+ MsiGetFeatureState(handle, name, &current_state, &future_state);
+ return (current_state == INSTALLSTATE_LOCAL);
+}
+
+bool IsModuleSelectedForInstallation(MSIHANDLE handle, LPCTSTR name)
+{
+ INSTALLSTATE current_state;
+ INSTALLSTATE future_state;
+ MsiGetFeatureState(handle, name, &current_state, &future_state);
+ return (future_state == INSTALLSTATE_LOCAL);
+}
+
+bool IsModuleSelectedForDeinstallation(MSIHANDLE handle, LPCTSTR name)
+{
+ INSTALLSTATE current_state;
+ INSTALLSTATE future_state;
+ MsiGetFeatureState(handle, name, &current_state, &future_state);
+ return ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_ABSENT));
+}
+
+bool IsCompleteDeinstallation(MSIHANDLE handle)
+{
+ std::wstring rm;
+ GetMsiProp(handle, TEXT("REMOVE"), rm);
+ return (rm == TEXT("ALL"));
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/msihelper.hxx b/setup_native/source/win32/customactions/reg4msdoc/msihelper.hxx
new file mode 100644
index 000000000000..a07dfbaa9f92
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/msihelper.hxx
@@ -0,0 +1,167 @@
+#ifndef INCLUDED_MSIHELPER_HXX
+#define INCLUDED_MSIHELPER_HXX
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include <msiquery.h>
+#include <string>
+
+/**
+ Get the value of the named property
+
+ @param handle
+ [in] a valid msi handle.
+
+ @param name
+ [in] the name of the property.
+
+ @param value
+ [out] receives thes value of the property.
+
+ @returns
+ <TRUE/>if the property was found.
+*/
+bool GetMsiProp(MSIHANDLE handle, LPCTSTR name, /*out*/std::wstring& value);
+
+/**
+ Set the value of a binary property which can only
+ have the values "0" or "1" to "1".
+
+ @param handle
+ [in] a valid msi handle.
+
+ @param name
+ [in] the name of the property.
+*/
+void SetMsiProp(MSIHANDLE handle, LPCTSTR name);
+
+/**
+ Set the value of a binary property which can only
+ have the values "0" or "1" to "0".
+
+ @param handle
+ [in] a valid msi handle.
+
+ @param name
+ [in] the name of the property.
+*/
+void UnsetMsiProp(MSIHANDLE handle, LPCTSTR name);
+
+/**
+ Returns whether a certain property is set meaning
+ its value is "1". This method should be used for
+ binary properties whose value can be "0" or "1".
+
+ @returns
+ <TRUE/>if the value of the specified property is
+ "1" else if the property is not defined or its
+ value is other than "1" <FALSE/> will be returned.
+*/
+bool IsSetMsiProp(MSIHANDLE handle, LPCTSTR name);
+
+/**
+ Query if this is an installation for all user or not.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @returns
+ <TRUE/>if this is an all user installation
+*/
+bool IsAllUserInstallation(MSIHANDLE handle);
+
+/**
+ Returns the destination folder of the office installation
+ as system path. The returned path contains a final '\'.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @returns
+ the destination path of the office installation finalized
+ with a '\'.
+*/
+std::wstring GetOfficeInstallationPath(MSIHANDLE handle);
+
+/**
+ Returns the absolute path of the office executable that
+ will be installed as system path.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @returns
+ the absolute system path of the office executable (e.g.
+ (C:\Program Files\StarOffice 8\program\soffice.exe").
+*/
+std::wstring GetOfficeExecutablePath(MSIHANDLE handle);
+
+/**
+ Get the name of the office that will be installed
+ (e.g. StarOffice 8, StarSuite 8, ...).
+
+ @param handle
+ [in] a valid msi handle.
+
+ @returns
+ the name of the office product that will be installed.
+*/
+std::wstring GetProductName(MSIHANDLE handle);
+
+/**
+ Determine if the specified module is installed locally.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @param name
+ [in] the name of the module.
+
+ @returns
+ <TRUE/>if the specified module is installed locally.
+*/
+bool IsModuleInstalled(MSIHANDLE handle, LPCTSTR name);
+
+/**
+ Determine if the specified module is selected to be installed
+ locally.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @param name
+ [in] the name of the module.
+
+ @returns
+ <TRUE/>if the specified module is about to be installed locally.
+*/
+bool IsModuleSelectedForInstallation(MSIHANDLE handle, LPCTSTR name);
+
+/**
+ Determine if the specified module which is locally installed is
+ selected for deinstallation.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @param name
+ [in] the name of the module.
+
+ @returns
+ <TRUE/>if the specified module is about to be deinstalled.
+*/
+bool IsModuleSelectedForDeinstallation(MSIHANDLE handle, LPCTSTR name);
+
+/**
+ Determine whether this is a complete uninstallation or not.
+
+ @param handle
+ [in] a valid msi handle.
+
+ @returns
+ <TRUE/>if this is a complete deinstallation.
+*/
+bool IsCompleteDeinstallation(MSIHANDLE handle);
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/reg4msdocmsi.cxx b/setup_native/source/win32/customactions/reg4msdoc/reg4msdocmsi.cxx
new file mode 100644
index 000000000000..0eea790bb632
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/reg4msdocmsi.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * $RCSfile: reg4msdocmsi.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include <msiquery.h>
+
+#ifndef _REGISTER_HXX_
+#include "register.hxx"
+#endif
+
+#ifndef INCLUDED_MSIHELPER_HXX
+#include "msihelper.hxx"
+#endif
+
+#include <memory>
+#include <string>
+
+#define ELEMENTS_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
+
+void DetermineWordPreselectionState(MSIHANDLE handle)
+{
+ if (query_preselect_registration_for_ms_application(handle, MSWORD))
+ SetMsiProp(handle, TEXT("SELECT_WORD"));
+}
+
+void DetermineExcelPreselectionState(MSIHANDLE handle)
+{
+ if (query_preselect_registration_for_ms_application(handle, MSEXCEL))
+ SetMsiProp(handle, TEXT("SELECT_EXCEL"));
+}
+
+void DeterminePowerPointPreselectionState(MSIHANDLE handle)
+{
+ if (query_preselect_registration_for_ms_application(handle, MSPOWERPOINT))
+ SetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
+}
+
+extern "C" UINT __stdcall InstallUiSequenceEntry(MSIHANDLE handle)
+{
+ //MessageBox(NULL, TEXT("InstallUiSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
+
+ if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin")))
+ {
+ DetermineWordPreselectionState(handle);
+ }
+ else if (IsModuleInstalled(handle, TEXT("gm_p_Wrt_Bin")) &&
+ !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")) &&
+ IsRegisteredFor(handle, MSWORD))
+ {
+ SetMsiProp(handle, TEXT("SELECT_WORD"));
+ }
+ else
+ {
+ UnsetMsiProp(handle, TEXT("SELECT_WORD"));
+ }
+
+ if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Calc_Bin")))
+ {
+ DetermineExcelPreselectionState(handle);
+ }
+ else if (IsModuleInstalled(handle, TEXT("gm_p_Calc_Bin")) &&
+ !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")) &&
+ IsRegisteredFor(handle, MSEXCEL))
+ {
+ SetMsiProp(handle, TEXT("SELECT_EXCEL"));
+ }
+ else
+ {
+ UnsetMsiProp(handle, TEXT("SELECT_EXCEL"));
+ }
+
+ if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Impress_Bin")))
+ {
+ DeterminePowerPointPreselectionState(handle);
+ }
+ else if (IsModuleInstalled(handle, TEXT("gm_p_Impress_Bin")) &&
+ !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")) &&
+ IsRegisteredFor(handle, MSPOWERPOINT))
+ {
+ SetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
+ }
+ else
+ {
+ UnsetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
+ }
+ return ERROR_SUCCESS;
+}
+
+extern "C" UINT __stdcall InstallExecSequenceEntry(MSIHANDLE handle)
+{
+ //MessageBox(NULL, TEXT("InstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
+
+ int reg4 = 0;
+ int unreg4 = 0;
+
+ // we always register as html editor for Internet Explorer
+ // if writer is installed because there's no harm if we do so
+ if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin")))
+ reg4 |= HTML_EDITOR;
+
+ if (IsSetMsiProp(handle, TEXT("SELECT_WORD")) && !IsRegisteredFor(handle, MSWORD))
+ reg4 |= MSWORD;
+ else if (!IsSetMsiProp(handle, TEXT("SELECT_WORD")) && IsRegisteredFor(handle, MSWORD))
+ unreg4 |= MSWORD;
+
+ if (IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && !IsRegisteredFor(handle, MSEXCEL))
+ reg4 |= MSEXCEL;
+ else if (!IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && IsRegisteredFor(handle, MSEXCEL))
+ unreg4 |= MSEXCEL;
+
+ if (IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && !IsRegisteredFor(handle, MSPOWERPOINT))
+ reg4 |= MSPOWERPOINT;
+ else if (!IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && IsRegisteredFor(handle, MSPOWERPOINT))
+ unreg4 |= MSPOWERPOINT;
+
+ if (reg4)
+ {
+ Register4MsDoc(handle, reg4);
+
+ if (IsModuleSelectedForInstallation(handle, TEXT("gm_o_Activexcontrol")))
+ RegisterActiveX4MsDoc(handle, reg4);
+ }
+
+ if (unreg4)
+ {
+ Unregister4MsDoc(handle, unreg4);
+
+ if (IsModuleInstalled(handle, TEXT("gm_o_Activexcontrol")))
+ UnregisterActiveX4MsDoc(handle, unreg4);
+ }
+ return ERROR_SUCCESS;
+}
+
+extern "C" UINT __stdcall DeinstallExecSequenceEntry(MSIHANDLE handle)
+{
+ //MessageBox(NULL, TEXT("DeinstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
+
+ if (IsCompleteDeinstallation(handle))
+ {
+ Unregister4MsDocAll(handle);
+ UnregisterActiveX4MsDocAll(handle);
+ return ERROR_SUCCESS;
+ }
+
+ if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")))
+ {
+ Unregister4MsDoc(handle, MSWORD | HTML_EDITOR);
+ UnregisterActiveX4MsDoc(handle, MSWORD);
+ }
+
+ if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")))
+ {
+ Unregister4MsDoc(handle, MSEXCEL);
+ UnregisterActiveX4MsDoc(handle, MSEXCEL);
+ }
+
+ if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")))
+ {
+ Unregister4MsDoc(handle, MSPOWERPOINT);
+ UnregisterActiveX4MsDoc(handle, MSPOWERPOINT);
+ }
+
+ if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_o_Activexcontrol")))
+ UnregisterActiveX4MsDocAll(handle);
+
+ return ERROR_SUCCESS;
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/register.cxx b/setup_native/source/win32/customactions/reg4msdoc/register.cxx
new file mode 100644
index 000000000000..2e01b4b900a9
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/register.cxx
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * $RCSfile: register.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _REGISTER_HXX_
+#include "register.hxx"
+#endif
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#include "registryexception.hxx"
+#endif
+
+#ifndef _REGISTRATIONCONTEXTINFORMATION_HXX_
+#include "registrationcontextinformation.hxx"
+#endif
+
+#ifndef _USERREGISTRAR_HXX_
+#include "userregistrar.hxx"
+#endif
+
+#ifndef _WINDOWSREGISTRY_HXX_
+#include "windowsregistry.hxx"
+#endif
+
+#ifndef _STRINGCONVERTER_HXX_
+#include "stringconverter.hxx"
+#endif
+
+#ifndef INCLUDED_MSIHELPER_HXX
+#include "msihelper.hxx"
+#endif
+
+#include <shlobj.h>
+#include <assert.h>
+
+
+typedef std::auto_ptr<Registrar> RegistrarPtr;
+
+namespace /* private */
+{
+ RegistrarPtr CreateRegistrar(bool InstallForAllUser, const RegistrationContextInformation& RegCtx)
+ {
+ RegistrarPtr RegPtr;
+
+ if (InstallForAllUser)
+ RegPtr = RegistrarPtr(new Registrar(RegCtx));
+ else
+ RegPtr = RegistrarPtr(new UserRegistrar(RegCtx));
+
+ return RegPtr;
+ }
+} // namespace private
+
+bool query_preselect_registration_for_ms_application(MSIHANDLE handle, int Register)
+{
+ bool preselect = false;
+
+ try
+ {
+ RegistrationContextInformation RegContext(handle, GetOfficeExecutablePath(handle));
+ RegistrarPtr CurrentRegistrar = CreateRegistrar(IsAllUserInstallation(handle), RegContext);
+
+ if (Register & MSWORD)
+ preselect = CurrentRegistrar->QueryPreselectMsWordRegistration();
+ else if (Register & MSEXCEL)
+ preselect = CurrentRegistrar->QueryPreselectMsExcelRegistration();
+ else if (Register & MSPOWERPOINT)
+ preselect = CurrentRegistrar->QueryPreselectMsPowerPointRegistration();
+ }
+ catch(RegistryException&)
+ {
+ assert(false);
+ }
+ return preselect;
+}
+
+//-----------------------------------------
+// registers StarOffice for MS document
+// types and as default HTML editor if
+// specified
+//-----------------------------------------
+
+void Register4MsDoc(MSIHANDLE handle, int Register)
+{
+ try
+ {
+ RegistrationContextInformation RegContext(handle, GetOfficeExecutablePath(handle));
+ RegistrarPtr CurrentRegistrar = CreateRegistrar(IsAllUserInstallation(handle), RegContext);
+
+ if ((Register & MSWORD))
+ CurrentRegistrar->RegisterForMsWord();
+
+ if ((Register & MSEXCEL))
+ CurrentRegistrar->RegisterForMsExcel();
+
+ if ((Register & MSPOWERPOINT))
+ CurrentRegistrar->RegisterForMsPowerPoint();
+
+ if ((Register & HTML_EDITOR))
+ CurrentRegistrar->RegisterAsHtmlEditorForInternetExplorer();
+
+ if ((Register & DEFAULT_SHELL_HTML_EDITOR))
+ {
+ CurrentRegistrar->RegisterAsDefaultHtmlEditorForInternetExplorer();
+ CurrentRegistrar->RegisterAsDefaultShellHtmlEditor();
+ }
+ }
+ catch(RegistryException&)
+ {
+ assert(false);
+ }
+
+ if (Register)
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
+}
+
+void Unregister4MsDoc(MSIHANDLE handle, int Unregister)
+{
+ try
+ {
+ RegistrationContextInformation RegContext(handle, GetOfficeExecutablePath(handle));
+ RegistrarPtr CurrentRegistrar = CreateRegistrar(IsAllUserInstallation(handle), RegContext);
+
+ if ((Unregister & MSWORD) && CurrentRegistrar->IsRegisteredFor(MSWORD))
+ CurrentRegistrar->UnregisterForMsWord();
+
+ if ((Unregister & HTML_EDITOR) && CurrentRegistrar->IsRegisteredFor(HTML_EDITOR))
+ CurrentRegistrar->UnregisterAsHtmlEditorForInternetExplorer();
+
+ if ((Unregister & MSEXCEL) && CurrentRegistrar->IsRegisteredFor(MSEXCEL))
+ CurrentRegistrar->UnregisterForMsExcel();
+
+ if ((Unregister & MSPOWERPOINT) && CurrentRegistrar->IsRegisteredFor(MSPOWERPOINT))
+ CurrentRegistrar->UnregisterForMsPowerPoint();
+
+ if ((Unregister & DEFAULT_HTML_EDITOR_FOR_IE) && CurrentRegistrar->IsRegisteredFor(DEFAULT_HTML_EDITOR_FOR_IE))
+ CurrentRegistrar->UnregisterAsDefaultHtmlEditorForInternetExplorer();
+
+ if ((Unregister & DEFAULT_SHELL_HTML_EDITOR) && CurrentRegistrar->IsRegisteredFor(DEFAULT_SHELL_HTML_EDITOR))
+ CurrentRegistrar->UnregisterAsDefaultShellHtmlEditor();
+ }
+ catch(RegistryException&)
+ {
+ assert(false);
+ }
+
+ if (Unregister)
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
+}
+
+//-----------------------------------------
+// restores the entries for the selected
+// registry entries
+// Algorithm:
+//
+// 1.
+// Target key exist (e.g. '.doc')
+// Default value == soffice.?
+// Backup key != empty
+// Action: Replace Default value with backup
+// key
+//
+// 2.
+// Target key exist
+// Default value == soffice.?
+// Backup key == empty
+// Action: delete default value
+//
+// 3.
+// Target key exist
+// Default value != soffice.?
+// Action: nop
+//
+// 4.
+// Target key does not exist
+// Action: nop
+//-----------------------------------------
+
+void Unregister4MsDocAll(MSIHANDLE handle)
+{
+ try
+ {
+ RegistrationContextInformation RegContext(handle, GetOfficeExecutablePath(handle));
+ RegistrarPtr CurrentRegistrar = CreateRegistrar(IsAllUserInstallation(handle), RegContext);
+
+ CurrentRegistrar->UnregisterAllAndCleanUpRegistry();
+ }
+ catch(RegistryException&)
+ {
+ assert(false);
+ }
+}
+
+//-----------------------------------------
+// restores lost settings formerly made
+// with Register4MsDoc
+//-----------------------------------------
+
+void RepairRegister4MsDocSettings(MSIHANDLE handle)
+{
+ try
+ {
+ RegistrationContextInformation RegContext(handle, GetOfficeExecutablePath(handle));
+ RegistrarPtr CurrentRegistrar = CreateRegistrar(IsAllUserInstallation(handle), RegContext);
+
+ CurrentRegistrar->RepairRegistrationState();
+ }
+ catch(RegistryException&)
+ {
+ assert(false);
+ }
+}
+
+bool IsRegisteredFor(MSIHANDLE handle, int State)
+{
+ bool Registered = false;
+
+ try
+ {
+ RegistrationContextInformation RegContext(handle, GetOfficeExecutablePath(handle));
+ RegistrarPtr CurrentRegistrar = CreateRegistrar(IsAllUserInstallation(handle), RegContext);
+
+ Registered = CurrentRegistrar->IsRegisteredFor(State);
+ }
+ catch(RegistryException&)
+ {
+ assert(false);
+ }
+ return Registered;
+}
+
+#define SO60_UNINSTALL_KEY L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\StarOffice 6.0"
+#define SO_BACKUP_KEY L"soffice6.bak"
+#define REGMSDOCSTATE L"Reg4MsDocState"
+#define SOFTWARE_CLASSES L"Software\\Classes"
+
+int FixReturnRegistrationState(MSIHANDLE handle)
+{
+ int registration_state = 0;
+
+ try
+ {
+ WindowsRegistry registry;
+
+ RegistryValue rv_regmsdocstate = RegistryValue(
+ new RegistryValueImpl(REGMSDOCSTATE, 0));
+
+ RegistryKey so_bak_key;
+
+ if (IsAllUserInstallation(handle))
+ {
+ RegistryKey hkcr_key = registry.GetClassesRootKey();
+
+ if (hkcr_key->HasSubKey(SO_BACKUP_KEY))
+ so_bak_key = hkcr_key->OpenSubKey(SO_BACKUP_KEY);
+ else
+ so_bak_key = hkcr_key->CreateSubKey(SO_BACKUP_KEY);
+
+ if (!so_bak_key->HasValue(REGMSDOCSTATE))
+ {
+ // set a defined value
+ so_bak_key->SetValue(rv_regmsdocstate);
+
+ RegistryKey hklm_key = registry.GetLocalMachineKey();
+
+ if (hklm_key->HasSubKey(SO60_UNINSTALL_KEY))
+ {
+ RegistryKey so_uninst_key =
+ hklm_key->OpenSubKey(SO60_UNINSTALL_KEY);
+
+ if (so_uninst_key->HasValue(REGMSDOCSTATE))
+ so_bak_key->CopyValue(so_uninst_key, REGMSDOCSTATE);
+ }
+ }
+ }
+ else
+ {
+ RegistryKey hkcu_classes_key =
+ registry.GetCurrentUserKey()->OpenSubKey(SOFTWARE_CLASSES);
+
+ so_bak_key = hkcu_classes_key->CreateSubKey(SO_BACKUP_KEY);
+
+ if (!so_bak_key->HasValue(REGMSDOCSTATE))
+ {
+ // set a defined value
+ so_bak_key->SetValue(rv_regmsdocstate);
+
+ RegistryKey hklm_sftw_classes =
+ registry.GetLocalMachineKey()->OpenSubKey(SOFTWARE_CLASSES, false);
+
+ RegistryKey so_bak_key_old;
+
+ if (hklm_sftw_classes->HasSubKey(SO_BACKUP_KEY))
+ {
+ so_bak_key_old = hklm_sftw_classes->OpenSubKey(SO_BACKUP_KEY, false);
+
+ if (so_bak_key_old->HasValue(REGMSDOCSTATE))
+ so_bak_key->CopyValue(so_bak_key_old, REGMSDOCSTATE);
+ }
+ else // try the uninstall key
+ {
+ RegistryKey hklm_key = registry.GetLocalMachineKey();
+
+ if (hklm_key->HasSubKey(SO60_UNINSTALL_KEY))
+ {
+ RegistryKey so_uninst_key =
+ hklm_key->OpenSubKey(SO60_UNINSTALL_KEY);
+
+ if (so_uninst_key->HasValue(REGMSDOCSTATE))
+ so_bak_key->CopyValue(so_uninst_key, REGMSDOCSTATE);
+ }
+ }
+ }
+ }
+
+ rv_regmsdocstate = so_bak_key->GetValue(REGMSDOCSTATE);
+ registration_state = rv_regmsdocstate->GetDataAsInt();
+ }
+ catch(RegistryException&)
+ {
+ registration_state = 0;
+ }
+
+ return registration_state;
+}
+
+
+// ActiveX control registration
+
+inline HINSTANCE LoadActiveXLibrary(MSIHANDLE handle)
+{
+ std::string axpath = UnicodeToAnsiString(
+ (GetOfficeInstallationPath(handle) + TEXT("program\\so_activex.dll")));
+ return LoadLibraryExA(axpath.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+}
+
+inline bool IsValidHandle(HINSTANCE hinst)
+{ return ((hinst != INVALID_HANDLE_VALUE) && (hinst != NULL)); }
+
+typedef int (__stdcall *DllDocProc)(int, BOOL);
+
+void RegisterActiveX4MsDoc(MSIHANDLE handle, int nPref)
+{
+ HINSTANCE hinst = LoadActiveXLibrary(handle);
+ if (IsValidHandle(hinst))
+ {
+ DllDocProc DllRegisterServerDoc = (DllDocProc)GetProcAddress(hinst, "DllRegisterServerDoc");
+ if (DllRegisterServerDoc)
+ DllRegisterServerDoc(nPref, IsAllUserInstallation(handle));
+ FreeLibrary(hinst);
+ }
+}
+
+void UnregisterActiveX4MsDoc(MSIHANDLE handle, int nPref)
+{
+ HINSTANCE hinst = LoadActiveXLibrary(handle);
+ if (IsValidHandle(hinst))
+ {
+ DllDocProc DllUnregisterServerDoc = (DllDocProc)GetProcAddress(hinst, "DllUnregisterServerDoc");
+ if (DllUnregisterServerDoc)
+ DllUnregisterServerDoc(nPref, IsAllUserInstallation(handle));
+ FreeLibrary(hinst);
+ }
+}
+
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/register.hxx b/setup_native/source/win32/customactions/reg4msdoc/register.hxx
new file mode 100644
index 000000000000..f8aec9bcd5f3
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/register.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * $RCSfile: register.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _REGISTER_HXX_
+#define _REGISTER_HXX_
+
+#ifndef _CONSTANTS_HXX_
+#include "constants.hxx"
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <msi.h>
+
+#include <string>
+
+const int MOD_WRITER = 0x1;
+const int MOD_CALC = 0x2;
+const int MOD_IMPRESS = 0x4;
+const int MOD_ACTIVEX = 0x40;
+
+/* registers StarOffice for MS document
+ types and as default HTML editor if
+ specified */
+void Register4MsDoc(MSIHANDLE handle, int Register);
+
+void Unregister4MsDoc(MSIHANDLE handle, int Unregister);
+
+/* restores the entries for the selected
+ registry entries */
+void Unregister4MsDocAll(MSIHANDLE handle);
+
+/* restores lost settings formerly made
+ with Register4MsDoc */
+void RepairRegister4MsDocSettings(MSIHANDLE handle);
+
+/** Returns whether we are registered for */
+bool IsRegisteredFor(MSIHANDLE handle, int State);
+
+/** Returns whether we should preselect the
+ registration checkbox for a certain
+ application type or not */
+bool query_preselect_registration_for_ms_application(
+ MSIHANDLE handle, int Register);
+
+// StarOffice 6.0 saved the registration
+// state in HKEY_LOCAL_MACHINE\Software\
+// Microsoft\Windows\CurrentVersion\Uninstall\
+// StarOffice 6.0\Reg4MsdocState we move this
+// value if available to the new registry
+// location
+int FixReturnRegistrationState(MSIHANDLE handle);
+
+// ActiveX control registration
+void RegisterActiveX4MsDoc(MSIHANDLE handle, int nPref);
+void UnregisterActiveX4MsDoc(MSIHANDLE handle, int nPref);
+
+inline void UnregisterActiveX4MsDocAll(MSIHANDLE handle)
+{ UnregisterActiveX4MsDoc(handle, 0x07); }
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registrar.cxx b/setup_native/source/win32/customactions/reg4msdoc/registrar.cxx
new file mode 100644
index 000000000000..a5391d88aabd
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registrar.cxx
@@ -0,0 +1,704 @@
+// Registrar.cpp: Implementierung der Klasse Registrar.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRAR_HXX_
+#include "registrar.hxx"
+#endif
+
+#ifndef _REGISTRYVALUEIMPL_HXX_
+#include "RegistryValueImpl.hxx"
+#endif
+
+#ifndef _WINDOWSREGISTRY_HXX_
+#include "windowsregistry.hxx"
+#endif
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#include "registryexception.hxx"
+#endif
+
+#include <assert.h>
+
+const int MSWORD = 0x1;
+const int MSEXCEL = 0x2;
+const int MSPOWERPOINT = 0x4;
+const int DEFAULT_HTML_EDITOR_FOR_IE = 0x8;
+const int HTML_EDITOR = 0x10;
+const int DEFAULT_SHELL_HTML_EDITOR = 0x20;
+
+namespace /* private */
+{
+ const std::wstring HTM_OPENWITHLIST = L".htm\\OpenWithList";
+ const std::wstring APPLICATIONS = L"Applications";
+ const std::wstring SHELL_EDIT_COMMAND = L"shell\\edit\\command";
+ const std::wstring HTML_EDIT = L"HTML Edit";
+ const std::wstring HTML_EDIT_DISPLAY_NAME = L"Edit Display Name";
+ const std::wstring SHELL_EDIT_COMMAND_BACKUP = L"Shell Edit Cmd";
+ const std::wstring DEFAULT_HTML_EDITOR = L"Default HTML Editor";
+ const std::wstring MS_IE_DEF_HTML_EDITOR = L"Software\\Microsoft\\Internet Explorer\\Default HTML Editor";
+ const std::wstring MS_IE_DEF_HTML_EDITOR_SHL_EDIT_CMD = L"Software\\Microsoft\\Internet Explorer\\Default HTML Editor\\shell\\edit\\command";
+}
+
+Registrar::Registrar(const RegistrationContextInformation& RegContext) :
+ m_ContextInformation(RegContext),
+ FORWARD_KEY_PREFIX(L"OpenOffice.org"),//FORWARD_KEY_PREFIX(L"soffice6"),
+ DEFAULT_VALUE_NAME(L""),
+ BACKUP_VALUE_NAME(L"Backup"),
+ PRIVATE_BACKUP_KEY_NAME(L"OpenOffice.org.reg4msdocmsi"),//PRIVATE_BACKUP_KEY_NAME(L"soffice6.bak"),
+ REGISTRATION_STATE(L"Reg4MsDocState")
+{
+ m_RootKey = WindowsRegistry().GetClassesRootKey();
+}
+
+Registrar::~Registrar()
+{
+}
+
+void Registrar::RegisterForMsWord() const
+{
+ assert(m_RootKey.get());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetWordDocumentFileExtension(),
+ m_ContextInformation.GetWordDocumentDisplayName(),
+ m_ContextInformation.GetWordDocumentDefaultIconEntry(),
+ m_ContextInformation.GetWordDocumentDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetWordTemplateFileExtension(),
+ m_ContextInformation.GetWordTemplateDisplayName(),
+ m_ContextInformation.GetWordTemplateDefaultIconEntry(),
+ m_ContextInformation.GetWordTemplateDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ SaveRegisteredFor(MSWORD);
+}
+
+void Registrar::UnregisterForMsWord() const
+{
+ assert(m_RootKey.get());
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetWordDocumentFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetWordTemplateFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ SaveNotRegisteredFor(MSWORD);
+}
+
+bool Registrar::QueryPreselectForMsApplication(const std::wstring& file_extension) const
+{
+ bool preselect = false;
+
+ // We use HKCR else we would not see that a registration for
+ // MS Office applications already exist if we are about to
+ // register in HKCU\Software\Classes
+ RegistryKey root_key = WindowsRegistry().GetClassesRootKey();
+
+ if (!root_key->HasSubKey(file_extension))
+ {
+ preselect = true;
+ }
+ else
+ {
+ RegistryKey RegKey = root_key->OpenSubKey(file_extension, false);
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegistryValue RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ if (REG_SZ == RegVal->GetType() &&
+ IsOpenOfficeRegisteredForMsApplication(RegVal->GetDataAsUniString()))
+ preselect = true;
+ }
+ }
+ return preselect;
+}
+
+bool Registrar::QueryPreselectMsWordRegistration() const
+{
+ return QueryPreselectForMsApplication(
+ m_ContextInformation.GetWordDocumentFileExtension());
+}
+
+void Registrar::RegisterForMsExcel() const
+{
+ assert(m_RootKey.get());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetExcelSheetFileExtension(),
+ m_ContextInformation.GetExcelSheetDisplayName(),
+ m_ContextInformation.GetExcelSheetDefaultIconEntry(),
+ m_ContextInformation.GetExcelSheetDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetExcelTemplateFileExtension(),
+ m_ContextInformation.GetExcelTemplateDisplayName(),
+ m_ContextInformation.GetExcelTemplateDefaultIconEntry(),
+ m_ContextInformation.GetExcelTemplateDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ SaveRegisteredFor(MSEXCEL);
+}
+
+void Registrar::UnregisterForMsExcel() const
+{
+ assert(m_RootKey.get());
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetExcelSheetFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetExcelTemplateFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ SaveNotRegisteredFor(MSEXCEL);
+}
+
+bool Registrar::QueryPreselectMsExcelRegistration() const
+{
+ return QueryPreselectForMsApplication(
+ m_ContextInformation.GetExcelSheetFileExtension());
+}
+
+void Registrar::RegisterForMsPowerPoint() const
+{
+ assert(m_RootKey.get());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetPowerPointDocumentFileExtension(),
+ m_ContextInformation.GetPowerPointDocumentDisplayName(),
+ m_ContextInformation.GetPowerPointDocumentDefaultIconEntry(),
+ m_ContextInformation.GetPowerPointDocumentDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetPowerPointShowFileExtension(),
+ m_ContextInformation.GetPowerPointShowDisplayName(),
+ m_ContextInformation.GetPowerPointShowDefaultIconEntry(),
+ m_ContextInformation.GetPowerPointShowDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ RegisterForMsOfficeApplication(
+ m_ContextInformation.GetPowerPointTemplateFileExtension(),
+ m_ContextInformation.GetPowerPointTemplateDisplayName(),
+ m_ContextInformation.GetPowerPointTemplateDefaultIconEntry(),
+ m_ContextInformation.GetPowerPointTemplateDefaultShellCommand(),
+ m_ContextInformation.ShellNewCommandDisplayName());
+
+ SaveRegisteredFor(MSPOWERPOINT);
+}
+
+void Registrar::UnregisterForMsPowerPoint() const
+{
+ assert(m_RootKey.get());
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetPowerPointDocumentFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetPowerPointShowFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ try
+ {
+ UnregisterForMsOfficeApplication(
+ m_ContextInformation.GetPowerPointTemplateFileExtension());
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ SaveNotRegisteredFor(MSPOWERPOINT);
+}
+
+//-----------------------------------------
+/*
+*/
+bool Registrar::QueryPreselectMsPowerPointRegistration() const
+{
+ return QueryPreselectForMsApplication( m_ContextInformation.GetPowerPointDocumentFileExtension()) &&
+ QueryPreselectForMsApplication( m_ContextInformation.GetPowerPointShowFileExtension());
+}
+
+//-----------------------------------------
+/** The documentation says we have to
+ make the following entries to register
+ a html editor for the Internet Explorer
+ HKCR\.htm\OpenWithList\App Friendly Name\shell\edit\command
+ But the reality shows that this works only
+ with Internet Explorer 5.x
+ Internet Explorer 6.0 wants the follwoing
+ entries:
+ HKCR\.htm\OpenWithList\App.exe
+ HKCR\Applications\App.ex\shell\edit\command
+*/
+void Registrar::RegisterAsHtmlEditorForInternetExplorer() const
+{
+ assert(m_RootKey.get());
+
+ std::wstring OOFriendlyAppName = m_ContextInformation.GetOpenOfficeFriendlyAppName();
+
+ std::wstring RegKeyName = HTM_OPENWITHLIST + std::wstring(L"\\") + OOFriendlyAppName;
+ RegistryKey RegKey = m_RootKey->CreateSubKey(RegKeyName);
+
+ RegKey = RegKey->CreateSubKey(SHELL_EDIT_COMMAND);
+
+ RegistryValue RegVal(
+ new RegistryValueImpl(
+ DEFAULT_VALUE_NAME,
+ m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Open)));
+
+ RegKey->SetValue(RegVal);
+
+ RegKeyName = APPLICATIONS + std::wstring(L"\\") + OOFriendlyAppName;
+ RegKey = m_RootKey->CreateSubKey(RegKeyName);
+
+ RegVal->SetName(L"FriendlyAppName");
+ RegVal->SetValue(OOFriendlyAppName);
+ RegKey->SetValue(RegVal);
+
+ RegKey = RegKey->CreateSubKey(SHELL_EDIT_COMMAND);
+ RegVal->SetName(DEFAULT_VALUE_NAME);
+ RegVal->SetValue(
+ m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Open));
+ RegKey->SetValue(RegVal);
+
+ SaveRegisteredFor(HTML_EDITOR);
+}
+
+void Registrar::UnregisterAsHtmlEditorForInternetExplorer() const
+{
+ assert(m_RootKey.get());
+
+ try
+ {
+ std::wstring OOFriendlyAppName = m_ContextInformation.GetOpenOfficeFriendlyAppName();
+
+ std::wstring RegKeyName = APPLICATIONS + std::wstring(L"\\") + OOFriendlyAppName;
+ if (m_RootKey->HasSubKey(RegKeyName))
+ m_RootKey->DeleteSubKeyTree(RegKeyName);
+
+ RegKeyName = HTM_OPENWITHLIST + std::wstring(L"\\") + OOFriendlyAppName;
+
+ if (m_RootKey->HasSubKey(RegKeyName))
+ m_RootKey->DeleteSubKeyTree(RegKeyName);
+ }
+ catch(RegistryKeyNotFoundException&)
+ {}
+
+ SaveNotRegisteredFor(HTML_EDITOR);
+}
+
+void Registrar::RegisterAsDefaultHtmlEditorForInternetExplorer() const
+{
+ assert(m_RootKey.get());
+
+ RegistryKey RegistrationRootKey = GetRootKeyForDefHtmlEditorForIERegistration();
+
+ RegistryKey RegKey = RegistrationRootKey->CreateSubKey(MS_IE_DEF_HTML_EDITOR_SHL_EDIT_CMD);
+
+ RegistryValue RegVal = RegistryValue(new RegistryValueImpl(DEFAULT_VALUE_NAME, L""));
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring CmdLine = RegVal->GetDataAsUniString();
+
+ if (std::wstring::npos == CmdLine.find(m_ContextInformation.GetOpenOfficeExecutableName()))
+ {
+ RegistryKey BackupRegKey = m_RootKey->CreateSubKey(PRIVATE_BACKUP_KEY_NAME + L"\\" + DEFAULT_HTML_EDITOR);
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ BackupRegKey->CopyValue(RegKey, DEFAULT_VALUE_NAME);
+
+ RegKey = RegistrationRootKey->OpenSubKey(MS_IE_DEF_HTML_EDITOR);
+ if (RegKey->HasValue(L"Description"))
+ BackupRegKey->CopyValue(RegKey, L"Description");
+ }
+ }
+
+ RegVal->SetValue(
+ m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Open));
+ RegKey = RegistrationRootKey->OpenSubKey(MS_IE_DEF_HTML_EDITOR_SHL_EDIT_CMD);
+ RegKey->SetValue(RegVal);
+
+ RegVal->SetName(L"Description");
+ RegVal->SetValue(m_ContextInformation.GetOpenOfficeFriendlyAppName());
+ RegKey = RegistrationRootKey->OpenSubKey(MS_IE_DEF_HTML_EDITOR);
+ RegKey->SetValue(RegVal);
+
+ SaveRegisteredFor(DEFAULT_HTML_EDITOR_FOR_IE);
+}
+
+void Registrar::UnregisterAsDefaultHtmlEditorForInternetExplorer() const
+{
+ assert(m_RootKey.get());
+
+ RegistryKey RegistrationRootKey = GetRootKeyForDefHtmlEditorForIERegistration();
+
+ RegistryKey RegKey = RegistrationRootKey->OpenSubKey(MS_IE_DEF_HTML_EDITOR_SHL_EDIT_CMD);
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegistryValue RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring CmdLine = RegVal->GetDataAsUniString();
+
+ if (std::wstring::npos != CmdLine.find(m_ContextInformation.GetOpenOfficeExecutableName()))
+ {
+ RegistryKey BackupRegKey = m_RootKey->OpenSubKey(PRIVATE_BACKUP_KEY_NAME);
+
+ if (BackupRegKey->HasSubKey(DEFAULT_HTML_EDITOR))
+ {
+ BackupRegKey = BackupRegKey->OpenSubKey(DEFAULT_HTML_EDITOR);
+
+ if (BackupRegKey->HasValue(DEFAULT_VALUE_NAME))
+ RegKey->CopyValue(BackupRegKey, DEFAULT_VALUE_NAME);
+ else
+ RegKey->DeleteValue(DEFAULT_VALUE_NAME);
+
+ RegKey = RegistrationRootKey->OpenSubKey(MS_IE_DEF_HTML_EDITOR);
+
+ if (BackupRegKey->HasValue(L"Description"))
+ RegKey->CopyValue(BackupRegKey, L"Description");
+ else
+ RegKey->DeleteValue(L"Description");
+ }
+ else
+ {
+ RegKey->DeleteValue(DEFAULT_VALUE_NAME);
+ RegKey = RegistrationRootKey->OpenSubKey(MS_IE_DEF_HTML_EDITOR);
+ RegKey->DeleteValue(L"Description");
+ }
+ }
+ }
+
+ SaveNotRegisteredFor(DEFAULT_HTML_EDITOR_FOR_IE);
+}
+
+void Registrar::RegisterAsDefaultShellHtmlEditor() const
+{
+ assert(m_RootKey.get());
+
+ RegistryKey RegKey = m_RootKey->CreateSubKey(L".htm");
+
+ RegistryValue RegVal = RegistryValue(
+ new RegistryValueImpl(DEFAULT_VALUE_NAME, L""));
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring HtmFwdKey = RegVal->GetDataAsUniString();
+ if (0 == HtmFwdKey.length() || !m_RootKey->HasSubKey(HtmFwdKey))
+ HtmFwdKey = L".htm";
+
+ RegKey = m_RootKey->CreateSubKey(HtmFwdKey + L"\\" + SHELL_EDIT_COMMAND);
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring CmdLine = RegVal->GetDataAsUniString();
+
+ // backup old values if we are not in place
+ if (std::wstring::npos == CmdLine.find(m_ContextInformation.GetOpenOfficeExecutableName()))
+ {
+ RegistryKey BackupRegKey = m_RootKey->CreateSubKey(PRIVATE_BACKUP_KEY_NAME + L"\\" + HTML_EDIT);
+ BackupRegKey->CopyValue(RegKey, DEFAULT_VALUE_NAME, SHELL_EDIT_COMMAND_BACKUP);
+ }
+ }
+
+ RegVal->SetValue(
+ m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Open));
+
+ RegKey->SetValue(RegVal);
+
+ SaveRegisteredFor(DEFAULT_SHELL_HTML_EDITOR);
+}
+
+void Registrar::UnregisterAsDefaultShellHtmlEditor() const
+{
+ assert(m_RootKey.get());
+
+ try
+ {
+ RegistryKey RegKey = m_RootKey->OpenSubKey(L".htm");
+
+ RegistryValue RegVal = RegistryValue(
+ new RegistryValueImpl(DEFAULT_VALUE_NAME, L""));
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring HtmFwdKey = RegVal->GetDataAsUniString();
+
+ if (0 == HtmFwdKey.length() || !m_RootKey->HasSubKey(HtmFwdKey))
+ HtmFwdKey = L".htm";
+
+ RegKey = m_RootKey->OpenSubKey(HtmFwdKey + L"\\" + SHELL_EDIT_COMMAND);
+
+ RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring CmdLine = RegVal->GetDataAsUniString();
+
+ if (std::wstring::npos != CmdLine.find(m_ContextInformation.GetOpenOfficeExecutableName()))
+ {
+ RegistryKey BackupRegKey = m_RootKey->CreateSubKey(PRIVATE_BACKUP_KEY_NAME + L"\\" + HTML_EDIT);
+
+ if (BackupRegKey->HasValue(SHELL_EDIT_COMMAND_BACKUP))
+ RegKey->CopyValue(BackupRegKey, SHELL_EDIT_COMMAND_BACKUP, DEFAULT_VALUE_NAME);
+ else
+ RegKey->DeleteValue(DEFAULT_VALUE_NAME);
+ }
+ }
+ catch(RegistryKeyNotFoundException&)
+ {
+ }
+
+ SaveNotRegisteredFor(DEFAULT_SHELL_HTML_EDITOR);
+}
+
+void Registrar::SaveRegisteredFor(int State) const
+{
+ assert(m_RootKey.get());
+
+ int NewState = GetRegisterState();
+ NewState |= State;
+ SetRegisterState(NewState);
+}
+
+void Registrar::SaveNotRegisteredFor(int State) const
+{
+ assert(m_RootKey.get());
+
+ int NewState = GetRegisterState();
+ NewState &= ~State;
+ SetRegisterState(NewState);
+}
+
+int Registrar::GetRegisterState() const
+{
+ int State = 0;
+
+ RegistryKey RegKey = m_RootKey->CreateSubKey(PRIVATE_BACKUP_KEY_NAME);
+
+ if (RegKey->HasValue(REGISTRATION_STATE))
+ {
+ RegistryValue RegVal = RegKey->GetValue(REGISTRATION_STATE);
+ if (REG_DWORD == RegVal->GetType())
+ State = RegVal->GetDataAsInt();
+ }
+
+ return State;
+}
+
+void Registrar::SetRegisterState(int NewState) const
+{
+ RegistryKey RegKey = m_RootKey->CreateSubKey(PRIVATE_BACKUP_KEY_NAME);
+ RegistryValue RegVal = RegistryValue(new RegistryValueImpl(REGISTRATION_STATE, NewState));
+ RegKey->SetValue(RegVal);
+}
+
+bool Registrar::IsRegisteredFor(int State) const
+{
+ assert(m_RootKey.get());
+
+ RegistryKey RegKey = m_RootKey->CreateSubKey(PRIVATE_BACKUP_KEY_NAME);
+
+ int SavedState = 0;
+
+ if (RegKey->HasValue(REGISTRATION_STATE))
+ {
+ RegistryValue RegVal = RegKey->GetValue(REGISTRATION_STATE);
+ if (REG_DWORD == RegVal->GetType())
+ SavedState = RegVal->GetDataAsInt();
+ }
+
+ return ((SavedState & State) == State);
+}
+
+//--------------------------------------
+/** Restore the last registration state (necessary for
+ Setup repair) */
+void Registrar::RepairRegistrationState() const
+{
+ assert(m_RootKey.get());
+
+ if (IsRegisteredFor(MSWORD))
+ RegisterForMsWord();
+
+ if (IsRegisteredFor(MSEXCEL))
+ RegisterForMsExcel();
+
+ if (IsRegisteredFor(MSPOWERPOINT))
+ RegisterForMsPowerPoint();
+
+ if (IsRegisteredFor(DEFAULT_HTML_EDITOR_FOR_IE))
+ RegisterAsDefaultHtmlEditorForInternetExplorer();
+
+ if (IsRegisteredFor(HTML_EDITOR))
+ RegisterAsHtmlEditorForInternetExplorer();
+
+ if (IsRegisteredFor(DEFAULT_SHELL_HTML_EDITOR))
+ RegisterAsDefaultShellHtmlEditor();
+}
+
+/** Unregisters all and delete all Registry keys we have written */
+void Registrar::UnregisterAllAndCleanUpRegistry() const
+{
+ assert(m_RootKey.get());
+
+ if (IsRegisteredFor(MSWORD))
+ UnregisterForMsWord();
+
+ if (IsRegisteredFor(MSEXCEL))
+ UnregisterForMsExcel();
+
+ if (IsRegisteredFor(MSPOWERPOINT))
+ UnregisterForMsPowerPoint();
+
+ if (IsRegisteredFor(DEFAULT_HTML_EDITOR_FOR_IE))
+ UnregisterAsDefaultHtmlEditorForInternetExplorer();
+
+ if (IsRegisteredFor(HTML_EDITOR))
+ UnregisterAsHtmlEditorForInternetExplorer();
+
+ if (IsRegisteredFor(DEFAULT_SHELL_HTML_EDITOR))
+ UnregisterAsDefaultShellHtmlEditor();
+
+ if (m_RootKey->HasSubKey(PRIVATE_BACKUP_KEY_NAME))
+ m_RootKey->DeleteSubKeyTree(PRIVATE_BACKUP_KEY_NAME);
+}
+
+void Registrar::RegisterForMsOfficeApplication(
+ const std::wstring& FileExtension,
+ const std::wstring& DocumentDisplayName,
+ const std::wstring& DefaultIconEntry,
+ const std::wstring& DefaultShellCommand,
+ const std::wstring& ShellNewCommandDisplayName) const
+{
+ assert(m_RootKey.get());
+
+ std::wstring ForwardKeyName = FORWARD_KEY_PREFIX + FileExtension;
+
+ RegistryKey ForwardKey = m_RootKey->CreateSubKey(ForwardKeyName);
+ RegistryValue RegVal(new RegistryValueImpl(std::wstring(DEFAULT_VALUE_NAME), DocumentDisplayName));
+ ForwardKey->SetValue(RegVal);
+
+ RegistryKey RegKey = ForwardKey->CreateSubKey(L"DefaultIcon");
+ RegVal->SetValue(DefaultIconEntry);
+ RegKey->SetValue(RegVal);
+
+ RegistryKey RegKeyShell = ForwardKey->CreateSubKey(L"shell");
+ RegVal->SetValue(DefaultShellCommand);
+ RegKeyShell->SetValue(RegVal);
+
+ RegKey = RegKeyShell->CreateSubKey(L"new");
+ RegVal->SetValue(ShellNewCommandDisplayName);
+ RegKey->SetValue(RegVal);
+
+ RegKey = RegKey->CreateSubKey(L"command");
+ RegVal->SetValue(m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::New));
+ RegKey->SetValue(RegVal);
+
+ RegKey = RegKeyShell->CreateSubKey(L"open\\command");
+ RegVal->SetValue(m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Open));
+ RegKey->SetValue(RegVal);
+
+ RegKey = RegKeyShell->CreateSubKey(L"print\\command");
+ RegVal->SetValue(m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Print));
+ RegKey->SetValue(RegVal);
+
+ RegKey = RegKeyShell->CreateSubKey(L"printto\\command");
+ RegVal->SetValue(m_ContextInformation.GetOpenOfficeCommandline(RegistrationContextInformation::SHELL_COMMAND::Printto));
+ RegKey->SetValue(RegVal);
+
+ // set the new forward key under the appropriate extension
+ RegKey = m_RootKey->CreateSubKey(FileExtension);
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+
+ if (REG_SZ == RegVal->GetType())
+ {
+ std::wstring str = RegVal->GetDataAsUniString();
+ if (!IsOpenOfficeRegisteredForMsApplication(str))
+ ForwardKey->CopyValue(RegKey, DEFAULT_VALUE_NAME, BACKUP_VALUE_NAME);
+ }
+ }
+
+ RegVal->SetValue(ForwardKeyName);
+ RegKey->SetValue(RegVal);
+}
+
+void Registrar::UnregisterForMsOfficeApplication(const std::wstring& FileExtension) const
+{
+ std::wstring FwdRegKeyName = FORWARD_KEY_PREFIX + FileExtension;
+
+ if (m_RootKey->HasSubKey(FileExtension))
+ {
+ RegistryKey RegKey = m_RootKey->OpenSubKey(FileExtension);
+
+ if (RegKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegistryValue RegVal = RegKey->GetValue(DEFAULT_VALUE_NAME);
+ if (REG_SZ == RegVal->GetType() &&
+ IsOpenOfficeRegisteredForMsApplication(RegVal->GetDataAsUniString()))
+ {
+ RegistryKey FwdRegKey = m_RootKey->CreateSubKey(FwdRegKeyName);
+
+ if (FwdRegKey->HasValue(BACKUP_VALUE_NAME))
+ RegKey->CopyValue(FwdRegKey, BACKUP_VALUE_NAME, DEFAULT_VALUE_NAME);
+ else
+ RegKey->DeleteValue(DEFAULT_VALUE_NAME);
+ }
+ }
+ }
+
+ if (m_RootKey->HasSubKey(FwdRegKeyName))
+ m_RootKey->DeleteSubKeyTree(FwdRegKeyName);
+}
+
+RegistryKey Registrar::GetRootKeyForDefHtmlEditorForIERegistration() const
+{
+ return WindowsRegistry().GetLocalMachineKey();
+}
+
+bool Registrar::IsOpenOfficeRegisteredForMsApplication(const std::wstring& DocumentExtensionDefValue) const
+{
+ return (std::wstring::npos != DocumentExtensionDefValue.find(FORWARD_KEY_PREFIX));
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registrar.hxx b/setup_native/source/win32/customactions/reg4msdoc/registrar.hxx
new file mode 100644
index 000000000000..96f805bf9416
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registrar.hxx
@@ -0,0 +1,107 @@
+// Registrar.h: Schnittstelle für die Klasse Registrar.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRAR_HXX_
+#define _REGISTRAR_HXX_
+
+#ifndef _REGISTRY_HXX_
+#include "registry.hxx"
+#endif
+
+#ifndef _REGISTRATIONCONTEXTINFORMATION_HXX_
+#include "registrationcontextinformation.hxx"
+#endif
+
+#ifndef _CONSTANTS_HXX_
+#include "constants.hxx"
+#endif
+
+class Registrar
+{
+public:
+
+ Registrar(const RegistrationContextInformation& RegContext);
+
+ virtual ~Registrar();
+
+ bool IsRegisteredFor(int State) const;
+
+ virtual void RegisterForMsWord() const;
+ virtual void UnregisterForMsWord() const;
+ virtual bool QueryPreselectMsWordRegistration() const;
+
+ virtual void RegisterForMsExcel() const;
+ virtual void UnregisterForMsExcel() const;
+ virtual bool QueryPreselectMsExcelRegistration() const;
+
+ virtual void RegisterForMsPowerPoint() const;
+ virtual void UnregisterForMsPowerPoint() const;
+ virtual bool QueryPreselectMsPowerPointRegistration() const;
+
+ virtual void RegisterAsHtmlEditorForInternetExplorer() const;
+ virtual void UnregisterAsHtmlEditorForInternetExplorer() const;
+
+ virtual void RegisterAsDefaultHtmlEditorForInternetExplorer() const;
+ virtual void UnregisterAsDefaultHtmlEditorForInternetExplorer() const;
+
+ virtual void RegisterAsDefaultShellHtmlEditor() const;
+ virtual void UnregisterAsDefaultShellHtmlEditor() const;
+
+ /** Restore the last registration state (necessary for
+ Setup repair)
+ */
+ virtual void RepairRegistrationState() const;
+
+ /** Unregisters all and delete all Registry keys we have written
+ */
+ virtual void UnregisterAllAndCleanUpRegistry() const;
+
+protected:
+
+ virtual void RegisterForMsOfficeApplication(
+ const std::wstring& FileExtension,
+ const std::wstring& DocumentDisplayName,
+ const std::wstring& DefaultIconEntry,
+ const std::wstring& DefaultShellCommand,
+ const std::wstring& ShellNewCommandDisplayName) const;
+
+ virtual void UnregisterForMsOfficeApplication(
+ const std::wstring& FileExtension) const;
+
+ virtual RegistryKey GetRootKeyForDefHtmlEditorForIERegistration() const;
+
+ void SaveRegisteredFor(int State) const;
+ void SaveNotRegisteredFor(int State) const;
+
+ int GetRegisterState() const;
+ void SetRegisterState(int NewState) const;
+
+ virtual bool QueryPreselectForMsApplication(const std::wstring& file_extension) const;
+
+ /** A helper function (for readability) returns true if OpenOffice is already
+ registered for a MS application
+
+ @param DocumentExtensionDefValue
+ The default value of the appropriate document extension Registry key
+ */
+ bool IsOpenOfficeRegisteredForMsApplication(const std::wstring& DocumentExtensionDefValue) const;
+
+protected:
+ const RegistrationContextInformation& m_ContextInformation;
+
+ const std::wstring FORWARD_KEY_PREFIX;
+ const std::wstring DEFAULT_VALUE_NAME;
+ const std::wstring BACKUP_VALUE_NAME;
+ const std::wstring PRIVATE_BACKUP_KEY_NAME;
+ const std::wstring REGISTRATION_STATE;
+
+ RegistryKey m_RootKey;
+
+// prevent copy/assignment
+private:
+ Registrar(const Registrar&);
+ Registrar& operator=(const Registrar&);
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.cxx b/setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.cxx
new file mode 100644
index 000000000000..f481ee8b4d7b
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.cxx
@@ -0,0 +1,322 @@
+//Implementierung der Klasse RegistrationContextInformation.
+
+#include <assert.h>
+
+#ifndef _REGISTRATIONCONTEXTINFORMATION_HXX_
+#include "registrationcontextinformation.hxx"
+#endif
+
+#ifndef INCLUDED_MSIHELPER_HXX
+#include "msihelper.hxx"
+#endif
+
+#define WINDOWS_LEAN_AND_MEAN
+#include <windows.h>
+#include <assert.h>
+#include <algorithm>
+
+namespace /* private */
+{
+ const int MAX_REGKEY_LENGTH_WIN9X = 16300;
+}
+
+RegistrationContextInformation::RegistrationContextInformation(MSIHANDLE hMsi, const std::wstring& OpenOfficeExecutablePath) :
+ msihandle_(hMsi),
+ m_IsWin9x(true),
+ m_OOExecPath(OpenOfficeExecutablePath)
+{
+ OSVERSIONINFOA osverinfo;
+ ZeroMemory(&osverinfo, sizeof(osverinfo));
+ osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
+ GetVersionExA(&osverinfo);
+
+ m_IsWin9x = (osverinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
+ assert(m_OOExecPath.length());
+ ExtractOpenOfficeExecNameFromPath();
+}
+
+std::wstring RegistrationContextInformation::GetWordDocumentDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_WORD_DOCUMENT"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft Word Document");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetWordDocumentFileExtension() const
+{
+ return std::wstring(TEXT(".doc"));
+}
+
+std::wstring RegistrationContextInformation::GetWordDocumentDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",1"));
+}
+
+std::wstring RegistrationContextInformation::GetWordDocumentDefaultShellCommand() const
+{
+ return std::wstring(TEXT("open"));
+}
+
+std::wstring RegistrationContextInformation::GetWordTemplateDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_WORD_TEMPLATE"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft Word Template");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetWordTemplateFileExtension() const
+{
+ return std::wstring(TEXT(".dot"));
+}
+
+std::wstring RegistrationContextInformation::GetWordTemplateDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",2"));
+}
+
+std::wstring RegistrationContextInformation::GetWordTemplateDefaultShellCommand() const
+{
+ return std::wstring(TEXT("new"));
+}
+
+std::wstring RegistrationContextInformation::GetExcelSheetDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_EXCEL_WORKSHEET"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft Excel Worksheet");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetExcelSheetFileExtension() const
+{
+ return std::wstring(TEXT(".xls"));
+}
+
+std::wstring RegistrationContextInformation::GetExcelSheetDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",3"));
+}
+
+std::wstring RegistrationContextInformation::GetExcelSheetDefaultShellCommand() const
+{
+ return std::wstring(TEXT("open"));
+}
+
+std::wstring RegistrationContextInformation::GetExcelTemplateDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_EXCEL_TEMPLATE"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft Excel Template");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetExcelTemplateFileExtension() const
+{
+ return std::wstring(TEXT(".xlt"));
+}
+
+std::wstring RegistrationContextInformation::GetExcelTemplateDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",4"));
+}
+
+std::wstring RegistrationContextInformation::GetExcelTemplateDefaultShellCommand() const
+{
+ return std::wstring(TEXT("new"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointDocumentDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_POWERPOINT_PRESENTATION"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft PowerPoint Presentation");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointDocumentFileExtension() const
+{
+ return std::wstring(TEXT(".ppt"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointDocumentDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",7"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointDocumentDefaultShellCommand() const
+{
+ return std::wstring(TEXT("open"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointTemplateDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_POWERPOINT_TEMPLATE"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft PowerPoint Template");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointTemplateFileExtension() const
+{
+ return std::wstring(TEXT(".pot"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointTemplateDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",8"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointTemplateDefaultShellCommand() const
+{
+ return std::wstring(TEXT("new"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointShowDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_MS_POWERPOINT_SHOW"), str);
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("Microsoft PowerPoint Show");
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointShowFileExtension() const
+{
+ return std::wstring(TEXT(".pps"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointShowDefaultIconEntry() const
+{
+ return m_OOExecPath + std::wstring(TEXT(",7"));
+}
+
+std::wstring RegistrationContextInformation::GetPowerPointShowDefaultShellCommand() const
+{
+ return std::wstring(TEXT("open"));
+}
+
+//----------------------------------------------
+/** The string for the "New" command that should appear
+ in the Explorer context menu when someone right
+ clicks a Microsoft document
+*/
+std::wstring RegistrationContextInformation::ShellNewCommandDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_NEW_DISPLAY_NAME"), str);
+ std::wstring::size_type idx = str.find(TEXT("~"));
+
+ if(std::wstring::npos != idx)
+ str.replace(idx, 1, TEXT("&"));
+
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("&New");
+
+ return str;
+}
+
+/** The string for the "Edit" command that should
+ appear in the Explorer context menu when someone
+ right clicks a document
+*/
+std::wstring RegistrationContextInformation::ShellEditCommandDisplayName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("STR_EDIT"), str);
+ std::wstring::size_type idx = str.find(TEXT("~"));
+
+ if(std::wstring::npos != idx)
+ str.replace(idx, 1, TEXT("&"));
+
+ if (m_IsWin9x && !IsConvertableToAnsi(str))
+ str = TEXT("&Edit");
+
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetOpenOfficeFriendlyAppName() const
+{
+ std::wstring str;
+ GetMsiProp(msihandle_, TEXT("ProductName"), str);
+ return str;
+}
+
+std::wstring RegistrationContextInformation::GetOpenOfficeExecutablePath() const
+{
+ return m_OOExecPath;
+}
+
+//----------------------------------------------
+/** The name of the executable (currently "soffice.exe"
+ but may change in the future, who knows) */
+std::wstring RegistrationContextInformation::GetOpenOfficeExecutableName() const
+{
+ return m_OOExecName;
+}
+
+/** A command line for the specified shell command */
+std::wstring RegistrationContextInformation::GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand) const
+{
+ // quote the path to OpenOffice, this is important
+ // for Windows 9x
+ std::wstring cmd_line = std::wstring(TEXT("\"")) + m_OOExecPath + std::wstring(TEXT("\""));
+
+ switch(ShellCommand)
+ {
+ case New:
+ cmd_line += std::wstring(TEXT(" -n \"%1\""));
+ break;
+
+ case Open:
+ cmd_line += std::wstring(TEXT(" -o \"%1\""));
+ break;
+
+ case Print:
+ cmd_line += std::wstring(TEXT(" -p \"%1\""));
+ break;
+
+ case Printto:
+ cmd_line += std::wstring(TEXT(" -pt \"%2\" \"%1\""));
+ break;
+
+ default:
+ assert(false);
+ }
+ return cmd_line;
+}
+
+bool RegistrationContextInformation::IsConvertableToAnsi(const std::wstring& String) const
+{
+ char buff[MAX_REGKEY_LENGTH_WIN9X];
+ BOOL bUsedDefChar = 0;
+
+ if (String.length() > 0)
+ {
+ int rc = WideCharToMultiByte(
+ CP_ACP,
+ WC_COMPOSITECHECK | WC_DEFAULTCHAR,
+ String.c_str(),
+ static_cast<int>(String.length()),
+ buff,
+ sizeof(buff),
+ NULL,
+ &bUsedDefChar);
+ }
+ return !bUsedDefChar;
+}
+
+void RegistrationContextInformation::ExtractOpenOfficeExecNameFromPath()
+{
+ std::wstring::size_type idx = m_OOExecPath.find_last_of(TEXT('\\'));
+ assert(idx != std::wstring::npos); // assert valid path
+ m_OOExecName = m_OOExecPath.substr(idx + 1);
+}
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.hxx b/setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.hxx
new file mode 100644
index 000000000000..82f9853d3398
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registrationcontextinformation.hxx
@@ -0,0 +1,140 @@
+// MsOfficeDocumentInformation.h: Schnittstelle für die Klasse MsOfficeDocumentInformation.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRATIONCONTEXTINFORMATION_HXX_
+#define _REGISTRATIONCONTEXTINFORMATION_HXX_
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <msi.h>
+
+#include <string>
+
+/** A simple implementation class that returns the
+ appropriate display names for the Microsoft
+ Office document types.
+ Under Windows 9x this class checks if the
+ document display name is convertable to an ANSI
+ string and if not returns an english default.
+ So we avoid garbage if soemone for instance
+ installs an japanese StarOffice/OpenOffice
+ under a German Windows 98 for instance.
+*/
+class RegistrationContextInformation
+{
+public:
+
+ enum SHELL_COMMAND {New, Open, Print, Printto};
+
+ RegistrationContextInformation(MSIHANDLE hMsi, const std::wstring& OpenOfficeExecutablePath);
+
+ /** Word document information
+ The icon index is the index of the icon
+ in soffice.exe to be associated with
+ word document files
+ */
+ std::wstring GetWordDocumentDisplayName() const;
+ std::wstring GetWordDocumentFileExtension() const;
+ std::wstring GetWordDocumentDefaultIconEntry() const;
+ std::wstring GetWordDocumentDefaultShellCommand() const;
+
+ /** Word template information
+ The icon index is the index of the icon
+ in soffice.exe to be associated with
+ word template files
+ */
+ std::wstring GetWordTemplateDisplayName() const;
+ std::wstring GetWordTemplateFileExtension() const;
+ std::wstring GetWordTemplateDefaultIconEntry() const;
+ std::wstring GetWordTemplateDefaultShellCommand() const;
+
+ /** Excel sheet information
+ The icon index is the index of the icon
+ in soffice.exe to be associated with
+ Excel sheets
+ */
+ std::wstring GetExcelSheetDisplayName() const;
+ std::wstring GetExcelSheetFileExtension() const;
+ std::wstring GetExcelSheetDefaultIconEntry() const;
+ std::wstring GetExcelSheetDefaultShellCommand() const;
+
+ /** Excel template information
+ The icon index is the index of the icon
+ in soffice.exe to be associated with
+ Excel template files
+ */
+ std::wstring GetExcelTemplateDisplayName() const;
+ std::wstring GetExcelTemplateFileExtension() const;
+ std::wstring GetExcelTemplateDefaultIconEntry() const;
+ std::wstring GetExcelTemplateDefaultShellCommand() const;
+
+ /** PowerPoint document information
+ The icon index is the index of the icon
+ in soffice.exe to be associated with
+ PowerPoint document files
+ */
+ std::wstring GetPowerPointDocumentDisplayName() const;
+ std::wstring GetPowerPointDocumentFileExtension() const;
+ std::wstring GetPowerPointDocumentDefaultIconEntry() const;
+ std::wstring GetPowerPointDocumentDefaultShellCommand() const;
+
+ /** PowerPoint template information
+ The icon index is the index of the icon
+ in soffice.exe to be associated with
+ PowerPoint template files
+ */
+ std::wstring GetPowerPointTemplateDisplayName() const;
+ std::wstring GetPowerPointTemplateFileExtension() const;
+ std::wstring GetPowerPointTemplateDefaultIconEntry() const;
+ std::wstring GetPowerPointTemplateDefaultShellCommand() const;
+
+ /** PowerPoint Show information
+ */
+ std::wstring GetPowerPointShowDisplayName() const;
+ std::wstring GetPowerPointShowFileExtension() const;
+ std::wstring GetPowerPointShowDefaultIconEntry() const;
+ std::wstring GetPowerPointShowDefaultShellCommand() const;
+
+ /** The string for the "New" command that should appear
+ in the Explorer context menu when someone right
+ clicks a Microsoft document
+ */
+ std::wstring ShellNewCommandDisplayName() const;
+
+ /** The string for the "Edit" command that should
+ appear in the Explorer context menu when someone
+ right clicks a document
+ */
+ std::wstring ShellEditCommandDisplayName() const;
+
+ /** A friendly name for the application
+ */
+ std::wstring GetOpenOfficeFriendlyAppName() const;
+
+ /** The path to the StarOffice/OpenOffice executable
+ */
+ std::wstring GetOpenOfficeExecutablePath() const;
+
+ /** The name of the executable (currently "soffice.exe"
+ but may change in the future, who knows)
+ */
+ std::wstring GetOpenOfficeExecutableName() const;
+
+ /** A command line for the specified shell command
+ */
+ std::wstring GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand) const;
+
+private:
+ bool IsConvertableToAnsi(const std::wstring& String) const;
+
+ void ExtractOpenOfficeExecNameFromPath();
+
+private:
+ MSIHANDLE msihandle_;
+ bool m_IsWin9x;
+ std::wstring m_OOExecPath;
+ std::wstring m_OOExecName;
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registry.cxx b/setup_native/source/win32/customactions/reg4msdoc/registry.cxx
new file mode 100644
index 000000000000..6dd4e012e075
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registry.cxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * $RCSfile: registry.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _REGISTRY_HXX_
+#include "registry.hxx"
+#endif
+
+#include <assert.h>
+#include <algorithm>
+
+#pragma warning(disable : 4786)
+
+//-----------------------------------------------------
+/** Create instance and open the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+*/
+RegistryKeyImpl::RegistryKeyImpl(HKEY RootKey, const std::wstring& KeyName) :
+ m_hRootKey(RootKey),
+ m_hSubKey(0),
+ m_KeyName(KeyName),
+ m_IsWriteable(false)
+{
+}
+
+//-----------------------------------------------------
+/** Create instance and open the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+*/
+RegistryKeyImpl::RegistryKeyImpl(HKEY RootKey) :
+ m_hRootKey(RootKey),
+ m_hSubKey(0),
+ m_IsWriteable(false)
+{
+}
+
+//-----------------------------------------------------
+/** Create an instances of the specified Registry key,
+ the key is assumed to be already opened.
+*/
+RegistryKeyImpl::RegistryKeyImpl(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable) :
+ m_hRootKey(RootKey),
+ m_hSubKey(SubKey),
+ m_KeyName(KeyName),
+ m_IsWriteable(Writeable)
+{
+}
+
+//-----------------------------------------------------
+/**
+*/
+RegistryKeyImpl::~RegistryKeyImpl()
+{
+ if (IsOpen())
+ Close();
+}
+
+
+//############################################
+// Queries
+//############################################
+
+
+//-----------------------------------------------------
+/** The name of the key at hand, maybe empty
+ if this is any of the root keys
+*/
+std::wstring RegistryKeyImpl::GetName() const
+{
+ return m_KeyName;
+}
+
+//-----------------------------------------------------
+/**
+*/
+bool RegistryKeyImpl::IsOpen() const
+{
+ return m_hSubKey != 0;
+}
+
+//-----------------------------------------------------
+/** Is this one of the root keys
+ HKEY_CLASSES_ROOT
+ HKEY_CURRENT_USER
+ etc.
+*/
+bool RegistryKeyImpl::IsRootKey() const
+{
+ return (0 == m_KeyName.length());
+}
+
+//-----------------------------------------------------
+/** Do we have write access on the key at hand
+*/
+bool RegistryKeyImpl::IsWriteable() const
+{
+ return m_IsWriteable;
+}
+
+//-----------------------------------------------------
+/** Convenience function to determine if the
+ Registry key at hand has the specified
+ value
+
+ @precond IsOpen = true
+
+ throws RegistryAccessDenyException
+*/
+bool RegistryKeyImpl::HasValue(const std::wstring& Name) const
+{
+ StringListPtr names = GetSubValueNames();
+
+ StringList::iterator iter_end = names->end();
+ StringList::iterator iter = std::find(names->begin(), iter_end, Name);
+
+ return (iter != iter_end);
+}
+
+//-----------------------------------------------------
+/** Convenience function to determine if the
+ Registry key at hand has the specified
+ sub-key
+
+ @precond IsOpen = true
+
+ throws RegistryAccessDenyException
+*/
+bool RegistryKeyImpl::HasSubKey(const std::wstring& Name) const
+{
+ StringListPtr names = GetSubKeyNames();
+
+ StringList::iterator iter_end = names->end();
+ StringList::iterator iter = std::find(names->begin(), iter_end, Name);
+
+ return (iter != iter_end);
+}
+
+//-----------------------------------------------------
+/**
+*/
+void RegistryKeyImpl::Close()
+{
+ LONG rc = RegCloseKey(m_hSubKey);
+ assert(ERROR_SUCCESS == rc);
+
+ m_hSubKey = 0;
+ m_IsWriteable = false;
+}
+
+//-----------------------------------------------------
+/** Copies the specified value from RegistryKey to
+ the registry key at hand, if a value with this
+ name already exist under the registry key at hand
+ it will be overwritten
+
+ @precond IsOpen = true
+ IsWriteable = true
+ RegistryKey.HasSubValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+*/
+void RegistryKeyImpl::CopyValue(const RegistryKey& RegistryKey, const std::wstring& Name)
+{
+ assert(RegistryKey->HasValue(Name));
+ SetValue(RegistryKey->GetValue(Name));
+ assert(HasValue(Name));
+}
+
+/** Copies the specified value from RegistryKey to
+ the registry key at hand under a new name,
+ if a value with this name already exist there
+ it will be overwritten
+
+ @precond IsOpen = true
+ IsWriteable = true
+ RegistryKey.HasSubValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+*/
+void RegistryKeyImpl::CopyValue(const RegistryKey& RegistryKey, const std::wstring& Name, const std::wstring& NewName)
+{
+ assert(RegistryKey->HasValue(Name));
+
+ RegistryValue RegVal = RegistryKey->GetValue(Name);
+ RegVal->SetName(NewName);
+ SetValue(RegVal);
+
+ assert(HasValue(NewName));
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registry.hxx b/setup_native/source/win32/customactions/reg4msdoc/registry.hxx
new file mode 100644
index 000000000000..a847d525c477
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registry.hxx
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * $RCSfile: registry.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _REGISTRY_HXX_
+#define _REGISTRY_HXX_
+
+#include <windows.h>
+#include <memory>
+#include <vector>
+#include <string>
+
+#include "registryvalueimpl.hxx"
+
+//---------------------------------------
+// forward declaration
+//---------------------------------------
+
+class RegistryKeyImpl;
+
+//---------------------------------------
+// typedefs
+//---------------------------------------
+
+typedef std::auto_ptr<RegistryKeyImpl> RegistryKey;
+typedef std::vector<std::wstring> StringList;
+typedef std::auto_ptr<StringList> StringListPtr;
+
+//---------------------------------------
+//
+//---------------------------------------
+
+class RegistryKeyImpl
+{
+public:
+
+ //############################################
+ // Destruction
+ //############################################
+
+ virtual ~RegistryKeyImpl();
+
+
+ //############################################
+ // Queries
+ //############################################
+
+
+ /** The name of the key at hand, maybe empty
+ if this is any of the root keys
+ */
+ std::wstring GetName() const;
+
+ /** The number of sub values of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+ */
+ virtual size_t GetSubValueCount() const = 0;
+
+ /** The number of sub-keys of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+ */
+ virtual size_t GetSubKeyCount() const = 0;
+
+ bool IsOpen() const;
+
+ /** Do we have write access on the key at hand
+ */
+ bool IsWriteable() const;
+
+ /** The StringList will be allocated on the heap,
+ so this is in fact a transfer of ownership
+ to the caller
+
+ @precond IsOpen = true
+
+ @throws RegistryIOException
+ */
+ virtual StringListPtr GetSubKeyNames() const = 0;
+
+ /** The StringList will be allocated on the heap,
+ so this is in fact a transfer of ownership
+ to the caller
+
+ @precond IsOpen = true
+
+ @throws RegistryIOException
+ */
+ virtual StringListPtr GetSubValueNames() const = 0;
+
+ /** Get the specified registry value
+
+ @precond IsOpen = true
+ */
+ virtual RegistryValue GetValue(const std::wstring& Name) const = 0;
+
+ /** Get the specified registry value, return the given
+ default value if value not found
+
+ @precond IsOpen = true
+ */
+ virtual RegistryValue GetValue(const std::wstring& Name, const RegistryValue& Default) const = 0;
+
+ /** Convenience function to determine if the
+ Registry key at hand has the specified
+ value
+
+ @precond IsOpen = true
+
+ throws RegistryAccessDenyException
+ */
+ bool HasValue(const std::wstring& Name) const;
+
+ /** Convenience function to determine if the
+ Registry key at hand has the specified
+ sub-key
+
+ @precond IsOpen = true
+
+ throws RegistryAccessDenyException
+ */
+ bool HasSubKey(const std::wstring& Name) const;
+
+
+ //############################################
+ // Commands
+ //############################################
+
+
+ /** Open the registry key, has no effect if
+ the key is already open
+
+ @precond IsOpen = false
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ */
+ virtual void Open(bool Writeable = true) = 0;
+
+ /** Close the registry key at hand, further
+ using it without re-opening may cause
+ RegistryIOExceptions to be thrown
+
+ This is a template method that calls
+ ImplClose which has to be overwritten
+ by sub-classes
+ */
+ void Close();
+
+ /** Open the specified sub-key of the registry key
+ at hand
+
+ @precond IsOpen = true
+ HasSubKey(Name) = true
+
+ @throws RegistryIOException
+ RegistryKeyNotFoundException
+ RegistryAccessDeniedException
+ */
+ virtual RegistryKey OpenSubKey(const std::wstring& Name, bool Writeable = true) = 0;
+
+ /** Creates a new sub-key below the key at hand
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual RegistryKey CreateSubKey(const std::wstring& Name) = 0;
+
+ /** Deletes a sub-key below the key at hand, the
+ key must not have sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void DeleteSubKey(const std::wstring& Name) = 0;
+
+ /** Deletes a sub-key below the key at hand with all
+ its sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true;
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void DeleteSubKeyTree(const std::wstring& Name) = 0;
+
+ /** Delete the specified value
+
+ @precond IsOpen = true
+ IsWriteable = true
+ HasValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+ */
+ virtual void DeleteValue(const std::wstring& Name) = 0;
+
+ /** Set the specified registry value
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void SetValue(const RegistryValue& Value) = 0;
+
+
+ /** Copies the specified value from RegistryKey to
+ the registry key at hand, if a value with this
+ name already exist under the registry key at hand
+ it will be overwritten
+
+ @precond IsOpen = true
+ IsWriteable = true
+ RegistryKey.HasSubValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+ */
+ virtual void CopyValue(const RegistryKey& RegistryKey, const std::wstring& Name);
+
+ /** Copies the specified value from RegistryKey to
+ the registry key at hand under a new name,
+ if a value with this name already exist there
+ it will be overwritten
+
+ @precond IsOpen = true
+ IsWriteable = true
+ RegistryKey.HasSubValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+ */
+ virtual void CopyValue(const RegistryKey& RegistryKey, const std::wstring& Name, const std::wstring& NewName);
+
+ //############################################
+ // Creation
+ // only possible through WindowsRegistry class
+ //############################################
+
+
+protected:
+ /** Create instance of the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+ */
+ RegistryKeyImpl(HKEY RootKey, const std::wstring& KeyName);
+
+ /** Create instance of the specified Registry key.
+ RootKey should only one of the predefined
+ keys HKEY_CLASSES_ROOT, HKEY_CURRENT_USER,
+ HKEY_LOCAL_MACHINE, HKEY_USERS
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+ */
+ RegistryKeyImpl(HKEY RootKey);
+
+ /** Create an instances of the specified Registry key,
+ the key is assumed to be already opened.
+ */
+ RegistryKeyImpl(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable = true);
+
+ /** Is this one of the root keys
+ HKEY_CLASSES_ROOT
+ HKEY_CURRENT_USER
+ etc.
+ */
+ bool IsRootKey() const;
+
+protected:
+ HKEY m_hRootKey;
+ HKEY m_hSubKey;
+ std::wstring m_KeyName;
+ bool m_IsWriteable;
+
+// prevent copy and assignment
+private:
+ RegistryKeyImpl(const RegistryKeyImpl&);
+ RegistryKeyImpl& operator=(const RegistryKeyImpl&);
+
+//######################################
+// Friend declarations
+//######################################
+
+friend class WindowsRegistry;
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registryexception.cxx b/setup_native/source/win32/customactions/reg4msdoc/registryexception.cxx
new file mode 100644
index 000000000000..e0b1b153b4a1
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registryexception.cxx
@@ -0,0 +1,107 @@
+// RegistryException.cpp: Implementierung der Klasse RegistryException.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#include "registryexception.hxx"
+#endif
+
+#include <windows.h>
+
+//////////////////////////////////////////////////////////////////////
+// Konstruktion/Destruktion
+//////////////////////////////////////////////////////////////////////
+
+RegistryException::RegistryException(long ErrorCode) :
+ m_ErrorCode(ErrorCode),
+ m_ErrorMsg(0)
+{
+}
+
+/**
+*/
+RegistryException::~RegistryException()
+{
+ if (m_ErrorMsg)
+ LocalFree(m_ErrorMsg);
+}
+
+/**
+*/
+const char* RegistryException::what() const
+{
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ m_ErrorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &m_ErrorMsg,
+ 0,
+ NULL);
+
+ return reinterpret_cast<char*>(m_ErrorMsg);
+}
+
+/**
+*/
+long RegistryException::GetErrorCode() const
+{
+ return m_ErrorCode;
+}
+
+//#######################################
+// Thrown when a Registry key is accessed
+// that is closed
+//#######################################
+
+RegistryIOException::RegistryIOException(long ErrorCode) :
+ RegistryException(ErrorCode)
+{
+};
+
+//#######################################
+//
+//#######################################
+
+RegistryNoWriteAccessException::RegistryNoWriteAccessException(long ErrorCode) :
+ RegistryException(ErrorCode)
+{
+};
+
+//#######################################
+//
+//#######################################
+
+RegistryAccessDeniedException::RegistryAccessDeniedException(long ErrorCode) :
+ RegistryException(ErrorCode)
+{
+};
+
+//#######################################
+//
+//#######################################
+
+RegistryValueNotFoundException::RegistryValueNotFoundException(long ErrorCode) :
+ RegistryException(ErrorCode)
+{
+};
+
+//#######################################
+//
+//#######################################
+
+RegistryKeyNotFoundException::RegistryKeyNotFoundException(long ErrorCode) :
+ RegistryException(ErrorCode)
+{
+};
+
+//#######################################
+//
+//#######################################
+
+RegistryInvalidOperationException::RegistryInvalidOperationException(long ErrorCode) :
+ RegistryException(ErrorCode)
+{
+};
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registryexception.hxx b/setup_native/source/win32/customactions/reg4msdoc/registryexception.hxx
new file mode 100644
index 000000000000..aaa5168127bc
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registryexception.hxx
@@ -0,0 +1,104 @@
+// RegistryException.h: Schnittstelle für die Klasse RegistryException.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#define _REGISTRYEXCEPTION_HXX_
+
+#include <exception>
+
+//#######################################
+// Base class for all Registry exceptions
+//#######################################
+
+class RegistryException : public std::exception
+{
+public:
+
+ RegistryException(long ErrorCode);
+
+ virtual ~RegistryException();
+
+ /**
+ @descr Returns a string that describes the error if
+ available, else NULL will be returned. The
+ returned string is only temporary so the caller
+ has to copy it if he needs the string further.
+ */
+ virtual const char* what() const;
+
+ /**
+ @descr Returns the error code.
+ */
+
+ long GetErrorCode() const;
+
+private:
+ long m_ErrorCode;
+ void* m_ErrorMsg;
+};
+
+//#######################################
+// Thrown when a Registry key is accessed
+// that is closed
+//#######################################
+
+class RegistryIOException : public RegistryException
+{
+public:
+ RegistryIOException(long ErrorCode);
+};
+
+//#######################################
+// Thrown when trying to write to a readonly registry key
+//#######################################
+
+class RegistryNoWriteAccessException : public RegistryException
+{
+public:
+ RegistryNoWriteAccessException(long ErrorCode);
+};
+
+//#######################################
+// Thrown when trying to access an registry key, with improper
+// access rights
+//#######################################
+
+class RegistryAccessDeniedException : public RegistryException
+{
+public:
+ RegistryAccessDeniedException(long ErrorCode);
+};
+
+//#######################################
+// A specified registry value could not be read because it is not
+// available
+//#######################################
+
+class RegistryValueNotFoundException : public RegistryException
+{
+public:
+ RegistryValueNotFoundException(long ErrorCode);
+};
+
+//#######################################
+// A specified registry key was not found
+//#######################################
+
+class RegistryKeyNotFoundException : public RegistryException
+{
+public:
+ RegistryKeyNotFoundException(long ErrorCode);
+};
+
+//#######################################
+// A specified registry operation is invalid
+//#######################################
+
+class RegistryInvalidOperationException : public RegistryException
+{
+public:
+ RegistryInvalidOperationException(long ErrorCode);
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.cxx b/setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.cxx
new file mode 100644
index 000000000000..813d62db1c64
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.cxx
@@ -0,0 +1,184 @@
+// RegistryValueImpl.cpp: Implementierung der Klasse RegistryValueImpl.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRYVALUEIMPL_HXX_
+#include "registryvalueimpl.hxx"
+#endif
+
+#include <malloc.h>
+#include <windows.h>
+#include <assert.h>
+
+#include "stringconverter.hxx"
+
+//#################################
+// Creation/Destruction
+//#################################
+
+//--------------------------------------------
+/**
+*/
+RegistryValueImpl::RegistryValueImpl(const std::wstring& Name, int Value) :
+ m_Name(Name),
+ m_Type(REG_DWORD),
+ m_IntData(Value)
+{
+}
+
+//--------------------------------------------
+/**
+*/
+RegistryValueImpl::RegistryValueImpl(const std::wstring& Name, const std::wstring& Value) :
+ m_Name(Name),
+ m_Type(REG_SZ),
+ m_StringData(Value),
+ m_IntData(0)
+{
+}
+
+//--------------------------------------------
+/**
+*/
+RegistryValueImpl::RegistryValueImpl(const std::wstring& Name, const std::string& Value) :
+ m_Name(Name),
+ m_Type(REG_SZ),
+ m_IntData(0)
+{
+ m_StringData = AnsiToUnicodeString(Value);
+}
+
+#if (_MSC_VER >= 1300)
+RegistryValueImpl::RegistryValueImpl(const RegistryValueImpl& s) :
+ m_Name(s.m_Name),
+ m_Type(s.m_Type),
+ m_StringData(s.m_StringData),
+ m_IntData(s.m_IntData)
+ {
+}
+#endif
+//--------------------------------------------
+/**
+*/
+RegistryValueImpl::~RegistryValueImpl()
+{
+}
+
+//#################################
+// Query
+//#################################
+
+//--------------------------------------------
+/** Returns the name of the value
+*/
+std::wstring RegistryValueImpl::GetName() const
+{
+ return m_Name;
+}
+
+//--------------------------------------------
+/** Return the size of data held
+*/
+size_t RegistryValueImpl::GetDataSize() const
+{
+ size_t size = 0;
+
+ if (REG_DWORD == m_Type)
+ size = sizeof(m_IntData);
+ else if (REG_SZ == m_Type)
+ size = m_StringData.length() ? ((m_StringData.length() + 1) * sizeof(wchar_t)) : 0;
+
+ return size;
+}
+
+//--------------------------------------------
+/** Get a pointer to the data buffer
+ in order to copy the data
+*/
+const void* RegistryValueImpl::GetDataBuffer() const
+{
+ const void* pData = 0;
+
+ if (REG_DWORD == m_Type)
+ pData = reinterpret_cast<const void*>(&m_IntData);
+ else if (REG_SZ == m_Type)
+ pData = reinterpret_cast<const void*>(m_StringData.c_str());
+
+ return pData;
+}
+
+//--------------------------------------------
+/** Returns the data as string
+*/
+std::wstring RegistryValueImpl::GetDataAsUniString() const
+{
+ assert(REG_SZ == m_Type);
+ return m_StringData;
+}
+
+//--------------------------------------------
+/** Returns the data as string
+*/
+std::string RegistryValueImpl::GetDataAsAnsiString() const
+{
+ assert(REG_SZ == m_Type);
+ return UnicodeToAnsiString(m_StringData);
+}
+
+//--------------------------------------------
+/** Returns the data as number
+*/
+int RegistryValueImpl::GetDataAsInt() const
+{
+ assert(REG_DWORD == m_Type);
+ return m_IntData;
+}
+
+//--------------------------------------------
+/** Returns the type of the data
+*/
+int RegistryValueImpl::GetType() const
+{
+ return m_Type;
+}
+
+
+//#################################
+// Command
+//#################################
+
+
+//--------------------------------------------
+/** Set a new name
+*/
+void RegistryValueImpl::SetName(const std::wstring& NewName)
+{
+ m_Name = NewName;
+}
+
+//--------------------------------------------
+/**
+*/
+void RegistryValueImpl::SetValue(const std::wstring& NewValue)
+{
+ m_Type = REG_SZ;
+ m_StringData = NewValue;
+}
+
+//--------------------------------------------
+/**
+*/
+void RegistryValueImpl::SetValue(const std::string& NewValue)
+{
+ m_Type = REG_SZ;
+ m_StringData = AnsiToUnicodeString(NewValue);
+}
+
+//--------------------------------------------
+/**
+*/
+void RegistryValueImpl::SetValue(int NewValue)
+{
+ m_Type = REG_DWORD;
+ m_IntData = NewValue;
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.hxx b/setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.hxx
new file mode 100644
index 000000000000..a64058e29141
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registryvalueimpl.hxx
@@ -0,0 +1,108 @@
+// RegistryValueImpl.h: Schnittstelle für die Klasse RegistryValueImpl.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _REGISTRYVALUEIMPL_HXX_
+#define _REGISTRYVALUEIMPL_HXX_
+
+#include <memory>
+#include <string>
+
+class RegistryValueImpl
+{
+public:
+
+ //#################################
+ // Creation/Destruction
+ //#################################
+
+ RegistryValueImpl(const std::wstring& Name, int Value);
+
+ RegistryValueImpl(const std::wstring& Name, const std::wstring& Value);
+
+ RegistryValueImpl(const std::wstring& Name, const std::string& Value);
+
+ #if (_MSC_VER >= 1300)
+ RegistryValueImpl::RegistryValueImpl(const RegistryValueImpl& s);
+ #endif
+
+ virtual ~RegistryValueImpl();
+
+
+ //#################################
+ // Query
+ //#################################
+
+
+ /** Returns the name of the value
+ */
+ std::wstring GetName() const;
+
+ /** Return the size of data held
+ */
+ size_t GetDataSize() const;
+
+ /** Get a pointer to the data buffer
+ in order to copy the data
+ */
+ const void* GetDataBuffer() const;
+
+ /** Returns the data as unicode string
+
+ @precond GetType = STRING
+ */
+ std::wstring GetDataAsUniString() const;
+
+ /** Returns the data as ansi string
+
+ @precond GetType = STRING
+ */
+ std::string GetDataAsAnsiString() const;
+
+ /** Returns the data as number
+
+ @precond GetType = NUMBER
+ */
+ int GetDataAsInt() const;
+
+ /** Returns the type of the data
+ */
+ int GetType() const;
+
+ //#################################
+ // Command
+ //#################################
+
+
+ /** Set a new name
+ */
+ void SetName(const std::wstring& NewName);
+
+ /**
+ */
+ void SetValue(const std::wstring& NewValue);
+
+ /**
+ */
+ void SetValue(const std::string& NewValue);
+
+ /**
+ */
+ void SetValue(int NewValue);
+
+ //#################################
+ // Private data
+ //#################################
+
+private:
+ std::wstring m_Name;
+ int m_Type;
+ std::wstring m_StringData;
+ int m_IntData;
+};
+
+
+typedef std::auto_ptr<RegistryValueImpl> RegistryValue;
+
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registryw9x.cxx b/setup_native/source/win32/customactions/reg4msdoc/registryw9x.cxx
new file mode 100644
index 000000000000..6b32083c2dcf
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registryw9x.cxx
@@ -0,0 +1,593 @@
+/*************************************************************************
+ *
+ * $RCSfile: registryw9x.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//---------------------------------------
+//
+//---------------------------------------
+
+#ifndef _REGISTRYW9X_HXX_
+#include "registryw9x.hxx"
+#endif
+
+#include <windows.h>
+#include <malloc.h>
+
+#ifndef _REGISTRYVALUEIMPL_HXX_
+#include "registryvalueimpl.hxx"
+#endif
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#include "registryexception.hxx"
+#endif
+
+#ifndef _STRINGCONVERTER_HXX_
+#include "stringconverter.hxx"
+#endif
+
+#include <assert.h>
+
+#pragma warning(disable : 4786)
+
+//---------------------------------------
+//
+//---------------------------------------
+
+const size_t MAX_TMP_BUFF_SIZE = 1024 * sizeof(wchar_t);
+
+
+//############################################
+// Creation
+// only possible through WindowsRegistry class
+//############################################
+
+
+//-----------------------------------------------------
+/** Create instance and open the specified Registry key
+*/
+RegistryKeyImplWin9x::RegistryKeyImplWin9x(HKEY RootKey, const std::wstring& KeyName) :
+ RegistryKeyImpl(RootKey, KeyName)
+{
+}
+
+//-----------------------------------------------------
+/** Create instance and open the specified Registry key
+*/
+RegistryKeyImplWin9x::RegistryKeyImplWin9x(HKEY RootKey) :
+ RegistryKeyImpl(RootKey)
+{
+}
+
+//-----------------------------------------------------
+/** Create an instances of the specified Registry key,
+ the key is assumed to be already opened.
+*/
+RegistryKeyImplWin9x::RegistryKeyImplWin9x(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable) :
+ RegistryKeyImpl(RootKey, SubKey, KeyName, Writeable)
+{
+}
+
+
+//############################################
+// Queries
+//############################################
+
+
+//-----------------------------------------------------
+/** The number of sub values of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+*/
+size_t RegistryKeyImplWin9x::GetSubValueCount() const
+{
+ assert(IsOpen());
+
+ DWORD nSubValues = 0;
+
+ LONG rc = RegQueryInfoKeyA(
+ m_hSubKey,
+ 0, 0, 0, 0, 0, 0, &nSubValues, 0, 0, 0, 0);
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return nSubValues;
+}
+
+//-----------------------------------------------------
+/** The number of sub-keys of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+*/
+size_t RegistryKeyImplWin9x::GetSubKeyCount() const
+{
+ assert(IsOpen());
+
+ DWORD nSubKeys = 0;
+
+ LONG rc = RegQueryInfoKeyA(
+ m_hSubKey,
+ 0, 0, 0, &nSubKeys, 0, 0, 0, 0, 0, 0, 0);
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return nSubKeys;
+}
+
+//-----------------------------------------------------
+/**
+*/
+StringListPtr RegistryKeyImplWin9x::GetSubKeyNames() const
+{
+ assert(IsOpen());
+
+ char buff[1024];
+ DWORD buff_size = sizeof(buff);
+ FILETIME ftime;
+
+ StringList* key_names = new StringList();
+
+ LONG rc = ERROR_SUCCESS;
+
+ for (DWORD i = 0; /* left empty */; i++)
+ {
+ rc = RegEnumKeyExA(
+ m_hSubKey, i, buff, &buff_size,
+ 0, 0, 0, &ftime);
+
+ if (ERROR_SUCCESS != rc &&
+ ERROR_MORE_DATA != rc)
+ break;
+
+ buff_size = sizeof(buff);
+
+ key_names->push_back(AnsiToUnicodeString(buff));
+ }
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_NO_MORE_ITEMS != rc && ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return (StringListPtr) key_names;
+}
+
+//-----------------------------------------------------
+/**
+*/
+StringListPtr RegistryKeyImplWin9x::GetSubValueNames() const
+{
+ assert(IsOpen());
+
+ char buff[1024];
+ DWORD buff_size = sizeof(buff);
+
+ StringList* value_names = new StringList();
+
+ LONG rc = ERROR_SUCCESS;
+
+ for (DWORD i = 0; /* left empty */; i++)
+ {
+ rc = RegEnumValueA(
+ m_hSubKey, i, buff, &buff_size,
+ 0, 0, 0, 0);
+
+ if (ERROR_SUCCESS != rc &&
+ ERROR_MORE_DATA != rc)
+ break;
+
+ buff_size = sizeof(buff);
+
+ value_names->push_back(AnsiToUnicodeString(buff));
+ }
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_NO_MORE_ITEMS != rc && ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return (StringListPtr) value_names;
+}
+
+//-----------------------------------------------------
+/** Get the specified registry value
+
+ @precond IsOpen = true
+*/
+RegistryValue RegistryKeyImplWin9x::GetValue(const std::wstring& Name) const
+{
+ assert(IsOpen());
+
+ DWORD Type;
+ char buff[MAX_TMP_BUFF_SIZE];
+ DWORD size = sizeof(buff);
+
+ LONG rc = RegQueryValueExA(
+ m_hSubKey,
+ UnicodeToAnsiString(Name).c_str(),
+ 0,
+ &Type,
+ reinterpret_cast<LPBYTE>(buff),
+ &size);
+
+ if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryValueNotFoundException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ RegistryValue regval;
+
+ if (REG_DWORD == Type)
+ {
+ regval = RegistryValue(new RegistryValueImpl(Name, *(reinterpret_cast<int*>(buff))));
+ }
+ else if (REG_SZ == Type || REG_EXPAND_SZ == Type || REG_MULTI_SZ == Type)
+ {
+ if (size > 0)
+ regval = RegistryValue(new RegistryValueImpl(Name, std::string(reinterpret_cast<char*>(buff))));
+ else
+ regval = RegistryValue(new RegistryValueImpl(Name, std::string()));
+ }
+ else
+ {
+ assert(false);
+ }
+
+ return regval;
+}
+
+//-----------------------------------------------------
+/** Get the specified registry value, return the given
+ default value if value not found
+
+ @precond IsOpen = true
+*/
+RegistryValue RegistryKeyImplWin9x::GetValue(const std::wstring& Name, const RegistryValue& Default) const
+{
+ assert(IsOpen());
+
+ DWORD Type;
+ char buff[MAX_TMP_BUFF_SIZE];
+ DWORD size = sizeof(buff);
+
+ LONG rc = RegQueryValueExA(
+ m_hSubKey,
+ UnicodeToAnsiString(Name).c_str(),
+ 0,
+ &Type,
+ reinterpret_cast<LPBYTE>(buff),
+ &size);
+
+ if (ERROR_FILE_NOT_FOUND == rc)
+ {
+ #if (_MSC_VER < 1300)
+ return Default;
+ #else
+ RegistryValue regval_ptr;
+ regval_ptr = RegistryValue(new RegistryValueImpl(*Default));
+ return regval_ptr;
+ #endif
+ }
+
+ if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ RegistryValue regval;
+
+ if (REG_DWORD == Type)
+ regval = RegistryValue(new RegistryValueImpl(Name, *reinterpret_cast<int*>(buff)));
+ else if (REG_SZ == Type || REG_EXPAND_SZ == Type || REG_MULTI_SZ == Type)
+ regval = RegistryValue(new RegistryValueImpl(Name, std::string(reinterpret_cast<char*>(buff))));
+ else
+ assert(false);
+
+ return regval;
+}
+
+
+//############################################
+// Commands
+//############################################
+
+
+//-----------------------------------------------------
+/** Open the registry key, has no effect if
+ the key is already open
+
+ @precond IsOpen = false
+
+ @throws RegistryKeyNotFoundException
+ RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+*/
+void RegistryKeyImplWin9x::Open(bool Writeable)
+{
+ assert(!IsOpen());
+
+ REGSAM regsam = KEY_READ;
+
+ if (Writeable)
+ regsam |= KEY_WRITE;
+
+ LONG rc = RegOpenKeyExA(
+ m_hRootKey,
+ UnicodeToAnsiString(m_KeyName).c_str(),
+ 0,
+ regsam,
+ &m_hSubKey);
+
+ if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryKeyNotFoundException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ m_IsWriteable = Writeable;
+
+ assert(IsOpen());
+}
+
+//-----------------------------------------------------
+/** Open the specified sub-key of the registry key
+ at hand
+
+ @precond IsOpen = true
+ HasSubKey(Name) = true
+
+ @throws RegistryIOException
+ RegistryKeyNotFoundException
+ RegistryAccessDeniedException
+*/
+RegistryKey RegistryKeyImplWin9x::OpenSubKey(const std::wstring& Name, bool Writeable)
+{
+ RegistryKey regkey(new RegistryKeyImplWin9x(m_hSubKey, Name));
+ regkey->Open(Writeable);
+ return regkey;
+}
+
+//-----------------------------------------------------
+/** Creates a new sub-key below the key at hand
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+
+RegistryKey RegistryKeyImplWin9x::CreateSubKey(const std::wstring& Name)
+{
+ assert(IsOpen());
+ assert(IsWriteable());
+
+ HKEY hRoot = IsRootKey() ? m_hRootKey : m_hSubKey;
+
+ HKEY hKey;
+
+ LONG rc = RegCreateKeyExA(
+ hRoot,
+ UnicodeToAnsiString(Name).c_str(),
+ 0,
+ 0,
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ | KEY_WRITE,
+ 0,
+ &hKey,
+ 0);
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return RegistryKey(new RegistryKeyImplWin9x(hRoot, hKey, Name));
+}
+
+//-----------------------------------------------------
+/** Deletes a sub-key below the key at hand, the
+ key must not have sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+void RegistryKeyImplWin9x::DeleteSubKey(const std::wstring& Name)
+{
+ assert(IsOpen());
+ assert(IsWriteable());
+ assert(HasSubKey(Name));
+
+ RegistryKey SubKey = OpenSubKey(Name);
+
+ size_t nSubKeyCount = SubKey->GetSubKeyCount();
+
+ assert(0 == nSubKeyCount);
+
+ if (nSubKeyCount)
+ throw RegistryInvalidOperationException(ERROR_NOT_SUPPORTED);
+
+ LONG rc = RegDeleteKeyA(m_hSubKey, UnicodeToAnsiString(Name).c_str());
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
+//-----------------------------------------------------
+/** Deletes a sub-key below the key at hand with all
+ its sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true;
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+void RegistryKeyImplWin9x::DeleteSubKeyTree(const std::wstring& Name)
+{
+ LONG rc = RegDeleteKeyA(m_hSubKey, UnicodeToAnsiString(Name).c_str());
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
+//-----------------------------------------------------
+/** Delete the specified value
+
+ @precond IsOpen = true
+ IsWriteable = true
+ HasValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+*/
+void RegistryKeyImplWin9x::DeleteValue(const std::wstring& Name)
+{
+ assert(IsOpen());
+ assert(HasValue(Name));
+ assert(IsWriteable());
+
+ LONG rc = RegDeleteValueA(
+ m_hSubKey,
+ UnicodeToAnsiString(Name).c_str());
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryNoWriteAccessException(rc);
+ else if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryValueNotFoundException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
+//-----------------------------------------------------
+/** Set the specified registry value
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+void RegistryKeyImplWin9x::SetValue(const RegistryValue& Value)
+{
+ assert(IsOpen());
+ assert(IsWriteable());
+
+ LONG rc = ERROR_SUCCESS;
+
+ if (REG_SZ == Value->GetType())
+ {
+ std::string AnsiStr = Value->GetDataAsAnsiString();
+
+ rc = RegSetValueExA(
+ m_hSubKey,
+ UnicodeToAnsiString(Value->GetName()).c_str(),
+ 0,
+ Value->GetType(),
+ reinterpret_cast<const unsigned char*>(AnsiStr.c_str()),
+ static_cast<DWORD>((AnsiStr.length() + 1)));
+ }
+ else
+ {
+ rc = RegSetValueExA(
+ m_hSubKey,
+ UnicodeToAnsiString(Value->GetName()).c_str(),
+ 0,
+ Value->GetType(),
+ reinterpret_cast<const unsigned char*>(Value->GetDataBuffer()),
+ static_cast<DWORD>(Value->GetDataSize()));
+ }
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registryw9x.hxx b/setup_native/source/win32/customactions/reg4msdoc/registryw9x.hxx
new file mode 100644
index 000000000000..11998db991f0
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registryw9x.hxx
@@ -0,0 +1,236 @@
+/*************************************************************************
+ *
+ * $RCSfile: registryw9x.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:32 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _REGISTRYW9X_HXX_
+#define _REGISTRYW9X_HXX_
+
+#include "registry.hxx"
+
+#ifndef _REGISTRY_HXX_
+#include "registry.hxx"
+#endif
+
+//---------------------------------------
+// constants
+//---------------------------------------
+
+class RegistryKeyImplWin9x : public RegistryKeyImpl
+{
+public:
+
+ //############################################
+ // Queries
+ //############################################
+
+ /** The number of sub values of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+ */
+ virtual size_t GetSubValueCount() const;
+
+ /** The number of sub-keys of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+ */
+ virtual size_t GetSubKeyCount() const;
+
+ virtual StringListPtr GetSubKeyNames() const;
+
+ virtual StringListPtr GetSubValueNames() const;
+
+ /** Get the specified registry value
+
+ @precond IsOpen = true
+ */
+ virtual RegistryValue GetValue(const std::wstring& Name) const;
+
+ /** Get the specified registry value, return the given
+ default value if value not found
+
+ @precond IsOpen = true
+ */
+ virtual RegistryValue GetValue(const std::wstring& Name, const RegistryValue& Default) const;
+
+ //############################################
+ // Commands
+ //############################################
+
+ /** Open the registry key, has no effect if
+ the key is already open
+
+ @precond IsOpen = false
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ */
+ virtual void Open(bool Writeable = true);
+
+ /** Open the specified sub-key of the registry key
+ at hand
+
+ @precond IsOpen = true
+ HasSubKey(Name) = true
+
+ @throws RegistryIOException
+ RegistryKeyNotFoundException
+ RegistryAccessDeniedException
+ */
+ virtual RegistryKey OpenSubKey(const std::wstring& Name, bool Writeable = true);
+
+ /** Creates a new sub-key below the key at hand
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual RegistryKey CreateSubKey(const std::wstring& Name);
+
+ /** Deletes a sub-key below the key at hand, the
+ key must not have sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void DeleteSubKey(const std::wstring& Name);
+
+ /** Deletes a sub-key below the key at hand with all
+ its sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true;
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void DeleteSubKeyTree(const std::wstring& Name);
+
+ /** Delete the specified value
+
+ @precond IsOpen = true
+ IsWriteable = true
+ HasValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+ */
+ virtual void DeleteValue(const std::wstring& Name);
+
+ /** Set the specified registry value
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void SetValue(const RegistryValue& Value);
+
+ //############################################
+ // Creation
+ //
+ // only possible through WindowsRegistry class
+ //############################################
+
+protected:
+ /** Create instance and open the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+ */
+ RegistryKeyImplWin9x(HKEY RootKey, const std::wstring& KeyName);
+
+ /** Create instance and open the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+ */
+ RegistryKeyImplWin9x(HKEY RootKey);
+
+ /** Create an instances of the specified Registry key,
+ the key is assumed to be already opened.
+ */
+ RegistryKeyImplWin9x(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable = true);
+
+// prevent copy/assignment
+private:
+ RegistryKeyImplWin9x(const RegistryKeyImplWin9x&);
+ RegistryKeyImplWin9x& operator=(const RegistryKeyImplWin9x&);
+
+//######################################
+// Friend declarations
+//######################################
+
+friend class WindowsRegistry;
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registrywnt.cxx b/setup_native/source/win32/customactions/reg4msdoc/registrywnt.cxx
new file mode 100644
index 000000000000..e2c6f6bb64e7
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registrywnt.cxx
@@ -0,0 +1,653 @@
+/*************************************************************************
+ *
+ * $RCSfile: registrywnt.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//---------------------------------------
+//
+//---------------------------------------
+
+#include <windows.h>
+#include <malloc.h>
+
+#ifndef _REGISTRYWNT_HXX_
+#include "registrywnt.hxx"
+#endif
+
+#ifndef _REGISTRYVALUEIMPL_HXX_
+#include "registryvalueimpl.hxx"
+#endif
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#include "registryexception.hxx"
+#endif
+
+#include <assert.h>
+
+#pragma warning(disable : 4786)
+
+//---------------------------------------
+//
+//---------------------------------------
+
+const size_t MAX_TMP_BUFF_SIZE = 1024 * sizeof(wchar_t);
+
+
+//############################################
+// Creation
+// only possible through WindowsRegistry class
+//############################################
+
+
+//-----------------------------------------------------
+/** Create instance and open the specified Registry key
+*/
+RegistryKeyImplWinNT::RegistryKeyImplWinNT(HKEY RootKey, const std::wstring& KeyName) :
+ RegistryKeyImpl(RootKey, KeyName)
+{
+}
+
+//-----------------------------------------------------
+/** Create instance and open the specified Registry key
+*/
+RegistryKeyImplWinNT::RegistryKeyImplWinNT(HKEY RootKey) :
+ RegistryKeyImpl(RootKey)
+{
+}
+
+//-----------------------------------------------------
+/** Create an instances of the specified Registry key,
+ the key is assumed to be already opened.
+*/
+RegistryKeyImplWinNT::RegistryKeyImplWinNT(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable) :
+ RegistryKeyImpl(RootKey, SubKey, KeyName, Writeable)
+{
+}
+
+
+//############################################
+// Queries
+//############################################
+
+
+//-----------------------------------------------------
+/** The number of sub values of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+*/
+size_t RegistryKeyImplWinNT::GetSubValueCount() const
+{
+ assert(IsOpen());
+
+ DWORD nSubValues = 0;
+
+ LONG rc = RegQueryInfoKeyW(
+ m_hSubKey,
+ 0, 0, 0, 0, 0, 0, &nSubValues, 0, 0, 0, 0);
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return nSubValues;
+}
+
+//-----------------------------------------------------
+/** The number of sub-keys of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+*/
+size_t RegistryKeyImplWinNT::GetSubKeyCount() const
+{
+ assert(IsOpen());
+
+ DWORD nSubKeys = 0;
+
+ LONG rc = RegQueryInfoKeyA(
+ m_hSubKey,
+ 0, 0, 0, &nSubKeys, 0, 0, 0, 0, 0, 0, 0);
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return nSubKeys;
+}
+
+//-----------------------------------------------------
+/**
+*/
+StringListPtr RegistryKeyImplWinNT::GetSubKeyNames() const
+{
+ assert(IsOpen());
+
+ wchar_t buff[1024];
+ DWORD buff_size = sizeof(buff);
+ FILETIME ftime;
+
+ StringList* key_names = new StringList();
+
+ LONG rc = ERROR_SUCCESS;
+
+ for (DWORD i = 0; /* left empty */; i++)
+ {
+ rc = RegEnumKeyExW(
+ m_hSubKey, i, buff, &buff_size,
+ 0, 0, 0, &ftime);
+
+ if (ERROR_SUCCESS != rc &&
+ ERROR_MORE_DATA != rc)
+ break;
+
+ buff_size = sizeof(buff);
+
+ key_names->push_back(buff);
+ }
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_NO_MORE_ITEMS != rc && ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+#if (_MSC_VER < 1300)
+ return key_names;
+#else
+ return (StringListPtr) key_names;
+#endif
+}
+
+//-----------------------------------------------------
+/**
+*/
+StringListPtr RegistryKeyImplWinNT::GetSubValueNames() const
+{
+ assert(IsOpen());
+
+ wchar_t buff[1024];
+ DWORD buff_size = sizeof(buff);
+
+ StringList* value_names = new StringList();
+
+ LONG rc = ERROR_SUCCESS;
+
+ for (DWORD i = 0; /* left empty */; i++)
+ {
+ rc = RegEnumValueW(
+ m_hSubKey, i, buff, &buff_size,
+ 0, 0, 0, 0);
+
+ if (ERROR_SUCCESS != rc &&
+ ERROR_MORE_DATA != rc)
+ break;
+
+ buff_size = sizeof(buff);
+
+ value_names->push_back(buff);
+ }
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_NO_MORE_ITEMS != rc && ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+#if (_MSC_VER < 1300)
+ return value_names;
+#else
+ return (StringListPtr) value_names;
+#endif
+}
+
+//-----------------------------------------------------
+/** Get the specified registry value
+
+ @precond IsOpen = true
+*/
+RegistryValue RegistryKeyImplWinNT::GetValue(const std::wstring& Name) const
+{
+ assert(IsOpen());
+
+ DWORD Type;
+ wchar_t buff[MAX_TMP_BUFF_SIZE];
+ DWORD size = sizeof(buff);
+
+ LONG rc = RegQueryValueExW(
+ m_hSubKey,
+ Name.c_str(),
+ 0,
+ &Type,
+ reinterpret_cast<LPBYTE>(buff),
+ &size);
+
+ if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryValueNotFoundException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ RegistryValue regval;
+
+ if (REG_DWORD == Type)
+ {
+ regval = RegistryValue(new RegistryValueImpl(Name, *(reinterpret_cast<int*>(buff))));
+ }
+ else if (REG_SZ == Type || REG_EXPAND_SZ == Type || REG_MULTI_SZ == Type)
+ {
+ if (size > 0)
+ regval = RegistryValue(new RegistryValueImpl(Name, std::wstring(reinterpret_cast<wchar_t*>(buff))));
+ else
+ regval = RegistryValue(new RegistryValueImpl(Name, std::wstring()));
+ }
+ else
+ {
+ assert(false);
+ }
+
+ return regval;
+}
+
+//-----------------------------------------------------
+/** Get the specified registry value, return the given
+ default value if value not found
+
+ @precond IsOpen = true
+*/
+RegistryValue RegistryKeyImplWinNT::GetValue(const std::wstring& Name, const RegistryValue& Default) const
+{
+ assert(IsOpen());
+
+ DWORD Type;
+ wchar_t buff[MAX_TMP_BUFF_SIZE];
+ DWORD size = sizeof(buff);
+
+ LONG rc = RegQueryValueExW(
+ m_hSubKey,
+ Name.c_str(),
+ 0,
+ &Type,
+ reinterpret_cast<LPBYTE>(buff),
+ &size);
+
+ if (ERROR_FILE_NOT_FOUND == rc)
+ {
+ #if (_MSC_VER < 1300)
+ return Default;
+ #else
+ RegistryValue regval_ptr;
+ regval_ptr = RegistryValue(new RegistryValueImpl(*Default));
+ return regval_ptr;
+ #endif
+ }
+
+ if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ RegistryValue regval;
+
+ if (REG_DWORD == Type)
+ regval = RegistryValue(new RegistryValueImpl(Name, *reinterpret_cast<int*>(buff)));
+ else if (REG_SZ == Type || REG_EXPAND_SZ == Type || REG_MULTI_SZ == Type)
+ regval = RegistryValue(new RegistryValueImpl(Name, std::wstring(reinterpret_cast<wchar_t*>(buff))));
+ else
+ assert(false);
+
+ return regval;
+}
+
+
+//############################################
+// Commands
+//############################################
+
+
+//-----------------------------------------------------
+/** Open the registry key, has no effect if
+ the key is already open
+
+ @precond IsOpen = false
+
+ @throws RegistryKeyNotFoundException
+ RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+*/
+void RegistryKeyImplWinNT::Open(bool Writeable)
+{
+ assert(!IsOpen());
+
+ REGSAM regsam = KEY_READ;
+
+ if (Writeable)
+ regsam |= KEY_WRITE;
+
+ LONG rc = RegOpenKeyExW(
+ m_hRootKey,
+ m_KeyName.c_str(),
+ 0,
+ regsam,
+ &m_hSubKey);
+
+ if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryKeyNotFoundException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ m_IsWriteable = Writeable;
+
+ assert(IsOpen());
+}
+
+//-----------------------------------------------------
+/** Open the specified sub-key of the registry key
+ at hand
+
+ @precond IsOpen = true
+ HasSubKey(Name) = true
+
+ @throws RegistryIOException
+ RegistryKeyNotFoundException
+ RegistryAccessDeniedException
+*/
+RegistryKey RegistryKeyImplWinNT::OpenSubKey(const std::wstring& Name, bool Writeable)
+{
+ RegistryKey regkey(new RegistryKeyImplWinNT(m_hSubKey, Name));
+ regkey->Open(Writeable);
+ return regkey;
+}
+
+//-----------------------------------------------------
+/** Creates a new sub-key below the key at hand
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+
+RegistryKey RegistryKeyImplWinNT::CreateSubKey(const std::wstring& Name)
+{
+ assert(IsOpen());
+ assert(IsWriteable());
+
+ HKEY hRoot = IsRootKey() ? m_hRootKey : m_hSubKey;
+
+ HKEY hKey;
+
+ LONG rc = RegCreateKeyExW(
+ hRoot,
+ Name.c_str(),
+ 0,
+ 0,
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ | KEY_WRITE,
+ 0,
+ &hKey,
+ 0);
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return RegistryKey(new RegistryKeyImplWinNT(hRoot, hKey, Name));
+}
+
+//-----------------------------------------------------
+/** Deletes a sub-key below the key at hand, the
+ key must not have sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+void RegistryKeyImplWinNT::DeleteSubKey(const std::wstring& Name)
+{
+ assert(IsOpen());
+ assert(IsWriteable());
+ assert(HasSubKey(Name));
+
+ RegistryKey SubKey = OpenSubKey(Name);
+
+ size_t nSubKeyCount = SubKey->GetSubKeyCount();
+
+ assert(0 == nSubKeyCount);
+
+ if (nSubKeyCount)
+ throw RegistryInvalidOperationException(ERROR_NOT_SUPPORTED);
+
+ LONG rc = RegDeleteKeyW(m_hSubKey, Name.c_str());
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
+//-----------------------------------------------------
+/** Deletes a sub-key below the key at hand with all
+ its sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true;
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+void RegistryKeyImplWinNT::DeleteSubKeyTree(const std::wstring& Name)
+{
+ ImplDeleteSubKeyTree(m_hSubKey, Name);
+}
+
+//-----------------------------------------------------
+/** Deletes a sub-key below the key at hand with all
+ its sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true;
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+LONG RegistryKeyImplWinNT::ImplDeleteSubKeyTree(HKEY RootKey, const std::wstring& Name)
+{
+ assert(IsOpen());
+
+ HKEY hKey;
+
+ LONG rc = RegOpenKeyExW(
+ RootKey,
+ Name.c_str(),
+ 0,
+ KEY_READ | DELETE,
+ &hKey);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ wchar_t* lpSubKey;
+ DWORD nMaxSubKeyLen;
+
+ rc = RegQueryInfoKeyW(
+ hKey, 0, 0, 0, 0,
+ &nMaxSubKeyLen,
+ 0, 0, 0, 0, 0, 0);
+
+ nMaxSubKeyLen++; // space for trailing '\0'
+
+ lpSubKey = reinterpret_cast<wchar_t*>(
+ _alloca(nMaxSubKeyLen*sizeof(wchar_t)));
+
+ while (ERROR_SUCCESS == rc)
+ {
+ DWORD nLen = nMaxSubKeyLen;
+
+ rc = RegEnumKeyExW(
+ hKey,
+ 0, // always index zero
+ lpSubKey,
+ &nLen,
+ 0, 0, 0, 0);
+
+ if (ERROR_NO_MORE_ITEMS == rc)
+ {
+ rc = RegDeleteKeyW(RootKey, Name.c_str());
+ break;
+ }
+ else if (rc == ERROR_SUCCESS)
+ {
+ rc = ImplDeleteSubKeyTree(hKey, lpSubKey);
+ }
+
+ } // while
+
+ RegCloseKey(hKey);
+
+ } // if
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryKeyNotFoundException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+
+ return rc;
+}
+
+//-----------------------------------------------------
+/** Delete the specified value
+
+ @precond IsOpen = true
+ IsWriteable = true
+ HasValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+*/
+void RegistryKeyImplWinNT::DeleteValue(const std::wstring& Name)
+{
+ assert(IsOpen());
+ assert(HasValue(Name));
+ assert(IsWriteable());
+
+ LONG rc = RegDeleteValueW(
+ m_hSubKey,
+ Name.c_str());
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryNoWriteAccessException(rc);
+ else if (ERROR_FILE_NOT_FOUND == rc)
+ throw RegistryValueNotFoundException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
+//-----------------------------------------------------
+/** Set the specified registry value
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+*/
+void RegistryKeyImplWinNT::SetValue(const RegistryValue& Value)
+{
+ assert(IsOpen());
+ assert(IsWriteable());
+
+ LONG rc = RegSetValueExW(
+ m_hSubKey,
+ Value->GetName().c_str(),
+ 0,
+ Value->GetType(),
+ reinterpret_cast<const unsigned char*>(Value->GetDataBuffer()),
+ static_cast<DWORD>(Value->GetDataSize()));
+
+ if (ERROR_INVALID_HANDLE == rc)
+ throw RegistryIOException(rc);
+ else if (ERROR_ACCESS_DENIED == rc)
+ throw RegistryAccessDeniedException(rc);
+ else if (ERROR_SUCCESS != rc)
+ throw RegistryException(rc);
+}
+
+
+
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/registrywnt.hxx b/setup_native/source/win32/customactions/reg4msdoc/registrywnt.hxx
new file mode 100644
index 000000000000..15d94463883a
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/registrywnt.hxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * $RCSfile: registrywnt.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _REGISTRYWNT_HXX_
+#define _REGISTRYWNT_HXX_
+
+#ifndef _REGISTRY_HXX_
+#include "registry.hxx"
+#endif
+
+//---------------------------------------
+// constants
+//---------------------------------------
+
+class RegistryKeyImplWinNT : public RegistryKeyImpl
+{
+public:
+
+ //############################################
+ // Queries
+ //############################################
+
+ /** The number of sub values of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+ */
+ virtual size_t GetSubValueCount() const;
+
+ /** The number of sub-keys of the key at hand
+
+ @precond IsOpen = true
+
+ @throws
+ */
+ virtual size_t GetSubKeyCount() const;
+
+ virtual StringListPtr GetSubKeyNames() const;
+
+ virtual StringListPtr GetSubValueNames() const;
+
+ /** Get the specified registry value
+
+ @precond IsOpen = true
+ */
+ virtual RegistryValue GetValue(const std::wstring& Name) const;
+
+ /** Get the specified registry value, return the given
+ default value if value not found
+
+ @precond IsOpen = true
+ */
+ virtual RegistryValue GetValue(const std::wstring& Name, const RegistryValue& Default) const;
+
+ //############################################
+ // Commands
+ //############################################
+
+ /** Open the registry key, has no effect if
+ the key is already open
+
+ @precond IsOpen = false
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ */
+ virtual void Open(bool Writeable = true);
+
+ /** Open the specified sub-key of the registry key
+ at hand
+
+ @precond IsOpen = true
+ HasSubKey(Name) = true
+
+ @throws RegistryIOException
+ RegistryKeyNotFoundException
+ RegistryAccessDeniedException
+ */
+ virtual RegistryKey OpenSubKey(const std::wstring& Name, bool Writeable = true);
+
+ /** Creates a new sub-key below the key at hand
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual RegistryKey CreateSubKey(const std::wstring& Name);
+
+ /** Deletes a sub-key below the key at hand, the
+ key must not have sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void DeleteSubKey(const std::wstring& Name);
+
+ /** Deletes a sub-key below the key at hand with all
+ its sub-keys
+
+ @precond IsOpen = true
+ IsWriteable = true;
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void DeleteSubKeyTree(const std::wstring& Name);
+
+ /** Delete the specified value
+
+ @precond IsOpen = true
+ IsWriteable = true
+ HasValue(Name) = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDeniedException
+ RegistryValueNotFoundException
+ */
+ virtual void DeleteValue(const std::wstring& Name);
+
+ /** Set the specified registry value
+
+ @precond IsOpen = true
+ IsWriteable = true
+
+ @throws RegistryIOException
+ RegistryWriteAccessDenyException
+ */
+ virtual void SetValue(const RegistryValue& Value);
+
+ //############################################
+ // Creation
+ //
+ // only possible through WindowsRegistry class
+ //############################################
+
+protected:
+ /** Create instance and open the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+ */
+ RegistryKeyImplWinNT(HKEY RootKey, const std::wstring& KeyName);
+
+ /** Create instance and open the specified Registry key
+
+ @throws RegistryWriteAccessDenyException
+ RegistryAccessDenyException
+ RegistryKeyNotFoundException
+ */
+ RegistryKeyImplWinNT(HKEY RootKey);
+
+ /** Create an instances of the specified Registry key,
+ the key is assumed to be already opened.
+ */
+ RegistryKeyImplWinNT(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable = true);
+
+private:
+
+ LONG ImplDeleteSubKeyTree(HKEY RootKey, const std::wstring& Name);
+
+//prevent copy and assignment
+private:
+ RegistryKeyImplWinNT(const RegistryKeyImplWinNT&);
+ RegistryKeyImplWinNT& operator=(const RegistryKeyImplWinNT&);
+
+//######################################
+// Friend declarations
+//######################################
+
+friend class WindowsRegistry;
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/stringconverter.cxx b/setup_native/source/win32/customactions/reg4msdoc/stringconverter.cxx
new file mode 100644
index 000000000000..9f5156e538f9
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/stringconverter.cxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * $RCSfile: stringconverter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _STRINGCONVERTER_HXX_
+#include "stringconverter.hxx"
+#endif
+
+#include <windows.h>
+#include <malloc.h>
+
+/** Convert a Unicode string to an ANSI string based on CP_ACP
+*/
+std::string UnicodeToAnsiString(const std::wstring& UniString)
+{
+ int len = WideCharToMultiByte(
+ CP_ACP, 0, UniString.c_str(), -1, 0, 0, 0, 0);
+
+ char* buff = reinterpret_cast<char*>(_alloca(len));
+
+ WideCharToMultiByte(
+ CP_ACP, 0, UniString.c_str(), -1, buff, len, 0, 0);
+
+ return std::string(buff);
+}
+
+/** Convert an ANSI string to unicode based on CP_ACP
+*/
+std::wstring AnsiToUnicodeString(const std::string& AnsiString)
+{
+ int len = MultiByteToWideChar(
+ CP_ACP, 0, AnsiString.c_str(), -1, 0, 0);
+
+ wchar_t* buff = reinterpret_cast<wchar_t*>(_alloca(len * sizeof(wchar_t)));
+
+ MultiByteToWideChar(
+ CP_ACP, 0, AnsiString.c_str(), -1, buff, len);
+
+ return std::wstring(buff);
+}
+
+
diff --git a/setup_native/source/win32/customactions/reg4msdoc/stringconverter.hxx b/setup_native/source/win32/customactions/reg4msdoc/stringconverter.hxx
new file mode 100644
index 000000000000..ada2f1416a7c
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/stringconverter.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: stringconverter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2004-05-26 17:05:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _STRINGCONVERTER_HXX_
+#define _STRINGCONVERTER_HXX_
+
+#include <string>
+
+/** Convert a Unicode string to an ANSI string based on CP_ACP
+*/
+std::string UnicodeToAnsiString(const std::wstring& UniString);
+
+/** Convert an ANSI string to unicode based on CP_ACP
+*/
+std::wstring AnsiToUnicodeString(const std::string& AnsiString);
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx b/setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx
new file mode 100644
index 000000000000..2a71b4846555
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx
@@ -0,0 +1,143 @@
+// UserRegistrar.cpp: Implementierung der Klasse UserRegistrar.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _USERREGISTRAR_HXX_
+#include "userregistrar.hxx"
+#endif
+
+#ifndef _REGISTRYVALUEIMPL_HXX_
+#include "registryvalueimpl.hxx"
+#endif
+
+#ifndef _WINDOWSREGISTRY_HXX_
+#include "windowsregistry.hxx"
+#endif
+
+#ifndef _REGISTRYEXCEPTION_HXX_
+#include "registryexception.hxx"
+#endif
+
+//--------------------------------------
+/**
+*/
+UserRegistrar::UserRegistrar(const RegistrationContextInformation& RegContext) :
+ Registrar(RegContext)
+{
+ RegistryKey RegKey = WindowsRegistry().GetCurrentUserKey();
+ m_RootKey = RegKey->OpenSubKey(L"Software\\Classes");
+}
+
+//###################################
+// Command
+//###################################
+
+//--------------------------------------
+/**
+*/
+void UserRegistrar::UnregisterAsHtmlEditorForInternetExplorer() const
+{
+ Registrar::UnregisterAsHtmlEditorForInternetExplorer();
+
+ DeleteHtmFileAssociationKeys();
+
+ try
+ {
+ RegistryKey RegKey = m_RootKey->OpenSubKey(L"Applications");
+ if ((0 == RegKey->GetSubValueCount()) && (0 == RegKey->GetSubKeyCount()))
+ {
+ RegKey->Close();
+ m_RootKey->DeleteSubKey(L"Applications");
+ }
+ }
+ catch(RegistryKeyNotFoundException&)
+ {
+ }
+}
+
+//--------------------------------------
+/**
+*/
+void UserRegistrar::RegisterAsDefaultShellHtmlEditor() const
+{
+ RegistryKey LocalHtmKey = m_RootKey->CreateSubKey(L".htm");
+
+ if (!LocalHtmKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegistryKey HKCRKey = WindowsRegistry().GetClassesRootKey();
+
+ if (HKCRKey->HasSubKey(L".htm"))
+ {
+ RegistryKey RootHtmKey = HKCRKey->OpenSubKey(L".htm", false);
+
+ if (RootHtmKey->HasValue(DEFAULT_VALUE_NAME))
+ {
+ RegistryValue RegVal = RootHtmKey->GetValue(DEFAULT_VALUE_NAME);
+
+ std::wstring RootHtmFwdKey = RegVal->GetDataAsUniString();
+
+ if (HKCRKey->HasSubKey(RootHtmFwdKey))
+ {
+ m_RootKey->CreateSubKey(RootHtmFwdKey);
+ LocalHtmKey->CopyValue(RootHtmKey, DEFAULT_VALUE_NAME);
+ }
+ }
+ }
+ }
+
+ // calling base class method
+ Registrar::RegisterAsDefaultShellHtmlEditor();
+}
+
+//--------------------------------------
+/**
+*/
+void UserRegistrar::UnregisterAsDefaultShellHtmlEditor() const
+{
+ // calling base class method
+ Registrar::UnregisterAsDefaultShellHtmlEditor();
+ DeleteHtmFileAssociationKeys();
+}
+
+//--------------------------------------
+/**
+*/
+void UserRegistrar::UnregisterForMsOfficeApplication(
+ const std::wstring& FileExtension) const
+{
+ /// calling base class method
+ Registrar::UnregisterForMsOfficeApplication(FileExtension);
+
+ if (m_RootKey->HasSubKey(FileExtension))
+ {
+ RegistryKey RegKey = m_RootKey->OpenSubKey(FileExtension);
+
+ if ((0 == RegKey->GetSubKeyCount()) && (0 == RegKey->GetSubValueCount()))
+ {
+ RegKey->Close();
+ m_RootKey->DeleteSubKey(FileExtension);
+ }
+ }
+}
+
+//--------------------------------------
+/**
+*/
+RegistryKey UserRegistrar::GetRootKeyForDefHtmlEditorForIERegistration() const
+{
+ return WindowsRegistry().GetCurrentUserKey();
+}
+
+//--------------------------------------
+/**
+*/
+void UserRegistrar::DeleteHtmFileAssociationKeys() const
+{
+ // Later delete the created keys if they are empty and have not changed meanwhile.
+ // Remeber: if we create a new registry key in the user part of the
+ // registry, changes to that key via the merged key HKEY_CLASSES_ROOT
+ // go into the user branch HKEY_CURRENT_USER and are not visible for other users.
+ // so we must carefully detect if the keys have not changed in order to prevent accidentally
+ // deleting a key and so destroying existing associations
+ // See MSDN: "Merged View of HKEY_CLASSES_ROOT"
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/userregistrar.hxx b/setup_native/source/win32/customactions/reg4msdoc/userregistrar.hxx
new file mode 100644
index 000000000000..b2df8edaa0da
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/userregistrar.hxx
@@ -0,0 +1,45 @@
+// UserRegistrar.h: Schnittstelle für die Klasse UserRegistrar.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _USERREGISTRAR_HXX_
+#define _USERREGISTRAR_HXX_
+
+#ifndef _REGISTRAR_HXX_
+#include "registrar.hxx"
+#endif
+
+class UserRegistrar : public Registrar
+{
+public:
+
+ //###################################
+ // Creation
+ //###################################
+
+ UserRegistrar(const RegistrationContextInformation& RegContext);
+
+ //###################################
+ // Command
+ //###################################
+
+ virtual void UnregisterAsHtmlEditorForInternetExplorer() const;
+
+ virtual void RegisterAsDefaultShellHtmlEditor() const;
+ virtual void UnregisterAsDefaultShellHtmlEditor() const;
+
+protected:
+ virtual void UnregisterForMsOfficeApplication(
+ const std::wstring& FileExtension) const;
+
+ virtual RegistryKey GetRootKeyForDefHtmlEditorForIERegistration() const;
+
+private:
+
+ /** Delete the privately created file associations
+ for htm files if the keys are empty
+ */
+ void DeleteHtmFileAssociationKeys() const;
+};
+
+#endif
diff --git a/setup_native/source/win32/customactions/reg4msdoc/windowsregistry.cxx b/setup_native/source/win32/customactions/reg4msdoc/windowsregistry.cxx
new file mode 100644
index 000000000000..1c7ebf8d66e5
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/windowsregistry.cxx
@@ -0,0 +1,75 @@
+// WindowsRegistry.cpp: Implementierung der Klasse WindowsRegistry.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "windowsregistry.hxx"
+#include "registrywnt.hxx"
+#include "registryw9x.hxx"
+
+//------------------------------
+//
+//------------------------------
+
+WindowsRegistry::WindowsRegistry()
+{
+ OSVERSIONINFOA osverinfo;
+ ZeroMemory(&osverinfo, sizeof(osverinfo));
+ osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
+ GetVersionExA(&osverinfo);
+
+ m_IsWinNT = (osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+
+//------------------------------
+//
+//------------------------------
+
+RegistryKey WindowsRegistry::GetClassesRootKey(bool Writeable) const
+{
+ return GetRegistryKey(HKEY_CLASSES_ROOT, Writeable);
+}
+
+//------------------------------
+//
+//------------------------------
+
+RegistryKey WindowsRegistry::GetCurrentUserKey(bool Writeable) const
+{
+ return GetRegistryKey(HKEY_CURRENT_USER, Writeable);
+}
+
+//------------------------------
+//
+//------------------------------
+
+RegistryKey WindowsRegistry::GetLocalMachineKey(bool Writeable) const
+{
+ return GetRegistryKey(HKEY_LOCAL_MACHINE, Writeable);
+}
+
+//------------------------------
+//
+//------------------------------
+
+RegistryKey WindowsRegistry::GetUserKey(bool Writeable) const
+{
+ return GetRegistryKey(HKEY_USERS, Writeable);
+}
+
+//------------------------------
+//
+//------------------------------
+
+RegistryKey WindowsRegistry::GetRegistryKey(HKEY RootKey, bool Writeable) const
+{
+ RegistryKey regkey;
+
+ if (m_IsWinNT)
+ regkey = RegistryKey(new RegistryKeyImplWinNT(RootKey));
+ else
+ regkey = RegistryKey(new RegistryKeyImplWin9x(RootKey));
+
+ regkey->Open(Writeable);
+
+ return regkey;
+}
diff --git a/setup_native/source/win32/customactions/reg4msdoc/windowsregistry.hxx b/setup_native/source/win32/customactions/reg4msdoc/windowsregistry.hxx
new file mode 100644
index 000000000000..9a9a0b7fdf39
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg4msdoc/windowsregistry.hxx
@@ -0,0 +1,33 @@
+// WindowsRegistry.h: Schnittstelle für die Klasse WindowsRegistry.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef _WINDOWSREGISTRY_HXX_
+#define _WINDOWSREGISTRY_HXX_
+
+#include <windows.h>
+#include "Registry.hxx"
+
+/** Basically a factory class
+*/
+class WindowsRegistry
+{
+public:
+ WindowsRegistry();
+
+ RegistryKey GetClassesRootKey(bool Writeable = true) const;
+
+ RegistryKey GetCurrentUserKey(bool Writeable = true) const;
+
+ RegistryKey GetLocalMachineKey(bool Writeable = true) const;
+
+ RegistryKey GetUserKey(bool Writeable = true) const;
+
+private:
+ RegistryKey GetRegistryKey(HKEY RootKey, bool Writeable) const;
+
+private:
+ bool m_IsWinNT;
+};
+
+#endif