fdo#53009: For msi installer, only default-select a subset of dictionaries

Change-Id: I3ee3fb5e5142ce4956776467b2ffcb19ed3b10c2
This commit is contained in:
Stephan Bergmann
2012-09-11 13:05:56 +02:00
parent 8bb4cc03cf
commit e2fac98819
4 changed files with 176 additions and 1 deletions

View File

@@ -3,12 +3,13 @@ pk setup_native usr1 - all sn_mkou
pk setup_native\scripts\source nmake - u sn_source NULL
pk setup_native\scripts nmake - u sn_scripts sn_source.u NULL
pk setup_native\source\mac nmake - u sn_mac NULL
pk setup_native\source\packinfo nmake - w sn_packinfo NULL
pk setup_native\source\win32\customactions\tools nmake - w sn_tools NULL
pk setup_native\source\win32\customactions\rebase nmake - w sn_rebase NULL
pk setup_native\source\win32\customactions\regactivex nmake - w sn_regactivex NULL
pk setup_native\source\win32\customactions\regpatchactivex nmake - w sn_regpatchactivex NULL
pk setup_native\source\win32\customactions\reg4allmsdoc nmake - w sn_reg4allmsdoc NULL
pk setup_native\source\win32\customactions\sellang nmake - w sn_sellang NULL
pk setup_native\source\win32\customactions\sellang nmake - w sn_sellang sn_packinfo.w NULL
pk setup_native\source\win32\customactions\thesaurus nmake - w sn_thesaurus NULL
pk setup_native\source\win32\customactions\javafilter nmake - w sn_javafilter NULL
pk setup_native\source\win32\customactions\quickstarter nmake - w sn_quickstarter NULL

View File

@@ -0,0 +1,24 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
PRJ = ../..
PRJNAME = setup_native
TARGET = packinfo
.INCLUDE: settings.mk
ALLTAR: $(OUT)/inc/spellchecker_selection.hxx
.INCLUDE: target.mk
$(OUT)/inc/spellchecker_selection.hxx .ERRREMOVE : spellchecker_selection.pl \
spellchecker_selection.txt
$(PERL) -w spellchecker_selection.pl <spellchecker_selection.txt >$@
# vim: set noet sw=4 ts=4:

View File

@@ -0,0 +1,68 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
use List::Util qw[max];
@ARGV == 0 or die 'Usage: translates from stdin to stdout';
my %map = ();
my $max = 0;
while (<>) {
next if /^\s*(#.*)?$/;
/^ \s* ([a-z]{2}(?:-[A-Z]{2})?) \s* = \s*
\"(EMPTY|[a-z]{2}(?:-[A-Z]{2})?(?:,[a-z]{2}(?:-[A-Z]{2})?)*)\" \s* $/x
or die "bad input line \"$_\"";
my $lang = $1;
$lang =~ tr/-/_/;
my $dicts = $2;
$dicts =~ tr/-/_/;
!exists($map{$lang}) or die "duplicate values for $lang";
if ($dicts eq 'EMPTY') {
@{$map{$lang}} = ();
} else {
@{$map{$lang}} = split(/,/, $dicts);
$max = max($max, scalar(@{$map{$lang}}));
}
}
++$max;
print <<EOF;
// generated by setup_native/source/packinfo/spellchecker_selection.pl
#ifndef INCLUDED_SETUP_NATIVE_SOURCE_PACKINFO_SPELLCHECKER_SELECTION_HXX
#define INCLUDED_SETUP_NATIVE_SOURCE_PACKINFO_SPELLCHECKER_SELECTION_HXX
#include "sal/config.h"
namespace setup_native {
struct LanguageDictionaries {
char const * language;
char const * dictionaries[$max];
};
LanguageDictionaries const languageDictionaries[] = {
EOF
foreach $i (sort(keys(%map))) {
print(" { \"$i\", {");
foreach $j (sort(@{$map{$i}})) {
print(" \"$j\",");
}
print(" 0 } },\n");
}
print <<EOF;
};
}
#endif
EOF

View File

@@ -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;