X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fparagraph_pimpl.C;h=bad7602b1d0e286ef030524a38709432eb5f81d0;hb=ca6838b288daf07eec7d7a381d74c639c0de3a46;hp=aad1f2bb493aac4199acaaaf8d132be966689a6f;hpb=62ef9250a2a81ce258ebb04e0431a21bd1824575;p=lyx.git diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index aad1f2bb49..bad7602b1d 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -58,6 +58,15 @@ special_phrase const special_phrases[] = { size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase); + +bool isEncoding(BufferParams const & bparams, LyXFont const & font, + string const & encoding) +{ + return (bparams.inputenc == encoding + || (bparams.inputenc == "auto" + && font.language()->encoding()->latexName() == encoding)); +} + } // namespace anon @@ -154,14 +163,23 @@ void Paragraph::Pimpl::acceptChanges(pos_type start, pos_type end) { BOOST_ASSERT(start >= 0 && start <= size()); BOOST_ASSERT(end > start && end <= size() + 1); - + for (pos_type pos = start; pos < end; ++pos) { switch (lookupChange(pos).type) { case Change::UNCHANGED: + // accept changes in nested inset + if (pos < size() && owner_->isInset(pos)) { + owner_->getInset(pos)->acceptChanges(); + } + break; case Change::INSERTED: changes_.set(Change(Change::UNCHANGED), pos); + // also accept changes in nested inset + if (pos < size() && owner_->isInset(pos)) { + owner_->getInset(pos)->acceptChanges(); + } break; case Change::DELETED: @@ -175,10 +193,6 @@ void Paragraph::Pimpl::acceptChanges(pos_type start, pos_type end) break; } - // also accept changes in nested insets - if (pos < size() && owner_->isInset(pos)) { - owner_->getInset(pos)->acceptChanges(); - } } } @@ -191,7 +205,7 @@ void Paragraph::Pimpl::rejectChanges(pos_type start, pos_type end) for (pos_type pos = start; pos < end; ++pos) { switch (lookupChange(pos).type) { case Change::UNCHANGED: - // also reject changes inside of insets + // reject changes in nested inset if (pos < size() && owner_->isInset(pos)) { owner_->getInset(pos)->rejectChanges(); } @@ -569,13 +583,8 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, case 0xb9: // ¹ SUPERSCRIPT ONE case 0xac: // ¬ NOT SIGN case 0xb5: // µ MICRO SIGN - if ((bparams.inputenc == "latin1" || - bparams.inputenc == "latin9") || - (bparams.inputenc == "auto" && - (font.language()->encoding()->latexName() - == "latin1" || - font.language()->encoding()->latexName() - == "latin9"))) { + if (isEncoding(bparams, font, "latin1") + || isEncoding(bparams, font, "latin9")) { os << "\\ensuremath{"; os.put(c); os << '}'; @@ -651,6 +660,73 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, } break; + case 0x20ac: // EURO SIGN + if (isEncoding(bparams, font, "latin9") + || isEncoding(bparams, font, "cp1251") + || isEncoding(bparams, font, "utf8") + || isEncoding(bparams, font, "latin10") + || isEncoding(bparams, font, "cp858")) { + os.put(c); + } else { + os << "\\texteuro{}"; + column += 10; + } + break; + + // These characters are covered by latin1, but not + // by latin9 (a.o.). We have to support them because + // we switched the default of latin1-languages to latin9 + case 0xa4: // CURRENCY SYMBOL + case 0xa6: // BROKEN BAR + case 0xa8: // DIAERESIS + case 0xb4: // ACUTE ACCENT + case 0xb8: // CEDILLA + case 0xbd: // 1/2 FRACTION + case 0xbc: // 1/4 FRACTION + case 0xbe: // 3/4 FRACTION + if (isEncoding(bparams, font, "latin1") + || isEncoding(bparams, font, "latin5") + || isEncoding(bparams, font, "utf8")) { + os.put(c); + break; + } else { + switch (c) { + case 0xa4: + os << "\\textcurrency{}"; + column += 15; + break; + case 0xa6: + os << "\\textbrokenbar{}"; + column += 16; + break; + case 0xa8: + os << "\\textasciidieresis{}"; + column += 20; + break; + case 0xb4: + os << "\\textasciiacute{}"; + column += 17; + break; + case 0xb8: // from latin1.def: + os << "\\c\\ "; + column += 3; + break; + case 0xbd: + os << "\\textonehalf{}"; + column += 14; + break; + case 0xbc: + os << "\\textonequarter{}"; + column += 17; + break; + case 0xbe: + os << "\\textthreequarters{}"; + column += 20; + break; + } + break; + } + case '$': case '&': case '%': case '#': case '{': case '}': case '_': @@ -747,7 +823,7 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features, << endl; features.require("noun"); lyxerr[Debug::LATEX] << "Noun enabled. Font: " - << fcit->font().stateText(0) + << to_utf8(fcit->font().stateText(0)) << endl; } switch (fcit->font().color()) { @@ -762,7 +838,7 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features, default: features.require("color"); lyxerr[Debug::LATEX] << "Color enabled. Font: " - << fcit->font().stateText(0) + << to_utf8(fcit->font().stateText(0)) << endl; } @@ -801,6 +877,12 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features, break; } } + // these glyphs require the textcomp package + if (getChar(i) == 0x20ac || getChar(i) == 0xa4 + || getChar(i) == 0xa6 || getChar(i) == 0xa8 + || getChar(i) == 0xb4 || getChar(i) == 0xbd + || getChar(i) == 0xbc || getChar(i) == 0xbe) + features.require("textcomp"); } }