int RunLinuxDoc(BufferView *, int, string const &);
int RunDocBook(int, string const &);
void MenuWrite(Buffer * buf);
-void MenuWriteAs(Buffer * buffer);
+bool MenuWriteAs(Buffer * buffer);
void MenuReload(Buffer * buf);
void MenuLayoutSave();
// should be moved to BufferView.C
// Half of this func should be in LyXView, the rest in BufferView.
-void MenuWriteAs(Buffer * buffer)
+bool MenuWriteAs(Buffer * buffer)
{
// Why do we require BufferView::text to be able to write a
// document? I see no point in that. (Lgb)
if (!IsLyXFilename(fname))
fname += ".lyx";
- fname = fileDlg.Select(_("Enter Filename to Save Document as"),
- OnlyPath(fname),
- "*.lyx",
- OnlyFilename(fname));
+ if (buffer->isUnnamed()) {
+ fname = fileDlg.Select(_("Enter Filename to Save Document as"),
+ "",
+ "*.lyx",
+ "");
+ } else {
+ fname = fileDlg.Select(_("Enter Filename to Save Document as"),
+ OnlyPath(fname),
+ "*.lyx",
+ OnlyFilename(fname));
+ }
AllowInput(current_view);
if (fname.empty()) {
- return;
+ return false;
}
// Make sure the absolute filename ends with appropriate suffix
string s = MakeAbsPath(fname);
if (!AskQuestion(_("Same name as document already has:"),
MakeDisplayPath(s, 50),
_("Save anyway?")))
- return;
+ return false;
// Falls through to name change and save
}
// No, but do we have another file with this name open?
ShowMessage(buffer, _("Document renamed to '"),
MakeDisplayPath(s), _("', but not saved..."));
}
- return;
+ return false;
} // Check whether the file exists
else {
FileInfo myfile(s);
if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
MakeDisplayPath(s, 50),
_("Replace file?")))
- return;
+ return false;
}
// Ok, change the name of the buffer
buffer->fileName(s);
buffer->markDirty();
+ buffer->setUnnamed(false);
// And save
// Small bug: If the save fails, we have irreversible changed the name
// of the document.
MenuWrite(buffer);
+ return true;
}
}
// HTML
else if (extyp == "html") {
- MenuMakeHTML(buffer);
- }
- // HTML from linuxdoc
- else if (extyp == "html-linuxdoc") {
- MenuMakeHTML_LinuxDoc(buffer);
- }
- // HTML from docbook
- else if (extyp == "html-docbook") {
- MenuMakeHTML_DocBook(buffer);
+ if (buffer->isLinuxDoc())
+ MenuMakeHTML_LinuxDoc(buffer);
+ else if (buffer->isDocBook())
+ MenuMakeHTML_DocBook(buffer);
+ else
+ MenuMakeHTML(buffer);
}
else {
ShowMessage(buffer, _("Unknown export type: ") + extyp);
if (!bv->available())
return;
- if (bv->buffer()->isBakClean()
- || bv->buffer()->isReadonly()) {
+ if (bv->buffer()->isBakClean() ||
+ bv->buffer()->isReadonly() || bv->buffer()->isUnnamed()) {
// We don't save now, but we'll try again later
bv->owner()->resetAutosaveTimer();
return;
ifs.unsetf(ios::skipws);
istream_iterator<char> ii(ifs);
istream_iterator<char> end;
+#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
+ // We use this until the compilers get better...
+ vector<char> tmp;
+ copy(ii, end, back_inserter(tmp));
+ string tmpstr(tmp.begin(), tmp.end());
+#else
+ // This is what we want to use and what we will use once the
+ // compilers get good enough.
//string tmpstr(ii, end); // yet a reason for using std::string
// alternate approach to get the file into a string:
string tmpstr;
copy(ii, end, back_inserter(tmpstr));
+#endif
// insert the string
current_view->hideCursor();