#include "ParagraphParameters.h"
#include "ParIterator.h"
#include "PDFOptions.h"
+#include "SpellChecker.h"
#include "sgml.h"
#include "TexRow.h"
#include "TexStream.h"
#include "Undo.h"
#include "VCBackend.h"
#include "version.h"
+#include "WordLangTuple.h"
#include "WordList.h"
#include "insets/InsetBibitem.h"
#include "support/lassert.h"
#include "support/convert.h"
#include "support/debug.h"
+#include "support/docstring_list.h"
#include "support/ExceptionMessage.h"
#include "support/FileName.h"
#include "support/FileNameList.h"
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 348; // uwestoehr: add support for \*phantom
+int const LYX_FORMAT = 349; // jspitzm: initial XeTeX support
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
/// This is here to force the test to be done whenever parent_buffer
/// is accessed.
Buffer const * parent() const {
+ // if parent_buffer is not loaded, then it has been unloaded,
+ // which means that parent_buffer is an invalid pointer. So we
+ // set it to null in that case.
if (!theBufferList().isLoaded(parent_buffer))
parent_buffer = 0;
return parent_buffer;
Buffer * master =
checkAndLoadLyXFile(master_file, true);
if (master) {
+ // necessary e.g. after a reload
+ // to re-register the child (bug 5873)
+ // FIXME: clean up updateMacros (here, only
+ // child registering is needed).
+ master->updateMacros();
// set master as master buffer, but only
// if we are a real child
if (master->isChild(this))
else if (master->isFullyLoaded())
LYXERR0("The master '"
<< params().master
- << "' assigned to this document '"
+ << "' assigned to this document ("
<< absFileName()
- << "' does not include "
+ << ") does not include "
"this document. Ignoring the master assignment.");
}
}
return false;
}
- removeAutosaveFile(d->filename.absFilename());
+ removeAutosaveFile();
saveCheckSum(d->filename);
message(str + _(" done."));
bool Buffer::makeLaTeXFile(FileName const & fname,
string const & original_path,
- OutputParams const & runparams,
+ OutputParams const & runparams_in,
bool output_preamble, bool output_body) const
{
+ OutputParams runparams = runparams_in;
+ if (params().useXetex)
+ runparams.flavor = OutputParams::XETEX;
+
string const encoding = runparams.encoding->iconvName();
LYXERR(Debug::LATEX, "makeLaTeXFile encoding: " << encoding << "...");
{
OutputParams runparams(¶ms().encoding());
runparams.nice = true;
- runparams.flavor = OutputParams::LATEX;
+ runparams.flavor = params().useXetex ?
+ OutputParams::XETEX : OutputParams::LATEX;
runparams.linelen = lyxrc.plaintext_linelen;
// No side effect of file copying and image conversion
runparams.dryrun = true;
} // namespace anon
+FileName Buffer::getAutosaveFilename() const
+{
+ string const fpath = isUnnamed() ? lyxrc.document_path : filePath();
+ string const fname = "#" + d->filename.onlyFileName() + "#";
+ return makeAbsPath(fname, fpath);
+}
+
+
+void Buffer::removeAutosaveFile() const
+{
+ FileName const f = getAutosaveFilename();
+ if (f.exists())
+ f.removeFile();
+}
+
+
// Perfect target for a thread...
void Buffer::autoSave() const
{
// emit message signal.
message(_("Autosaving current document..."));
-
- // create autosave filename
- string fname = filePath();
- fname += '#';
- fname += d->filename.onlyFileName();
- fname += '#';
-
- AutoSaveBuffer autosave(*this, FileName(fname));
+ AutoSaveBuffer autosave(*this, getAutosaveFilename());
autosave.start();
markBakClean();
return "docbook";
if (isLiterate())
return "literate";
+ if (params().useXetex)
+ return "xetex";
if (params().encoding().package() == Encoding::japanese)
return "platex";
return "latex";
bool inword = false;
bool ignoreword = false;
string lang_code;
+ // Go backward a bit if needed in order to return the word currently
+ // pointed by 'from'.
+ while (from && from.pos() && isLetter(from))
+ from.backwardPos();
+ // OK, we start from here.
to = from;
-
while (to.depth()) {
if (isLetter(to)) {
if (!inword) {
}
to.forwardPos();
}
-
+ from = to;
+ word.clear();
return false;
}
+
+int Buffer::spellCheck(DocIterator & from, DocIterator & to,
+ WordLangTuple & word_lang, docstring_list & suggestions) const
+{
+ int progress = 0;
+ SpellChecker::Result res = SpellChecker::OK;
+ SpellChecker * speller = theSpellChecker();
+ suggestions.clear();
+ docstring word;
+ while (nextWord(from, to, word)) {
+ ++progress;
+ string lang_code = lyxrc.spellchecker_use_alt_lang
+ ? lyxrc.spellchecker_alt_lang
+ : from.paragraph().getFontSettings(params(), from.pos()).language()->code();
+ WordLangTuple wl(word, lang_code);
+ res = speller->check(wl);
+ // ... just bail out if the spellchecker reports an error.
+ if (!speller->error().empty()) {
+ throw ExceptionMessage(WarningException,
+ _("The spellchecker has failed."), speller->error());
+ }
+ if (res != SpellChecker::OK && res != SpellChecker::IGNORED_WORD) {
+ word_lang = wl;
+ break;
+ }
+ from = to;
+ }
+ while (!(word = speller->nextMiss()).empty())
+ suggestions.push_back(word);
+ return progress;
+}
+
} // namespace lyx