]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpecialChar.cpp
Properly fix handling of title layouts within insets (#11787)
[lyx.git] / src / insets / InsetSpecialChar.cpp
index 76da971ea0bbea1e03250ea1727e658f6e96fc31..2e51e95d3f84c676284d91bbf3d0c7dd9722f185 100644 (file)
@@ -15,6 +15,7 @@
 #include "InsetSpecialChar.h"
 
 #include "Dimension.h"
+#include "Encoding.h"
 #include "Font.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
@@ -81,6 +82,29 @@ docstring InsetSpecialChar::toolTip(BufferView const &, int, int) const
 }
 
 
+Inset::RowFlags InsetSpecialChar::rowFlags() const
+{
+       switch (kind_) {
+       case ALLOWBREAK:
+       case HYPHENATION:
+       case SLASH:
+               // these are the elements that allow line breaking
+               return CanBreakAfter;
+       case NOBREAKDASH:
+       case END_OF_SENTENCE:
+       case LIGATURE_BREAK:
+       case LDOTS:
+       case MENU_SEPARATOR:
+       case PHRASE_LYX:
+       case PHRASE_TEX:
+       case PHRASE_LATEX2E:
+       case PHRASE_LATEX:
+               break;
+       }
+       return Inline;
+}
+
+
 namespace {
 
 // helper function: draw text and update x.
@@ -384,6 +408,7 @@ void InsetSpecialChar::latex(otexstream & os,
                             OutputParams const & rp) const
 {
        bool const rtl = rp.local_font->isRightToLeft();
+       bool const utf8 = rp.encoding->iconvName() == "UTF-8";
        string lswitch = "";
        string lswitche = "";
        if (rtl && !rp.use_polyglossia) {
@@ -399,10 +424,15 @@ void InsetSpecialChar::latex(otexstream & os,
                os << "\\-";
                break;
        case ALLOWBREAK:
+               // U+200B not yet supported by utf8 inputenc
                os << "\\LyXZeroWidthSpace" << termcmd;
                break;
        case LIGATURE_BREAK:
-               os << "\\textcompwordmark" << termcmd;
+               if (utf8)
+                       // U+200C ZERO WIDTH NON-JOINER
+                       os.put(0x200c);
+               else
+                       os << "\\textcompwordmark" << termcmd;
                break;
        case END_OF_SENTENCE:
                os << "\\@.";
@@ -544,31 +574,31 @@ int InsetSpecialChar::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetSpecialChar::xhtml(XMLStream & xs, OutputParams const &) const
 {
        switch (kind_) {
        case HYPHENATION:
                break;
        case ALLOWBREAK:
-               xs << XHTMLStream::ESCAPE_NONE << "&#8203;";
+               xs << XMLStream::ESCAPE_NONE << "&#8203;";
                break;
        case LIGATURE_BREAK:
-               xs << XHTMLStream::ESCAPE_NONE << "&#8204;";
+               xs << XMLStream::ESCAPE_NONE << "&#8204;";
                break;
        case END_OF_SENTENCE:
                xs << '.';
                break;
        case LDOTS:
-               xs << XHTMLStream::ESCAPE_NONE << "&hellip;";
+               xs << XMLStream::ESCAPE_NONE << "&hellip;";
                break;
        case MENU_SEPARATOR:
-               xs << XHTMLStream::ESCAPE_NONE << "&rArr;";
+               xs << XMLStream::ESCAPE_NONE << "&rArr;";
                break;
        case SLASH:
-               xs << XHTMLStream::ESCAPE_NONE << "&frasl;";
+               xs << XMLStream::ESCAPE_NONE << "&frasl;";
                break;
        case NOBREAKDASH:
-               xs << XHTMLStream::ESCAPE_NONE << "&#8209;";
+               xs << XMLStream::ESCAPE_NONE << "&#8209;";
                break;
        case PHRASE_LYX:
                xs << "LyX";
@@ -577,7 +607,7 @@ docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const
                xs << "TeX";
                break;
        case PHRASE_LATEX2E:
-               xs << "LaTeX2" << XHTMLStream::ESCAPE_NONE << "&#x3b5;";
+               xs << "LaTeX2" << XMLStream::ESCAPE_NONE << "&#x3b5;";
                break;
        case PHRASE_LATEX:
                xs << "LaTeX";