Initial work to fix bug involving embedded macros and

XHTML output.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38613 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-05-07 11:57:08 +00:00
parent 0ba6efb073
commit 5855043599
7 changed files with 18 additions and 14 deletions

View File

@ -830,7 +830,7 @@ bool Buffer::readDocument(Lexer & lex)
}
usermacros.clear();
updateMacros();
updateMacroInstances();
updateMacroInstances(InternalUpdate);
return res;
}
@ -1281,7 +1281,7 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
// FIXME Do we need to do this all the time? I.e., in children
// of a master we are exporting?
updateBuffer();
updateMacroInstances();
updateMacroInstances(OutputUpdate);
try {
os.texrow().reset();
@ -1512,7 +1512,7 @@ void Buffer::makeDocBookFile(FileName const & fname,
// make sure we are ready to export
// this needs to be done before we validate
updateBuffer();
updateMacroInstances();
updateMacroInstances(OutputUpdate);
writeDocBookSource(ofs, fname.absFileName(), runparams, body_only);
@ -1608,7 +1608,7 @@ void Buffer::makeLyXHTMLFile(FileName const & fname,
// make sure we are ready to export
// this has to be done before we validate
updateBuffer(UpdateMaster, OutputUpdate);
updateMacroInstances();
updateMacroInstances(OutputUpdate);
writeLyXHTMLSource(ofs, runparams, body_only);
@ -2927,7 +2927,7 @@ void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_mast
}
void Buffer::updateMacroInstances() const
void Buffer::updateMacroInstances(UpdateType utype) const
{
LYXERR(Debug::MACROS, "updateMacroInstances for "
<< d->filename.onlyFileName());
@ -2945,7 +2945,7 @@ void Buffer::updateMacroInstances() const
MacroContext mc = MacroContext(this, it);
for (DocIterator::idx_type i = 0; i < n; ++i) {
MathData & data = minset->cell(i);
data.updateMacros(0, mc);
data.updateMacros(0, mc, utype);
}
}
}

View File

@ -530,7 +530,7 @@ public:
/// Collect macro definitions in paragraphs
void updateMacros() const;
/// Iterate through the whole buffer and try to resolve macros
void updateMacroInstances() const;
void updateMacroInstances(UpdateType) const;
/// List macro names of this buffer, the parent and the children
void listMacroNames(MacroNameSet & macros) const;

View File

@ -252,7 +252,7 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
}
Cursor & cur = mi.base.bv->cursor();
const_cast<MathData*>(this)->updateMacros(&cur, mi.macrocontext);
const_cast<MathData*>(this)->updateMacros(&cur, mi.macrocontext, InternalUpdate);
DocIterator const & inlineCompletionPos = mi.base.bv->inlineCompletionPos();
MathData const * inlineCompletionData = 0;
@ -387,7 +387,8 @@ void MathData::updateBuffer(ParIterator const & it, UpdateType utype)
}
void MathData::updateMacros(Cursor * cur, MacroContext const & mc)
void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
UpdateType utype)
{
// If we are editing a macro, we cannot update it immediately,
// otherwise wrong undo steps will be recorded (bug 6208).
@ -484,7 +485,7 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc)
if (inset->asScriptInset())
inset = inset->asScriptInset()->nuc()[0].nucleus();
LASSERT(inset->asMacro(), /**/);
inset->asMacro()->updateRepresentation();
inset->asMacro()->updateRepresentation(cur, mc, utype);
}
}

View File

@ -167,7 +167,7 @@ public:
/// attach/detach arguments to macros, updating the cur to
/// stay visually at the same position (cur==0 is allowed)
void updateMacros(Cursor * cur, MacroContext const & mc);
void updateMacros(Cursor * cur, MacroContext const & mc, UpdateType);
///
void updateBuffer(ParIterator const &, UpdateType);

View File

@ -311,7 +311,8 @@ void MathMacro::updateMacro(MacroContext const & mc)
}
void MathMacro::updateRepresentation()
void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
UpdateType utype)
{
// known macro?
if (macro_ == 0)
@ -342,6 +343,8 @@ void MathMacro::updateRepresentation()
}
// expanding macro with the values
macro_->expand(values, expanded_.cell(0));
if (utype == OutputUpdate && !expanded_.cell(0).empty())
expanded_.cell(0).updateMacros(cur, mc, utype);
// get definition for list edit mode
docstring const & display = macro_->display();
asArray(display.empty() ? macro_->definition() : display, definition_);

View File

@ -139,7 +139,7 @@ protected:
/// update macro definition
void updateMacro(MacroContext const & mc);
/// check if macro definition changed, argument changed etc. and adapt
void updateRepresentation();
void updateRepresentation(Cursor * cur, MacroContext const & mc, UpdateType);
/// empty macro, put arguments into args, possibly strip arity-attachedArgsNum_ empty ones.
/// Includes the optional arguments.
void detachArguments(std::vector<MathData> & args, bool strip);

View File

@ -40,7 +40,7 @@ void writePlaintextFile(Buffer const & buf, FileName const & fname,
// make sure we are ready to export
buf.updateBuffer();
buf.updateMacroInstances();
buf.updateMacroInstances(OutputUpdate);
writePlaintextFile(buf, ofs, runparams);
}