On Mon, Feb 8, 2010 at 9:37 PM, Jürgen Spitzmüller <[email protected]> wrote:
> + for (i = 0; i < num_lines; ++i) {
(attached)
--
John C. McCabe-Dansted
Index: mathed/MacroTable.h
===================================================================
--- mathed/MacroTable.h (revision 33347)
+++ mathed/MacroTable.h (working copy)
@@ -81,7 +81,7 @@
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 {
Index: mathed/MathMacroTemplate.h
===================================================================
--- mathed/MathMacroTemplate.h (revision 33347)
+++ mathed/MathMacroTemplate.h (working copy)
@@ -49,7 +49,7 @@
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;
///
Index: mathed/MathMacroTemplate.cpp
===================================================================
--- mathed/MathMacroTemplate.cpp (revision 33347)
+++ mathed/MathMacroTemplate.cpp (working copy)
@@ -1154,8 +1154,10 @@
}
-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 @@
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;
}
Index: mathed/MacroTable.cpp
===================================================================
--- mathed/MacroTable.cpp (revision 33347)
+++ mathed/MacroTable.cpp (working copy)
@@ -152,7 +152,7 @@
}
-void MacroData::write(odocstream & os, bool overwriteRedefinition) const
+int MacroData::write(odocstream & os, bool overwriteRedefinition) const
{
updateData();
@@ -160,14 +160,14 @@
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);
}
Index: TexRow.h
===================================================================
--- TexRow.h (revision 33347)
+++ TexRow.h (working copy)
@@ -37,6 +37,9 @@
/// 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
Index: TexRow.cpp
===================================================================
--- TexRow.cpp (revision 33347)
+++ TexRow.cpp (working copy)
@@ -44,6 +44,13 @@
rowlist.push_back(tmp);
}
+void TexRow::newlines(int num_lines)
+{
+ int i;
+ for (i = 0; i < num_lines; ++i) {
+ newline();
+ }
+}
bool TexRow::getIdFromRow(int row, int & id, int & pos) const
{
Index: Buffer.cpp
===================================================================
--- Buffer.cpp (revision 33347)
+++ Buffer.cpp (working copy)
@@ -1341,8 +1341,11 @@
// 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);