#include "DispatchResult.h"
#include "Encoding.h"
#include "ErrorList.h"
-#include "Exporter.h"
#include "Format.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "Session.h"
#include "TextClassList.h"
#include "ToolbarBackend.h"
-#include "Undo.h"
#include "insets/InsetBox.h"
#include "insets/InsetBranch.h"
using support::FileName;
using support::fileSearch;
using support::i18nLibFileSearch;
-using support::isDirWriteable;
-using support::isFileReadable;
-using support::isStrInt;
-using support::makeAbsPath;
using support::makeDisplayPath;
+using support::makeAbsPath;
using support::package;
using support::quoteName;
using support::rtrim;
return;
// if the current buffer is not that one, switch to it.
- if (lyx_view_->buffer()->fileName() != file) {
+ if (lyx_view_->buffer()->absFileName() != file) {
if (!switchToBuffer)
return;
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
case LFUN_BUFFER_SWITCH:
// toggle on the current buffer, but do not toggle off
// the other ones (is that a good idea?)
- if (buf && to_utf8(cmd.argument()) == buf->fileName())
+ if (buf && to_utf8(cmd.argument()) == buf->absFileName())
flag.setOnOff(true);
break;
case LFUN_BUFFER_EXPORT:
enable = cmd.argument() == "custom"
- || Exporter::isExportable(*buf, to_utf8(cmd.argument()));
+ || buf->isExportable(to_utf8(cmd.argument()));
break;
case LFUN_BUFFER_CHKTEX:
break;
case LFUN_BUILD_PROGRAM:
- enable = Exporter::isExportable(*buf, "program");
+ enable = buf->isExportable("program");
break;
case LFUN_VC_REGISTER:
enable = buf->lyxvc().inUse();
break;
case LFUN_BUFFER_RELOAD:
- enable = !buf->isUnnamed() && fs::exists(buf->fileName())
+ enable = !buf->isUnnamed() && fs::exists(buf->absFileName())
&& (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method));
break;
|| name == "prefs"
|| name == "texinfo";
else if (name == "print")
- enable = Exporter::isExportable(*buf, "dvi")
+ enable = buf->isExportable("dvi")
&& lyxrc.print_command != "none";
else if (name == "character") {
if (!view())
}
}
else if (name == "latexlog")
- enable = isFileReadable(FileName(buf->getLogName().second));
+ enable = FileName(buf->logName().second).isFileReadable();
else if (name == "spellchecker")
#if defined (USE_ASPELL) || defined (USE_ISPELL) || defined (USE_PSPELL)
enable = !buf->isReadonly();
if (buf.isClean())
return true;
- docstring const file = makeDisplayPath(buf.fileName(), 30);
+ docstring const file = makeDisplayPath(buf.absFileName(), 30);
docstring text = bformat(_("The document %1$s has unsaved "
"changes.\n\nDo you want to save "
"the document?"), file);
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (!lyx_view_->buffer()->isUnnamed()) {
docstring const str = bformat(_("Saving document %1$s..."),
- makeDisplayPath(lyx_view_->buffer()->fileName()));
+ makeDisplayPath(lyx_view_->buffer()->absFileName()));
lyx_view_->message(str);
lyx_view_->buffer()->menuWrite();
lyx_view_->message(str + _(" done."));
if (!b->isClean()) {
if (!b->isUnnamed()) {
b->menuWrite();
- lyxerr[Debug::ACTION] << "Saved " << b->fileName() << endl;
+ lyxerr[Debug::ACTION] << "Saved " << b->absFileName() << endl;
} else
b->writeAs();
}
case LFUN_BUFFER_RELOAD: {
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- docstring const file = makeDisplayPath(lyx_view_->buffer()->fileName(), 20);
+ docstring const file = makeDisplayPath(lyx_view_->buffer()->absFileName(), 20);
docstring text = bformat(_("Any changes will be lost. Are you sure "
"you want to revert to the saved version of the document %1$s?"), file);
int const ret = Alert::prompt(_("Revert to saved document?"),
case LFUN_BUFFER_UPDATE:
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- Exporter::Export(lyx_view_->buffer(), argument, true);
+ lyx_view_->buffer()->doExport(argument, true);
break;
case LFUN_BUFFER_VIEW:
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- Exporter::preview(lyx_view_->buffer(), argument);
+ lyx_view_->buffer()->preview(argument);
break;
case LFUN_MASTER_BUFFER_UPDATE:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->getMasterBuffer());
- Exporter::Export(lyx_view_->buffer()->getMasterBuffer(), argument, true);
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->masterBuffer());
+ lyx_view_->buffer()->masterBuffer()->doExport(argument, true);
break;
case LFUN_MASTER_BUFFER_VIEW:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->getMasterBuffer());
- Exporter::preview(lyx_view_->buffer()->getMasterBuffer(), argument);
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->masterBuffer());
+ lyx_view_->buffer()->masterBuffer()->preview(argument);
break;
case LFUN_BUILD_PROGRAM:
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- Exporter::Export(lyx_view_->buffer(), "program", true);
+ lyx_view_->buffer()->doExport("program", true);
break;
case LFUN_BUFFER_CHKTEX:
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (argument == "custom")
lyx_view_->getDialogs().show("sendto");
- else {
- Exporter::Export(lyx_view_->buffer(), argument, false);
- }
+ else
+ lyx_view_->buffer()->doExport(argument, false);
break;
case LFUN_BUFFER_EXPORT_CUSTOM: {
// Output to filename
if (format->name() == "lyx") {
- string const latexname =
- buffer->getLatexName(false);
+ string const latexname = buffer->latexName(false);
filename = changeExtension(latexname,
format->extension());
filename = addName(buffer->temppath(), filename);
break;
} else {
- Exporter::Export(buffer, format_name, true, filename);
+ buffer->doExport(format_name, true, filename);
}
// Substitute $$FName for filename
Buffer * buffer = lyx_view_->buffer();
- if (!Exporter::Export(buffer, "dvi", true)) {
- showPrintError(buffer->fileName());
+ if (!buffer->doExport("dvi", true)) {
+ showPrintError(buffer->absFileName());
break;
}
Systemcall one;
int res = 0;
string const dviname =
- changeExtension(buffer->getLatexName(true),
- "dvi");
+ changeExtension(buffer->latexName(true), "dvi");
if (target == "printer") {
if (!lyxrc.print_spool_command.empty()) {
FileName const filename(makeAbsPath(target_name,
lyx_view_->buffer()->filePath()));
FileName const dvifile(makeAbsPath(dviname, path));
- if (fs::exists(filename.toFilesystemEncoding())) {
+ if (filename.exists()) {
docstring text = bformat(
_("The file %1$s already exists.\n\n"
"Do you want to overwrite that file?"),
}
if (res != 0)
- showPrintError(buffer->fileName());
+ showPrintError(buffer->absFileName());
break;
}
// --- lyxserver commands ----------------------------
case LFUN_SERVER_GET_NAME:
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- setMessage(from_utf8(lyx_view_->buffer()->fileName()));
+ setMessage(from_utf8(lyx_view_->buffer()->absFileName()));
LYXERR(Debug::INFO) << "FNAME["
- << lyx_view_->buffer()->fileName()
+ << lyx_view_->buffer()->absFileName()
<< "] " << endl;
break;
lyx_view_->getDialogs().show("character", data);
} else if (name == "latexlog") {
pair<Buffer::LogType, string> const logfile =
- lyx_view_->buffer()->getLogName();
+ lyx_view_->buffer()->logName();
switch (logfile.first) {
case Buffer::latexlog:
data = "latex ";
case REF_CODE:
case TOC_CODE:
case HYPERLINK_CODE: {
- InsetCommandParams p(name);
+ InsetCommandParams p(code);
data = InsetCommandMailer::params2string(name, p);
break;
}
if (data.empty())
// default type is requested
data = "include";
- InsetCommandParams p("include", data);
+ InsetCommandParams p(INCLUDE_CODE, data);
data = InsetIncludeMailer::params2string(p);
break;
}
break;
}
case CITE_CODE: {
- InsetCommandParams p("cite");
+ InsetCommandParams p(CITE_CODE);
data = InsetCommandMailer::params2string(name, p);
break;
}
arg = token(argument, '|', 0);
opt1 = token(argument, '|', 1);
}
- InsetCommandParams icp("cite");
+ InsetCommandParams icp(CITE_CODE);
icp["key"] = from_utf8(arg);
if (!opt1.empty())
icp["before"] = from_utf8(opt1);
// Set the parent name of the child document.
// This makes insertion of citations and references in the child work,
// when the target is in the parent or another child document.
- child->setParentName(parent->fileName());
- updateLabels(*child->getMasterBuffer());
+ child->setParentName(parent->absFileName());
+ updateLabels(*child->masterBuffer());
lyx_view_->setBuffer(child);
if (parsed)
lyx_view_->showErrorList("Parse");
<< endl;
}
- if (defaults.writeFile(FileName(defaults.fileName())))
+ if (defaults.writeFile(FileName(defaults.absFileName())))
setMessage(bformat(_("Document defaults saved in %1$s"),
makeDisplayPath(fname)));
else
Buffer * buffer = lyx_view_->buffer();
TextClassPtr oldClass = buffer->params().getTextClassPtr();
- recordUndoFullDocument(view());
+
+ Cursor & cur = view()->cursor();
+ cur.recordUndoFullDocument();
istringstream ss(argument);
Lexer lex(0,0);
lyx_view_->buffer()->params().getEngine();
if (oldEngine != newEngine) {
- Cursor & cur = view()->cursor();
FuncRequest fr(LFUN_INSET_REFRESH);
Inset & inset = lyx_view_->buffer()->inset();
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
TextClassPtr oldClass = buffer->params().getTextClassPtr();
- recordUndoFullDocument(view());
+ view()->cursor().recordUndoFullDocument();
buffer->params().clearLayoutModules();
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
TextClassPtr oldClass = buffer->params().getTextClassPtr();
- recordUndoFullDocument(view());
+ view()->cursor().recordUndoFullDocument();
buffer->params().addLayoutModule(argument);
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
//Save the old, possibly modular, layout for use in conversion.
TextClassPtr oldClass = buffer->params().getTextClassPtr();
- recordUndoFullDocument(view());
+ view()->cursor().recordUndoFullDocument();
buffer->params().setBaseClass(new_class);
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
if (lyx_view_->buffer()) {
string const trypath = lyx_view_->buffer()->filePath();
// If directory is writeable, use this as default.
- if (isDirWriteable(FileName(trypath)))
+ if (FileName(trypath).isDirWritable())
initpath = trypath;
}
filename = addName(lyxrc.document_path,
"newfile" + convert<string>(++newfile_number) + ".lyx");
while (theBufferList().exists(filename) ||
- fs::is_readable(FileName(filename).toFilesystemEncoding())) {
+ FileName(filename).isReadable()) {
++newfile_number;
filename = addName(lyxrc.document_path,
"newfile" + convert<string>(newfile_number) +
if (lyx_view_->buffer()) {
string const trypath = lyx_view_->buffer()->filePath();
// If directory is writeable, use this as default.
- if (isDirWriteable(FileName(trypath)))
+ if (FileName(trypath).isDirWritable())
initpath = trypath;
}
filename = fullname.absFilename();
// if the file doesn't exist, let the user create one
- if (!fs::exists(fullname.toFilesystemEncoding())) {
+ if (!fullname.exists()) {
// the user specifically chose this name. Believe him.
Buffer * const b = newFile(filename, string(), true);
if (b)
if (lyx_view_->buffer()) {
string const trypath = lyx_view_->buffer()->filePath();
// If directory is writeable, use this as default.
- if (isDirWriteable(FileName(trypath)))
+ if (FileName(trypath).isDirWritable())
initpath = trypath;
}
// if the file exists already, and we didn't do
// -i lyx thefile.lyx, warn
- if (fs::exists(lyxfile.toFilesystemEncoding()) && fullname != lyxfile) {
+ if (lyxfile.exists() && fullname != lyxfile) {
docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
docstring text = bformat(_("The document %1$s already exists.\n\n"
void LyXFunc::reloadBuffer()
{
- FileName filename(lyx_view_->buffer()->fileName());
+ FileName filename(lyx_view_->buffer()->absFileName());
docstring const disp_fn = makeDisplayPath(filename.absFilename());
docstring str;
closeBuffer();
case LyXRC::RC_DISPLAY_GRAPHICS:
case LyXRC::RC_DOCUMENTPATH:
if (lyxrc_orig.document_path != lyxrc_new.document_path) {
- string const encoded = FileName(
- lyxrc_new.document_path).toFilesystemEncoding();
- if (fs::exists(encoded) && fs::is_directory(encoded))
+ FileName path(lyxrc_new.document_path);
+ if (path.exists() && path.isDirectory())
support::package().document_dir() = FileName(lyxrc.document_path);
}
case LyXRC::RC_ESC_CHARS: