/// is this an unnamed file (New...)?
bool unnamed;
+ /// is this an internal bufffer?
+ bool internal_buffer;
+
/// buffer is r/o
bool read_only;
Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
Buffer const * cloned_buffer)
: owner_(owner), lyx_clean(true), bak_clean(true), unnamed(false),
- read_only(readonly_), filename(file), file_fully_loaded(false),
- toc_backend(owner), macro_lock(false), timestamp_(0), checksum_(0),
- wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false),
- bibfile_cache_valid_(false), cite_labels_valid_(false),
- preview_loader_(0), cloned_buffer_(cloned_buffer), clone_list_(0),
+ internal_buffer(false), read_only(readonly_), filename(file),
+ file_fully_loaded(false), toc_backend(owner), macro_lock(false),
+ timestamp_(0), checksum_(0), wa_(0), gui_(0), undo_(*owner),
+ bibinfo_cache_valid_(false), bibfile_cache_valid_(false),
+ cite_labels_valid_(false), preview_loader_(0),
+ cloned_buffer_(cloned_buffer), clone_list_(0),
doing_export(false), parent_buffer(0)
{
if (!cloned_buffer_) {
bibfile_status_ = cloned_buffer_->d->bibfile_status_;
cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_;
unnamed = cloned_buffer_->d->unnamed;
+ internal_buffer = cloned_buffer_->d->internal_buffer;
}
params().html_latex_end.clear();
params().html_math_img_scale = 1.0;
params().output_sync_macro.erase();
+ params().local_layout.clear();
for (int i = 0; i < 4; ++i) {
params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
Encoding const * const enc = runparams.encoding;
if (enc) {
for (size_t n = 0; n < inputpath.size(); ++n) {
- docstring const glyph =
- docstring(1, inputpath[n]);
- if (enc->latexChar(inputpath[n], true) != glyph) {
+ if (!enc->encodable(inputpath[n])) {
+ docstring const glyph(1, inputpath[n]);
LYXERR0("Uncodable character '"
<< glyph
<< "' in input path!");
bool const output_preamble =
output == FullSource || output == OnlyPreamble;
bool const output_body =
- output == FullSource || output == OnlyBody;
+ output == FullSource || output == OnlyBody || output == IncludedFile;
if (output_preamble) {
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
}
if (output_body) {
- os << "<body>\n";
+ bool const output_body_tag = (output != IncludedFile);
+ if (output_body_tag)
+ os << "<body>\n";
XHTMLStream xs(os);
params().documentClass().counters().reset();
xhtmlParagraphs(text(), *this, xs, runparams);
- os << "</body>\n";
+ if (output_body_tag)
+ os << "</body>\n";
}
if (output_preamble)
/// retrieving fileName() nor for checking if it is unnamed or not.
bool Buffer::isInternal() const
{
- return fileName().extension() == "internal";
+ return d->internal_buffer;
+}
+
+
+void Buffer::setInternal(bool flag)
+{
+ d->internal_buffer = flag;
}
string Buffer::filePath() const
{
- return d->filename.onlyPath().absFileName() + "/";
+ int last = d->filename.onlyPath().absFileName().length() - 1;
+
+ return d->filename.onlyPath().absFileName()[last] == '/'
+ ? d->filename.onlyPath().absFileName()
+ : d->filename.onlyPath().absFileName() + "/";
}
// try previous macro if there is one
if (it == nameIt->second.begin())
break;
- it--;
+ --it;
}
}
}
convert<docstring>(par_end - 1))
<< "\n\n";
}
- TexRow texrow;
- texrow.reset();
- texrow.newline();
- texrow.newline();
// output paragraphs
- if (params().isDocBook())
- docbookParagraphs(text(), *this, os, runparams);
- else if (runparams.flavor == OutputParams::HTML) {
+ if (runparams.flavor == OutputParams::LYX) {
+ Paragraph const & par = text().paragraphs()[par_begin];
+ ostringstream ods;
+ depth_type dt = par.getDepth();
+ par.write(ods, params(), dt);
+ os << from_utf8(ods.str());
+ } else if (runparams.flavor == OutputParams::HTML) {
XHTMLStream xs(os);
setMathFlavor(runparams);
xhtmlParagraphs(text(), *this, xs, runparams);
// Probably should have some routine with a signature like them.
writePlaintextParagraph(*this,
text().paragraphs()[par_begin], os, runparams, dummy);
+ } else if (params().isDocBook()) {
+ docbookParagraphs(text(), *this, os, runparams);
} else {
+ TexRow texrow;
+ texrow.reset();
+ texrow.newline();
+ texrow.newline();
// latex or literate
otexstream ots(os, texrow);
latexParagraphs(*this, text(), ots, runparams);
else if (output == OnlyBody)
os << _("Preview body");
os << "\n\n";
- d->texrow.reset();
- d->texrow.newline();
- d->texrow.newline();
- if (params().isDocBook())
- writeDocBookSource(os, absFileName(), runparams, output);
- else if (runparams.flavor == OutputParams::HTML)
+ if (runparams.flavor == OutputParams::LYX) {
+ ostringstream ods;
+ if (output == FullSource)
+ write(ods);
+ else if (output == OnlyPreamble)
+ params().writeFile(ods);
+ else if (output == OnlyBody)
+ text().write(ods);
+ os << from_utf8(ods.str());
+ } else if (runparams.flavor == OutputParams::HTML) {
writeLyXHTMLSource(os, runparams, output);
- else {
+ } else if (runparams.flavor == OutputParams::TEXT) {
+ if (output == OnlyPreamble) {
+ os << _("% Plaintext does not have a preamble.");
+ } else
+ writePlaintextFile(*this, os, runparams);
+ } else if (params().isDocBook()) {
+ writeDocBookSource(os, absFileName(), runparams, output);
+ } else {
// latex or literate
+ d->texrow.reset();
+ d->texrow.newline();
+ d->texrow.newline();
otexstream ots(os, d->texrow);
writeLaTeXSource(ots, string(), runparams, output);
}
runparams.includeall = includeall;
vector<string> backs = params().backends();
Converters converters = theConverters();
+ bool need_nice_file = false;
if (find(backs.begin(), backs.end(), format) == backs.end()) {
// Get shortest path to format
converters.buildGraph();
}
return ExportNoPathToFormat;
}
- runparams.flavor = converters.getFlavor(path);
+ runparams.flavor = converters.getFlavor(path, this);
+ Graph::EdgePath::const_iterator it = path.begin();
+ Graph::EdgePath::const_iterator en = path.end();
+ for (; it != en; ++it)
+ if (theConverters().get(*it).nice) {
+ need_nice_file = true;
+ break;
+ }
} else {
backend_format = format;
makeDocBookFile(FileName(filename), runparams);
}
// LaTeX backend
- else if (backend_format == format) {
+ else if (backend_format == format || need_nice_file) {
runparams.nice = true;
- if (!makeLaTeXFile(FileName(filename), string(), runparams)) {
- if (d->cloned_buffer_) {
- d->cloned_buffer_->d->errorLists["Export"] =
- d->errorLists["Export"];
- }
+ bool const success = makeLaTeXFile(FileName(filename), string(), runparams);
+ if (d->cloned_buffer_)
+ d->cloned_buffer_->d->errorLists["Export"] = d->errorLists["Export"];
+ if (!success)
return ExportError;
- }
} else if (!lyxrc.tex_allows_spaces
&& contains(filePath(), ' ')) {
Alert::error(_("File name error"),
return ExportTexPathHasSpaces;
} else {
runparams.nice = false;
- if (!makeLaTeXFile(FileName(filename), filePath(), runparams)) {
- if (d->cloned_buffer_) {
- d->cloned_buffer_->d->errorLists["Export"] =
- d->errorLists["Export"];
- }
+ bool const success = makeLaTeXFile(
+ FileName(filename), filePath(), runparams);
+ if (d->cloned_buffer_)
+ d->cloned_buffer_->d->errorLists["Export"] = d->errorLists["Export"];
+ if (!success)
return ExportError;
- }
}
string const error_type = (format == "program")
// we need to check that the locations of child buffers
// are still valid.
checkChildBuffers();
+ checkMasterBuffer();
return true;
} else {
// save failed
d->position_to_children.clear();
}
+
+// If a child has been saved under a different name/path, it might have been
+// orphaned. Therefore the master needs to be reset (bug 8161).
+void Buffer::checkMasterBuffer()
+{
+ Buffer const * const master = masterBuffer();
+ if (master == this)
+ return;
+
+ // necessary to re-register the child (bug 5873)
+ // FIXME: clean up updateMacros (here, only
+ // child registering is needed).
+ master->updateMacros();
+ // (re)set master as master buffer, but only
+ // if we are a real child
+ if (master->isChild(this))
+ setParent(master);
+ else
+ setParent(0);
+}
+
} // namespace lyx