#include "errorlist.h"
#include "exporter.h"
#include "format.h"
+#include "funcrequest.h"
#include "gettext.h"
#include "iterators.h"
#include "language.h"
using std::pair;
using std::stack;
using std::vector;
+using std::string;
// all these externs should eventually be removed.
string filepath;
boost::scoped_ptr<Messages> messages;
+
+ /** set to true only when the file is fully loaded.
+ * Used to prevent the premature generation of previews
+ * and by the citation inset.
+ */
+ bool file_fully_loaded;
};
Buffer::Impl::Impl(Buffer & parent, string const & file, bool readonly_)
: nicefile(true),
lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
- filename(file), filepath(OnlyPath(file))
+ filename(file), filepath(OnlyPath(file)), file_fully_loaded(false)
{
lyxvc.buffer(&parent);
if (readonly_ || lyxrc.use_tempdir)
int Buffer::readParagraph(LyXLex & lex, string const & token,
ParagraphList & pars, ParagraphList::iterator & pit,
- Paragraph::depth_type & depth)
+ lyx::depth_type & depth)
{
static Change current_change;
int unknown = 0;
}
+bool Buffer::fully_loaded() const
+{
+ return pimpl_->file_fully_loaded;
+}
+
+
bool Buffer::readFile(LyXLex & lex, string const & filename,
ParagraphList::iterator pit)
{
" that it is probably corrupted."),
filename));
}
+ pimpl_->file_fully_loaded = true;
return true;
}
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
- LaTeXFeatures features(params());
+ LaTeXFeatures features(*this, params());
validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
niceFile() = nice; // this will be used by included files.
- LaTeXFeatures features(params());
+ LaTeXFeatures features(*this, params());
validate(features);
// Handle internal paragraph parsing -- layout already processed.
void Buffer::simpleLinuxDocOnePar(ostream & os,
ParagraphList::iterator par,
- Paragraph::depth_type /*depth*/) const
+ lyx::depth_type /*depth*/) const
{
LyXLayout_ptr const & style = par->layout();
niceFile() = nice; // this will be used by Insetincludes.
- LaTeXFeatures features(params());
+ LaTeXFeatures features(*this, params());
validate(features);
texrow().reset();
void Buffer::simpleDocBookOnePar(ostream & os,
ParagraphList::iterator par, int & desc_on,
- Paragraph::depth_type depth) const
+ lyx::depth_type depth) const
{
bool emph_flag = false;
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it) {
- it->getLabelList(list);
+ it->getLabelList(*this, list);
}
}
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it) {
- if (it->lyxCode() == InsetOld::BIBTEX_CODE)
- static_cast<InsetBibtex &>(*it).fillWithBibKeys(*this, keys);
- else if (it->lyxCode() == InsetOld::INCLUDE_CODE)
- static_cast<InsetInclude &>(*it).fillWithBibKeys(keys);
- else if (it->lyxCode() == InsetOld::BIBITEM_CODE) {
- InsetBibitem & bib = static_cast<InsetBibitem &>(*it);
- string const key = bib.getContents();
- string const opt = bib.getOptions();
+ if (it->lyxCode() == InsetOld::BIBTEX_CODE) {
+ InsetBibtex const & inset =
+ dynamic_cast<InsetBibtex const &>(*it);
+ inset.fillWithBibKeys(*this, keys);
+ } else if (it->lyxCode() == InsetOld::INCLUDE_CODE) {
+ InsetInclude const & inset =
+ dynamic_cast<InsetInclude const &>(*it);
+ inset.fillWithBibKeys(*this, keys);
+ } else if (it->lyxCode() == InsetOld::BIBITEM_CODE) {
+ InsetBibitem const & inset =
+ dynamic_cast<InsetBibitem const &>(*it);
+ string const key = inset.getContents();
+ string const opt = inset.getOptions();
string const ref; // = pit->asString(this, false);
string const info = opt + "TheBibliographyRef" + ref;
keys.push_back(pair<string, string>(key, info));
bool Buffer::dispatch(string const & command, bool * result)
{
- // Split command string into command and argument
- string cmd;
- string line = ltrim(command);
- string const arg = trim(split(line, cmd, ' '));
-
- return dispatch(lyxaction.LookupFunc(cmd), arg, result);
+ return dispatch(lyxaction.lookupFunc(command), result);
}
-bool Buffer::dispatch(int action, string const & argument, bool * result)
+bool Buffer::dispatch(FuncRequest const & func, bool * result)
{
bool dispatched = true;
- switch (action) {
+ switch (func.action) {
case LFUN_EXPORT: {
- bool const tmp = Exporter::Export(this, argument, false);
+ bool const tmp = Exporter::Export(this, func.argument, false);
if (result)
*result = tmp;
break;