CloneList * clone_list_;
/// are we in the process of exporting this buffer?
mutable bool doing_export;
+
+ /// compute statistics
+ /// \p from initial position
+ /// \p to points to the end position
+ void updateStatistics(DocIterator & from, DocIterator & to,
+ bool skipNoOutput = true);
+ /// statistics accessor functions
+ int wordCount() const { return word_count_; }
+ int charCount(bool with_blanks) const {
+ return char_count_
+ + (with_blanks ? blank_count_ : 0);
+ }
private:
/// So we can force access via the accessors.
mutable Buffer const * parent_buffer;
+ int word_count_;
+ int char_count_;
+ int blank_count_;
+
};
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];
d->file_fully_loaded = true;
d->read_only = !d->filename.isWritable();
- params().compressed = d->filename.isZippedFile();
+ params().compressed = formats.isZippedFile(d->filename);
saveCheckSum();
return ReadSuccess;
}
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!");
html::htmlize(doctitle, XHTMLStream::ESCAPE_ALL))
<< "</title>\n";
- os << "\n<!-- Text Class Preamble -->\n"
- << features.getTClassHTMLPreamble()
- << "\n<!-- Preamble Snippets -->\n"
- << from_utf8(features.getPreambleSnippets());
+ docstring styles = features.getTClassHTMLPreamble();
+ if (!styles.empty())
+ os << "\n<!-- Text Class Preamble -->\n" << styles << '\n';
+
+ styles = from_utf8(features.getPreambleSnippets());
+ if (!styles.empty())
+ os << "\n<!-- Preamble Snippets -->\n" << styles << '\n';
// we will collect CSS information in a stream, and then output it
// either here, as part of the header, or else in a separate file.
odocstringstream css;
- docstring styles = from_utf8(features.getCSSSnippets());
+ styles = from_utf8(features.getCSSSnippets());
if (!styles.empty())
css << "/* LyX Provided Styles */\n" << styles << '\n';
docstring const dstyles = css.str();
if (!dstyles.empty()) {
- os << "<style type='text/css'>\n"
- << dstyles
- << "\n</style>\n";
+ bool written = false;
+ if (params().html_css_as_file) {
+ // open a file for CSS info
+ ofdocstream ocss;
+ string const fcssname = addName(temppath(), "docstyle.css");
+ FileName const fcssfile = FileName(fcssname);
+ if (openFileWrite(ocss, fcssfile)) {
+ ocss << dstyles;
+ ocss.close();
+ written = true;
+ // write link to header
+ os << "<link rel='stylesheet' href='docstyle.css' type='text/css' />\n";
+ // register file
+ runparams.exportdata->addExternalFile("xhtml", fcssfile);
+ }
+ }
+ // we are here if the CSS is supposed to be written to the header
+ // or if we failed to write it to an external file.
+ if (!written) {
+ os << "<style type='text/css'>\n"
+ << dstyles
+ << "\n</style>\n";
+ }
}
os << "</head>\n";
}
XHTMLStream xs(os);
setMathFlavor(runparams);
xhtmlParagraphs(text(), *this, xs, runparams);
+ } else if (runparams.flavor == OutputParams::TEXT) {
+ bool dummy;
+ // FIXME Handles only one paragraph, unlike the others.
+ // Probably should have some routine with a signature like them.
+ writePlaintextParagraph(*this,
+ text().paragraphs()[par_begin], os, runparams, dummy);
} else {
// latex or literate
otexstream ots(os, texrow);
}
return ExportNoPathToFormat;
}
- runparams.flavor = converters.getFlavor(path);
+ runparams.flavor = converters.getFlavor(path, this);
} else {
backend_format = format;
// LaTeX backend
else if (backend_format == format) {
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")
}
+void Buffer::Impl::updateStatistics(DocIterator & from, DocIterator & to, bool skipNoOutput)
+{
+ bool inword = false;
+ word_count_ = 0;
+ char_count_ = 0;
+ blank_count_ = 0;
+
+ for (DocIterator dit = from ; dit != to && !dit.atEnd(); ) {
+ if (!dit.inTexted()) {
+ dit.forwardPos();
+ continue;
+ }
+
+ Paragraph const & par = dit.paragraph();
+ pos_type const pos = dit.pos();
+
+ // Copied and adapted from isWordSeparator() in Paragraph
+ if (pos == dit.lastpos()) {
+ inword = false;
+ } else {
+ Inset const * ins = par.getInset(pos);
+ if (ins && skipNoOutput && !ins->producesOutput()) {
+ // skip this inset
+ ++dit.top().pos();
+ // stop if end of range was skipped
+ if (!to.atEnd() && dit >= to)
+ break;
+ continue;
+ } else if (!par.isDeleted(pos)) {
+ if (par.isWordSeparator(pos))
+ inword = false;
+ else if (!inword) {
+ ++word_count_;
+ inword = true;
+ }
+ if (ins && ins->isLetter())
+ ++char_count_;
+ else if (ins && ins->isSpace())
+ ++blank_count_;
+ else {
+ char_type const c = par.getChar(pos);
+ if (isPrintableNonspace(c))
+ ++char_count_;
+ else if (isSpace(c))
+ ++blank_count_;
+ }
+ }
+ }
+ dit.forwardPos();
+ }
+}
+
+
+void Buffer::updateStatistics(DocIterator & from, DocIterator & to, bool skipNoOutput) const
+{
+ d->updateStatistics(from, to, skipNoOutput);
+}
+
+
+int Buffer::wordCount() const
+{
+ return d->wordCount();
+}
+
+
+int Buffer::charCount(bool with_blanks) const
+{
+ return d->charCount(with_blanks);
+}
+
+
Buffer::ReadStatus Buffer::reload()
{
setBusy(true);
d->filename.refresh();
docstring const disp_fn = makeDisplayPath(d->filename.absFileName());
+ // clear parent. this will get reset if need be.
+ d->setParent(0);
ReadStatus const status = loadLyXFile();
if (status == ReadSuccess) {
updateBuffer();