mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-12 16:50:39 +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/branches/BRANCH_1_6_X@33368 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
811688510c
commit
879272068b
@ -1213,8 +1213,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
|
||||
|
@ -151,7 +151,7 @@ void MacroData::updateData() const
|
||||
}
|
||||
|
||||
|
||||
void MacroData::write(odocstream & os, bool overwriteRedefinition) const
|
||||
int MacroData::write(odocstream & os, bool overwriteRedefinition) const
|
||||
{
|
||||
updateData();
|
||||
|
||||
@ -159,14 +159,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 {
|
||||
|
@ -1150,8 +1150,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.:
|
||||
@ -1214,11 +1216,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