1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifdef _MSC_VER 29*cdf0e10cSrcweir #pragma warning(push, 1) /* disable warnings within system headers */ 30*cdf0e10cSrcweir #endif 31*cdf0e10cSrcweir #define WIN32_LEAN_AND_MEAN 32*cdf0e10cSrcweir #include <windows.h> 33*cdf0e10cSrcweir #include <msiquery.h> 34*cdf0e10cSrcweir #ifdef _MSC_VER 35*cdf0e10cSrcweir #pragma warning(pop) 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <tchar.h> 39*cdf0e10cSrcweir #include "register.hxx" 40*cdf0e10cSrcweir #include "msihelper.hxx" 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <memory> 43*cdf0e10cSrcweir #include <string> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #define ELEMENTS_OF_ARRAY(a) (sizeof(a)/sizeof(a[0])) 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir void DetermineWordPreselectionState(MSIHANDLE handle) 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir if (query_preselect_registration_for_ms_application(handle, MSWORD)) 50*cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_WORD")); 51*cdf0e10cSrcweir } 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir void DetermineExcelPreselectionState(MSIHANDLE handle) 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir if (query_preselect_registration_for_ms_application(handle, MSEXCEL)) 56*cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_EXCEL")); 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir void DeterminePowerPointPreselectionState(MSIHANDLE handle) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir if (query_preselect_registration_for_ms_application(handle, MSPOWERPOINT)) 62*cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_POWERPOINT")); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir extern "C" UINT __stdcall InstallUiSequenceEntry(MSIHANDLE handle) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir //MessageBox(NULL, TEXT("InstallUiSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin"))) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir DetermineWordPreselectionState(handle); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir else if (IsModuleInstalled(handle, TEXT("gm_p_Wrt_Bin")) && 74*cdf0e10cSrcweir !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin")) && 75*cdf0e10cSrcweir IsRegisteredFor(handle, MSWORD)) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_WORD")); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir else 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir UnsetMsiProp(handle, TEXT("SELECT_WORD")); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Calc_Bin"))) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir DetermineExcelPreselectionState(handle); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir else if (IsModuleInstalled(handle, TEXT("gm_p_Calc_Bin")) && 89*cdf0e10cSrcweir !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin")) && 90*cdf0e10cSrcweir IsRegisteredFor(handle, MSEXCEL)) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_EXCEL")); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir else 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir UnsetMsiProp(handle, TEXT("SELECT_EXCEL")); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Impress_Bin"))) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir DeterminePowerPointPreselectionState(handle); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir else if (IsModuleInstalled(handle, TEXT("gm_p_Impress_Bin")) && 104*cdf0e10cSrcweir !IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin")) && 105*cdf0e10cSrcweir IsRegisteredFor(handle, MSPOWERPOINT)) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir SetMsiProp(handle, TEXT("SELECT_POWERPOINT")); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir UnsetMsiProp(handle, TEXT("SELECT_POWERPOINT")); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir SetMsiProp(handle, TEXT("UI_SEQUENCE_EXECUTED")); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir return ERROR_SUCCESS; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir extern "C" UINT __stdcall InstallExecSequenceEntry(MSIHANDLE handle) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir //MessageBox(NULL, TEXT("InstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // Do nothing in repair mode. 124*cdf0e10cSrcweir // Then UI_SEQUENCE_EXECUTED is not set and Installed is set! 125*cdf0e10cSrcweir // In silent installation UI_SEQUENCE_EXECUTED is also not set, but Installed is not set. 126*cdf0e10cSrcweir if ((!IsSetMsiProp(handle, TEXT("UI_SEQUENCE_EXECUTED"))) && (IsMsiPropNotEmpty(handle, TEXT("Installed")))) { return ERROR_SUCCESS; } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir int reg4 = 0; 129*cdf0e10cSrcweir int unreg4 = 0; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir // we always register as html editor for Internet Explorer 132*cdf0e10cSrcweir // if writer is installed because there's no harm if we do so 133*cdf0e10cSrcweir if (IsModuleSelectedForInstallation(handle, TEXT("gm_p_Wrt_Bin"))) 134*cdf0e10cSrcweir reg4 |= HTML_EDITOR; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if (IsSetMsiProp(handle, TEXT("SELECT_WORD")) && !IsRegisteredFor(handle, MSWORD)) 137*cdf0e10cSrcweir reg4 |= MSWORD; 138*cdf0e10cSrcweir else if (!IsSetMsiProp(handle, TEXT("SELECT_WORD")) && IsRegisteredFor(handle, MSWORD)) 139*cdf0e10cSrcweir unreg4 |= MSWORD; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir if (IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && !IsRegisteredFor(handle, MSEXCEL)) 142*cdf0e10cSrcweir reg4 |= MSEXCEL; 143*cdf0e10cSrcweir else if (!IsSetMsiProp(handle, TEXT("SELECT_EXCEL")) && IsRegisteredFor(handle, MSEXCEL)) 144*cdf0e10cSrcweir unreg4 |= MSEXCEL; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if (IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && !IsRegisteredFor(handle, MSPOWERPOINT)) 147*cdf0e10cSrcweir reg4 |= MSPOWERPOINT; 148*cdf0e10cSrcweir else if (!IsSetMsiProp(handle, TEXT("SELECT_POWERPOINT")) && IsRegisteredFor(handle, MSPOWERPOINT)) 149*cdf0e10cSrcweir unreg4 |= MSPOWERPOINT; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir if (reg4) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir Register4MsDoc(handle, reg4); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir if (unreg4) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir Unregister4MsDoc(handle, unreg4); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir return ERROR_SUCCESS; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir extern "C" UINT __stdcall DeinstallExecSequenceEntry(MSIHANDLE handle) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir //MessageBox(NULL, TEXT("DeinstallExecSequenceEntry"), TEXT("Information"), MB_OK | MB_ICONINFORMATION); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if (IsCompleteDeinstallation(handle)) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir Unregister4MsDocAll(handle); 170*cdf0e10cSrcweir return ERROR_SUCCESS; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Wrt_Bin"))) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir Unregister4MsDoc(handle, MSWORD | HTML_EDITOR); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Calc_Bin"))) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir Unregister4MsDoc(handle, MSEXCEL); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir if (IsModuleSelectedForDeinstallation(handle, TEXT("gm_p_Impress_Bin"))) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir Unregister4MsDoc(handle, MSPOWERPOINT); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir return ERROR_SUCCESS; 189*cdf0e10cSrcweir } 190