mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
* Allow to set language package on a per-document basis (fixes bug 2909).
File format change. Commit approved by Pavel on trac. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37457 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
699a2f72ef
commit
f27d5aa9ae
@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2011-02-03 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 411
|
||||
New buffer param \language_package to allow per-document
|
||||
language package selection (bug 2909).
|
||||
|
||||
2010-11-26 Richard Heck <rgheck@comcast.net>
|
||||
* Format incremented to 410 (r36520)
|
||||
Rename "\\begin_layout Labeling" to "\\begin_layout List"
|
||||
|
@ -2416,6 +2416,26 @@ def revert_labeling(document):
|
||||
document.body[i] = "\\begin_layout List"
|
||||
|
||||
|
||||
def revert_langpack(document):
|
||||
" revert \\language_package parameter "
|
||||
i = 0
|
||||
i = find_token(document.header, "\\language_package", 0)
|
||||
if i == -1:
|
||||
document.warning("Malformed document. No \\language_package param!")
|
||||
return
|
||||
|
||||
del document.header[i]
|
||||
|
||||
|
||||
def convert_langpack(document):
|
||||
" Add \\language_package parameter "
|
||||
i = find_token(document.header, "\language" , 0)
|
||||
if i == -1:
|
||||
document.warning("Malformed document. No \\language defined!")
|
||||
return
|
||||
|
||||
document.header.insert(i + 1, "\\language_package default")
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -2485,10 +2505,12 @@ convert = [[346, []],
|
||||
[407, []],
|
||||
[408, []],
|
||||
[409, [convert_use_xetex]],
|
||||
[410, []]
|
||||
[410, []],
|
||||
[411, [convert_langpack]]
|
||||
]
|
||||
|
||||
revert = [[409, [revert_labeling]],
|
||||
revert = [[409, [revert_langpack]],
|
||||
[409, [revert_labeling]],
|
||||
[408, [revert_use_xetex]],
|
||||
[407, [revert_script]],
|
||||
[406, [revert_multirowOffset]],
|
||||
|
@ -127,7 +127,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
int const LYX_FORMAT = 410; // rgh: dummy format for list->labeling
|
||||
int const LYX_FORMAT = 411; // spitz: lang_package buffer param
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -385,6 +385,7 @@ BufferParams::BufferParams()
|
||||
fonts_sans_scale = 100;
|
||||
fonts_typewriter_scale = 100;
|
||||
inputenc = "auto";
|
||||
lang_package = "default";
|
||||
graphics_driver = "default";
|
||||
default_output_format = "default";
|
||||
bibtex_command = "default";
|
||||
@ -601,6 +602,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
lex >> suppress_date;
|
||||
} else if (token == "\\language") {
|
||||
readLanguage(lex);
|
||||
} else if (token == "\\language_package") {
|
||||
lex.eatLine();
|
||||
lang_package = lex.getString();
|
||||
} else if (token == "\\inputencoding") {
|
||||
lex >> inputenc;
|
||||
} else if (token == "\\graphics") {
|
||||
@ -945,7 +949,8 @@ void BufferParams::writeFile(ostream & os) const
|
||||
// then the text parameters
|
||||
if (language != ignore_language)
|
||||
os << "\\language " << language->lang() << '\n';
|
||||
os << "\\inputencoding " << inputenc
|
||||
os << "\\language_package " << lang_package
|
||||
<< "\n\\inputencoding " << inputenc
|
||||
<< "\n\\fontencoding " << fontenc
|
||||
<< "\n\\font_roman " << fonts_roman
|
||||
<< "\n\\font_sans " << fonts_sans
|
||||
@ -2442,6 +2447,9 @@ string const BufferParams::font_encoding() const
|
||||
|
||||
string BufferParams::babelCall(string const & lang_opts, bool const langoptions) const
|
||||
{
|
||||
if (lang_package != "auto" && lang_package != "babel"
|
||||
&& lang_package != "default" && lang_package != "none")
|
||||
return lang_package;
|
||||
if (lyxrc.language_package_selection == LyXRC::LP_CUSTOM)
|
||||
return lyxrc.language_custom_package;
|
||||
// suppress the babel call if there is no BabelName defined
|
||||
|
@ -236,6 +236,8 @@ public:
|
||||
int tocdepth;
|
||||
///
|
||||
Language const * language;
|
||||
/// language package
|
||||
std::string lang_package;
|
||||
/// BranchList:
|
||||
BranchList & branchlist();
|
||||
BranchList const & branchlist() const;
|
||||
|
@ -294,20 +294,31 @@ bool LaTeXFeatures::useBabel() const
|
||||
{
|
||||
if (usePolyglossia())
|
||||
return false;
|
||||
return (lyxrc.language_package_selection != LyXRC::LP_NONE)
|
||||
|| (bufferParams().language->lang() != lyxrc.default_language
|
||||
&& !bufferParams().language->babel().empty())
|
||||
|| this->hasLanguages();
|
||||
if (bufferParams().lang_package == "default")
|
||||
return (lyxrc.language_package_selection != LyXRC::LP_NONE)
|
||||
|| (bufferParams().language->lang() != lyxrc.default_language
|
||||
&& !bufferParams().language->babel().empty())
|
||||
|| this->hasLanguages();
|
||||
return (bufferParams().lang_package != "none")
|
||||
|| (bufferParams().language->lang() != lyxrc.default_language
|
||||
&& !bufferParams().language->babel().empty())
|
||||
|| this->hasLanguages();
|
||||
}
|
||||
|
||||
|
||||
bool LaTeXFeatures::usePolyglossia() const
|
||||
{
|
||||
return (lyxrc.language_package_selection == LyXRC::LP_AUTO)
|
||||
&& isRequired("polyglossia")
|
||||
&& isAvailable("polyglossia")
|
||||
&& !params_.documentClass().provides("babel")
|
||||
&& this->hasPolyglossiaLanguages();
|
||||
if (bufferParams().lang_package == "default")
|
||||
return (lyxrc.language_package_selection == LyXRC::LP_AUTO)
|
||||
&& isRequired("polyglossia")
|
||||
&& isAvailable("polyglossia")
|
||||
&& !params_.documentClass().provides("babel")
|
||||
&& this->hasPolyglossiaLanguages();
|
||||
return (bufferParams().lang_package == "auto")
|
||||
&& isRequired("polyglossia")
|
||||
&& isAvailable("polyglossia")
|
||||
&& !params_.documentClass().provides("babel")
|
||||
&& this->hasPolyglossiaLanguages();
|
||||
}
|
||||
|
||||
|
||||
|
@ -964,6 +964,12 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(langModule->languagePackageCO, SIGNAL(activated(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(langModule->languagePackageED, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(languagePackageChanged(int)));
|
||||
|
||||
QAbstractItemModel * language_model = guiApp->languageModel();
|
||||
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
|
||||
@ -988,6 +994,17 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
langModule->quoteStyleCO->addItem(qt_("<<text>>"));
|
||||
langModule->quoteStyleCO->addItem(qt_(">>text<<"));
|
||||
|
||||
langModule->languagePackageCO->addItem(
|
||||
qt_("Default"), toqstr("default"));
|
||||
langModule->languagePackageCO->addItem(
|
||||
qt_("Automatic"), toqstr("auto"));
|
||||
langModule->languagePackageCO->addItem(
|
||||
qt_("Always Babel"), toqstr("babel"));
|
||||
langModule->languagePackageCO->addItem(
|
||||
qt_("Custom"), toqstr("custom"));
|
||||
langModule->languagePackageCO->addItem(
|
||||
qt_("None[[language package]]"), toqstr("none"));
|
||||
|
||||
|
||||
// color
|
||||
colorModule = new UiWidget<Ui::ColorUi>;
|
||||
@ -1877,6 +1894,13 @@ void GuiDocument::classChanged()
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::languagePackageChanged(int i)
|
||||
{
|
||||
langModule->languagePackageED->setEnabled(
|
||||
langModule->languagePackageCO->itemData(i).toString() == "custom");
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::bibtexChanged(int n)
|
||||
{
|
||||
biblioModule->bibtexOptionsED->setEnabled(n != 0);
|
||||
@ -2202,6 +2226,14 @@ void GuiDocument::applyView()
|
||||
QString const lang = langModule->languageCO->itemData(
|
||||
langModule->languageCO->currentIndex()).toString();
|
||||
bp_.language = lyx::languages.getLanguage(fromqstr(lang));
|
||||
|
||||
QString const pack = langModule->languagePackageCO->itemData(
|
||||
langModule->languagePackageCO->currentIndex()).toString();
|
||||
if (pack == "custom")
|
||||
bp_.lang_package =
|
||||
fromqstr(langModule->languagePackageED->text());
|
||||
else
|
||||
bp_.lang_package = fromqstr(pack);
|
||||
|
||||
//color
|
||||
bp_.backgroundcolor = set_backgroundcolor;
|
||||
@ -2614,6 +2646,16 @@ void GuiDocument::paramsToDialog()
|
||||
langModule->defaultencodingRB->setChecked(default_enc);
|
||||
langModule->otherencodingRB->setChecked(!default_enc);
|
||||
|
||||
int const p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
|
||||
if (p == -1) {
|
||||
langModule->languagePackageCO->setCurrentIndex(
|
||||
langModule->languagePackageCO->findData("custom"));
|
||||
langModule->languagePackageED->setText(toqstr(bp_.lang_package));
|
||||
} else {
|
||||
langModule->languagePackageCO->setCurrentIndex(p);
|
||||
langModule->languagePackageED->clear();
|
||||
}
|
||||
|
||||
//color
|
||||
if (bp_.isfontcolor) {
|
||||
colorModule->fontColorPB->setStyleSheet(
|
||||
|
@ -104,6 +104,7 @@ private Q_SLOTS:
|
||||
void browseLayout();
|
||||
void browseMaster();
|
||||
void classChanged();
|
||||
void languagePackageChanged(int);
|
||||
void bibtexChanged(int);
|
||||
void updateModuleInfo();
|
||||
void modulesChanged();
|
||||
|
@ -1,91 +1,44 @@
|
||||
<ui version="4.0" >
|
||||
<ui version="4.0">
|
||||
<class>LanguageUi</class>
|
||||
<widget class="QWidget" name="LanguageUi" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="LanguageUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>257</width>
|
||||
<height>257</height>
|
||||
<width>335</width>
|
||||
<height>282</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Encoding</string>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="languageL">
|
||||
<property name="text">
|
||||
<string>&Language:</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
<property name="buddy">
|
||||
<cstring>languageCO</cstring>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QRadioButton" name="defaultencodingRB" >
|
||||
<property name="text" >
|
||||
<string>Language &Default</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QRadioButton" name="otherencodingRB" >
|
||||
<property name="text" >
|
||||
<string>&Other:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QComboBox" name="encodingCO" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="duplicatesEnabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="languageCO">
|
||||
<property name="maxVisibleItems">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>71</width>
|
||||
<height>23</height>
|
||||
@ -93,45 +46,127 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="languageL" >
|
||||
<property name="text" >
|
||||
<string>&Language:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>languageCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="typeL" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="typeL">
|
||||
<property name="text">
|
||||
<string>&Quote Style:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>quoteStyleCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QComboBox" name="quoteStyleCO" />
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="quoteStyleCO"/>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="languageCO" >
|
||||
<property name="maxVisibleItems" >
|
||||
<number>20</number>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Encoding</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="defaultencodingRB">
|
||||
<property name="text">
|
||||
<string>Language &Default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="otherencodingRB">
|
||||
<property name="text">
|
||||
<string>&Other:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="encodingCO">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="duplicatesEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<item row="3" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="languagePackageLA">
|
||||
<property name="text">
|
||||
<string>Language pac&kage:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>languagePackageCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="languagePackageCO">
|
||||
<property name="toolTip">
|
||||
<string>Select which language package LyX should use</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="languagePackageED">
|
||||
<property name="toolTip">
|
||||
<string>Enter the command to load the language package (default: babel)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>38</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>71</width>
|
||||
<height>171</height>
|
||||
@ -149,7 +184,7 @@
|
||||
<tabstop>encodingCO</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections>
|
||||
@ -159,11 +194,11 @@
|
||||
<receiver>encodingCO</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>34</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>107</x>
|
||||
<y>145</y>
|
||||
</hint>
|
||||
|
Loading…
Reference in New Issue
Block a user