1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: reg4msdocmsi.cxx,v $
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 ************************************************************************/
32 #pragma warning(push, 1) /* disable warnings within system headers */
34 #define WIN32_LEAN_AND_MEAN
42 #include "register.hxx"
43 #include "msihelper.hxx"
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"));
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"));
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"));
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
; }
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")))
139 if (IsSetMsiProp(handle
, TEXT("SELECT_WORD")) && !IsRegisteredFor(handle
, MSWORD
))
141 else if (!IsSetMsiProp(handle
, TEXT("SELECT_WORD")) && IsRegisteredFor(handle
, MSWORD
))
144 if (IsSetMsiProp(handle
, TEXT("SELECT_EXCEL")) && !IsRegisteredFor(handle
, MSEXCEL
))
146 else if (!IsSetMsiProp(handle
, TEXT("SELECT_EXCEL")) && IsRegisteredFor(handle
, 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
;
156 Register4MsDoc(handle
, reg4
);
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
;