summaryrefslogtreecommitdiff
path: root/setup_native/source/win32/customactions/languagepacks
diff options
context:
space:
mode:
Diffstat (limited to 'setup_native/source/win32/customactions/languagepacks')
-rwxr-xr-xsetup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx64
-rw-r--r--setup_native/source/win32/customactions/languagepacks/exports.dxp2
-rw-r--r--setup_native/source/win32/customactions/languagepacks/lngpckinsthelper.cxx122
-rw-r--r--setup_native/source/win32/customactions/languagepacks/makefile.mk1
-rw-r--r--setup_native/source/win32/customactions/languagepacks/respintest.cxx40
5 files changed, 116 insertions, 113 deletions
diff --git a/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx b/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
index 9a933eea0334..3db87d3899c8 100755
--- a/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
+++ b/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -42,9 +42,9 @@
#ifdef UNICODE
#define _UNICODE
-#define _tstring wstring
+#define _tstring wstring
#else
-#define _tstring string
+#define _tstring string
#endif
#include <tchar.h>
#include <string>
@@ -54,14 +54,14 @@
#include <systools/win32/uwinapi.h>
#include <../tools/seterror.hxx>
-#define WININIT_FILENAME "wininit.ini"
-#define RENAME_SECTION "rename"
+#define WININIT_FILENAME "wininit.ini"
+#define RENAME_SECTION "rename"
#ifdef DEBUG
inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
{
- _TCHAR buffer[1024];
- va_list args;
+ _TCHAR buffer[1024];
+ va_list args;
va_start( args, pFormat );
_vsntprintf( buffer, elementsof(buffer), pFormat, args );
@@ -75,9 +75,9 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
{
- std::_tstring result;
- TCHAR szDummy[1] = TEXT("");
- DWORD nChars = 0;
+ std::_tstring result;
+ TCHAR szDummy[1] = TEXT("");
+ DWORD nChars = 0;
if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
{
@@ -85,14 +85,14 @@ static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sPro
LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
ZeroMemory( buffer, nBytes );
MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
- result = buffer;
+ result = buffer;
}
- return result;
+ return result;
}
-
+
static inline bool IsSetMsiProperty(MSIHANDLE handle, const std::_tstring& sProperty)
-{
+{
std::_tstring value = GetMsiProperty(handle, sProperty);
return (value.length() > 0);
}
@@ -109,30 +109,30 @@ static inline void SetMsiProperty(MSIHANDLE handle, const std::_tstring& sProper
static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWORD dwFlags )
{
- BOOL fSuccess = FALSE; // assume failure
+ BOOL fSuccess = FALSE; // assume failure
// Windows 9x has a special mechanism to move files after reboot
if ( dwFlags & MOVEFILE_DELAY_UNTIL_REBOOT )
{
- CHAR szExistingFileNameA[MAX_PATH];
- CHAR szNewFileNameA[MAX_PATH] = "NUL";
+ CHAR szExistingFileNameA[MAX_PATH];
+ CHAR szNewFileNameA[MAX_PATH] = "NUL";
// Path names in WININIT.INI must be in short path name form
- if (
+ if (
GetShortPathNameA( lpExistingFileNameA, szExistingFileNameA, MAX_PATH ) &&
(!lpNewFileNameA || GetShortPathNameA( lpNewFileNameA, szNewFileNameA, MAX_PATH ))
)
{
- CHAR szBuffer[32767]; // The buffer size must not exceed 32K
- DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer, elementsof(szBuffer), WININIT_FILENAME );
+ CHAR szBuffer[32767]; // The buffer size must not exceed 32K
+ DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer, elementsof(szBuffer), WININIT_FILENAME );
- CHAR szRename[MAX_PATH]; // This is enough for at most to times 67 chracters
+ CHAR szRename[MAX_PATH]; // This is enough for at most to times 67 chracters
strcpy( szRename, szNewFileNameA );
strcat( szRename, "=" );
strcat( szRename, szExistingFileNameA );
- size_t lnRename = strlen(szRename);
+ size_t lnRename = strlen(szRename);
if ( dwBufLen + lnRename + 2 <= elementsof(szBuffer) )
{
@@ -154,7 +154,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
if ( !fSuccess && GetLastError() != ERROR_ACCESS_DENIED &&
0 != (dwFlags & (MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) )
{
- BOOL bFailIfExist = 0 == (dwFlags & MOVEFILE_REPLACE_EXISTING);
+ BOOL bFailIfExist = 0 == (dwFlags & MOVEFILE_REPLACE_EXISTING);
fSuccess = CopyFileA( lpExistingFileNameA, lpNewFileNameA, bFailIfExist );
@@ -177,22 +177,22 @@ static BOOL MoveFileExImpl( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, D
extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle )
{
- std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
- std::_tstring sResourceDir = sInstDir + TEXT("Basis\\program\\resource\\");
- std::_tstring sPattern = sResourceDir + TEXT("vcl*.res");
+ std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
+ std::_tstring sResourceDir = sInstDir + TEXT("Basis\\program\\resource\\");
+ std::_tstring sPattern = sResourceDir + TEXT("vcl*.res");
- WIN32_FIND_DATA aFindFileData;
- HANDLE hFind = FindFirstFile( sPattern.c_str(), &aFindFileData );
+ WIN32_FIND_DATA aFindFileData;
+ HANDLE hFind = FindFirstFile( sPattern.c_str(), &aFindFileData );
if ( IsValidHandle(hFind) )
{
- BOOL fSuccess = false;
- bool fRenameSucceeded;
+ BOOL fSuccess = false;
+ bool fRenameSucceeded;
do
{
- std::_tstring sResourceFile = sResourceDir + aFindFileData.cFileName;
- std::_tstring sIntermediate = sResourceFile + TEXT(".tmp");
+ std::_tstring sResourceFile = sResourceDir + aFindFileData.cFileName;
+ std::_tstring sIntermediate = sResourceFile + TEXT(".tmp");
fRenameSucceeded = MoveFileExImpl( sResourceFile.c_str(), sIntermediate.c_str(), MOVEFILE_REPLACE_EXISTING );
if ( fRenameSucceeded )
diff --git a/setup_native/source/win32/customactions/languagepacks/exports.dxp b/setup_native/source/win32/customactions/languagepacks/exports.dxp
index d01befd5d0d9..c098a38d547f 100644
--- a/setup_native/source/win32/customactions/languagepacks/exports.dxp
+++ b/setup_native/source/win32/customactions/languagepacks/exports.dxp
@@ -2,3 +2,5 @@ SetProductInstallationPath
RegisterLanguagePack
GetUserInstallMode
IsOfficeRunning
+RegisterExtensions
+
diff --git a/setup_native/source/win32/customactions/languagepacks/lngpckinsthelper.cxx b/setup_native/source/win32/customactions/languagepacks/lngpckinsthelper.cxx
index d3a6c81b59ed..c802c8964944 100644
--- a/setup_native/source/win32/customactions/languagepacks/lngpckinsthelper.cxx
+++ b/setup_native/source/win32/customactions/languagepacks/lngpckinsthelper.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -24,7 +24,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
#ifdef _MSC_VER
#pragma warning(push, 1) /* disable warnings within system headers */
#endif
@@ -43,92 +43,92 @@
class RegistryKeyGuard
{
-public:
+public:
RegistryKeyGuard(HKEY hkey = 0) :
hkey_(hkey)
{
}
-
+
~RegistryKeyGuard()
{
if (hkey_)
RegCloseKey(hkey_);
- }
+ }
private:
HKEY hkey_;
private:
RegistryKeyGuard(const RegistryKeyGuard&);
- RegistryKeyGuard& operator=(const RegistryKeyGuard&);
+ RegistryKeyGuard& operator=(const RegistryKeyGuard&);
};
typedef std::vector<TCHAR> CharacterBuffer_t;
/* throws std::runtime_error when the value "Path" could
- not be found or contains an empty string or is not of
- type REG_SZ. All such conditions are invalid for a
+ not be found or contains an empty string or is not of
+ type REG_SZ. All such conditions are invalid for a
properly installed product. */
-std::string FindProductInstallationPath(HKEY hkey)
-{
+std::string FindProductInstallationPath(HKEY hkey)
+{
DWORD nSubKeys;
DWORD lLongestSubKey;
-
- if (RegQueryInfoKey(hkey, NULL, NULL, NULL, &nSubKeys, &lLongestSubKey, NULL, NULL, NULL, NULL, NULL, NULL) !=
+
+ if (RegQueryInfoKey(hkey, NULL, NULL, NULL, &nSubKeys, &lLongestSubKey, NULL, NULL, NULL, NULL, NULL, NULL) !=
ERROR_SUCCESS)
throw std::runtime_error("Cannot query info for registery key");
-
+
CharacterBuffer_t buff(lLongestSubKey + 1);
-
+
for (DWORD i = 0; i < nSubKeys; i++)
{
buff[0] = 0;
LONG ret = RegEnumKey(hkey, i, &buff[0], buff.size());
-
+
if ((ret != ERROR_SUCCESS) && (ret != ERROR_MORE_DATA))
throw std::runtime_error("Error enumerating registry key");
-
+
HKEY hSubKey;
- if (RegOpenKey(hkey, &buff[0], &hSubKey) != ERROR_SUCCESS)
- continue;
-
+ if (RegOpenKey(hkey, &buff[0], &hSubKey) != ERROR_SUCCESS)
+ continue;
+
RegistryKeyGuard guard(hSubKey);
-
+
DWORD type;
TCHAR pbuff[MAX_PATH];
DWORD size = sizeof(pbuff);
if ((RegQueryValueEx(
hSubKey, TEXT("Path"), NULL, &type, reinterpret_cast<LPBYTE>(pbuff), &size) != ERROR_SUCCESS) ||
- (type != REG_SZ))
+ (type != REG_SZ))
continue;
-
- std::string path(pbuff);
+
+ std::string path(pbuff);
std::string::size_type idx = path.rfind("program\\soffice.exe");
- if (idx != std::string::npos)
- return path.substr(0, idx);
- } // for
-
- throw std::runtime_error("No valid product path found");
+ if (idx != std::string::npos)
+ return path.substr(0, idx);
+ } // for
+
+ throw std::runtime_error("No valid product path found");
}
UINT GetInstallProperty(MSIHANDLE handle, LPCTSTR name, CharacterBuffer_t* buffer)
-{
+{
DWORD size = buffer->size();
UINT ret = MsiGetProperty(handle, name, &(*buffer)[0], &size);
-
+
if (ret == ERROR_MORE_DATA)
{
buffer->resize(size + 1);
size = buffer->size();
ret = MsiGetProperty(handle, name, &(*buffer)[0], &size);
- }
+ }
return ret;
}
-/*
+/*
Try to find the installation path to an already installed product.
The installation path will be written in the Windows registry
- during the installation. There may exist different products in
- parallel e.g. StarOffice, StarSuite, OpenOffice.org. It will be
+ during the installation. There may exist different products in
+ parallel e.g. StarOffice, StarSuite, OpenOffice.org. It will be
searched in this order for an installed product. If a product
will be found the path to the product will be set in the property
"INSTALLLOCATION" else nothing will be done.
@@ -136,37 +136,37 @@ UINT GetInstallProperty(MSIHANDLE handle, LPCTSTR name, CharacterBuffer_t* buffe
extern "C" UINT __stdcall SetProductInstallationPath(MSIHANDLE handle)
{
//MessageBox(NULL, TEXT("SetProductInstallationPath"), TEXT("Language Pack Installation Helper"), MB_OK | MB_ICONINFORMATION);
-
+
try
- {
- CharacterBuffer_t regKeyProdPath(MAX_PATH);
-
+ {
+ CharacterBuffer_t regKeyProdPath(MAX_PATH);
+
GetInstallProperty(handle, TEXT("REGKEYPRODPATH"), &regKeyProdPath);
-
+
HKEY hKey;
if ((RegOpenKey(HKEY_CURRENT_USER, &regKeyProdPath[0], &hKey) == ERROR_SUCCESS) ||
(RegOpenKey(HKEY_LOCAL_MACHINE, &regKeyProdPath[0], &hKey) == ERROR_SUCCESS))
- {
+ {
RegistryKeyGuard guard(hKey);
- std::string path = FindProductInstallationPath(hKey);
- MsiSetProperty(handle, TEXT("INSTALLLOCATION"), path.c_str());
- }
+ std::string path = FindProductInstallationPath(hKey);
+ MsiSetProperty(handle, TEXT("INSTALLLOCATION"), path.c_str());
+ }
}
catch(std::runtime_error& ex)
{
ex = ex; // no warnings
- }
- return ERROR_SUCCESS;
+ }
+ return ERROR_SUCCESS;
}
void MakeCfgimportCommandLine(CharacterBuffer_t* productPath)
-{
+{
char* p = &(*productPath)[0] + lstrlen(&(*productPath)[0]) - 1;
- if (*p != '\\')
- lstrcat(&(*productPath)[0], "\\program\\configimport.exe --spool");
+ if (*p != '\\')
+ lstrcat(&(*productPath)[0], "\\program\\configimport.exe --spool");
else
- lstrcat(&(*productPath)[0], "program\\configimport.exe --spool");
+ lstrcat(&(*productPath)[0], "program\\configimport.exe --spool");
}
/*
@@ -175,18 +175,18 @@ void MakeCfgimportCommandLine(CharacterBuffer_t* productPath)
extern "C" UINT __stdcall RegisterLanguagePack(MSIHANDLE handle)
{
//MessageBox(NULL, TEXT("RegisterLanguagePack"), TEXT("Language Pack Installation Helper"), MB_OK | MB_ICONINFORMATION);
-
- CharacterBuffer_t productPath(MAX_PATH);
- GetInstallProperty(handle, TEXT("INSTALLLOCATION"), &productPath);
- MakeCfgimportCommandLine(&productPath);
-
- STARTUPINFO si;
+
+ CharacterBuffer_t productPath(MAX_PATH);
+ GetInstallProperty(handle, TEXT("INSTALLLOCATION"), &productPath);
+ MakeCfgimportCommandLine(&productPath);
+
+ STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
-
+
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
-
+
if (CreateProcess(
NULL, &productPath[0], NULL, NULL,
FALSE, CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS, NULL,
@@ -195,10 +195,10 @@ extern "C" UINT __stdcall RegisterLanguagePack(MSIHANDLE handle)
// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);
- // Close process and thread handles.
+ // Close process and thread handles.
CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- }
- return ERROR_SUCCESS;
+ CloseHandle(pi.hThread);
+ }
+ return ERROR_SUCCESS;
}
diff --git a/setup_native/source/win32/customactions/languagepacks/makefile.mk b/setup_native/source/win32/customactions/languagepacks/makefile.mk
index 69526077c509..8da47ab1cc4f 100644
--- a/setup_native/source/win32/customactions/languagepacks/makefile.mk
+++ b/setup_native/source/win32/customactions/languagepacks/makefile.mk
@@ -77,6 +77,7 @@ STDSHL+= \
#SHL1LIBS = $(SLB)$/$(TARGET).lib
SHL1OBJS = $(SLOFILES) \
+ $(SLO)$/registerextensions.obj \
$(SLO)$/seterror.obj
SHL1TARGET = $(TARGET)
diff --git a/setup_native/source/win32/customactions/languagepacks/respintest.cxx b/setup_native/source/win32/customactions/languagepacks/respintest.cxx
index 6a98af8a3f30..a7e65a9cb84d 100644
--- a/setup_native/source/win32/customactions/languagepacks/respintest.cxx
+++ b/setup_native/source/win32/customactions/languagepacks/respintest.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -51,7 +51,7 @@
using namespace std;
-namespace
+namespace
{
string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
{
@@ -84,7 +84,7 @@ namespace
{
MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
}
-} // namespace
+} // namespace
extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
{
@@ -102,16 +102,16 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
// 1. Searching for "ProductCode" in setup.ini
string sSetupiniPath = sOfficeInstallPath + TEXT("program\\setup.ini");
-
+
TCHAR szValue[32767];
- GetPrivateProfileString(
- TEXT("Bootstrap"),
+ GetPrivateProfileString(
+ TEXT("Bootstrap"),
TEXT("ProductCode"),
TEXT("INVALIDDIRECTORY"),
szValue,
elementsof(szValue),
- sSetupiniPath.c_str()
+ sSetupiniPath.c_str()
);
if ( !_tcsicmp( szValue, TEXT("INVALIDDIRECTORY") ) )
@@ -127,13 +127,13 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
szValue[0] = '\0';
- GetPrivateProfileString(
- TEXT("Bootstrap"),
+ GetPrivateProfileString(
+ TEXT("Bootstrap"),
TEXT("buildid"),
TEXT("ISWRONGPRODUCT"),
szValue,
elementsof(szValue),
- sSetupiniPath.c_str()
+ sSetupiniPath.c_str()
);
if ( !_tcsicmp( szValue, TEXT("ISWRONGPRODUCT") ) )
@@ -154,7 +154,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
// MessageBox(NULL, "ISWRONGPRODUCT 2 set after searching PRODUCTMAJOR", "DEBUG", MB_OK);
SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
- return ERROR_SUCCESS;
+ return ERROR_SUCCESS;
}
// 3. Only for patch: Comparing "PRODUCTMINOR from property table and "ProductMinor" from InfoFile
@@ -168,15 +168,15 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
szValue[0] = '\0';
- GetPrivateProfileString(
- TEXT("Bootstrap"),
+ GetPrivateProfileString(
+ TEXT("Bootstrap"),
TEXT("ProductBuildid"),
TEXT("8918"),
szValue,
elementsof(szValue),
- sSetupiniPath.c_str()
+ sSetupiniPath.c_str()
);
-
+
int InstalledProductMinor = atoi(szValue);
if ( InstalledProductMinor >= PatchProductMinor )
@@ -184,7 +184,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
SetMsiProperty( handle, TEXT("PATCHISOLDER"), TEXT("YES") );
// MessageBox(NULL, "PATCHISOLDER set", "DEBUG", MB_OK);
SetMsiErrorCode( MSI_ERROR_PATCHISOLDER );
- return ERROR_SUCCESS;
+ return ERROR_SUCCESS;
}
}
@@ -192,13 +192,13 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
szValue[0] = '\0';
- GetPrivateProfileString(
- TEXT("Bootstrap"),
+ GetPrivateProfileString(
+ TEXT("Bootstrap"),
TEXT("ALLUSERS"),
TEXT(""),
szValue,
elementsof(szValue),
- sSetupiniPath.c_str()
+ sSetupiniPath.c_str()
);
if ( szValue[0] )
@@ -206,6 +206,6 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
SetMsiProperty( handle, TEXT("ALLUSERS"), szValue );
// MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
}
-
+
return ERROR_SUCCESS;
}