From 89f92ec00bfc199af1658a9e49b6d1557e791a2e Mon Sep 17 00:00:00 2001 From: Joost Verburg Date: Wed, 1 Nov 2006 22:56:08 +0000 Subject: [PATCH] Improved spell checking on Windows: * New dictionary installers on ftp.lyx.org. Arabic is now also supported. * Added support for FTP downloads to the installer. * Independent registry settings for all Aspell directories. * Better backwards compatibility with older Aspell installations. * Improved multi-user installation of Aspell on Windows 2000/XP. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@15683 a592a061-630c-0410-9148-cb99ea01b6c8 --- .../packaging/installer/components/dicts.nsh | 99 +++++------ .../installer/components/external.nsh | 4 +- .../Win32/packaging/installer/settings.nsh | 8 +- .../patches/msvc/aspell-setter-sep06.patch | 163 +++++++++++------- 4 files changed, 156 insertions(+), 118 deletions(-) diff --git a/development/Win32/packaging/installer/components/dicts.nsh b/development/Win32/packaging/installer/components/dicts.nsh index 1558fd4b93..8af91a0f02 100644 --- a/development/Win32/packaging/installer/components/dicts.nsh +++ b/development/Win32/packaging/installer/components/dicts.nsh @@ -35,57 +35,58 @@ SectionEnd !define DICT '!insertmacro Dictionary' -${DICT} af-0.50-0 "Afrikaans" af 924 -${DICT} no-0.50-2 "Bokmål" no 1300 -${DICT} bg-0.50-0 "Bulgarian" bg 9059 -${DICT} ca-20040130-1 "Català" ca 1107 -${DICT} cs-20040614-1 "Cesky" cs 2096 -${DICT} da-1.4.42-1 "Dansk" da 3094 -${DICT} de-20030222-1 "Deutsch" de 2929 -${DICT} en-6.0-0 "English" en 1144 -${DICT} es-0.50-2 "Español" es 3018 -${DICT} eo-0.50-2 "Esperanto" eo 3863 -${DICT} et-0.1.21-1 "Estonian" et 931 -${DICT} fr-0.50-3 "Français" fr 4428 -${DICT} gl-0.50-0 "Galego" gl 3041 -${DICT} el-0.50-3 "Greek" el 3269 -${DICT} he-0.9-0 "Hebrew" he 1485 -${DICT} hr-0.51-0 "Hrvatski" hr 2006 -${DICT} is-0.51.1-0 "Icelandic" is 1556 -;${DICT} ia-0.50-1 "Interlingua" ia 605 -${DICT} it-2.2_20050523-0 "Italiano" it 699 -;${DICT} la-20020503-0 "Latin" la 179 -${DICT} hu-0.99.4.2-0 "Magyar" hu 1636 -${DICT} nl-0.50-2 "Nederlands" nl 1546 -${DICT} nn-0.50.1-1 "Nynorsk" nn 1962 -${DICT} pl-0.51-0 "Polski" pl 14018 -${DICT} pt-0.50-2 "Português" pt 2326 -${DICT} ro-0.50-2 "Romana" ro 338 -${DICT} ru-0.99f7-1 "Russian" ru 1477 -${DICT} gd-0.1.1-1 "Scottish" gd 187 -${DICT} sr-0.02 "Serbian" sr 3755 -${DICT} sk-0.52-0 "Slovenskı jazyk" sk 4709 -${DICT} sl-0.50-0 "Slovenski jezik" sl 5252 -${DICT} fi-0.7-0 "Suomi" fi 663 -${DICT} sv-0.51-0 "Svenska" sv 1040 -${DICT} tr-0.50-0 "Türkçe" tr 548 -;${DICT} hsb-0.01-1 "Upper Sorbian" hsb 374 -${DICT} uk-1.1-0 "Ukrainian" uk 583 -${DICT} cy-0.50-3 "Welsh" cy 1801 +${DICT} af-0.50-0 "Afrikaans" af 916 +${DICT} ar-1.2-0 "Arabic" ar 4345 +${DICT} no-0.50-2 "Bokmål" no 1283 +${DICT} bg-4.0-0 "Bulgarian" bg 5344 +${DICT} ca-20040130-1 "Català" ca 1095 +${DICT} cs-20040614-1 "Ceština" cs 2069 +${DICT} da-1.4.42-1 "Dansk" da 3041 +${DICT} de-20030222-1 "Deutsch" de 2874 +${DICT} en-6.0-0 "English" en 1130 +${DICT} es-0.50-2 "Español" es 2954 +${DICT} eo-0.50-2 "Esperanto" eo 3771 +${DICT} et-0.1.21-1 "Estonian" et 923 +${DICT} fr-0.50-3 "Français" fr 4333 +${DICT} gl-0.50-0 "Galego" gl 2973 +${DICT} el-0.50-3 "Greek" el 3206 +${DICT} he-1.0-0 "Hebrew" he 2026 +${DICT} hr-0.51-0 "Hrvatski" hr 1967 +${DICT} is-0.51.1-0 "Icelandic" is 1537 +${DICT} it-2.2_20050523-0 "Italiano" it 696 +${DICT} hu-0.99.4.2-0 "Magyar" hu 1608 +${DICT} nl-0.50-2 "Nederlands" nl 1526 +${DICT} nn-0.50.1-1 "Nynorsk" nn 1942 +${DICT} pl-0.51-0 "Polski" pl 13685 +${DICT} pt-0.50-2 "Português" pt 2291 +${DICT} ro-0.50-2 "Romana" ro 342 +${DICT} ru-0.99f7-1 "Russian" ru 1460 +${DICT} gd-0.1.1-1 "Scottish" gd 195 +${DICT} sr-0.02 "Serbian" sr 3684 +${DICT} sk-0.52-0 "Slovenskı" sk 4602 +${DICT} sl-0.50-0 "Slovenski jezik" sl 5227 +${DICT} fi-0.7-0 "Suomi" fi 660 +${DICT} sv-0.51-0 "Svenska" sv 1029 +${DICT} tr-0.50-0 "Türkçe" tr 549 +${DICT} uk-1.1-0 "Ukrainian" uk 582 +${DICT} cy-0.50-3 "Welsh" cy 1770 ;-------------------------------- ;Functions Function GetAspellHive + ;Check whether the system or local version of Aspell should be used + ;The patched Aspell uses the same logic + Push $R0 - ReadRegStr $R0 HKLM "Software\Aspell" "Base Path" + ReadRegStr $R0 HKCU "Software\Aspell" "Base Path" - ${if} $R0 != "" - StrCpy $R0 "machine" + ${if} $R0 == "" + StrCpy $R0 HKLM ${else} - StrCpy $R0 "user" + StrCpy $R0 HKCU ${endif} Exch $R0 @@ -103,11 +104,11 @@ Function DownloadDictionary dict_download: - ;Download using HTTP - NSISdl::download "http://wiki.lyx.org/uploads/Windows/Aspell6/aspell6-$R0.exe" "$PLUGINSDIR\aspell6-$R0.exe" /END + ;Download + InetLoad::load "${DOWNLOAD_ASPELLDICTS}/aspell6-$R0.exe" "$PLUGINSDIR\aspell6-$R0.exe" /END Pop $R3 - ${if} $R3 != "success" + ${if} $R3 != "OK" ;Download failed MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_DICT) ($R3)" IDYES dict_download Goto dict_noinstall @@ -117,15 +118,15 @@ Function DownloadDictionary ExecWait '"$PLUGINSDIR\aspell6-$R0.exe" /NoDirChange /AutoClose' - ${if} $AspellHive == "machine" + ${if} $AspellHive == HKLM ReadRegStr $R3 HKLM "Software\Aspell\Dictionaries" $R2 ${else} - ReadRegStr $R3 HKCU "Software\Aspell\Dictionaries" $R2 - ${endif} + ReadRegStr $R3 HKCU "Software\Aspell\Dictionaries" $R2 + ${endif} - ${if} $R3 == "" + ${if} $R3 == "" MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_NOTINSTALLED_DICT)" IDYES install_dict - ${endif} + ${endif} Delete "$PLUGINSDIR\aspell6-$R0.exe" diff --git a/development/Win32/packaging/installer/components/external.nsh b/development/Win32/packaging/installer/components/external.nsh index 5ae079595a..568f295ce3 100644 --- a/development/Win32/packaging/installer/components/external.nsh +++ b/development/Win32/packaging/installer/components/external.nsh @@ -74,10 +74,10 @@ External Components: MiKTeX, ImageMagick, Ghostscript download_${COMPONENT}: ;Download using HTTP - NSISdl::download "${DOWNLOAD_${COMPONENT}}" "$PLUGINSDIR\${COMPONENT}Setup.exe" + InetLoad::load "${DOWNLOAD_${COMPONENT}}" "$PLUGINSDIR\${COMPONENT}Setup.exe" /END Pop $R0 - ${if} $R0 != "success" + ${if} $R0 != "OK" ;Download failed MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($R0)" IDYES download_${COMPONENT} Goto noinstall_${COMPONENT} diff --git a/development/Win32/packaging/installer/settings.nsh b/development/Win32/packaging/installer/settings.nsh index beb36927b1..9332e91813 100644 --- a/development/Win32/packaging/installer/settings.nsh +++ b/development/Win32/packaging/installer/settings.nsh @@ -38,11 +38,13 @@ Settings for LyX installer ;-------------------------------- ;Locations of components to download -!define DOWNLOAD_LATEX "http://superb-west.dl.sourceforge.net/sourceforge/miktex/basic-miktex-2.5.2449.exe" -!define DOWNLOAD_IMAGEMAGICK "http://superb-west.dl.sourceforge.net/sourceforge/imagemagick/ImageMagick-6.3.0-0-Q16-windows-dll.exe" +!define DOWNLOAD_LATEX "http://superb-west.dl.sourceforge.net/sourceforge/miktex/basic-miktex-2.5.2471.exe" +!define DOWNLOAD_IMAGEMAGICK "http://superb-west.dl.sourceforge.net/sourceforge/imagemagick/ImageMagick-6.3.0-1-Q16-windows-dll.exe" !define DOWNLOAD_GHOSTSCRIPT "http://superb-west.dl.sourceforge.net/sourceforge/ghostscript/gs854w32.exe" !define DOWNLOAD_VIEWER "http://tug.ctan.org/tex-archive/nonfree/support/ghostscript/ghostgum/gsv48w32.exe" +!define DOWNLOAD_ASPELLDICTS "ftp://ftp.lyx.org/pub/lyx/contrib/aspell6-windows" + ;-------------------------------- ;Download size (in KB) @@ -62,7 +64,7 @@ Settings for LyX installer ;-------------------------------- ;Locations of setup files for components (for bundled setup) -!define INSTALL_LATEX "basic-miktex-2.5.2449.exe" +!define INSTALL_LATEX "basic-miktex-2.5.2471.exe" !define INSTALL_IMAGEMAGICK "ImageMagick-6.3.0-0-Q16-windows-dll.exe" !define INSTALL_GHOSTSCRIPT "gs854w32.exe" !define INSTALL_VIEWER "gsv48w32.exe" diff --git a/development/Win32/patches/msvc/aspell-setter-sep06.patch b/development/Win32/patches/msvc/aspell-setter-sep06.patch index 1ef45f7b12..b192465aef 100644 --- a/development/Win32/patches/msvc/aspell-setter-sep06.patch +++ b/development/Win32/patches/msvc/aspell-setter-sep06.patch @@ -1,52 +1,52 @@ -diff -riwbBu -Xex aspell-setter-sep06/common/config.cpp aspell-setter-sep06-modified/common/config.cpp ---- aspell-setter-sep06/common/config.cpp Mon Dec 12 17:41:06 2005 -+++ aspell-setter-sep06-modified/common/config.cpp Sun Sep 17 20:55:02 2006 -@@ -78,6 +78,11 @@ +diff -riwBu -Xex aspell-setter-sep06\common\config.cpp aspell-setter-sep06-modified\common\config.cpp +--- aspell-setter-sep06\common\config.cpp Mon Dec 12 17:41:06 2005 ++++ aspell-setter-sep06-modified\common\config.cpp Sun Oct 22 13:03:46 2006 +@@ -78,6 +78,10 @@ namespace aspell { +#ifdef WIN32PORT -+ HKEY GetRegHive(); -+ aspell::String ReadRegString(HKEY type, aspell::String key, aspell::String name); ++ String GetWindowsDir(String registry_name, String default_directory); +#endif + const char * const keyinfo_type_name[4] = { N_("string"), N_("integer"), N_("boolean"), N_("list") }; -@@ -642,20 +647,30 @@ +@@ -642,20 +646,19 @@ } else if (strcmp(i, "home-dir") == 0) { - //get the personal folder (e.g. "c:\My Documents") -+ //get the personal folder -+ -+ //get from registry -+ HKEY hive; -+ hive = GetRegHive(); -+ final_str = ReadRegString(hive, "Software\\Aspell", "Base Path"); -+ -+ //default location -+ if (final_str == "") { - char * dir = new char[MAX_PATH]; - LPITEMIDLIST items = 0; +- char * dir = new char[MAX_PATH]; +- LPITEMIDLIST items = 0; - HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_PERSONAL, &items); -+ HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &items); - if ((NOERROR == hand) && items) { - if (SHGetPathFromIDList(items, dir)) { - for (char *ptr = dir; *ptr; ++ptr) - if ('\\' == *ptr) - *ptr = '/'; - final_str = dir; -+ final_str.append("/Aspell"); - } - CoTaskMemFree(items); - } - delete [] dir; -+ } +- if ((NOERROR == hand) && items) { +- if (SHGetPathFromIDList(items, dir)) { +- for (char *ptr = dir; *ptr; ++ptr) +- if ('\\' == *ptr) +- *ptr = '/'; +- final_str = dir; +- } +- CoTaskMemFree(items); +- } +- delete [] dir; ++ final_str = GetWindowsDir("Base Path", ""); ++ ++ } else if (strcmp(i, "dict-dir") == 0) { ++ ++ final_str = GetWindowsDir("Dictionary Path", "Dictionaries"); ++ ++ } else if (strcmp(i, "data-dir") == 0) { ++ ++ final_str = GetWindowsDir("Data Path", "Data"); ++ ++ } else if (strcmp(i, "personal-dir") == 0) { ++ ++ final_str = GetWindowsDir("Personal Path", "Personal"); } #endif -@@ -1394,20 +1409,6 @@ +@@ -1394,20 +1397,6 @@ return no_err; } @@ -67,7 +67,7 @@ diff -riwbBu -Xex aspell-setter-sep06/common/config.cpp aspell-setter-sep06-modi static const KeyInfo config_keys[] = { // the description should be under 50 chars {"actual-dict-dir", KeyInfoString, "", 0} -@@ -1484,7 +1485,7 @@ +@@ -1484,7 +1473,7 @@ , {"per-conf-path", KeyInfoString, "", 0} , {"personal", KeyInfoString, PERSONAL, N_("personal dictionary file name")} @@ -76,21 +76,20 @@ diff -riwbBu -Xex aspell-setter-sep06/common/config.cpp aspell-setter-sep06-modi , {"prefix", KeyInfoString, PREFIX, N_("prefix directory")} , {"repl", KeyInfoString, REPL, -@@ -1525,10 +1526,12 @@ +@@ -1525,10 +1514,8 @@ , {"warn", KeyInfoBool, "true", N_("enable warnings")} #ifdef WIN32PORT - , {"dict-subdir", KeyInfoString, "dicts", -+ , {"dict-subdir", KeyInfoString, "Dictionaries", - N_("sub directory for dictionaries")} - , {"data-subdir", KeyInfoString, "data", - N_("sub directory for other data")} -+ , {"personal-subdir", KeyInfoString, "Personal", -+ N_("sub directory for personal data")} +- N_("sub directory for dictionaries")} +- , {"data-subdir", KeyInfoString, "data", +- N_("sub directory for other data")} ++ , {"personal-dir", KeyInfoString, PERSONAL_DIR, ++ N_("directory for personal dictionaries")} #endif // -@@ -1587,5 +1590,53 @@ +@@ -1587,5 +1574,88 @@ config_impl_keys_begin, config_impl_keys_end); } @@ -132,21 +131,56 @@ diff -riwbBu -Xex aspell-setter-sep06/common/config.cpp aspell-setter-sep06-modi + + String value; + -+ if (ReadRegString(HKEY_LOCAL_MACHINE, "Software\\Aspell", "Dictionary Path") == "") ++ if (ReadRegString(HKEY_CURRENT_USER, "Software\\Aspell", "Base Path").empty()) + { -+ return HKEY_CURRENT_USER; -+ } else { + return HKEY_LOCAL_MACHINE; ++ } else { ++ return HKEY_CURRENT_USER; + } + + } + ++ String GetWindowsDir(String registry_name, String default_dir) ++ { ++ ++ String final_dir; ++ ++ // Get directory from registry ++ HKEY hive; ++ hive = GetRegHive(); ++ final_dir = ReadRegString(hive, "Software\\Aspell", registry_name); ++ ++ // Default location in "Documents and Settings" ++ if (final_dir.empty()) { ++ ++ char * dir = new char[MAX_PATH]; ++ LPITEMIDLIST items = 0; ++ HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &items); ++ ++ if ((NOERROR == hand) && items) { ++ if (SHGetPathFromIDList(items, dir)) { ++ for (char *ptr = dir; *ptr; ++ptr) ++ if ('\\' == *ptr) ++ *ptr = '/'; ++ final_dir = dir; ++ final_dir.append("/Aspell/"); ++ final_dir.append(default_dir.c_str()); ++ } ++ CoTaskMemFree(items); ++ } ++ ++ } ++ ++ return final_dir; ++ ++ } ++ +#endif } -diff -riwbBu -Xex aspell-setter-sep06/common/vector.hpp aspell-setter-sep06-modified/common/vector.hpp ---- aspell-setter-sep06/common/vector.hpp Thu Oct 13 09:42:54 2005 -+++ aspell-setter-sep06-modified/common/vector.hpp Sun Sep 17 19:50:46 2006 +diff -riwBu -Xex aspell-setter-sep06\common\vector.hpp aspell-setter-sep06-modified\common\vector.hpp +--- aspell-setter-sep06\common\vector.hpp Thu Oct 13 08:42:54 2005 ++++ aspell-setter-sep06-modified\common\vector.hpp Sun Sep 17 18:50:45 2006 @@ -50,10 +50,10 @@ T * data_end() {return &*this->end();} @@ -160,10 +194,10 @@ diff -riwbBu -Xex aspell-setter-sep06/common/vector.hpp aspell-setter-sep06-modi template U * datap() { -diff -riwbBu -Xex aspell-setter-sep06/win32/dirs.h aspell-setter-sep06-modified/win32/dirs.h ---- aspell-setter-sep06/win32/dirs.h Thu Oct 13 13:29:34 2005 -+++ aspell-setter-sep06-modified/win32/dirs.h Sun Sep 17 20:26:26 2006 -@@ -1,16 +1,26 @@ +diff -riwBu -Xex aspell-setter-sep06\win32\dirs.h aspell-setter-sep06-modified\win32\dirs.h +--- aspell-setter-sep06\win32\dirs.h Thu Oct 13 12:29:34 2005 ++++ aspell-setter-sep06-modified\win32\dirs.h Sun Oct 22 12:55:10 2006 +@@ -1,16 +1,27 @@ #ifndef dirs_h #define dirs_h @@ -171,20 +205,19 @@ diff -riwbBu -Xex aspell-setter-sep06/win32/dirs.h aspell-setter-sep06-modified/ -# define DATA_DIR "" -# define CONF_DIR "" -# define DICT_DIR "" -+# define DATA_DIR "" -+# define CONF_DIR "" -+# define DICT_DIR "" -+# define PERSONAL_DIR "" ++# define DATA_DIR "!data-dir" ++# define DICT_DIR "!dict-dir" ++# define PERSONAL_DIR "!personal-dir" + +#if defined(WIN32_USE_EXECUTABLE_DIR) +# define HOME_DIR "" -+# define PERSONAL "/.pws" -+# define REPL "/.prepl" ++# define PERSONAL "/.pws" ++# define REPL "/.prepl" # define PREFIX "!prefix" +#elif defined(WIN32_USE_PERSONAL_DIR) +# define HOME_DIR "!home-dir" -+# define PERSONAL "/.pws" -+# define REPL "/.prepl" ++# define PERSONAL "/.pws" ++# define REPL "/.prepl" +# define PREFIX "" #else -# define DATA_DIR "aspell-win32/data" @@ -192,15 +225,17 @@ diff -riwbBu -Xex aspell-setter-sep06/win32/dirs.h aspell-setter-sep06-modified/ -# define DICT_DIR "dicts" -# define PREFIX "aspell-win32" +# define HOME_DIR "<$HOME|./>" -+# define PERSONAL "/.aspell..pws" -+# define REPL "/.aspell..prepl" ++# define PERSONAL "/.aspell..pws" ++# define REPL "/.aspell..prepl" +# define PREFIX "" #endif ++ ++#define CONF_DIR HOME_DIR #endif -diff -riwbBu -Xex aspell-setter-sep06/win32/settings.h aspell-setter-sep06-modified/win32/settings.h ---- aspell-setter-sep06/win32/settings.h Wed Sep 6 10:51:16 2006 -+++ aspell-setter-sep06-modified/win32/settings.h Sun Sep 17 18:55:23 2006 +diff -riwBu -Xex aspell-setter-sep06\win32\settings.h aspell-setter-sep06-modified\win32\settings.h +--- aspell-setter-sep06\win32\settings.h Wed Sep 06 09:51:16 2006 ++++ aspell-setter-sep06-modified\win32\settings.h Sun Sep 17 17:55:23 2006 @@ -9,9 +9,6 @@ /* Defined if curses like POSIX Functions should be used */ #undef CURSES_ONLY