diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2008-08-27 10:16:06 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2008-08-27 10:16:06 +0000 |
commit | ed7ffacb002190f78b3d174d775500c46d76b0ab (patch) | |
tree | 407068d7d8efadcb99d43f783a8d3f8f2177914b | |
parent | f1b8efb400450d895e55253c969011df43278e6b (diff) |
INTEGRATION: CWS native184_DEV300 (1.4.24); FILE MERGED
2008/08/12 09:04:39 is 1.4.24.1: #i92654# change encoding of link content
-rw-r--r-- | setup_native/source/win32/customactions/shellextensions/layerlinks.cxx | 94 |
1 files changed, 71 insertions, 23 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx b/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx index 6c8c6cc6a..c1635da07 100644 --- a/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx +++ b/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx @@ -1,13 +1,13 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: layerlinks.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.5 $ * * This file is part of OpenOffice.org. * @@ -54,7 +54,7 @@ using namespace std; -namespace +namespace { string GetMsiProperty(MSIHANDLE handle, const string& sProperty) { @@ -97,7 +97,7 @@ namespace } } } -} // namespace +} // namespace extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) { @@ -107,7 +107,7 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) string sBasisLinkPath = sOfficeInstallPath + TEXT("basis-link"); string sUreLinkPath = sBasisInstallPath + TEXT("ure-link"); - + if ( IsSetMsiProperty(handle, TEXT("ADMININSTALL")) ) { string sOooBaseVersion = GetMsiProperty(handle, TEXT("OOOBASEVERSION")); @@ -118,7 +118,7 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) } else { - sBasisInstallPath = TEXT("..\\") + sBasisRootName + TEXT("\\Basis ") + sOooBaseVersion; + sBasisInstallPath = TEXT("..\\") + sBasisRootName + TEXT("\\Basis ") + sOooBaseVersion; } sUreInstallPath = TEXT("..\\URE"); } @@ -132,7 +132,7 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) // MessageBox(NULL, myText2.c_str(), "DEBUG", MB_OK); // creating basis-link in brand layer - + HANDLE h1file = CreateFile( sBasisLinkPath.c_str(), GENERIC_WRITE, @@ -141,16 +141,40 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - + if (IsValidHandle(h1file)) { DWORD dummy; - WriteFile( h1file, sBasisInstallPath.c_str(), sBasisInstallPath.size() ,&dummy, 0 ); - CloseHandle(h1file); - } + + // Converting string into UTF-8 encoding and writing into file "basis-link" + + int nCharsRequired = MultiByteToWideChar( CP_ACP, 0, sBasisInstallPath.c_str(), -1, NULL, 0 ); + if ( nCharsRequired ) + { + LPWSTR lpPathW = new WCHAR[nCharsRequired]; + if ( MultiByteToWideChar( CP_ACP, 0, sBasisInstallPath.c_str(), -1, lpPathW, nCharsRequired ) ) + { + nCharsRequired = WideCharToMultiByte( CP_UTF8, 0, lpPathW, -1, NULL, 0, NULL, NULL ); + if ( nCharsRequired ) + { + LPSTR lpPathUTF8 = new CHAR[nCharsRequired]; + WideCharToMultiByte( CP_UTF8, 0, lpPathW, -1, lpPathUTF8, nCharsRequired, NULL, NULL ); + + // WriteFile( h1file, sBasisInstallPath.c_str(), sBasisInstallPath.size() ,&dummy, 0 ); + WriteFile( h1file, lpPathUTF8, strlen(lpPathUTF8) ,&dummy, 0 ); + + delete lpPathUTF8; + } + } + + delete lpPathW; + } + + CloseHandle(h1file); + } // creating ure-link in basis layer - + HANDLE h2file = CreateFile( sUreLinkPath.c_str(), GENERIC_WRITE, @@ -159,15 +183,39 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - + if (IsValidHandle(h2file)) { DWORD dummy; - WriteFile( h2file, sUreInstallPath.c_str(), sUreInstallPath.size() ,&dummy, 0 ); - CloseHandle(h2file); - } - - return ERROR_SUCCESS; + + // Converting string into UTF-8 encoding and writing into file "basis-link" + + int nCharsRequired = MultiByteToWideChar( CP_ACP, 0, sUreInstallPath.c_str(), -1, NULL, 0 ); + if ( nCharsRequired ) + { + LPWSTR lpPathW = new WCHAR[nCharsRequired]; + if ( MultiByteToWideChar( CP_ACP, 0, sUreInstallPath.c_str(), -1, lpPathW, nCharsRequired ) ) + { + nCharsRequired = WideCharToMultiByte( CP_UTF8, 0, lpPathW, -1, NULL, 0, NULL, NULL ); + if ( nCharsRequired ) + { + LPSTR lpPathUTF8 = new CHAR[nCharsRequired]; + WideCharToMultiByte( CP_UTF8, 0, lpPathW, -1, lpPathUTF8, nCharsRequired, NULL, NULL ); + + // WriteFile( h2file, sUreInstallPath.c_str(), sUreInstallPath.size() ,&dummy, 0 ); + WriteFile( h2file, lpPathUTF8, strlen(lpPathUTF8) ,&dummy, 0 ); + + delete lpPathUTF8; + } + } + + delete lpPathW; + } + + CloseHandle(h2file); + } + + return ERROR_SUCCESS; } extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle) @@ -182,8 +230,8 @@ extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle) // string myText2 = TEXT("Deleting Ure-Link: ") + sUreLinkPath; // MessageBox(NULL, myText2.c_str(), "DEBUG", MB_OK); - - // Deleting link to basis layer + + // Deleting link to basis layer // string myText1 = TEXT("Deleting Basis-Link: ") + sBasisLinkPath; // MessageBox(NULL, myText1.c_str(), "DEBUG", MB_OK); DeleteFile(sBasisLinkPath.c_str()); @@ -203,7 +251,7 @@ extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle) // MessageBox(NULL, myText4.c_str(), "DEBUG", MB_OK); // } - // Deleting link to URE layer, if URE dir no longer exists + // Deleting link to URE layer, if URE dir no longer exists if ( ! ureDirExists ) { // string myText5 = TEXT("URE directory does not exist: ") + sUreDirName; @@ -212,6 +260,6 @@ extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle) // string myText6 = TEXT("URE link removed: ") + sUreLinkPath; // MessageBox(NULL, myText6.c_str(), "DEBUG", MB_OK); } - + return ERROR_SUCCESS; -} +} |