void Buffer::getLabelList(vector<docstring> & list) const
{
- /// if this is a child document and the parent is already loaded
- /// Use the parent's list instead [ale990407]
- Buffer const * tmp = masterBuffer();
- if (!tmp) {
- lyxerr << "masterBuffer() failed!" << endl;
- BOOST_ASSERT(tmp);
- }
- if (tmp != this) {
- tmp->getLabelList(list);
+ // If this is a child document, use the parent's list instead.
+ if (d->parent_buffer) {
+ d->parent_buffer->getLabelList(list);
return;
}
- updateMacros();
-
- for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
- it.nextInset()->getLabelList(list);
+ list.clear();
+ Toc & toc = d->toc_backend.toc("label");
+ TocIterator toc_it = toc.begin();
+ TocIterator end = toc.end();
+ for (; toc_it != end; ++toc_it) {
+ if (toc_it->depth() == 0)
+ list.push_back(toc_it->str());
+ }
}
void Buffer::updateBibfilesCache() const
{
- // if this is a child document and the parent is already loaded
- // update the parent's cache instead
- Buffer const * tmp = masterBuffer();
- BOOST_ASSERT(tmp);
- if (tmp != this) {
- tmp->updateBibfilesCache();
+ // If this is a child document, use the parent's cache instead.
+ if (d->parent_buffer) {
+ d->parent_buffer->updateBibfilesCache();
return;
}
EmbeddedFileList const & Buffer::getBibfilesCache() const
{
- // if this is a child document and the parent is already loaded
- // use the parent's cache instead
- Buffer const * tmp = masterBuffer();
- BOOST_ASSERT(tmp);
- if (tmp != this)
- return tmp->getBibfilesCache();
+ // If this is a child document, use the parent's cache instead.
+ if (d->parent_buffer)
+ return d->parent_buffer->getBibfilesCache();
// We update the cache when first used instead of at loading time.
if (d->bibfilesCache_.empty())
// If there is a master buffer, query that
if (d->parent_buffer) {
d->macro_lock = true;
- MacroData const * macro
- = d->parent_buffer->getMacro(name, *this, false);
+ MacroData const * macro = d->parent_buffer->getMacro(
+ name, *this, false);
d->macro_lock = false;
if (macro)
return macro;
}
-MacroData const * Buffer::getMacro(docstring const & name, Buffer const & child, bool global) const
+MacroData const * Buffer::getMacro(docstring const & name,
+ Buffer const & child, bool global) const
{
// look where the child buffer is included first
- Impl::BufferPositionMap::iterator it
- = d->children_positions.find(&child);
+ Impl::BufferPositionMap::iterator it = d->children_positions.find(&child);
if (it == d->children_positions.end())
return 0;
}
-void Buffer::updateEnvironmentMacros(DocIterator & it,
- pit_type lastpit,
- DocIterator & scope) const
+void Buffer::updateEnvironmentMacros(DocIterator & it, pit_type lastpit,
+ DocIterator & scope) const
{
Paragraph & par = it.paragraph();
- depth_type depth
- = par.params().depth();
- Length const & leftIndent
- = par.params().leftIndent();
+ depth_type depth = par.params().depth();
+ Length const & leftIndent = par.params().leftIndent();
// look for macros in each paragraph
while (it.pit() <= lastpit) {
// increased depth?
if ((par.params().depth() > depth
- || par.params().leftIndent() != leftIndent)
+ || par.params().leftIndent() != leftIndent)
&& par.layout().isEnvironment()) {
updateBlockMacros(it, scope);
continue;
if (iit->inset->lyxCode() == INCLUDE_CODE) {
// get buffer of external file
InsetCommand const & inset
- = static_cast<InsetCommand const &>(*iit->inset);
+ = static_cast<InsetCommand const &>(*iit->inset);
InsetCommandParams const & ip = inset.params();
d->macro_lock = true;
Buffer * child = loadIfNeeded(*this, ip);
// register its position, but only when it is
// included first in the buffer
if (d->children_positions.find(child)
- == d->children_positions.end())
+ == d->children_positions.end())
d->children_positions[child] = it;
// register child with its scope
d->position_to_children[it] = Impl::ScopeBuffer(scope, child);
-
continue;
}
continue;
// register macro
- d->macros[macroTemplate.name()][it]
- = Impl::ScopeMacro(scope, MacroData(*this, it));
+ d->macros[macroTemplate.name()][it] =
+ Impl::ScopeMacro(scope, MacroData(*this, it));
}
// next paragraph
d->macro_lock = true;
// loop over macro names
- Impl::NamePositionScopeMacroMap::iterator nameIt
- = d->macros.begin();
- Impl::NamePositionScopeMacroMap::iterator nameEnd
- = d->macros.end();
+ Impl::NamePositionScopeMacroMap::iterator nameIt = d->macros.begin();
+ Impl::NamePositionScopeMacroMap::iterator nameEnd = d->macros.end();
for (; nameIt != nameEnd; ++nameIt)
macros.insert(nameIt->first);
// loop over children
- Impl::BufferPositionMap::iterator it
- = d->children_positions.begin();
- Impl::BufferPositionMap::iterator end
- = d->children_positions.end();
+ Impl::BufferPositionMap::iterator it = d->children_positions.begin();
+ Impl::BufferPositionMap::iterator end = d->children_positions.end();
for (; it != end; ++it)
it->first->listMacroNames(macros);
static InsetLabel const * dummy_il = 0;
static References const dummy_refs;
- it = d->ref_cache_.insert(make_pair(label, make_pair(dummy_il, dummy_refs))).first;
+ it = d->ref_cache_.insert(
+ make_pair(label, make_pair(dummy_il, dummy_refs))).first;
return it->second.second;
}
InsetCode code)
{
//FIXME: This does not work for child documents yet.
- BOOST_ASSERT(code == CITE_CODE || code == REF_CODE);
+ BOOST_ASSERT(code == CITE_CODE);
// Check if the label 'from' appears more than once
vector<docstring> labels;
-
string paramName;
- if (code == CITE_CODE) {
- BiblioInfo keys;
- keys.fillWithBibKeys(this);
- BiblioInfo::const_iterator bit = keys.begin();
- BiblioInfo::const_iterator bend = keys.end();
+ BiblioInfo keys;
+ keys.fillWithBibKeys(this);
+ BiblioInfo::const_iterator bit = keys.begin();
+ BiblioInfo::const_iterator bend = keys.end();
- for (; bit != bend; ++bit)
- // FIXME UNICODE
- labels.push_back(bit->first);
- paramName = "key";
- } else {
- getLabelList(labels);
- paramName = "reference";
- }
+ for (; bit != bend; ++bit)
+ // FIXME UNICODE
+ labels.push_back(bit->first);
+ paramName = "key";
if (count(labels.begin(), labels.end(), from) > 1)
return;
d->texrow.newline();
if (isLatex())
writeLaTeXSource(os, filePath(), runparams, true, true);
- else {
+ else
writeDocBookSource(os, absFileName(), runparams, false);
- }
} else {
runparams.par_begin = par_begin;
runparams.par_end = par_end;
- if (par_begin + 1 == par_end)
+ if (par_begin + 1 == par_end) {
os << "% "
<< bformat(_("Preview source code for paragraph %1$d"), par_begin)
<< "\n\n";
- else
+ } else {
os << "% "
<< bformat(_("Preview source code from paragraph %1$s to %2$s"),
convert<docstring>(par_begin),
convert<docstring>(par_end - 1))
<< "\n\n";
+ }
d->texrow.newline();
d->texrow.newline();
// output paragraphs
- if (isLatex()) {
+ if (isLatex())
latexParagraphs(*this, text(), os, d->texrow, runparams);
- } else {
+ else
// DocBook
docbookParagraphs(paragraphs(), *this, os, runparams);
- }
}
}