#include "support/textutils.h"
#include "support/types.h"
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
+#include "support/bind.h"
+#include "support/shared_ptr.h"
#include <algorithm>
#include <fstream>
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 385; // uwestoehr: support to change the shaded box color
+int const LYX_FORMAT = 397; // rgh: remove Nameref support
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
// We are in our own directory. Why bother to mangle name?
// In fact I wrote this code to circumvent a problematic behaviour
// (bug?) of EMX mkstemp().
- FileName tmpfl(package().temp_dir().absFilename() + "/lyx_tmpbuf" +
+ FileName tmpfl(package().temp_dir().absFileName() + "/lyx_tmpbuf" +
convert<string>(count++));
if (!tmpfl.createDirectory(0777)) {
throw ExceptionMessage(WarningException, _("Disk Error: "), bformat(
_("LyX could not create the temporary directory '%1$s' (Disk is full maybe?)"),
- from_utf8(tmpfl.absFilename())));
+ from_utf8(tmpfl.absFileName())));
}
return tmpfl;
}
if (!d->cloned_buffer_ && !d->temppath.destroyDirectory()) {
Alert::warning(_("Could not remove temporary directory"),
bformat(_("Could not remove the temporary directory %1$s"),
- from_utf8(d->temppath.absFilename())));
+ from_utf8(d->temppath.absFileName())));
}
// Remove any previewed LaTeX snippets associated with this buffer.
Buffer * Buffer::clone() const
{
- Buffer * buffer_clone = new Buffer(fileName().absFilename(), false, this);
+ Buffer * buffer_clone = new Buffer(fileName().absFileName(), false, this);
buffer_clone->d->macro_lock = true;
buffer_clone->d->children_positions.clear();
// FIXME (Abdel 09/01/2010): this is too complicated. The whole children_positions and
string const Buffer::temppath() const
{
- return d->temppath.absFilename();
+ return d->temppath.absFileName();
}
FileName latex_name =
makeLatexName(d->exportFileName());
return no_path ? latex_name.onlyFileName()
- : latex_name.absFilename();
+ : latex_name.absFileName();
}
FileName Buffer::Impl::exportFileName() const
{
docstring const branch_suffix =
- params.branchlist().getFilenameSuffix();
+ params.branchlist().getFileNameSuffix();
if (branch_suffix.empty())
return filename;
string const name = filename.onlyFileNameWithoutExt()
+ to_utf8(branch_suffix);
- FileName res(filename.onlyPath().absFilename() + "/" + name);
+ FileName res(filename.onlyPath().absFileName() + "/" + name);
res.changeExtension(filename.extension());
return res;
string const path = temppath();
FileName const fname(addName(temppath(),
- onlyFilename(changeExtension(filename,
+ onlyFileName(changeExtension(filename,
".log"))));
// FIXME: how do we know this is the name of the build log?
FileName const bname(
- addName(path, onlyFilename(
+ addName(path, onlyFileName(
changeExtension(filename,
formats.extension(bufferFormat()) + ".out"))));
LYXERR(Debug::FILES, "Log name calculated as: " << bname);
if (type)
*type = buildlog;
- return bname.absFilename();
+ return bname.absFileName();
// If we have a newer master file log or only a master log, show this
} else if (fname != masterfname
&& (!fname.exists() && (masterfname.exists()
LYXERR(Debug::FILES, "Log name calculated as: " << masterfname);
if (type)
*type = mtype;
- return masterfname.absFilename();
+ return masterfname.absFileName();
}
LYXERR(Debug::FILES, "Log name calculated as: " << fname);
if (type)
*type = latexlog;
- return fname.absFilename();
+ return fname.absFileName();
}
params().isfontcolor = false;
params().notefontcolor = lyx::rgbFromHexName("#cccccc");
params().boxbgcolor = lyx::rgbFromHexName("#ff0000");
+ params().html_latex_start.clear();
+ params().html_latex_end.clear();
+ params().html_math_img_scale = 1.0;
+ params().output_sync_macro.erase();
for (int i = 0; i < 4; ++i) {
params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
if (!params().master.empty()) {
FileName const master_file = makeAbsPath(params().master,
onlyPath(absFileName()));
- if (isLyXFilename(master_file.absFilename())) {
+ if (isLyXFileName(master_file.absFileName())) {
Buffer * master =
checkAndLoadLyXFile(master_file, true);
if (master) {
if (!lex.checkFor("\\lyxformat")) {
Alert::error(_("Document format failure"),
bformat(_("%1$s is not a readable LyX document."),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return failure;
}
// Save the timestamp and checksum of disk file. If filename is an
// emergency file, save the timestamp and checksum of the original lyx file
// because isExternallyModified will check for this file. (BUG4193)
- string diskfile = filename.absFilename();
+ string diskfile = filename.absFileName();
if (suffixIs(diskfile, ".emergency"))
diskfile = diskfile.substr(0, diskfile.size() - 10);
saveCheckSum(FileName(diskfile));
" version of LyX, but a temporary"
" file for converting it could"
" not be created."),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return failure;
}
FileName const lyx2lyx = libFileSearch("lyx2lyx", "lyx2lyx");
" version of LyX, but the"
" conversion script lyx2lyx"
" could not be found."),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return failure;
}
ostringstream command;
bformat(_("%1$s is from an older version"
" of LyX, but the lyx2lyx script"
" failed to convert it."),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
else
Alert::error(_("Conversion script failed"),
bformat(_("%1$s is from a newer version"
" of LyX and cannot be converted by the"
" lyx2lyx script."),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return failure;
} else {
bool const ret = readFile(tmpfile);
Alert::error(_("Document format failure"),
bformat(_("%1$s ended unexpectedly, which means"
" that it is probably corrupted."),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return failure;
}
backupName = FileName(absFileName() + '~');
if (!lyxrc.backupdir_path.empty()) {
string const mangledName =
- subst(subst(backupName.absFilename(), '/', '!'), ':', '!');
+ subst(subst(backupName.absFileName(), '/', '!'), ':', '!');
backupName = FileName(addName(lyxrc.backupdir_path,
mangledName));
}
+ // do not copy because of #6587
if (fileName().moveTo(backupName)) {
madeBackup = true;
} else {
Alert::error(_("Backup failure"),
bformat(_("Cannot create backup file %1$s.\n"
"Please check whether the directory exists and is writeable."),
- from_utf8(backupName.absFilename())));
+ from_utf8(backupName.absFileName())));
//LYXERR(Debug::DEBUG, "Fs error: " << fe.what());
}
}
bool retval = false;
docstring const str = bformat(_("Saving document %1$s..."),
- makeDisplayPath(fname.absFilename()));
+ makeDisplayPath(fname.absFileName()));
message(str);
string const encoded_fname = fname.toSafeFilesystemEncoding(os::CREATE);
if (isClean())
return docstring();
- string const doc = isUnnamed() ? onlyFilename(absFileName()) : absFileName();
+ string const doc = isUnnamed() ? onlyFileName(absFileName()) : absFileName();
docstring user_message = bformat(
_("LyX: Attempting to save document %1$s\n"), from_utf8(doc));
}
// 2) In HOME directory.
- string s = addName(package().home_dir().absFilename(), absFileName());
+ string s = addName(package().home_dir().absFileName(), absFileName());
s += ".emergency";
lyxerr << ' ' << s << endl;
if (writeFile(FileName(s))) {
// 3) In "/tmp" directory.
// MakeAbsPath to prepend the current
// drive letter on OS/2
- s = addName(package().temp_dir().absFilename(), absFileName());
+ s = addName(package().temp_dir().absFileName(), absFileName());
s += ".emergency";
lyxerr << ' ' << s << endl;
if (writeFile(FileName(s))) {
// Just to be sure. (Asger)
d->texrow.newline();
+ //for (int i = 0; i<d->texrow.rows(); i++) {
+ // int id,pos;
+ // if (d->texrow.getIdFromRow(i+1,id,pos) && id>0)
+ // lyxerr << i+1 << ":" << id << ":" << getParFromID(id).paragraph().asString()<<"\n";
+ //}
+
LYXERR(Debug::INFO, "Finished making LaTeX file.");
LYXERR(Debug::INFO, "Row count was " << d->texrow.rows() - 1 << '.');
}
if (!openFileWrite(ofs, fname))
return;
- writeDocBookSource(ofs, fname.absFilename(), runparams, body_only);
+ writeDocBookSource(ofs, fname.absFileName(), runparams, body_only);
ofs.close();
if (ofs.fail())
// get LaTeX-Filename
FileName const path(temppath());
- string const name = addName(path.absFilename(), latexName());
+ string const name = addName(path.absFileName(), latexName());
string const org_path = filePath();
PathChanger p(path); // path to LaTeX file
makeLaTeXFile(FileName(name), org_path, runparams);
TeXErrors terr;
- Chktex chktex(lyxrc.chktex_command, onlyFilename(name), filePath());
+ Chktex chktex(lyxrc.chktex_command, onlyFileName(name), filePath());
int const res = chktex.run(terr); // run chktex
if (res == -1) {
updateMacros();
for_each(paragraphs().begin(), paragraphs().end(),
- boost::bind(&Paragraph::validate, _1, boost::ref(features)));
+ bind(&Paragraph::validate, _1, ref(features)));
if (lyxerr.debugging(Debug::LATEX)) {
features.showStruct();
bool enable = true;
- switch (cmd.action_) {
+ switch (cmd.action()) {
case LFUN_BUFFER_TOGGLE_READ_ONLY:
flag.setOnOff(isReadonly());
{
if (isInternal()) {
// FIXME? if there is an Buffer LFUN that can be dispatched even
- // if internal, put a switch '(cmd.action_)' here.
+ // if internal, put a switch '(cmd.action())' here.
dr.dispatched(false);
return;
}
bool dispatched = true;
undo().beginUndoGroup();
- switch (func.action_) {
+ switch (func.action()) {
case LFUN_BUFFER_TOGGLE_READ_ONLY:
if (lyxvc().inUse())
lyxvc().toggleReadOnly();
break;
case LFUN_BRANCH_ADD: {
- docstring const branch_name = func.argument();
+ docstring branch_name = func.argument();
if (branch_name.empty()) {
dispatched = false;
break;
}
BranchList & branch_list = params().branchlist();
- Branch * branch = branch_list.find(branch_name);
- if (branch) {
- LYXERR0("Branch " << branch_name << " already exists.");
- dr.setError(true);
- docstring const msg =
- bformat(_("Branch \"%1$s\" already exists."), branch_name);
- dr.setMessage(msg);
- } else {
- branch_list.add(branch_name);
- branch = branch_list.find(branch_name);
- string const x11hexname = X11hexname(branch->color());
- docstring const str = branch_name + ' ' + from_ascii(x11hexname);
- lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
- dr.setError(false);
- dr.update(Update::Force);
+ vector<docstring> const branches =
+ getVectorFromString(branch_name, branch_list.separator());
+ docstring msg;
+ for (vector<docstring>::const_iterator it = branches.begin();
+ it != branches.end(); ++it) {
+ branch_name = *it;
+ Branch * branch = branch_list.find(branch_name);
+ if (branch) {
+ LYXERR0("Branch " << branch_name << " already exists.");
+ dr.setError(true);
+ if (!msg.empty())
+ msg += ("\n");
+ msg += bformat(_("Branch \"%1$s\" already exists."), branch_name);
+ } else {
+ branch_list.add(branch_name);
+ branch = branch_list.find(branch_name);
+ string const x11hexname = X11hexname(branch->color());
+ docstring const str = branch_name + ' ' + from_ascii(x11hexname);
+ lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
+ dr.setError(false);
+ dr.update(Update::Force);
+ }
}
+ if (!msg.empty())
+ dr.setMessage(msg);
break;
}
bformat(_("Branch \"%1$s\" does not exist."), branchName);
dr.setMessage(msg);
} else {
- branch->setSelected(func.action_ == LFUN_BRANCH_ACTIVATE);
+ branch->setSelected(func.action() == LFUN_BRANCH_ACTIVATE);
dr.setError(false);
dr.update(Update::Force);
+ dr.forceBufferUpdate();
}
break;
}
}
}
- if (success)
+ if (success) {
dr.update(Update::Force);
+ dr.forceBufferUpdate();
+ }
break;
}
docstring text = bformat(
_("The file %1$s already exists.\n\n"
"Do you want to overwrite that file?"),
- makeDisplayPath(filename.absFilename()));
+ makeDisplayPath(filename.absFileName()));
if (Alert::prompt(_("Overwrite file?"),
text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0)
break;
Language const * newL = languages.getLanguage(argument);
if (!newL || oldL == newL)
break;
- if (oldL->rightToLeft() == newL->rightToLeft() && !isMultiLingual())
+ if (oldL->rightToLeft() == newL->rightToLeft() && !isMultiLingual()) {
changeLanguage(oldL, newL);
+ dr.forceBufferUpdate();
+ }
break;
}
string Buffer::absFileName() const
{
- return d->filename.absFilename();
+ return d->filename.absFileName();
}
string Buffer::filePath() const
{
- return d->filename.onlyPath().absFilename() + "/";
+ return d->filename.onlyPath().absFileName() + "/";
}
AutoSaveBuffer(Buffer const & buffer, FileName const & fname)
: buffer_(buffer), fname_(fname) {}
///
- virtual boost::shared_ptr<ForkedProcess> clone() const
+ virtual shared_ptr<ForkedProcess> clone() const
{
- return boost::shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
+ return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
}
///
int start()
{
command_ = to_utf8(bformat(_("Auto-saving %1$s"),
- from_utf8(fname_.absFilename())));
+ from_utf8(fname_.absFileName())));
return run(DontWait);
}
private:
} // namespace anon
-FileName Buffer::getAutosaveFilename() const
+FileName Buffer::getAutosaveFileName() const
{
// if the document is unnamed try to save in the backup dir, else
// in the default document path, and as a last try in the filePath,
void Buffer::removeAutosaveFile() const
{
- FileName const f = getAutosaveFilename();
+ FileName const f = getAutosaveFileName();
if (f.exists())
f.removeFile();
}
void Buffer::moveAutosaveFile(support::FileName const & oldauto) const
{
- FileName const newauto = getAutosaveFilename();
+ FileName const newauto = getAutosaveFileName();
oldauto.refresh();
if (newauto != oldauto && oldauto.exists())
if (!oldauto.moveTo(newauto))
// emit message signal.
message(_("Autosaving current document..."));
- AutoSaveBuffer autosave(*this, getAutosaveFilename());
+ AutoSaveBuffer autosave(*this, getAutosaveFileName());
autosave.start();
d->bak_clean = true;
return false;
if (put_in_tempdir) {
- result_file = tmp_result_file.absFilename();
+ result_file = tmp_result_file.absFileName();
return true;
}
- result_file = changeExtension(d->exportFileName().absFilename(), ext);
+ result_file = changeExtension(d->exportFileName().absFileName(), ext);
// We need to copy referenced files (e. g. included graphics
// if format == "dvi") to the result dir.
vector<ExportedFile> const files =
runparams.exportdata->externalFiles(format);
string const dest = onlyPath(result_file);
- CopyStatus status = SUCCESS;
+ bool use_force = use_gui ? lyxrc.export_overwrite == ALL_FILES
+ : force_overwrite == ALL_FILES;
+ CopyStatus status = use_force ? FORCE : SUCCESS;
vector<ExportedFile>::const_iterator it = files.begin();
vector<ExportedFile>::const_iterator const en = files.end();
message(_("Document export cancelled."));
} else if (tmp_result_file.exists()) {
// Finally copy the main file
+ use_force = use_gui ? lyxrc.export_overwrite != NO_FILES
+ : force_overwrite != NO_FILES;
+ if (status == SUCCESS && use_force)
+ status = FORCE;
status = copyFile(format, tmp_result_file,
FileName(result_file), result_file,
status == FORCE);
{
// File information about normal file
if (!s.exists()) {
- docstring const file = makeDisplayPath(s.absFilename(), 50);
+ docstring const file = makeDisplayPath(s.absFileName(), 50);
docstring text = bformat(_("The specified document\n%1$s"
"\ncould not be read."), file);
Alert::error(_("Could not read document"), text);
}
// Check if emergency save file exists and is newer.
- FileName const e(s.absFilename() + ".emergency");
+ FileName const e(s.absFileName() + ".emergency");
if (e.exists() && s.exists() && e.lastModified() > s.lastModified()) {
- docstring const file = makeDisplayPath(s.absFilename(), 20);
+ docstring const file = makeDisplayPath(s.absFileName(), 20);
docstring const text =
bformat(_("An emergency save of the document "
"%1$s exists.\n\n"
else
str = _("Document was NOT successfully recovered.");
str += "\n\n" + bformat(_("Remove emergency file now?\n(%1$s)"),
- makeDisplayPath(e.absFilename()));
+ makeDisplayPath(e.absFileName()));
if (!Alert::prompt(_("Delete emergency file?"), str, 1, 1,
_("&Remove"), _("&Keep it"))) {
}
// Now check if autosave file is newer.
- FileName const a(onlyPath(s.absFilename()) + '#' + onlyFilename(s.absFilename()) + '#');
+ FileName const a(onlyPath(s.absFileName()) + '#' + onlyFileName(s.absFileName()) + '#');
if (a.exists() && s.exists() && a.lastModified() > s.lastModified()) {
- docstring const file = makeDisplayPath(s.absFilename(), 20);
+ docstring const file = makeDisplayPath(s.absFileName(), 20);
docstring const text =
bformat(_("The backup of the document "
"%1$s is newer.\n\nLoad the "
removeAutosaveFile();
// e.g., read-only status could have changed due to version control
d->filename.refresh();
- docstring const disp_fn = makeDisplayPath(d->filename.absFilename());
+ docstring const disp_fn = makeDisplayPath(d->filename.absFileName());
bool const success = loadLyXFile(d->filename);
if (success) {
updateBuffer();
changed(true);
+ updateTitles();
markClean();
message(bformat(_("Document %1$s reloaded."), disp_fn));
} else {
docstring const & incfile = inset_inc->getParam("filename");
string oldloc = cbuf->absFileName();
string newloc = makeAbsPath(to_utf8(incfile),
- onlyPath(absFileName())).absFilename();
+ onlyPath(absFileName())).absFileName();
if (oldloc == newloc)
continue;
// the location of the child file is incorrect.