mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
support for the document class option leqno
- fileformat change
This commit is contained in:
parent
d318a8a6f2
commit
3f8c15a7c6
@ -6,6 +6,10 @@ changes happened in particular if possible. A good example would be
|
||||
2010-01-10 entry.
|
||||
|
||||
-----------------------
|
||||
2017-04-25 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 542: support for document class option "leqno"
|
||||
New buffer parameter \math_number_before
|
||||
|
||||
2017-04-19 Günter Milde <milde@lyx.org>
|
||||
* Format incremented to 541: changes \SpecialChar:
|
||||
- new argument "allowbreak" to mark an optional line break
|
||||
|
@ -2122,6 +2122,7 @@ def revert_rotfloat(document):
|
||||
|
||||
i = i + 1
|
||||
|
||||
|
||||
def convert_allowbreak(document):
|
||||
" Zero widths Space-inset -> \SpecialChar allowbreak. "
|
||||
body = "\n".join(document.body)
|
||||
@ -2131,6 +2132,7 @@ def convert_allowbreak(document):
|
||||
"\\SpecialChar allowbreak\n")
|
||||
document.body = body.split("\n")
|
||||
|
||||
|
||||
def revert_allowbreak(document):
|
||||
" \SpecialChar allowbreak -> Zero widths Space-inset. "
|
||||
body = "\n".join(document.body)
|
||||
@ -2141,6 +2143,45 @@ def revert_allowbreak(document):
|
||||
document.body = body.split("\n")
|
||||
|
||||
|
||||
def convert_mathnumberpos(document):
|
||||
" add the \math_number_before tag "
|
||||
# check if the document uses the class option "leqno"
|
||||
k = find_token(document.header, "\\quotes_style", 0)
|
||||
regexp = re.compile(r'^.*leqno.*')
|
||||
i = find_re(document.header, regexp, 0)
|
||||
if i != -1:
|
||||
document.header.insert(k, "\\math_number_before 1")
|
||||
# delete the found option
|
||||
document.header[i] = document.header[i].replace(",leqno", "")
|
||||
document.header[i] = document.header[i].replace(", leqno", "")
|
||||
document.header[i] = document.header[i].replace("leqno,", "")
|
||||
j = find_re(document.header, regexp, 0)
|
||||
if i == j:
|
||||
# then we have fleqn as the only option
|
||||
del document.header[i]
|
||||
else:
|
||||
document.header.insert(k, "\\math_number_before 0")
|
||||
|
||||
|
||||
def revert_mathnumberpos(document):
|
||||
" add the document class option leqno"
|
||||
regexp = re.compile(r'(\\math_number_before 1)')
|
||||
i = find_re(document.header, regexp, 0)
|
||||
if i == -1:
|
||||
regexp = re.compile(r'(\\math_number_before)')
|
||||
j = find_re(document.header, regexp, 0)
|
||||
del document.header[j]
|
||||
else:
|
||||
k = find_token(document.header, "\\options", 0)
|
||||
if k != -1:
|
||||
document.header[k] = document.header[k].replace("\\options", "\\options leqno,")
|
||||
del document.header[i]
|
||||
else:
|
||||
l = find_token(document.header, "\\use_default_options", 0)
|
||||
document.header.insert(l, "\\options leqno")
|
||||
del document.header[i + 1]
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -2180,9 +2221,11 @@ convert = [
|
||||
[539, []],
|
||||
[540, []],
|
||||
[541, [convert_allowbreak]],
|
||||
]
|
||||
[542, [convert_mathnumberpos]]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[541, [revert_mathnumberpos]],
|
||||
[540, [revert_allowbreak]],
|
||||
[539, [revert_rotfloat]],
|
||||
[538, [revert_baselineskip]],
|
||||
|
@ -385,6 +385,7 @@ BufferParams::BufferParams()
|
||||
makeDocumentClass();
|
||||
paragraph_separation = ParagraphIndentSeparation;
|
||||
is_math_indent = false;
|
||||
math_number_before = false;
|
||||
quotes_style = InsetQuotesParams::EnglishQuotes;
|
||||
dynamic_quotes = false;
|
||||
fontsize = "default";
|
||||
@ -852,6 +853,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
} else if (token == "\\math_indentation") {
|
||||
lex.next();
|
||||
pimpl_->mathindent = Length(lex.getString());
|
||||
} else if (token == "\\math_number_before") {
|
||||
lex >> math_number_before;
|
||||
} else if (token == "\\quotes_style") {
|
||||
string qstyle;
|
||||
lex >> qstyle;
|
||||
@ -1352,6 +1355,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
|
||||
os << "\n\\is_math_indent " << is_math_indent;
|
||||
if (is_math_indent && !getMathIndent().empty())
|
||||
os << "\n\\math_indentation " << getMathIndent().asString();
|
||||
os << "\n\\math_number_before " << math_number_before;
|
||||
os << "\n\\quotes_style "
|
||||
<< string_quotes_style[quotes_style]
|
||||
<< "\n\\dynamic_quotes " << dynamic_quotes
|
||||
@ -1636,6 +1640,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
if (is_math_indent)
|
||||
clsoptions << "fleqn,";
|
||||
|
||||
if (math_number_before)
|
||||
clsoptions << "leqno,";
|
||||
|
||||
// language should be a parameter to \documentclass
|
||||
if (language->babel() == "hebrew"
|
||||
&& default_language->babel() != "hebrew")
|
||||
|
@ -109,6 +109,10 @@ public:
|
||||
/// Whether formulas are indented
|
||||
bool is_math_indent;
|
||||
|
||||
|
||||
/// number formulas before them
|
||||
bool math_number_before;
|
||||
|
||||
/** Whether paragraphs are separated by using a indent like in
|
||||
* articles or by using a little skip like in letters.
|
||||
*/
|
||||
|
@ -1279,6 +1279,12 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(mathsModule->allPackagesNotPB, SIGNAL(clicked()),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(mathsModule->MathNumberingPosCO, SIGNAL(activated(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
|
||||
mathsModule->MathNumberingPosCO->addItem(qt_("Before"));
|
||||
mathsModule->MathNumberingPosCO->addItem(qt_("After"));
|
||||
mathsModule->MathNumberingPosCO->setCurrentIndex(2);
|
||||
|
||||
|
||||
// latex class
|
||||
@ -2922,6 +2928,19 @@ void GuiDocument::applyView()
|
||||
textLayoutModule->MathIndentLengthCO));
|
||||
bp_.setMathIndent(mathindent);
|
||||
}
|
||||
switch (mathsModule->MathNumberingPosCO->currentIndex()) {
|
||||
case 0:
|
||||
bp_.math_number_before = true;
|
||||
break;
|
||||
case 1:
|
||||
bp_.math_number_before = false;
|
||||
break;
|
||||
default:
|
||||
// this should never happen
|
||||
bp_.math_number_before = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Page Layout
|
||||
if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
|
||||
bp_.pagestyle = "default";
|
||||
@ -3403,6 +3422,10 @@ void GuiDocument::paramsToDialog()
|
||||
textLayoutModule->MathIndentCO->setCurrentIndex(indent);
|
||||
setMathIndent(indent);
|
||||
}
|
||||
if (bp_.math_number_before)
|
||||
mathsModule->MathNumberingPosCO->setCurrentIndex(0);
|
||||
else
|
||||
mathsModule->MathNumberingPosCO->setCurrentIndex(1);
|
||||
|
||||
map<string, string> const & packages = BufferParams::auto_packages();
|
||||
for (map<string, string>::const_iterator it = packages.begin();
|
||||
|
@ -13,8 +13,72 @@
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="4">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="allPakcagesLA">
|
||||
<property name="text">
|
||||
<string>All packages:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QPushButton" name="allPackagesAutoPB">
|
||||
<property name="text">
|
||||
<string>Load A&utomatically</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="allPackagesAlwaysPB">
|
||||
<property name="text">
|
||||
<string>Load Alwa&ys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" colspan="2">
|
||||
<widget class="QPushButton" name="allPackagesNotPB">
|
||||
<property name="text">
|
||||
<string>Do &Not Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="MathNumberingPosL">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>115</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number formulas:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2">
|
||||
<widget class="QComboBox" name="MathNumberingPosCO">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Size of the indentation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<spacer name="horizontalSpacer_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>268</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="6">
|
||||
<widget class="QTableWidget" name="packagesTW">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -37,34 +101,6 @@
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="allPakcagesLA">
|
||||
<property name="text">
|
||||
<string>All packages:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="allPackagesAutoPB">
|
||||
<property name="text">
|
||||
<string>Load A&utomatically</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="allPackagesAlwaysPB">
|
||||
<property name="text">
|
||||
<string>Load Alwa&ys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="allPackagesNotPB">
|
||||
<property name="text">
|
||||
<string>Do &Not Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<includes>
|
||||
|
@ -494,6 +494,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
|
||||
h_font_tt_scale[1] = "100";
|
||||
//h_font_cjk
|
||||
h_is_mathindent = "0";
|
||||
h_math_number_before = "0";
|
||||
h_graphics = "default";
|
||||
h_default_output_format = "default";
|
||||
h_html_be_strict = "false";
|
||||
@ -1293,6 +1294,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
|
||||
os << "\\is_math_indent " << h_is_mathindent << "\n";
|
||||
if (!h_mathindentation.empty())
|
||||
os << "\\math_indentation " << h_mathindentation << "\n";
|
||||
os << "\\math_number_before " << h_math_number_before << "\n";
|
||||
os << "\\quotes_style " << h_quotes_style << "\n"
|
||||
<< "\\dynamic_quotes " << h_dynamic_quotes << "\n"
|
||||
<< "\\papercolumns " << h_papercolumns << "\n"
|
||||
@ -1687,6 +1689,13 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
||||
h_is_mathindent = "1";
|
||||
opts.erase(it);
|
||||
}
|
||||
// formula numbering side
|
||||
if ((it = find(opts.begin(), opts.end(), "leqno"))
|
||||
!= opts.end()) {
|
||||
h_math_number_before = "1";
|
||||
opts.erase(it);
|
||||
}
|
||||
|
||||
// paper orientation
|
||||
if ((it = find(opts.begin(), opts.end(), "landscape")) != opts.end()) {
|
||||
h_paperorientation = "landscape";
|
||||
|
@ -154,6 +154,7 @@ private:
|
||||
std::string h_font_cjk;
|
||||
std::string h_use_microtype;
|
||||
std::string h_is_mathindent;
|
||||
std::string h_math_number_before;
|
||||
std::string h_mathindentation;
|
||||
std::string h_graphics;
|
||||
std::string h_default_output_format;
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 541 // milde: \SpecialChar allowbreak
|
||||
#define LYX_FORMAT_TEX2LYX 541
|
||||
#define LYX_FORMAT_LYX 542 // uwestoehr: support for class option leqno
|
||||
#define LYX_FORMAT_TEX2LYX 542
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user