Am 20.04.2010 um 12:57 schrieb Jean-Marc Lasgouttes:

> Le 20 avr. 10 à 12:55, Jürgen Spitzmüller a écrit :
>> Stephan Witt wrote:
>>> Then I propose to use some hard coded path below $sysdir for the shipped
>>> directories and the user may specify another path for the extra
>>> dictionaries in preferences.
>> 
>> Note that we only have one path at disposal currently. So you need to use one
>> for both aims.
> 
> What do you mean?

I don't know of course.

But I meant something like the attached patch.
(Plus some appropriate action by packager for shipped files.)

Stephan

PS: The patch is not nice, I know. It should be refactored.

Index: src/Thesaurus.cpp
===================================================================
--- src/Thesaurus.cpp   (Revision 34227)
+++ src/Thesaurus.cpp   (Arbeitskopie)
@@ -16,6 +16,7 @@
 #include "LyXRC.h"
 
 #include "support/FileNameList.h"
+#include "support/Package.h"
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
@@ -78,38 +79,66 @@
 pair<string, string> Thesaurus::Private::getThesaurus(docstring const & lang)
 {
        string const thes_path = external_path(lyxrc.thesaurusdir_path);
-       LYXERR(Debug::FILES, "thesaurus path: " << thes_path);
-       if (thes_path.empty())
-               return make_pair(string(), string());
 
        if (thesaurusAvailable(lang))
                return make_pair(string(), string());
 
-       FileNameList const idx_files = FileName(thes_path).dirList("idx");
-       FileNameList const data_files = FileName(thes_path).dirList("dat");
        string idx;
        string data;
 
-       for (FileNameList::const_iterator it = idx_files.begin();
-            it != idx_files.end(); ++it) {
-               LYXERR(Debug::FILES, "found thesaurus idx file: " << 
it->onlyFileName());
-               if (contains(it->onlyFileName(), to_ascii(lang))) {
-                       idx = it->absFilename();
-                       LYXERR(Debug::FILES, "selected thesaurus idx file: " << 
idx);
-                       break;
+       if (!thes_path.empty()) {
+               FileNameList const idx_files = 
FileName(thes_path).dirList("idx");
+               FileNameList const data_files = 
FileName(thes_path).dirList("dat");
+
+               LYXERR(Debug::FILES, "thesaurus user path: " << thes_path);
+               for (FileNameList::const_iterator it = idx_files.begin();
+                         it != idx_files.end(); ++it) {
+                       LYXERR(Debug::FILES, "found thesaurus idx file: " << 
it->onlyFileName());
+                       if (contains(it->onlyFileName(), to_ascii(lang))) {
+                               idx = it->absFilename();
+                               LYXERR(Debug::FILES, "selected thesaurus idx 
file: " << idx);
+                               break;
+                               }
                        }
-               }
 
-       for (support::FileNameList::const_iterator it = data_files.begin();
-            it != data_files.end(); ++it) {
-               LYXERR(Debug::FILES, "found thesaurus data file: " << 
it->onlyFileName());
-               if (contains(it->onlyFileName(), to_ascii(lang))) {
-                       data = it->absFilename();
-                       LYXERR(Debug::FILES, "selected thesaurus data file: " 
<< data);
-                       break;
+               for (support::FileNameList::const_iterator it = 
data_files.begin();
+                         it != data_files.end(); ++it) {
+                       LYXERR(Debug::FILES, "found thesaurus data file: " << 
it->onlyFileName());
+                       if (contains(it->onlyFileName(), to_ascii(lang))) {
+                               data = it->absFilename();
+                               LYXERR(Debug::FILES, "selected thesaurus data 
file: " << data);
+                               break;
+                               }
                        }
-               }
+       }
 
+       if (idx.empty()) {
+               string const sys_path = 
external_path(addName(lyx::support::package().system_support().absFilename(),"thes"))
 ;
+               FileNameList const idx_files = 
FileName(sys_path).dirList("idx");
+               FileNameList const data_files = 
FileName(sys_path).dirList("dat");
+
+               LYXERR(Debug::FILES, "thesaurus sys path: " << sys_path);
+               for (FileNameList::const_iterator it = idx_files.begin();
+                         it != idx_files.end(); ++it) {
+                       LYXERR(Debug::FILES, "found thesaurus idx file: " << 
it->onlyFileName());
+                       if (contains(it->onlyFileName(), to_ascii(lang))) {
+                               idx = it->absFilename();
+                               LYXERR(Debug::FILES, "selected thesaurus idx 
file: " << idx);
+                               break;
+                               }
+                       }
+
+               for (support::FileNameList::const_iterator it = 
data_files.begin();
+                         it != data_files.end(); ++it) {
+                       LYXERR(Debug::FILES, "found thesaurus data file: " << 
it->onlyFileName());
+                       if (contains(it->onlyFileName(), to_ascii(lang))) {
+                               data = it->absFilename();
+                               LYXERR(Debug::FILES, "selected thesaurus data 
file: " << data);
+                               break;
+                               }
+                       }
+       }
+
        return make_pair(idx, data);
 }
 

Reply via email to