mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Patch by John McCabe-Dansted to fix bug #6502:
Wrong line count with parent math macros: * TeXRow.{cpp,h}: - new helper function to insert multiple newline at once. * mathed/MacroTable.{cpp,h}: * mathed/MacroTemplate.{cpp,h}: - make write() an int, returning number of newlines * Buffer.cpp (writeLaTeXSource): - update texrow's newline on parent macro output. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33367 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a61eeb1fb2
commit
a70e21a34e
@ -1341,8 +1341,11 @@ void Buffer::writeLaTeXSource(odocstream & os,
|
||||
// output the parent macros
|
||||
MacroSet::iterator it = parentMacros.begin();
|
||||
MacroSet::iterator end = parentMacros.end();
|
||||
for (; it != end; ++it)
|
||||
(*it)->write(os, true);
|
||||
for (; it != end; ++it) {
|
||||
int num_lines = (*it)->write(os, true);
|
||||
d->texrow.newlines(num_lines);
|
||||
}
|
||||
|
||||
} // output_preamble
|
||||
|
||||
d->texrow.start(paragraphs().begin()->id(), 0);
|
||||
|
@ -44,6 +44,12 @@ void TexRow::newline()
|
||||
rowlist.push_back(tmp);
|
||||
}
|
||||
|
||||
void TexRow::newlines(int num_lines)
|
||||
{
|
||||
for (int i = 0; i < num_lines; ++i) {
|
||||
newline();
|
||||
}
|
||||
}
|
||||
|
||||
bool TexRow::getIdFromRow(int row, int & id, int & pos) const
|
||||
{
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
/// Insert node when line is completed
|
||||
void newline();
|
||||
|
||||
/// Insert multiple nodes when zero or more lines are completed
|
||||
void newlines(int num_lines);
|
||||
|
||||
/**
|
||||
* getIdFromRow - find pid and position for a given row
|
||||
* @param row row number to find
|
||||
|
@ -152,7 +152,7 @@ void MacroData::updateData() const
|
||||
}
|
||||
|
||||
|
||||
void MacroData::write(odocstream & os, bool overwriteRedefinition) const
|
||||
int MacroData::write(odocstream & os, bool overwriteRedefinition) const
|
||||
{
|
||||
updateData();
|
||||
|
||||
@ -160,14 +160,14 @@ void MacroData::write(odocstream & os, bool overwriteRedefinition) const
|
||||
Inset * inset = pos_.nextInset();
|
||||
if (inset == 0 || inset->lyxCode() != MATHMACRO_CODE) {
|
||||
lyxerr << "BUG: No macro template found by MacroData" << endl;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// output template
|
||||
MathMacroTemplate const & tmpl =
|
||||
static_cast<MathMacroTemplate const &>(*inset);
|
||||
WriteStream wi(os, false, true, WriteStream::wsDefault);
|
||||
tmpl.write(wi, overwriteRedefinition);
|
||||
return tmpl.write(wi, overwriteRedefinition);
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
MacroType & type() { return type_; }
|
||||
|
||||
/// output as TeX macro, only works for lazy MacroData!!!
|
||||
void write(odocstream & os, bool overwriteRedefinition) const;
|
||||
int write(odocstream & os, bool overwriteRedefinition) const;
|
||||
|
||||
///
|
||||
bool operator==(MacroData const & x) const {
|
||||
|
@ -1154,8 +1154,10 @@ void MathMacroTemplate::write(WriteStream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const
|
||||
int MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const
|
||||
{
|
||||
int num_lines = 0;
|
||||
|
||||
if (os.latex()) {
|
||||
if (optionals_ > 0) {
|
||||
// macros with optionals use the xargs package, e.g.:
|
||||
@ -1218,11 +1220,16 @@ void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) cons
|
||||
if (os.latex()) {
|
||||
// writing .tex. done.
|
||||
os << "\n";
|
||||
++num_lines;
|
||||
} else {
|
||||
// writing .lyx, write special .tex export only if necessary
|
||||
if (!cell(displayIdx()).empty())
|
||||
if (!cell(displayIdx()).empty()) {
|
||||
os << "\n{" << cell(displayIdx()) << '}';
|
||||
++num_lines;
|
||||
}
|
||||
}
|
||||
|
||||
return num_lines;
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
void write(WriteStream & os) const;
|
||||
/// Output LaTeX code, but assume that the macro is not definied yet
|
||||
/// if overwriteRedefinition is true
|
||||
void write(WriteStream & os, bool overwriteRedefinition) const;
|
||||
int write(WriteStream & os, bool overwriteRedefinition) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user