mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
CMake/Windows compilation fix. Aiksaurus.h was not visible in frontend/qt4:
* pimpl the implementation details. Next step would probably be to have a virtual base class instead. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29453 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bd9de0b764
commit
e2025f59dc
@ -25,6 +25,14 @@
|
|||||||
|
|
||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBMYTHES
|
||||||
|
#include MYTHES_H_LOCATION
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_LIBAIKSAURUS
|
||||||
|
#include AIKSAURUS_H_LOCATION
|
||||||
|
#endif // HAVE_LIBAIKSAURUS
|
||||||
|
#endif // !HAVE_LIBMYTHES
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -34,20 +42,13 @@ using namespace lyx::support::os;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
#ifndef HAVE_LIBMYTHES
|
|
||||||
#ifdef HAVE_LIBAIKSAURUS
|
#ifdef HAVE_LIBAIKSAURUS
|
||||||
|
|
||||||
|
struct Thesaurus::Private
|
||||||
Thesaurus::Thesaurus()
|
|
||||||
: thes_(new Aiksaurus)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
Thesaurus::~Thesaurus()
|
|
||||||
{
|
{
|
||||||
delete thes_;
|
Private(): thes_(new Aiksaurus) {}
|
||||||
}
|
Aiksaurus * thes_;
|
||||||
|
};
|
||||||
|
|
||||||
Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &)
|
Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &)
|
||||||
{
|
{
|
||||||
@ -63,7 +64,7 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &)
|
|||||||
|
|
||||||
string const text = to_ascii(t);
|
string const text = to_ascii(t);
|
||||||
|
|
||||||
docstring error = from_ascii(thes_->error());
|
docstring error = from_ascii(d->thes_->error());
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
static bool sent_error = false;
|
static bool sent_error = false;
|
||||||
if (!sent_error) {
|
if (!sent_error) {
|
||||||
@ -74,7 +75,7 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &)
|
|||||||
}
|
}
|
||||||
return meanings;
|
return meanings;
|
||||||
}
|
}
|
||||||
if (!thes_->find(text.c_str()))
|
if (!d->thes_->find(text.c_str()))
|
||||||
return meanings;
|
return meanings;
|
||||||
|
|
||||||
// weird api, but ...
|
// weird api, but ...
|
||||||
@ -84,19 +85,19 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &)
|
|||||||
docstring meaning;
|
docstring meaning;
|
||||||
|
|
||||||
// correct, returns "" at the end
|
// correct, returns "" at the end
|
||||||
string ret = thes_->next(cur_meaning);
|
string ret = d->thes_->next(cur_meaning);
|
||||||
|
|
||||||
while (!ret.empty()) {
|
while (!ret.empty()) {
|
||||||
if (cur_meaning != prev_meaning) {
|
if (cur_meaning != prev_meaning) {
|
||||||
meaning = from_ascii(ret);
|
meaning = from_ascii(ret);
|
||||||
ret = thes_->next(cur_meaning);
|
ret = d->thes_->next(cur_meaning);
|
||||||
prev_meaning = cur_meaning;
|
prev_meaning = cur_meaning;
|
||||||
} else {
|
} else {
|
||||||
if (ret != text)
|
if (ret != text)
|
||||||
meanings[meaning].push_back(from_ascii(ret));
|
meanings[meaning].push_back(from_ascii(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = thes_->next(cur_meaning);
|
ret = d->thes_->next(cur_meaning);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Meanings::iterator it = meanings.begin();
|
for (Meanings::iterator it = meanings.begin();
|
||||||
@ -113,10 +114,7 @@ bool Thesaurus::thesaurusAvailable(docstring const & lang) const
|
|||||||
return prefixIs(lang, from_ascii("en_"));
|
return prefixIs(lang, from_ascii("en_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_LIBAIKSAURUS
|
#else // HAVE_LIBAIKSAURUS
|
||||||
#endif // !HAVE_LIBMYTHES
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBMYTHES
|
#ifdef HAVE_LIBMYTHES
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -139,20 +137,25 @@ docstring const from_iconv_encoding(string const & s, string const & encoding)
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
Thesaurus::Thesaurus()
|
struct Thesaurus::Private
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
Thesaurus::~Thesaurus()
|
|
||||||
{
|
{
|
||||||
for (Thesauri::iterator it = thes_.begin();
|
~Private()
|
||||||
it != thes_.end(); ++it) {
|
{
|
||||||
delete it->second;
|
for (Thesauri::iterator it = thes_.begin();
|
||||||
|
it != thes_.end(); ++it) {
|
||||||
|
delete it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/// add a thesaurus to the list
|
||||||
|
bool addThesaurus(docstring const & lang);
|
||||||
|
|
||||||
bool Thesaurus::addThesaurus(docstring const & lang)
|
typedef std::map<docstring, MyThes *> Thesauri;
|
||||||
|
/// the thesauri
|
||||||
|
Thesauri thes_;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool Thesaurus::Private::addThesaurus(docstring const & lang)
|
||||||
{
|
{
|
||||||
string const thes_path = external_path(lyxrc.thesaurusdir_path);
|
string const thes_path = external_path(lyxrc.thesaurusdir_path);
|
||||||
LYXERR(Debug::FILES, "thesaurus path: " << thes_path);
|
LYXERR(Debug::FILES, "thesaurus path: " << thes_path);
|
||||||
@ -199,8 +202,8 @@ bool Thesaurus::addThesaurus(docstring const & lang)
|
|||||||
|
|
||||||
bool Thesaurus::thesaurusAvailable(docstring const & lang) const
|
bool Thesaurus::thesaurusAvailable(docstring const & lang) const
|
||||||
{
|
{
|
||||||
for (Thesauri::const_iterator it = thes_.begin();
|
for (Thesauri::const_iterator it = d->thes_.begin();
|
||||||
it != thes_.end(); ++it) {
|
it != d->thes_.end(); ++it) {
|
||||||
if (it->first == lang)
|
if (it->first == lang)
|
||||||
if (it->second)
|
if (it->second)
|
||||||
return true;
|
return true;
|
||||||
@ -215,11 +218,11 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const & lan
|
|||||||
Meanings meanings;
|
Meanings meanings;
|
||||||
MyThes * mythes = 0;
|
MyThes * mythes = 0;
|
||||||
|
|
||||||
if (!addThesaurus(lang))
|
if (!d->addThesaurus(lang))
|
||||||
return meanings;
|
return meanings;
|
||||||
|
|
||||||
for (Thesauri::const_iterator it = thes_.begin();
|
for (Thesauri::const_iterator it = d->thes_.begin();
|
||||||
it != thes_.end(); ++it) {
|
it != d->thes_.end(); ++it) {
|
||||||
if (it->first == lang) {
|
if (it->first == lang) {
|
||||||
mythes = it->second;
|
mythes = it->second;
|
||||||
break;
|
break;
|
||||||
@ -265,15 +268,10 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const & lan
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#ifndef HAVE_LIBAIKSAURUS
|
|
||||||
Thesaurus::Thesaurus()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
struct Thesaurus::Private
|
||||||
Thesaurus::~Thesaurus()
|
|
||||||
{
|
{
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
Thesaurus::Meanings Thesaurus::lookup(docstring const &, docstring const &)
|
Thesaurus::Meanings Thesaurus::lookup(docstring const &, docstring const &)
|
||||||
@ -287,8 +285,18 @@ bool Thesaurus::thesaurusAvailable(docstring const &) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif // HAVE_LIBMYTHES
|
#endif // HAVE_LIBMYTHES
|
||||||
|
#endif // HAVE_LIBAIKSAURUS
|
||||||
|
|
||||||
|
Thesaurus::Thesaurus() : d(new Thesaurus::Private)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Thesaurus::~Thesaurus()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
// Global instance
|
// Global instance
|
||||||
Thesaurus thesaurus;
|
Thesaurus thesaurus;
|
||||||
|
@ -15,17 +15,9 @@
|
|||||||
|
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#ifdef HAVE_LIBMYTHES
|
|
||||||
#include MYTHES_H_LOCATION
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_LIBAIKSAURUS
|
|
||||||
#include AIKSAURUS_H_LOCATION
|
|
||||||
#endif // HAVE_LIBAIKSAURUS
|
|
||||||
#endif // !HAVE_LIBMYTHES
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -51,18 +43,8 @@ public:
|
|||||||
bool thesaurusAvailable(docstring const & lang) const;
|
bool thesaurusAvailable(docstring const & lang) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef HAVE_LIBMYTHES
|
struct Private;
|
||||||
/// add a thesaurus to the list
|
Private * const d;
|
||||||
bool addThesaurus(docstring const & lang);
|
|
||||||
|
|
||||||
typedef std::map<docstring, MyThes *> Thesauri;
|
|
||||||
/// the thesauri
|
|
||||||
Thesauri thes_;
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_LIBAIKSAURUS
|
|
||||||
Aiksaurus * thes_;
|
|
||||||
#endif // HAVE_LIBAIKSAURUS
|
|
||||||
#endif // !HAVE_LIBMYTHES
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Thesaurus thesaurus;
|
extern Thesaurus thesaurus;
|
||||||
|
Loading…
Reference in New Issue
Block a user