diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-04-13 15:58:42 +0200 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-04-13 15:58:42 +0200 |
commit | 0f83354b7c1119e3968ca85e9e5f1c4b10c3b215 (patch) | |
tree | c54f81a0f554bbf76083b92fdf047aee9e5bf4b1 /setup_native | |
parent | af1645d6a2c02dadfe212e030ad1ddcad9f17cae (diff) | |
parent | 6b93b84e641f6e0b6f446a45045ef93ec258c31f (diff) |
CWS-TOOLING: integrate CWS installer10
Diffstat (limited to 'setup_native')
-rw-r--r-- | setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp | 2 | ||||
-rw-r--r-- | setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx | 213 |
2 files changed, 198 insertions, 17 deletions
diff --git a/setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp b/setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp index 364ebc705df8..566981ba569e 100644 --- a/setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp +++ b/setup_native/source/win32/customactions/reg4allmsdoc/exports.dxp @@ -1 +1,3 @@ FindRegisteredExtensions +LookForRegisteredExtensions +RegisterSomeExtensions
\ No newline at end of file diff --git a/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx b/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx index 1be921ca5846..3aba597098fb 100644 --- a/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx +++ b/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx @@ -68,6 +68,11 @@ static const CHAR* g_Extensions[] = 0 }; +static const int WORD_START = 0; +static const int EXCEL_START = 7; +static const int POWERPOINT_START = 15; +static const int POWERPOINT_END = 23; + // ".xlam", // Office Excel 2007 XML macro-enabled add-in // ".ppam", // Office PowerPoint 2007 macro-enabled XML add-in // ".ppsm", // Office PowerPoint 2007 macro-enabled XML show @@ -90,15 +95,6 @@ static inline void OutputDebugStringFormat( LPCSTR, ... ) #endif //---------------------------------------------------------- -static bool IsModuleSelectedForInstallation( MSIHANDLE handle, LPCTSTR name ) -{ - INSTALLSTATE current_state; - INSTALLSTATE future_state; - MsiGetFeatureState(handle, name, ¤t_state, &future_state); - return (future_state == INSTALLSTATE_LOCAL); -} - -//---------------------------------------------------------- static BOOL CheckExtensionInRegistry( LPCSTR lpSubKey ) { BOOL bRet = false; @@ -264,6 +260,23 @@ bool IsSetMsiProp( MSIHANDLE handle, LPCSTR name ) } //---------------------------------------------------------- +static void registerForExtension( MSIHANDLE handle, const int nIndex, bool bRegister ) +{ + CHAR sPropName[256]; + StringCchCopyA( sPropName, 256, "REGISTER_" ); + StringCchCatA( sPropName, 256, (g_Extensions[nIndex])+1 ); + CharUpperBuffA( sPropName+9, 4 ); + + if ( bRegister ) { + MsiSetPropertyA( handle, sPropName, "1" ); + OutputDebugStringFormat( "Set MSI property %s.\n", sPropName ); + } else { + MsiSetPropertyA( handle, sPropName, "0" ); + OutputDebugStringFormat( "Unset MSI property %s.\n", sPropName ); + } +} + +//---------------------------------------------------------- static void registerForExtensions( MSIHANDLE handle, BOOL bRegisterAll ) { // Check all file extensions int nIndex = 0; @@ -271,23 +284,180 @@ static void registerForExtensions( MSIHANDLE handle, BOOL bRegisterAll ) { BOOL bRegister = bRegisterAll || CheckExtensionInRegistry( g_Extensions[nIndex] ); if ( bRegister ) - { - CHAR sPropName[256]; - StringCchCopyA( sPropName, 256, "REGISTER_" ); - StringCchCatA( sPropName, 256, (g_Extensions[nIndex])+1 ); - CharUpperBuffA( sPropName+9, 4 ); - MsiSetPropertyA( handle, sPropName, "1" ); - OutputDebugStringFormat( "Set MSI property %s.\n", sPropName ); - } + registerForExtension( handle, nIndex, true ); + ++nIndex; + } +} + +//---------------------------------------------------------- +static bool checkSomeExtensionInRegistry( const int nStart, const int nEnd ) +{ // Check all file extensions + int nIndex = nStart; + bool bFound = false; + + while ( !bFound && ( g_Extensions[nIndex] != 0 ) && ( nIndex < nEnd ) ) + { + bFound = ! CheckExtensionInRegistry( g_Extensions[nIndex] ); + + if ( bFound ) + OutputDebugStringFormat( "Found registration for [%s].\n", g_Extensions[nIndex] ); + ++nIndex; } + return bFound; } //---------------------------------------------------------- +static void registerSomeExtensions( MSIHANDLE handle, const int nStart, const int nEnd, bool bRegister ) +{ // Check all file extensions + int nIndex = nStart; + + while ( ( g_Extensions[nIndex] != 0 ) && ( nIndex < nEnd ) ) + { + registerForExtension( handle, nIndex++, bRegister ); + } +} + //---------------------------------------------------------- //---------------------------------------------------------- +//---------------------------------------------------------- +extern "C" UINT __stdcall LookForRegisteredExtensions( MSIHANDLE handle ) +{ + OutputDebugStringFormat( "LookForRegisteredExtensions: " ); + + INSTALLSTATE current_state; + INSTALLSTATE future_state; + + bool bWriterEnabled = false; + bool bCalcEnabled = false; + bool bImpressEnabled = false; + bool bRegisterNone = IsSetMsiProp( handle, "REGISTER_NO_MSO_TYPES" ); + + if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Wrt", ¤t_state, &future_state ) ) && + ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) ) + bWriterEnabled = true; + + OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Writer is [%d], will be [%d]", current_state, future_state ); + if ( bWriterEnabled ) + OutputDebugStringFormat( "LookForRegisteredExtensions: Writer is enabled" ); + else + OutputDebugStringFormat( "LookForRegisteredExtensions: Writer is NOT enabled" ); + + if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Calc", ¤t_state, &future_state ) ) && + ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) ) + bCalcEnabled = true; + + OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Calc is [%d], will be [%d]", current_state, future_state ); + if ( bCalcEnabled ) + OutputDebugStringFormat( "LookForRegisteredExtensions: Calc is enabled" ); + else + OutputDebugStringFormat( "LookForRegisteredExtensions: Calc is NOT enabled" ); + + if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Impress", ¤t_state, &future_state ) ) && + ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) ) + bImpressEnabled = true; + + OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Impress is [%d], will be [%d]", current_state, future_state ); + if ( bImpressEnabled ) + OutputDebugStringFormat( "LookForRegisteredExtensions: Impress is enabled" ); + else + OutputDebugStringFormat( "LookForRegisteredExtensions: Impress is NOT enabled" ); + + MsiSetPropertyA( handle, "SELECT_WORD", "" ); + MsiSetPropertyA( handle, "SELECT_EXCEL", "" ); + MsiSetPropertyA( handle, "SELECT_POWERPOINT", "" ); + + if ( ! bRegisterNone ) + { + if ( IsSetMsiProp( handle, "REGISTER_ALL_MSO_TYPES" ) ) + { + if ( bWriterEnabled ) + MsiSetPropertyA( handle, "SELECT_WORD", "1" ); + if ( bCalcEnabled ) + MsiSetPropertyA( handle, "SELECT_EXCEL", "1" ); + if ( bImpressEnabled ) + MsiSetPropertyA( handle, "SELECT_POWERPOINT", "1" ); + } + else + { + if ( bWriterEnabled && ! checkSomeExtensionInRegistry( WORD_START, EXCEL_START ) ) + { + MsiSetPropertyA( handle, "SELECT_WORD", "1" ); + OutputDebugStringFormat( "LookForRegisteredExtensions: Register for MicroSoft Word" ); + } + if ( bCalcEnabled && ! checkSomeExtensionInRegistry( EXCEL_START, POWERPOINT_START ) ) + { + MsiSetPropertyA( handle, "SELECT_EXCEL", "1" ); + OutputDebugStringFormat( "LookForRegisteredExtensions: Register for MicroSoft Excel" ); + } + if ( bImpressEnabled && ! checkSomeExtensionInRegistry( POWERPOINT_START, POWERPOINT_END ) ) + { + MsiSetPropertyA( handle, "SELECT_POWERPOINT", "1" ); + OutputDebugStringFormat( "LookForRegisteredExtensions: Register for MicroSoft PowerPoint" ); + } + } + } + + MsiSetPropertyA( handle, "FILETYPEDIALOGUSED", "1" ); + + return ERROR_SUCCESS; +} + +//---------------------------------------------------------- +extern "C" UINT __stdcall RegisterSomeExtensions( MSIHANDLE handle ) +{ + OutputDebugStringFormat( "RegisterSomeExtensions: " ); + + if ( IsSetMsiProp( handle, "SELECT_WORD" ) ) + { + registerSomeExtensions( handle, WORD_START, EXCEL_START, true ); + MsiSetFeatureState( handle, L"gm_p_Wrt_MSO_Reg", INSTALLSTATE_LOCAL ); + OutputDebugStringFormat( "RegisterSomeExtensions: Register for MicroSoft Word" ); + } + else + { + registerSomeExtensions( handle, WORD_START, EXCEL_START, false ); + MsiSetFeatureState( handle, L"gm_p_Wrt_MSO_Reg", INSTALLSTATE_ABSENT ); + } + + if ( IsSetMsiProp( handle, "SELECT_EXCEL" ) ) + { + registerSomeExtensions( handle, EXCEL_START, POWERPOINT_START, true ); + MsiSetFeatureState( handle, L"gm_p_Calc_MSO_Reg", INSTALLSTATE_LOCAL ); + OutputDebugStringFormat( "RegisterSomeExtensions: Register for MicroSoft Excel" ); + } + else + { + registerSomeExtensions( handle, EXCEL_START, POWERPOINT_START, false ); + MsiSetFeatureState( handle, L"gm_p_Calc_MSO_Reg", INSTALLSTATE_ABSENT ); + } + + if ( IsSetMsiProp( handle, "SELECT_POWERPOINT" ) ) + { + registerSomeExtensions( handle, POWERPOINT_START, POWERPOINT_END, true ); + MsiSetFeatureState( handle, L"gm_p_Impress_MSO_Reg", INSTALLSTATE_LOCAL ); + OutputDebugStringFormat( "RegisterSomeExtensions: Register for MicroSoft PowerPoint" ); + } + else + { + registerSomeExtensions( handle, POWERPOINT_START, POWERPOINT_END, false ); + MsiSetFeatureState( handle, L"gm_p_Impress_MSO_Reg", INSTALLSTATE_ABSENT ); + } + + return ERROR_SUCCESS; +} + +//---------------------------------------------------------- extern "C" UINT __stdcall FindRegisteredExtensions( MSIHANDLE handle ) { + if ( IsSetMsiProp( handle, "FILETYPEDIALOGUSED" ) ) + { + OutputDebugStringFormat( "FindRegisteredExtensions: FILETYPEDIALOGUSED!" ); + return ERROR_SUCCESS; + } + + OutputDebugStringFormat( "FindRegisteredExtensions:" ); + bool bRegisterAll = IsSetMsiProp( handle, "REGISTER_ALL_MSO_TYPES" ); if ( IsSetMsiProp( handle, "REGISTER_NO_MSO_TYPES" ) ) @@ -300,6 +470,15 @@ extern "C" UINT __stdcall FindRegisteredExtensions( MSIHANDLE handle ) else OutputDebugStringFormat( "FindRegisteredExtensions: " ); + // setting the msi properties SELECT_* will force registering for all corresponding + // file types + if ( IsSetMsiProp( handle, "SELECT_WORD" ) ) + registerSomeExtensions( handle, WORD_START, EXCEL_START, true ); + if ( IsSetMsiProp( handle, "SELECT_EXCEL" ) ) + registerSomeExtensions( handle, EXCEL_START, POWERPOINT_START, true ); + if ( IsSetMsiProp( handle, "SELECT_POWERPOINT" ) ) + registerSomeExtensions( handle, POWERPOINT_START, POWERPOINT_END, true ); + registerForExtensions( handle, bRegisterAll ); return ERROR_SUCCESS; |