summaryrefslogtreecommitdiff
path: root/setup_native/source/win32/customactions/sellang
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-09-11 13:05:56 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-11 17:11:08 +0200
commite2fac98819c00b4fb50f9de9d0f32d20092f3191 (patch)
treef57c883e92a47fbea53bf3be9cb68e789ca5941f /setup_native/source/win32/customactions/sellang
parent8bb4cc03cf81051aa04362f2bc3a867e4bd72bd0 (diff)
fdo#53009: For msi installer, only default-select a subset of dictionaries
Change-Id: I3ee3fb5e5142ce4956776467b2ffcb19ed3b10c2
Diffstat (limited to 'setup_native/source/win32/customactions/sellang')
-rw-r--r--setup_native/source/win32/customactions/sellang/sellang.cxx82
1 files changed, 82 insertions, 0 deletions
diff --git a/setup_native/source/win32/customactions/sellang/sellang.cxx b/setup_native/source/win32/customactions/sellang/sellang.cxx
index 103496fd9576..8d243b046021 100644
--- a/setup_native/source/win32/customactions/sellang/sellang.cxx
+++ b/setup_native/source/win32/customactions/sellang/sellang.cxx
@@ -49,6 +49,8 @@
#include <sal/macros.h>
#include <systools/win32/uwinapi.h>
+#include "spellchecker_selection.hxx"
+
BOOL GetMsiProp( MSIHANDLE hMSI, const char* pPropName, char** ppValue )
{
DWORD sz = 0;
@@ -203,6 +205,37 @@ present_in_ui_langs(const char *lang)
return FALSE;
}
+namespace {
+
+struct Dictionary {
+ char lang[sizeof("xx_XX")];
+ bool install;
+};
+
+void addMatchingDictionaries(char const * lang, Dictionary * dicts, int ndicts)
+{
+ for (int i = 0; i != SAL_N_ELEMENTS(setup_native::languageDictionaries);
+ ++i)
+ {
+ if (strcmp(lang, setup_native::languageDictionaries[i].language) == 0) {
+ for (char const * const * p = setup_native::languageDictionaries[i].
+ dictionaries;
+ *p != NULL; ++p)
+ {
+ for (int j = 0; j != ndicts; ++j) {
+ if (_stricmp(*p, dicts[j].lang) == 0) {
+ dicts[j].install = true;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+}
+
+}
+
extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
{
char feature[100];
@@ -210,6 +243,8 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
DWORD length;
int nlangs = 0;
char langs[MAX_LANGUAGES][6];
+ int ndicts = 0;
+ Dictionary dicts[MAX_LANGUAGES];
database = MsiGetActiveDatabase(handle);
@@ -245,6 +280,41 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
MsiCloseHandle(view);
+ /* Keep track of what dictionaries are included in this installer:
+ */
+ if (MsiDatabaseOpenViewA(
+ database,
+ ("SELECT Feature from Feature WHERE"
+ " Feature_Parent = 'gm_Dictionaries'"),
+ &view)
+ == ERROR_SUCCESS)
+ {
+ if (MsiViewExecute(view, NULL) == ERROR_SUCCESS) {
+ while (ndicts < MAX_LANGUAGES &&
+ MsiViewFetch(view, &record) == ERROR_SUCCESS)
+ {
+ length = sizeof(feature);
+ if (MsiRecordGetStringA(record, 1, feature, &length)
+ == ERROR_SUCCESS)
+ {
+ if (strncmp(
+ feature, "gm_r_ex_Dictionary_",
+ strlen("gm_r_ex_Dictionary_"))
+ == 0)
+ {
+ strcpy(
+ dicts[ndicts].lang,
+ feature + strlen("gm_r_ex_Dictionary_"));
+ dicts[ndicts].install = false;
+ ++ndicts;
+ }
+ }
+ MsiCloseHandle(record);
+ }
+ }
+ MsiCloseHandle(view);
+ }
+
if (nlangs > 0) {
int i;
char* pVal = NULL;
@@ -266,6 +336,7 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
rc = MsiSetFeatureStateA(handle, feature, INSTALLSTATE_ABSENT);
}
else {
+ addMatchingDictionaries(langs[i], dicts, ndicts);
sel_ui_lang++;
}
}
@@ -274,6 +345,7 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
* in the installer, install at least en_US localization.
*/
MsiSetFeatureStateA(handle, "gm_Langpack_r_en_US", INSTALLSTATE_LOCAL);
+ addMatchingDictionaries("en_US", dicts, ndicts);
}
}
else {
@@ -322,10 +394,20 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
UINT rc;
sprintf(feature, "gm_Langpack_r_%s", langs[i]);
rc = MsiSetFeatureStateA(handle, feature, INSTALLSTATE_ABSENT);
+ } else {
+ addMatchingDictionaries(langs[i], dicts, ndicts);
}
}
}
}
+
+ for (int i = 0; i != ndicts; ++i) {
+ if (!dicts[i].install) {
+ sprintf(feature, "gm_r_ex_Dictionary_%s", dicts[i].lang);
+ MsiSetFeatureStateA(handle, feature, INSTALLSTATE_ABSENT);
+ }
+ }
+
MsiCloseHandle(database);
return ERROR_SUCCESS;