]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Check path of Qt tools if qtchooser is detected
[lyx.git] / src / Paragraph.cpp
index 0c5feb0cf23a93082cfc2cc066bb3c37fd05ec1d..8ea300ea756c40ea47ccf95926ee919c91af6d01 100644 (file)
@@ -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<pos_type>(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];
@@ -2743,7 +2752,8 @@ void doFontSwitch(vector<html::FontTag> & 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;
@@ -2765,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;
@@ -3051,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);
                        }
@@ -3062,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;
 }