X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraph.cpp;h=8ea300ea756c40ea47ccf95926ee919c91af6d01;hb=0c7bd9a57f2a308bb9659200eda3b7e45f8d5d3c;hp=c25912172ce63ca0f27ea089c7298cc664087213;hpb=480937a103708a6510ae24c2ee91cd1459d67104;p=lyx.git diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index c25912172c..8ea300ea75 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -40,6 +40,7 @@ #include "ParagraphParameters.h" #include "SpellChecker.h" #include "sgml.h" +#include "texstream.h" #include "TextClass.h" #include "TexRow.h" #include "Text.h" @@ -562,6 +563,18 @@ void Paragraph::addChangesToToc(DocIterator const & cdit, } +void Paragraph::addChangesToBuffer(Buffer const & buf) const +{ + d->changes_.updateBuffer(buf); +} + + +bool Paragraph::isChangeUpdateRequired() const +{ + return d->changes_.isUpdateRequired(); +} + + bool Paragraph::isDeleted(pos_type start, pos_type end) const { LASSERT(start >= 0 && start <= size(), return false); @@ -1192,7 +1205,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & os, break; case '-': os << '-'; - if (i + 1 < end_pos && text_[i+1] == '-') { + if (i + 1 < static_cast(text_.size()) && + (end_pos == -1 || i + 1 < end_pos) && + text_[i+1] == '-') { // Prevent "--" becoming an endash and "---" becoming // an emdash. // Within \ttfamily, "--" is merged to "-" (no endash) @@ -1363,13 +1378,12 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const BufferParams const & bp = features.runparams().is_child ? buf.masterParams() : buf.params(); Font f; - TexRow texrow; // Using a string stream here circumvents the encoding // switching machinery of odocstream. Therefore the // output is wrong if this paragraph contains content // that needs to switch encoding. odocstringstream ods; - otexstream os(ods, texrow); + otexstream os(ods, false); if (is_command) { os << '\\' << from_ascii(layout_->latexname()); // we have to provide all the optional arguments here, even though @@ -1395,7 +1409,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const } } string const snippet = to_utf8(ods.str()); - features.addPreambleSnippet(snippet); + features.addPreambleSnippet(snippet, true); } } @@ -1426,7 +1440,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const icit->inset->validate(features); if (layout_->needprotect && icit->inset->lyxCode() == FOOT_CODE) - features.require("footmisc"); + features.require("NeedLyXFootnoteCode"); } } @@ -1731,7 +1745,10 @@ Font const & Paragraph::getFontSettings(BufferParams const & bparams, FontSpan Paragraph::fontSpan(pos_type pos) const { - LBUFERR(pos < size()); + LBUFERR(pos <= size()); + + if (pos == size()) + return FontSpan(pos, pos); pos_type start = 0; FontList::const_iterator cit = d->fontlist_.begin(); @@ -1820,14 +1837,6 @@ Font const Paragraph::getLayoutFont } -/// Returns the height of the highest font in range -FontSize Paragraph::highestFontInRange - (pos_type startpos, pos_type endpos, FontSize def_size) const -{ - return d->fontlist_.highestInRange(startpos, endpos, def_size); -} - - char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const { char_type c = d->text_[pos]; @@ -2567,8 +2576,7 @@ void Paragraph::latex(BufferParams const & bparams, if (allowcust && d->endTeXParParams(bparams, os, runparams) && runparams.encoding != prev_encoding) { runparams.encoding = prev_encoding; - if (!bparams.useNonTeXFonts) - os << setEncoding(prev_encoding->iconvName()); + os << setEncoding(prev_encoding->iconvName()); } LYXERR(Debug::LATEX, "Paragraph::latex... done " << this); @@ -2744,7 +2752,8 @@ void doFontSwitch(vector & tagsToOpen, docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, XHTMLStream & xs, OutputParams const & runparams, - Font const & outerfont, + Font const & outerfont, + bool start_paragraph, bool close_paragraph, pos_type initial) const { docstring retval; @@ -2766,7 +2775,8 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, Layout const & style = *d->layout_; - xs.startParagraph(allowEmpty()); + if (start_paragraph) + xs.startDivision(allowEmpty()); FontInfo font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font; @@ -3052,7 +3062,9 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, if (!runparams.for_toc || inset->isInToc()) { OutputParams np = runparams; np.local_font = &font; - if (!inset->getLayout().htmlisblock()) + // If the paragraph has size 1, then we are in the "special + // case" where we do not output the containing paragraph info + if (!inset->getLayout().htmlisblock() && size() != 1) np.html_in_par = true; retval += inset->xhtml(xs, np); } @@ -3063,8 +3075,13 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, font_old = font.fontInfo(); } + // FIXME XHTML + // I'm worried about what happens if a branch, say, is itself + // wrapped in some font stuff. I think that will not work. xs.closeFontTags(); - xs.endParagraph(); + if (close_paragraph) + xs.endDivision(); + return retval; } @@ -3270,8 +3287,6 @@ void Paragraph::forOutliner(docstring & os, size_t const maxlen, char_type const c = d->text_[i]; if (isPrintable(c)) os += c; - else if (c == '\t' || c == '\n') - os += ' '; else if (c == META_INSET) getInset(i)->forOutliner(os, tmplen, false); }