1*32b1fd08SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*32b1fd08SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*32b1fd08SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*32b1fd08SAndrew Rist * distributed with this work for additional information
6*32b1fd08SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*32b1fd08SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*32b1fd08SAndrew Rist * "License"); you may not use this file except in compliance
9*32b1fd08SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*32b1fd08SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*32b1fd08SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*32b1fd08SAndrew Rist * software distributed under the License is distributed on an
15*32b1fd08SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*32b1fd08SAndrew Rist * KIND, either express or implied. See the License for the
17*32b1fd08SAndrew Rist * specific language governing permissions and limitations
18*32b1fd08SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*32b1fd08SAndrew Rist *************************************************************/
21*32b1fd08SAndrew Rist
22*32b1fd08SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifdef _MSC_VER
25cdf0e10cSrcweir #pragma warning(push, 1) /* disable warnings within system headers */
26cdf0e10cSrcweir #endif
27cdf0e10cSrcweir #define WIN32_LEAN_AND_MEAN
28cdf0e10cSrcweir #include <windows.h>
29cdf0e10cSrcweir #include <msiquery.h>
30cdf0e10cSrcweir #ifdef _MSC_VER
31cdf0e10cSrcweir #pragma warning(pop)
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <tchar.h>
35cdf0e10cSrcweir #include "register.hxx"
36cdf0e10cSrcweir #include "msihelper.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <memory>
39cdf0e10cSrcweir #include <string>
40cdf0e10cSrcweir
41cdf0e10cSrcweir #define ELEMENTS_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
42cdf0e10cSrcweir
DetermineWordPreselectionState(MSIHANDLE handle)43cdf0e10cSrcweir void DetermineWordPreselectionState(MSIHANDLE handle)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir if (query_preselect_registration_for_ms_application(handle, MSWORD))
46cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_WORD"));
47cdf0e10cSrcweir }
48cdf0e10cSrcweir
DetermineExcelPreselectionState(MSIHANDLE handle)49cdf0e10cSrcweir void DetermineExcelPreselectionState(MSIHANDLE handle)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir if (query_preselect_registration_for_ms_application(handle, MSEXCEL))
52cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_EXCEL"));
53cdf0e10cSrcweir }
54cdf0e10cSrcweir
DeterminePowerPointPreselectionState(MSIHANDLE handle)55cdf0e10cSrcweir void DeterminePowerPointPreselectionState(MSIHANDLE handle)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir if (query_preselect_registration_for_ms_application(handle, MSPOWERPOINT))
58cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
InstallUiSequenceEntry(MSIHANDLE handle)61cdf0e10cSrcweir extern "C" UINT __stdcall InstallUiSequenceEntry(MSIHANDLE handle)
62cdf0e10cSrcweir {
63cdf0e10cSrcweir //MessageBox(NULL, TEXT("InstallUiSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
64cdf0e10cSrcweir
65cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin")))
66cdf0e10cSrcweir {
67cdf0e10cSrcweir DetermineWordPreselectionState(handle);
68cdf0e10cSrcweir }
69cdf0e10cSrcweir else if (IsModuleInstalled(handle, TEXT("gm_p_Wrt_Bin")) &&
70cdf0e10cSrcweir !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")) &&
71cdf0e10cSrcweir IsRegisteredFor(handle, MSWORD))
72cdf0e10cSrcweir {
73cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_WORD"));
74cdf0e10cSrcweir }
75cdf0e10cSrcweir else
76cdf0e10cSrcweir {
77cdf0e10cSrcweir UnsetMsiProp(handle, TEXT("SELECT_WORD"));
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
80cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Calc_Bin")))
81cdf0e10cSrcweir {
82cdf0e10cSrcweir DetermineExcelPreselectionState(handle);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir else if (IsModuleInstalled(handle, TEXT("gm_p_Calc_Bin")) &&
85cdf0e10cSrcweir !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")) &&
86cdf0e10cSrcweir IsRegisteredFor(handle, MSEXCEL))
87cdf0e10cSrcweir {
88cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_EXCEL"));
89cdf0e10cSrcweir }
90cdf0e10cSrcweir else
91cdf0e10cSrcweir {
92cdf0e10cSrcweir UnsetMsiProp(handle, TEXT("SELECT_EXCEL"));
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Impress_Bin")))
96cdf0e10cSrcweir {
97cdf0e10cSrcweir DeterminePowerPointPreselectionState(handle);
98cdf0e10cSrcweir }
99cdf0e10cSrcweir else if (IsModuleInstalled(handle, TEXT("gm_p_Impress_Bin")) &&
100cdf0e10cSrcweir !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")) &&
101cdf0e10cSrcweir IsRegisteredFor(handle, MSPOWERPOINT))
102cdf0e10cSrcweir {
103cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
104cdf0e10cSrcweir }
105cdf0e10cSrcweir else
106cdf0e10cSrcweir {
107cdf0e10cSrcweir UnsetMsiProp(handle, TEXT("SELECT_POWERPOINT"));
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
110cdf0e10cSrcweir SetMsiProp(handle, TEXT("UI_SEQUENCE_EXECUTED"));
111cdf0e10cSrcweir
112cdf0e10cSrcweir return ERROR_SUCCESS;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
InstallExecSequenceEntry(MSIHANDLE handle)115cdf0e10cSrcweir extern "C" UINT __stdcall InstallExecSequenceEntry(MSIHANDLE handle)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir //MessageBox(NULL, TEXT("InstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
118cdf0e10cSrcweir
119cdf0e10cSrcweir // Do nothing in repair mode.
120cdf0e10cSrcweir // Then UI_SEQUENCE_EXECUTED is not set and Installed is set!
121cdf0e10cSrcweir // In silent installation UI_SEQUENCE_EXECUTED is also not set, but Installed is not set.
122cdf0e10cSrcweir if ((!IsSetMsiProp(handle, TEXT("UI_SEQUENCE_EXECUTED"))) && (IsMsiPropNotEmpty(handle, TEXT("Installed")))) { return ERROR_SUCCESS; }
123cdf0e10cSrcweir
124cdf0e10cSrcweir int reg4 = 0;
125cdf0e10cSrcweir int unreg4 = 0;
126cdf0e10cSrcweir
127cdf0e10cSrcweir // we always register as html editor for Internet Explorer
128cdf0e10cSrcweir // if writer is installed because there's no harm if we do so
129cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin")))
130cdf0e10cSrcweir reg4 |= HTML_EDITOR;
131cdf0e10cSrcweir
132cdf0e10cSrcweir if (IsSetMsiProp(handle, TEXT("SELECT_WORD")) && !IsRegisteredFor(handle, MSWORD))
133cdf0e10cSrcweir reg4 |= MSWORD;
134cdf0e10cSrcweir else if (!IsSetMsiProp(handle, TEXT("SELECT_WORD")) && IsRegisteredFor(handle, MSWORD))
135cdf0e10cSrcweir unreg4 |= MSWORD;
136cdf0e10cSrcweir
137cdf0e10cSrcweir if (IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && !IsRegisteredFor(handle, MSEXCEL))
138cdf0e10cSrcweir reg4 |= MSEXCEL;
139cdf0e10cSrcweir else if (!IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && IsRegisteredFor(handle, MSEXCEL))
140cdf0e10cSrcweir unreg4 |= MSEXCEL;
141cdf0e10cSrcweir
142cdf0e10cSrcweir if (IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && !IsRegisteredFor(handle, MSPOWERPOINT))
143cdf0e10cSrcweir reg4 |= MSPOWERPOINT;
144cdf0e10cSrcweir else if (!IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && IsRegisteredFor(handle, MSPOWERPOINT))
145cdf0e10cSrcweir unreg4 |= MSPOWERPOINT;
146cdf0e10cSrcweir
147cdf0e10cSrcweir if (reg4)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir Register4MsDoc(handle, reg4);
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir if (unreg4)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir Unregister4MsDoc(handle, unreg4);
155cdf0e10cSrcweir }
156cdf0e10cSrcweir return ERROR_SUCCESS;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
DeinstallExecSequenceEntry(MSIHANDLE handle)159cdf0e10cSrcweir extern "C" UINT __stdcall DeinstallExecSequenceEntry(MSIHANDLE handle)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir //MessageBox(NULL, TEXT("DeinstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION);
162cdf0e10cSrcweir
163cdf0e10cSrcweir if (IsCompleteDeinstallation(handle))
164cdf0e10cSrcweir {
165cdf0e10cSrcweir Unregister4MsDocAll(handle);
166cdf0e10cSrcweir return ERROR_SUCCESS;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")))
170cdf0e10cSrcweir {
171cdf0e10cSrcweir Unregister4MsDoc(handle, MSWORD | HTML_EDITOR);
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")))
175cdf0e10cSrcweir {
176cdf0e10cSrcweir Unregister4MsDoc(handle, MSEXCEL);
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")))
180cdf0e10cSrcweir {
181cdf0e10cSrcweir Unregister4MsDoc(handle, MSPOWERPOINT);
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir return ERROR_SUCCESS;
185cdf0e10cSrcweir }
186