Update ooo320-m1
[ooovba.git] / setup_native / source / win32 / customactions / reg4msdoc / reg4msdocmsi.cxx
blob2918545b74e47a4d7f83c8621eae5dafde6c9c08
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: reg4msdocmsi.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifdef _MSC_VER
32 #pragma warning(push, 1) /* disable warnings within system headers */
33 #endif
34 #define WIN32_LEAN_AND_MEAN
35 #include <windows.h>
36 #include <msiquery.h>
37 #ifdef _MSC_VER
38 #pragma warning(pop)
39 #endif
41 #include <tchar.h>
42 #include "register.hxx"
43 #include "msihelper.hxx"
45 #include <memory>
46 #include <string>
48 #define ELEMENTS_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
50 void DetermineWordPreselectionState(MSIHANDLE handle)
52 if (query_preselect_registration_for_ms_application(handle, MSWORD))
53 SetMsiProp(handle, TEXT("SELECT_WORD"));
56 void DetermineExcelPreselectionState(MSIHANDLE handle)
58 if (query_preselect_registration_for_ms_application(handle, MSEXCEL))
59 SetMsiProp(handle, TEXT("SELECT_EXCEL"));
62 void DeterminePowerPointPreselectionState(MSIHANDLE handle)
64 if (query_preselect_registration_for_ms_application(handle, MSPOWERPOINT))
65 SetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
68 extern "C" UINT __stdcall InstallUiSequenceEntry(MSIHANDLE handle)
70 //MessageBox(NULL, TEXT("InstallUiSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
72 if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin")))
74 DetermineWordPreselectionState(handle);
76 else if (IsModuleInstalled(handle, TEXT("gm_p_Wrt_Bin")) &&
77 !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")) &&
78 IsRegisteredFor(handle, MSWORD))
80 SetMsiProp(handle, TEXT("SELECT_WORD"));
82 else
84 UnsetMsiProp(handle, TEXT("SELECT_WORD"));
87 if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Calc_Bin")))
89 DetermineExcelPreselectionState(handle);
91 else if (IsModuleInstalled(handle, TEXT("gm_p_Calc_Bin")) &&
92 !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")) &&
93 IsRegisteredFor(handle, MSEXCEL))
95 SetMsiProp(handle, TEXT("SELECT_EXCEL"));
97 else
99 UnsetMsiProp(handle, TEXT("SELECT_EXCEL"));
102 if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Impress_Bin")))
104 DeterminePowerPointPreselectionState(handle);
106 else if (IsModuleInstalled(handle, TEXT("gm_p_Impress_Bin")) &&
107 !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")) &&
108 IsRegisteredFor(handle, MSPOWERPOINT))
110 SetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
112 else
114 UnsetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
117 SetMsiProp(handle, TEXT("UI_SEQUENCE_EXECUTED"));
119 return ERROR_SUCCESS;
122 extern "C" UINT __stdcall InstallExecSequenceEntry(MSIHANDLE handle)
124 //MessageBox(NULL, TEXT("InstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
126 // Do nothing in repair mode.
127 // Then UI_SEQUENCE_EXECUTED is not set and Installed is set!
128 // In silent installation UI_SEQUENCE_EXECUTED is also not set, but Installed is not set.
129 if ((!IsSetMsiProp(handle, TEXT("UI_SEQUENCE_EXECUTED"))) && (IsMsiPropNotEmpty(handle, TEXT("Installed")))) { return ERROR_SUCCESS; }
131 int reg4 = 0;
132 int unreg4 = 0;
134 // we always register as html editor for Internet Explorer
135 // if writer is installed because there's no harm if we do so
136 if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin")))
137 reg4 |= HTML_EDITOR;
139 if (IsSetMsiProp(handle, TEXT("SELECT_WORD")) && !IsRegisteredFor(handle, MSWORD))
140 reg4 |= MSWORD;
141 else if (!IsSetMsiProp(handle, TEXT("SELECT_WORD")) && IsRegisteredFor(handle, MSWORD))
142 unreg4 |= MSWORD;
144 if (IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && !IsRegisteredFor(handle, MSEXCEL))
145 reg4 |= MSEXCEL;
146 else if (!IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && IsRegisteredFor(handle, MSEXCEL))
147 unreg4 |= MSEXCEL;
149 if (IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && !IsRegisteredFor(handle, MSPOWERPOINT))
150 reg4 |= MSPOWERPOINT;
151 else if (!IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && IsRegisteredFor(handle, MSPOWERPOINT))
152 unreg4 |= MSPOWERPOINT;
154 if (reg4)
156 Register4MsDoc(handle, reg4);
159 if (unreg4)
161 Unregister4MsDoc(handle, unreg4);
163 return ERROR_SUCCESS;
166 extern "C" UINT __stdcall DeinstallExecSequenceEntry(MSIHANDLE handle)
168 //MessageBox(NULL, TEXT("DeinstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
170 if (IsCompleteDeinstallation(handle))
172 Unregister4MsDocAll(handle);
173 return ERROR_SUCCESS;
176 if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")))
178 Unregister4MsDoc(handle, MSWORD | HTML_EDITOR);
181 if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")))
183 Unregister4MsDoc(handle, MSEXCEL);
186 if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")))
188 Unregister4MsDoc(handle, MSPOWERPOINT);
191 return ERROR_SUCCESS;