- UI support for the LaTeX-package undertilde, fileformat change, fixed the remaining part of bug #6622, Georg already implemented the non-UI support

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39464 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2011-08-10 03:37:33 +00:00
parent a95e0ee47b
commit 30de1c744e
10 changed files with 122 additions and 14 deletions

View File

@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2011-07-30 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 415 (r36xxx)
support for the LaTeX-package undertilde (fix bug 6622)
New buffer param \use_undertilde
2011-07-02 Pavel Sanda <sanda@lyx.org>
* Format incremented to 414 (rXXXX)
New InsetSpace param \textvisiblespace

View File

@ -25,14 +25,14 @@ import sys, os
# Uncomment only what you need to import, please.
from parser_tools import find_token, find_end_of_inset
from parser_tools import find_token, find_end_of_inset, get_value
#from parser_tools import find_token, find_end_of, find_tokens, \
#find_token_exact, find_end_of_inset, find_end_of_layout, \
#find_token_backwards, is_in_inset, get_value, get_quoted_value, \
#del_token, check_token, get_option_value
from lyx2lyx_tools import put_cmd_in_ert
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
#from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
# put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
@ -69,15 +69,66 @@ def revert_visible_space(document):
document.body[i:end + 1] = subst
def convert_undertilde(document):
" Load undertilde automatically "
i = find_token(document.header, "\\use_mathdots" , 0)
if i != -1:
document.header.insert(i + 1, "\\use_undertilde 1")
def revert_undertilde(document):
" Load undertilde if used in the document "
undertilde = find_token(document.header, "\\use_undertilde" , 0)
if undertilde == -1:
document.warning("No \\use_undertilde line. Assuming auto.")
else:
val = get_value(document.header, "\\use_undertilde", undertilde)
del document.header[undertilde]
try:
usetilde = int(val)
except:
document.warning("Invalid \\use_undertilde value: " + val + ". Assuming auto.")
# probably usedots has not been changed, but be safe.
usetilde = 1
if usetilde == 0:
# do not load case
return
if usetilde == 2:
# force load case
add_to_preamble(document, ["\\usepackage{undertilde}"])
return
# so we are in the auto case. we want to load undertilde if \utilde is used.
i = 0
while True:
i = find_token(document.body, '\\begin_inset Formula', i)
if i == -1:
return
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(i))
i += 1
continue
code = "\n".join(document.body[i:j])
if code.find("\\utilde") != -1:
add_to_preamble(document, ["\\@ifundefined{utilde}{\\usepackage{undertilde}}"])
return
i = j
##
# Conversion hub
#
supported_versions = ["2.1.0","2.1"]
convert = [[414, []]
convert = [[414, []],
[415, [convert_undertilde]]
]
revert = [[413, [revert_visible_space]]
revert = [[414, [revert_undertilde]],
[413, [revert_visible_space]]
]

View File

@ -30,10 +30,7 @@ underrightarrow decoration none amsmath
#have a possibility to turn automatic loading off like for ams
#undertilde decoration none accents
undertilde decoration none
#Do not load automatically, since it might conflict with user macros and we
#don't have a possibility to turn automatic loading off like for ams
#utilde decoration none undertilde
utilde decoration none
utilde decoration none undertilde
vec decoration none
widehat decoration none
widetilde decoration none

View File

@ -398,8 +398,7 @@ ToolbarSet
Item "check" "math-insert \check"
Item "widehat" "math-insert \widehat"
Item "widetilde" "math-insert \widetilde"
# enable this once the undertilde package is loaded automatically
# Item "utilde" "math-insert \utilde"
Item "utilde" "math-insert \utilde"
Item "vec" "math-insert \vec"
Item "acute" "math-insert \acute"
Item "ddot" "math-insert \ddot"

View File

@ -128,7 +128,7 @@ namespace {
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
int const LYX_FORMAT = 414; //ps : visible space
int const LYX_FORMAT = 415; //uwestoehr : support for package undertilde (bug 6622)
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -365,6 +365,7 @@ BufferParams::BufferParams()
use_esint = package_auto;
use_mhchem = package_auto;
use_mathdots = package_auto;
use_undertilde = package_auto;
cite_engine_ = ENGINE_BASIC;
use_bibtopic = false;
use_indices = false;
@ -686,6 +687,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
int usemathdots;
lex >> usemathdots;
use_mathdots = packagetranslator().find(usemathdots);
} else if (token == "\\use_undertilde") {
int useundertilde;
lex >> useundertilde;
use_undertilde = packagetranslator().find(useundertilde);
} else if (token == "\\cite_engine") {
string engine;
lex >> engine;
@ -991,6 +996,7 @@ void BufferParams::writeFile(ostream & os) const
<< "\n\\use_esint " << use_esint
<< "\n\\use_mhchem " << use_mhchem
<< "\n\\use_mathdots " << use_mathdots
<< "\n\\use_undertilde " << use_undertilde
<< "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
<< "\n\\use_indices " << convert<string>(use_indices)
@ -1163,6 +1169,8 @@ void BufferParams::validate(LaTeXFeatures & features) const
features.require("mhchem");
if (use_mathdots == package_on)
features.require("mathdots");
if (use_undertilde == package_on)
features.require("undertilde");
// Document-level line spacing
if (spacing().getSpace() != Spacing::Single && !spacing().isDefault())

View File

@ -349,6 +349,8 @@ public:
Package use_mhchem;
/// Whether and how to load mathdots
Package use_mathdots;
/// Whether and how to load undertilde
Package use_undertilde;
/// Split bibliography?
bool use_bibtopic;
/// Split the index?

View File

@ -614,8 +614,7 @@ char const * simplefeatures[] = {
"amscd",
"slashed",
"multirow",
"tfrupee",
"undertilde",
"tfrupee"
};
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
@ -745,6 +744,10 @@ string const LaTeXFeatures::getPackages() const
if (mustProvide("yhmath"))
packages << "\\usepackage{yhmath}\n";
if (mustProvide("undertilde") &&
params_.use_undertilde != BufferParams::package_off)
packages << "\\usepackage{undertilde}\n";
// [x]color and pdfcolmk are handled in getColorOptions() above
// makeidx.sty

View File

@ -1135,6 +1135,8 @@ GuiDocument::GuiDocument(GuiView & lv)
mathsModule->mhchemCB, SLOT(setDisabled(bool)));
connect(mathsModule->mathdotsautoCB, SIGNAL(toggled(bool)),
mathsModule->mathdotsCB, SLOT(setDisabled(bool)));
connect(mathsModule->undertildeautoCB, SIGNAL(toggled(bool)),
mathsModule->undertildeCB, SLOT(setDisabled(bool)));
connect(mathsModule->amsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
@ -1152,6 +1154,10 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(mathsModule->mathdotsautoCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(mathsModule->undertildeCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(mathsModule->undertildeautoCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
// latex class
@ -2343,6 +2349,14 @@ void GuiDocument::applyView()
else
bp_.use_mathdots = BufferParams::package_off;
}
if (mathsModule->undertildeautoCB->isChecked())
bp_.use_undertilde = BufferParams::package_auto;
else {
if (mathsModule->undertildeCB->isChecked())
bp_.use_undertilde = BufferParams::package_on;
else
bp_.use_undertilde = BufferParams::package_off;
}
// Page Layout
if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
@ -2756,6 +2770,11 @@ void GuiDocument::paramsToDialog()
mathsModule->mathdotsautoCB->setChecked(
bp_.use_mathdots == BufferParams::package_auto);
mathsModule->undertildeCB->setChecked(
bp_.use_undertilde == BufferParams::package_on);
mathsModule->undertildeautoCB->setChecked(
bp_.use_undertilde == BufferParams::package_auto);
switch (bp_.spacing().getSpace()) {
case Spacing::Other: nitem = 3; break;
case Spacing::Double: nitem = 2; break;

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MathsUi</class>
<widget class="QWidget" name="MathsUi">
@ -6,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>351</width>
<height>224</height>
<height>261</height>
</rect>
</property>
<property name="windowTitle">
@ -103,6 +104,29 @@
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="undertildeautoCB">
<property name="toolTip">
<string>The LaTeX package undertilde is only used if you use the math frame decoration 'utilde'</string>
</property>
<property name="text">
<string>Use u&amp;ndertilde package automatically</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="undertildeCB">
<property name="toolTip">
<string>The LaTeX package undertilde is always used</string>
</property>
<property name="text">
<string>Use undertilde pac&amp;kage</string>
</property>
</widget>
</item>
<item row="10" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>