1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
--- src/lib/IWORKLanguageManager.cpp.orig 2017-02-21 10:28:39.646017140 +0000
+++ src/lib/IWORKLanguageManager.cpp 2017-02-21 10:29:26.601817549 +0000
@@ -12,7 +12,9 @@
#include <cstdlib>
#include <stdexcept>
+#if !defined(DISABLE_LIBLANGTAG)
#include <liblangtag/langtag.h>
+#endif
#include "libetonyek_utils.h"
@@ -27,6 +29,7 @@
using std::string;
+#if !defined(DISABLE_LIBLANGTAG)
namespace
{
@@ -56,6 +59,7 @@
}
}
+#endif
struct IWORKLanguageManager::LangDB
{
@@ -67,6 +71,7 @@
IWORKLanguageManager::LangDB::LangDB()
: m_db()
{
+#if !defined(DISABLE_LIBLANGTAG)
shared_ptr<lt_lang_db_t> langDB(lt_db_get_lang(), lt_lang_db_unref);
shared_ptr<lt_iter_t> it(LT_ITER_INIT(langDB.get()), lt_iter_finish);
lt_pointer_t key(0);
@@ -77,6 +82,7 @@
lt_lang_t *const lang = reinterpret_cast<lt_lang_t *>(value);
m_db[lt_lang_get_name(lang)] = tag;
}
+#endif
}
IWORKLanguageManager::IWORKLanguageManager()
@@ -102,6 +108,10 @@
if (invIt != m_invalidTags.end())
return "";
+#if defined(DISABLE_LIBLANGTAG)
+ m_invalidTags.insert(tag);
+ return "";
+#else
const shared_ptr<lt_tag_t> &langTag = parseTag(tag);
if (!langTag)
{
@@ -114,6 +124,7 @@
addProperties(fullTag);
return fullTag;
+#endif
}
const std::string IWORKLanguageManager::addLanguage(const std::string &lang)
@@ -134,6 +145,10 @@
return "";
}
+#if defined(DISABLE_LIBLANGTAG)
+ m_invalidLangs.insert(lang);
+ return "";
+#else
const shared_ptr<lt_tag_t> &langTag = parseTag(langIt->second);
if (!langTag)
throw std::logic_error("cannot parse tag that came from liblangtag language DB");
@@ -143,6 +158,7 @@
addProperties(fullTag);
return fullTag;
+#endif
}
const std::string IWORKLanguageManager::addLocale(const std::string &locale)
@@ -156,6 +172,9 @@
if (invIt != m_invalidLocales.end())
return "";
+#if defined(DISABLE_LIBLANGTAG)
+ return "";
+#else
lt_error_t *error = 0;
const shared_ptr<lt_tag_t> tag(lt_tag_convert_from_locale_string(locale.c_str(), &error), lt_tag_unref);
if ((error && lt_error_is_set(error, LT_ERR_ANY)) || !tag)
@@ -170,14 +189,19 @@
addProperties(fullTag);
return fullTag;
+#endif
}
const std::string IWORKLanguageManager::getLanguage(const std::string &tag) const
{
+#if defined(DISABLE_LIBLANGTAG)
+ return "";
+#else
const shared_ptr<lt_tag_t> &langTag = parseTag(tag);
if (!langTag)
throw std::logic_error("cannot parse tag that has been successfully parsed before");
return lt_lang_get_name(lt_tag_get_language(langTag.get()));
+#endif
}
const IWORKLanguageManager::LangDB &IWORKLanguageManager::getLangDB() const
@@ -189,6 +213,9 @@
void IWORKLanguageManager::addProperties(const std::string &tag)
{
+#if defined(DISABLE_LIBLANGTAG)
+ return;
+#else
const shared_ptr<lt_tag_t> &langTag = parseTag(tag);
if (!langTag)
throw std::logic_error("cannot parse tag that has been successfully parsed before");
@@ -205,6 +232,7 @@
props.insert("fo:script", lt_script_get_tag(script));
m_propsMap[tag] = props;
+#endif
}
void IWORKLanguageManager::writeProperties(const std::string &tag, librevenge::RVNGPropertyList &props) const
|