X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraph.cpp;h=f2d97fe7c97cb9dbc60eac15e39e056391b14ec8;hb=7441172d4d9a26eb4824bb8bee003f457ef34f1c;hp=390de02b030b60c71375b8bac176dd87545fe53d;hpb=06675b853b4f2d896775f612115c7b9b79c2414c;p=lyx.git diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 390de02b03..f2d97fe7c9 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -84,14 +84,6 @@ using namespace lyx::support; namespace lyx { -namespace { - -/// Inset identifier (above 0x10ffff, for ucs-4) -char_type const META_INSET = 0x200001; - -} // namespace - - ///////////////////////////////////////////////////////////////////// // // SpellResultRange @@ -274,9 +266,9 @@ private: Ranges ranges_; /// the area of the paragraph with pending spell check FontSpan refresh_; - bool needs_refresh_; /// spell state cache version number SpellChecker::ChangeNumber current_change_number_; + bool needs_refresh_; void correctRangesAfterPos(pos_type pos, int offset) @@ -460,7 +452,7 @@ public: { int numskips = 0; while (it != et && it->first < start) { - int skip = it->last - it->first + 1; + long skip = it->last - it->first + 1; start += skip; numskips += skip; ++it; @@ -487,9 +479,6 @@ public: /// FontList fontlist_; - /// - int id_; - /// ParagraphParameters params_; @@ -514,11 +503,13 @@ public: Layout const * layout_; /// SpellCheckerState speller_state_; + /// + int id_; }; Paragraph::Private::Private(Paragraph * owner, Layout const & layout) - : owner_(owner), inset_owner_(nullptr), id_(-1), begin_of_body_(0), layout_(&layout) + : owner_(owner), inset_owner_(nullptr), begin_of_body_(0), layout_(&layout), id_(-1) { text_.reserve(100); } @@ -531,17 +522,16 @@ int Paragraph::Private::make_id() // LFUN_PARAGRAPH_GOTO to switch to a different buffer, for instance in the // outliner. // (thread-safe) - static atomic_uint next_id(0); + static int next_id(0); return next_id++; } Paragraph::Private::Private(Private const & p, Paragraph * owner) : owner_(owner), inset_owner_(p.inset_owner_), fontlist_(p.fontlist_), - id_(make_id()), params_(p.params_), changes_(p.changes_), insetlist_(p.insetlist_), begin_of_body_(p.begin_of_body_), text_(p.text_), words_(p.words_), - layout_(p.layout_) + layout_(p.layout_), id_(make_id()) { requestSpellCheck(p.text_.size()); } @@ -549,11 +539,11 @@ Paragraph::Private::Private(Private const & p, Paragraph * owner) Paragraph::Private::Private(Private const & p, Paragraph * owner, pos_type beg, pos_type end) - : owner_(owner), inset_owner_(p.inset_owner_), id_(make_id()), + : owner_(owner), inset_owner_(p.inset_owner_), params_(p.params_), changes_(p.changes_), insetlist_(p.insetlist_, beg, end), begin_of_body_(p.begin_of_body_), words_(p.words_), - layout_(p.layout_) + layout_(p.layout_), id_(make_id()) { if (beg >= pos_type(p.text_.size())) return; @@ -2403,8 +2393,9 @@ void Paragraph::latex(BufferParams const & bparams, pos_type body_pos = beginOfBody(); unsigned int column = 0; - // If we are inside an inset, the real outerfont is local_font - Font const real_outerfont = (runparams.local_font != nullptr) + // If we are inside an non inheritFont() inset, the real outerfont is local_font + Font const real_outerfont = (!inInset().inheritFont() + && runparams.local_font != nullptr) ? Font(runparams.local_font->fontInfo()) : outerfont; if (body_pos > 0) { @@ -2568,7 +2559,7 @@ void Paragraph::latex(BufferParams const & bparams, ++column; // Fully instantiated font - Font const current_font = getFont(bparams, i, real_outerfont); + Font const current_font = getFont(bparams, i, outerfont); Font const last_font = running_font; bool const in_ct_deletion = (bparams.output_changes @@ -3027,11 +3018,11 @@ void doFontSwitchDocBook(vector & tagsToOpen, class OptionalFontType { public: - bool has_value; xml::FontTypes ft; + bool has_value; - OptionalFontType(): has_value(false), ft(xml::FT_EMPH) {} // A possible value at random for ft. - OptionalFontType(xml::FontTypes ft): has_value(true), ft(ft) {} + OptionalFontType(): ft(xml::FT_EMPH), has_value(false) {} // A possible value at random for ft. + OptionalFontType(xml::FontTypes ft): ft(ft), has_value(true) {} }; OptionalFontType fontShapeToXml(FontShape fs) @@ -3058,13 +3049,10 @@ OptionalFontType fontFamilyToXml(FontFamily fm) switch (fm) { case ROMAN_FAMILY: return {xml::FT_ROMAN}; - break; case SANS_FAMILY: return {xml::FT_SANS}; - break; case TYPEWRITER_FAMILY: return {xml::FT_TYPE}; - break; case INHERIT_FAMILY: return {}; default: @@ -3111,6 +3099,10 @@ OptionalFontType fontSizeToXml(FontSize fs) struct DocBookFontState { + FontShape curr_fs = INHERIT_SHAPE; + FontFamily curr_fam = INHERIT_FAMILY; + FontSize curr_size = INHERIT_SIZE; + // track whether we have opened these tags bool emph_flag = false; bool bold_flag = false; @@ -3126,16 +3118,12 @@ struct DocBookFontState bool faml_flag = false; // size tags bool size_flag = false; - - FontShape curr_fs = INHERIT_SHAPE; - FontFamily curr_fam = INHERIT_FAMILY; - FontSize curr_size = INHERIT_SIZE; }; std::tuple, vector> computeDocBookFontSwitch(FontInfo const & font_old, Font const & font, std::string const & default_family, - DocBookFontState fs) + DocBookFontState & fs) { vector tagsToOpen; vector tagsToClose; @@ -3160,6 +3148,11 @@ std::tuple, vector> computeDocBookFontSwit if (font_old.strikeout() != curstate) doFontSwitchDocBook(tagsToOpen, tagsToClose, fs.sout_flag, curstate, xml::FT_SOUT); + // xout + curstate = font.fontInfo().xout(); + if (font_old.xout() != curstate) + doFontSwitchDocBook(tagsToOpen, tagsToClose, fs.xout_flag, curstate, xml::FT_XOUT); + // double underbar curstate = font.fontInfo().uuline(); if (font_old.uuline() != curstate) @@ -3182,16 +3175,14 @@ std::tuple, vector> computeDocBookFontSwit if (old_fs != fs.curr_fs) { if (fs.shap_flag) { OptionalFontType tag = fontShapeToXml(old_fs); - if (tag.has_value) { + if (tag.has_value) tagsToClose.push_back(docbookEndFontTag(tag.ft)); - } fs.shap_flag = false; } OptionalFontType tag = fontShapeToXml(fs.curr_fs); - if (tag.has_value) { + if (tag.has_value) tagsToOpen.push_back(docbookStartFontTag(tag.ft)); - } } // Font family @@ -3200,9 +3191,8 @@ std::tuple, vector> computeDocBookFontSwit if (old_fam != fs.curr_fam) { if (fs.faml_flag) { OptionalFontType tag = fontFamilyToXml(old_fam); - if (tag.has_value) { + if (tag.has_value) tagsToClose.push_back(docbookEndFontTag(tag.ft)); - } fs.faml_flag = false; } switch (fs.curr_fam) { @@ -3241,9 +3231,8 @@ std::tuple, vector> computeDocBookFontSwit if (old_size != fs.curr_size) { if (fs.size_flag) { OptionalFontType tag = fontSizeToXml(old_size); - if (tag.has_value) { + if (tag.has_value) tagsToClose.push_back(docbookEndFontTag(tag.ft)); - } fs.size_flag = false; } @@ -3257,7 +3246,7 @@ std::tuple, vector> computeDocBookFontSwit return std::tuple, vector>(tagsToOpen, tagsToClose); } -}// anonymous namespace +} // anonymous namespace void Paragraph::simpleDocBookOnePar(Buffer const & buf,